From 3cab914810be8ca87e31b753da5a1d06a3f5a833 Mon Sep 17 00:00:00 2001
From: lin <sbla5888@163.com>
Date: Tue, 02 Apr 2024 10:46:15 +0800
Subject: [PATCH] 短信优化
---
src/main/java/org/springblade/modules/smsRecord/service/impl/SmsRecordServiceImpl.java | 51 +++
src/main/java/org/springblade/modules/sms/entity/SmsTemplateEntity.java | 7
src/main/java/org/springblade/modules/smsRecord/mapper/SmsRecordMapper.xml | 66 ++++
src/main/java/org/springblade/modules/smsRecord/mapper/SmsRecordMapper.java | 60 ++++
src/main/java/org/springblade/modules/discuss/service/impl/UserTopicsServiceImpl.java | 236 +++++++++-------
src/main/java/org/springblade/modules/smsRecord/entity/SmsRecordEntity.java | 92 ++++++
src/main/java/org/springblade/modules/smsRecord/service/ISmsRecordService.java | 43 +++
src/main/java/org/springblade/modules/smsRecord/vo/SmsRecordVO.java | 35 ++
src/main/java/org/springblade/modules/smsRecord/wrapper/SmsRecordWrapper.java | 50 +++
src/main/java/org/springblade/modules/discuss/controller/UserTopicsController.java | 38 +
src/main/java/org/springblade/modules/smsRecord/controller/SmsRecordController.java | 126 +++++++++
src/main/java/org/springblade/modules/smsRecord/dto/SmsRecordDTO.java | 34 ++
12 files changed, 726 insertions(+), 112 deletions(-)
diff --git a/src/main/java/org/springblade/modules/discuss/controller/UserTopicsController.java b/src/main/java/org/springblade/modules/discuss/controller/UserTopicsController.java
index 09bae54..0ddb529 100644
--- a/src/main/java/org/springblade/modules/discuss/controller/UserTopicsController.java
+++ b/src/main/java/org/springblade/modules/discuss/controller/UserTopicsController.java
@@ -169,18 +169,34 @@
ExcelUtil.export(response, "投票人员" + DateUtil.time(), "投票人员数据表", list, UserTopicsExcel.class);
}
+ /**
+ * 导出Excel文件的方法。
+ * 该方法用于将用户主题数据导出为Excel格式,供用户下载。
+ *
+ * @param response 用于设置HTTP响应,包括内容类型和文件名等信息。
+ * @param userTopics 包含要导出的数据的用户主题视图对象。
+ * @return 该方法不返回任何内容,而是将数据直接输出到HTTP响应的输出流中。
+ */
@GetMapping("/exportDataIndex")
- public void exportExcel(HttpServletResponse response,UserTopicsVO userTopics) {
- try (OutputStream out = response.getOutputStream()) {
- response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
- response.setCharacterEncoding("utf-8");
- String fileName = URLEncoder.encode("投票人员", "UTF-8").replaceAll("\\+", "%20");
- response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName + ".xlsx");
- userTopicsService.handleExcel(out,userTopics);
- out.flush();
- } catch (Exception e) {
- logger.error(e.getMessage(),e);
- }}
+ public void exportExcel(HttpServletResponse response, UserTopicsVO userTopics) {
+ try (OutputStream out = response.getOutputStream()) {
+ // 设置响应的内容类型为Excel文件
+ response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
+ // 设置响应的字符编码为UTF-8
+ response.setCharacterEncoding("utf-8");
+ // 编码文件名,并替换+号为%20,以兼容URL下载
+ String fileName = URLEncoder.encode("投票人员", "UTF-8").replaceAll("\\+", "%20");
+ // 设置响应头,指示浏览器以附件形式下载文件,并设置文件名
+ response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName + ".xlsx");
+ // 调用服务层处理Excel数据的写入
+ userTopicsService.handleExcel(out, userTopics);
+ // 刷新输出流
+ out.flush();
+ } catch (Exception e) {
+ // 记录异常信息
+ logger.error(e.getMessage(), e);
+ }
+ }
}
diff --git a/src/main/java/org/springblade/modules/discuss/service/impl/UserTopicsServiceImpl.java b/src/main/java/org/springblade/modules/discuss/service/impl/UserTopicsServiceImpl.java
index 703f75f..71be2b8 100644
--- a/src/main/java/org/springblade/modules/discuss/service/impl/UserTopicsServiceImpl.java
+++ b/src/main/java/org/springblade/modules/discuss/service/impl/UserTopicsServiceImpl.java
@@ -106,17 +106,17 @@
@Override
@Transactional(rollbackFor = Exception.class)
public String batchSave(TopicsVO topics) throws Exception {
-// if (StringUtils.isNotBlank(topics.getPhone())) {
-// Object validateCode = redisTemplate.get(SMS_VALIDATE_PHONE + topics.getPhone());
-// if (validateCode == null) {
-// return "验证码已过期";
-// }
-// if (!validateCode.toString().equals(topics.getCode())) {
-// return "验证码错误";
-// }
-// //删除验证码
-// redisTemplate.del(SMS_VALIDATE_PHONE + topics.getPhone());
-// }
+ if (StringUtils.isNotBlank(topics.getPhone())) {
+ Object validateCode = redisTemplate.get(SMS_VALIDATE_PHONE + topics.getPhone());
+ if (validateCode == null) {
+ return "验证码已过期";
+ }
+ if (!validateCode.toString().equals(topics.getCode())) {
+ return "验证码错误";
+ }
+ //删除验证码
+ redisTemplate.del(SMS_VALIDATE_PHONE + topics.getPhone());
+ }
// 判断是否一户一票 还是一人一票
List<TopicsVO> topicsList = topics.getChildren();
IHouseholdService householdService = SpringUtils.getBean(IHouseholdService.class);
@@ -262,106 +262,140 @@
return save(userTopics);
}
- @Override
- public void handleExcel(OutputStream out, UserTopicsVO userTopics) {
+/**
+ * 处理Excel文件的生成,将用户主题数据写入Excel并输出到流中。
+ *
+ * @param out 输出流,用于保存生成的Excel文件。
+ * @param userTopics 用户主题数据,包含提案和投票记录信息。
+ */
+@Override
+public void handleExcel(OutputStream out, UserTopicsVO userTopics) {
- // 设置excel工作簿
- ExcelWriter excelWriter = EasyExcel.write(out)
- .build();
+ // 初始化Excel写入器
+ ExcelWriter excelWriter = EasyExcel.write(out)
+ .build();
-// List<householdExcel> userList = new ArrayList<>();
-// for (int i = 0; i < 10; i++) {
-// HouseHoldExcel houseHoldExcel = new HouseHoldExcel();
-// houseHoldExcel.setHouseCode(i+"1");
-// }
- //设置自动换行
+ // 设置内容自动换行的样式
+ WriteCellStyle contentWriteCellStyle = new WriteCellStyle();
+ contentWriteCellStyle.setWrapped(true);
- WriteCellStyle contentWriteCellStyle = new WriteCellStyle();
- contentWriteCellStyle.setWrapped(true);
+ // 处理并写入提案数据
+ List<holdExcel> proposal = getProposal(userTopics);
+ ExcelWriterSheetBuilder userExcelSheet = new ExcelWriterSheetBuilder();
+ userExcelSheet.registerWriteHandler(new HorizontalCellStyleStrategy(null,contentWriteCellStyle));
+ userExcelSheet.sheetName("小区投票人员");
+ userExcelSheet.sheetNo(0);
+ userExcelSheet.head(holdExcel.class);
+ excelWriter.write(proposal, userExcelSheet.build());
- List<holdExcel> proposal = getProposal(userTopics);
- ExcelWriterSheetBuilder userExcelSheet = new ExcelWriterSheetBuilder();
- userExcelSheet.registerWriteHandler(new HorizontalCellStyleStrategy(null,contentWriteCellStyle));
- userExcelSheet.sheetName("小区投票人员");
- userExcelSheet.sheetNo(0);
- userExcelSheet.head(holdExcel.class);
- excelWriter.write(proposal, userExcelSheet.build());
+ // 处理并写入投票记录数据
+ List<UserTopicsExcel> publicopinion = getPublicopinion(userTopics);
+ ExcelWriterSheetBuilder classExcelSheet = new ExcelWriterSheetBuilder();
+ classExcelSheet.registerWriteHandler(new HorizontalCellStyleStrategy(null,contentWriteCellStyle));
+ classExcelSheet.sheetName("投票记录");
+ classExcelSheet.sheetNo(1);
+ classExcelSheet.head(UserTopicsExcel.class);
+ excelWriter.write(publicopinion, classExcelSheet.build());
+ // 完成Excel写入并释放资源
+ excelWriter.finish();
-// List<householdExcel> classInfoList = new ArrayList<>();
-// for (int i = 0; i < 10; i++) {
-// HouseHoldExcel houseHoldExcel = new HouseHoldExcel();
-// houseHoldExcel.setHouseCode(i+"1");
-// }
- List<UserTopicsExcel> publicopinion = getPublicopinion(userTopics);
- ExcelWriterSheetBuilder classExcelSheet = new ExcelWriterSheetBuilder();
- classExcelSheet.registerWriteHandler(new HorizontalCellStyleStrategy(null,contentWriteCellStyle));
- classExcelSheet.sheetName("投票记录");
- classExcelSheet.sheetNo(1);
- classExcelSheet.head(UserTopicsExcel.class);
- excelWriter.write(publicopinion, classExcelSheet.build());
+}
- excelWriter.finish();
+ /**
+ * 获取首页的房屋记录
+ *
+ * @param userTopics 包含用户话题信息的对象,其中可能含有区域ID等关键信息
+ * @return 返回一个包含房屋记录信息的列表
+ */
+ private List<holdExcel> getProposal(UserTopicsVO userTopics) {
+ List<holdExcel> resultList = new ArrayList<>();
+ try {
+ // 检查区域ID字符串是否有效
+ JSONArray objects1 = validateAndParseDistrictId(userTopics.getDistrictId());
+ // 获取区域服务和话题服务的实例
+ IDistrictService districtService = SpringUtils.getBean(IDistrictService.class);
+ ITopicsService topicsService = SpringUtils.getBean(ITopicsService.class);
+ // 处理区域ID并查询对应的区域实体列表
+ List<String> aoiCodeList = processDistrictIds(districtService, objects1);
+ // 设置AOI代码列表到用户话题对象中
+ userTopics.setAoiCodeList(aoiCodeList);
+ // 查询并处理房屋列表信息
+ List<holdExcel> householdList = processHouseholdList(topicsService, userTopics);
+ resultList.addAll(householdList);
+ } catch (Exception e) {
+ // 适当的异常处理逻辑
+ // 例如:记录日志、返回错误信息等
+ e.printStackTrace();
+ }
+ return resultList;
+ }
+
+ /**
+ * 验证并解析区域ID字符串。
+ *
+ * @param districtIdStr 区域ID的字符串表示。不能为空或空白字符串。
+ * @return 返回一个JSONArray对象,包含解析后的区域ID。
+ * @throws IllegalArgumentException 如果区域ID字符串为空或空白字符串,抛出此异常。
+ */
+ private JSONArray validateAndParseDistrictId(String districtIdStr) throws IllegalArgumentException {
+ // 验证区域ID字符串是否为空
+ if (StringUtils.isBlank(districtIdStr)) {
+ throw new IllegalArgumentException("区域ID不能为空");
+ }
+ // 解析区域ID字符串为JSONArray对象
+ return JSON.parseArray(districtIdStr);
+ }
+
+ private List<String> processDistrictIds(IDistrictService districtService, JSONArray districtIds) {
+ List<String> collect1 = districtIds.stream().map(item -> (String) item).collect(Collectors.toList());
+ List<DistrictEntity> list3 = districtService.list(Wrappers.<DistrictEntity>lambdaQuery().in(DistrictEntity::getId, collect1));
+ return list3.stream().map(item -> item.getAoiCode()).collect(Collectors.toList());
+ }
+
+ private List<holdExcel> processHouseholdList(ITopicsService topicsService, UserTopicsVO userTopics) {
+ List<holdExcel> householdList = baseMapper.getHouseholdList(userTopics);
+ householdList.forEach(item -> processItem(topicsService, item));
+ return householdList;
+ }
+
+ private void processItem(ITopicsService topicsService, holdExcel item) {
+ if (StringUtils.isBlank(item.getOptionContent())) {
+ item.setVoteFlag("否");
+ } else {
+ List<Long> longs = Func.toLongList(item.getOptionContent());
+ for (Long aLong : longs) {
+ TopicsEntity topics = topicsService.getById(aLong);
+ setManagementRegulationsOrRulesOfProcedure(item, topics);
+ }
+ item.setVoteFlag("是");
+ }
+ }
+
+ private void setManagementRegulationsOrRulesOfProcedure(holdExcel item, TopicsEntity topics) {
+ if (StringUtils.isNotBlank(topics.getDiscussContent())) {
+ if (topics.getDiscussContent().equals("管理规约")) {
+ item.setManagementRegulations(topics.getOptionContent());
+ } else if (topics.getDiscussContent().equals("议事规则")) {
+ item.setRulesOfProcedure(topics.getOptionContent());
+ }
+ }
+ }
-// ExcelWriter excelWriter = EasyExcelFactory.write(out).build();
-// //设置内容样式
-// WriteCellStyle contentStyle = new WriteCellStyle();
-// contentStyle.setHorizontalAlignment(HorizontalAlignment.CENTER);//居中
-// contentStyle.setWrapped(true);//自动换行
-// //设置头部样式
-// WriteCellStyle headerStyle = new WriteCellStyle();
-// headerStyle.setHorizontalAlignment(HorizontalAlignment.CENTER);
-// //设置策略
-// HorizontalCellStyleStrategy horizontalCellStyleStrategy = new HorizontalCellStyleStrategy(headerStyle, contentStyle);
-// WriteSheet proposalSheet = EasyExcelFactory.writerSheet(0, "委员提案").head(HouseHoldExcel.class).registerWriteHandler(horizontalCellStyleStrategy).build();
-// WriteSheet publicopinionSheet = EasyExcelFactory.writerSheet(1, "社情民意").head(HouseHoldExcel.class).registerWriteHandler(horizontalCellStyleStrategy).build();
-// excelWriter.write(getProposal(userTopics), proposalSheet);
-// excelWriter.write(getPublicopinion(userTopics), publicopinionSheet);
-
- }
-
- //首页-房屋记录
- private List<holdExcel> getProposal(UserTopicsVO userTopics) {
- List<holdExcel> list = new ArrayList<>();
- JSONArray objects1 = JSON.parseArray(userTopics.getDistrictId());
- List<String> collect1 = objects1.stream().map(item -> (String) item).collect(Collectors.toList());
- IDistrictService bean3 = SpringUtils.getBean(IDistrictService.class);
- List<DistrictEntity> list3 = bean3.list(Wrappers.<DistrictEntity>lambdaQuery().in(DistrictEntity::getId, collect1));
- List<String> aoiCodeList = list3.stream().map(item -> item.getAoiCode()).collect(Collectors.toList());
- userTopics.setAoiCodeList(aoiCodeList);
- List<holdExcel> householdList = baseMapper.getHouseholdList(userTopics);
- householdList.stream().forEach(item -> {
- if (StringUtils.isBlank(item.getOptionContent())) {
- item.setVoteFlag("否");
- } else {
- ITopicsService bean = SpringUtils.getBean(ITopicsService.class);
-
- List<Long> longs = Func.toLongList(item.getOptionContent());
- for (Long aLong : longs) {
- TopicsEntity topics = bean.getById(aLong);
- if (StringUtils.isNotBlank(topics.getDiscussContent()) && topics.getDiscussContent().equals("管理规约")) {
- item.setManagementRegulations(topics.getOptionContent());
- }
- if (StringUtils.isNotBlank(topics.getDiscussContent()) && topics.getDiscussContent().equals("议事规则")) {
- item.setRulesOfProcedure(topics.getOptionContent());
- }
- }
-
- item.setVoteFlag("是");
- }
- });
- // 添加
- list.addAll(householdList);
- return list;
- }
-
- //首页-议事
+ /**
+ * 获取公开意见信息
+ *
+ * @param userTopics 用户话题VO对象,封装了用户话题的查询条件
+ * @return 返回用户话题的Excel格式列表,包含所有符合条件的意见信息
+ */
private List<UserTopicsExcel> getPublicopinion(UserTopicsVO userTopics) {
- List<UserTopicsExcel> list = new ArrayList<>();
- List<UserTopicsExcel> userTopicsExcels = baseMapper.getresultTwo(userTopics);
- list.addAll(userTopicsExcels);
- return list;
+ // 初始化返回列表
+ List<UserTopicsExcel> list = new ArrayList<>();
+ // 通过基础mapper查询结果,并将结果添加到列表中
+ List<UserTopicsExcel> userTopicsExcels = baseMapper.getresultTwo(userTopics);
+ list.addAll(userTopicsExcels);
+ return list;
}
}
diff --git a/src/main/java/org/springblade/modules/sms/entity/SmsTemplateEntity.java b/src/main/java/org/springblade/modules/sms/entity/SmsTemplateEntity.java
index e15925e..3f9b01c 100644
--- a/src/main/java/org/springblade/modules/sms/entity/SmsTemplateEntity.java
+++ b/src/main/java/org/springblade/modules/sms/entity/SmsTemplateEntity.java
@@ -90,4 +90,11 @@
@ApiModelProperty(value = "0:否 1:是", example = "")
@TableField("is_deleted")
private String isDeleted;
+
+ /**
+ * 1:否 2:是
+ */
+ @ApiModelProperty(value = "1:否 2:是", example = "")
+ @TableField("status")
+ private String status;
}
diff --git a/src/main/java/org/springblade/modules/smsRecord/controller/SmsRecordController.java b/src/main/java/org/springblade/modules/smsRecord/controller/SmsRecordController.java
new file mode 100644
index 0000000..e0a2dc4
--- /dev/null
+++ b/src/main/java/org/springblade/modules/smsRecord/controller/SmsRecordController.java
@@ -0,0 +1,126 @@
+/*
+ * Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * Neither the name of the dreamlu.net developer nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ * Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.modules.smsRecord.controller;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
+import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
+import lombok.AllArgsConstructor;
+import javax.validation.Valid;
+
+import org.springblade.core.secure.BladeUser;
+import org.springblade.core.mp.support.Condition;
+import org.springblade.core.mp.support.Query;
+import org.springblade.core.tool.api.R;
+import org.springblade.core.tool.utils.Func;
+import org.springframework.web.bind.annotation.*;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import org.springblade.modules.smsRecord.entity.SmsRecordEntity;
+import org.springblade.modules.smsRecord.vo.SmsRecordVO;
+import org.springblade.modules.smsRecord.wrapper.SmsRecordWrapper;
+import org.springblade.modules.smsRecord.service.ISmsRecordService;
+import org.springblade.core.boot.ctrl.BladeController;
+
+/**
+ * 短信记录表 控制器
+ *
+ * @author BladeX
+ * @since 2024-04-02
+ */
+@RestController
+@AllArgsConstructor
+@RequestMapping("blade-smsRecord/smsRecord")
+@Api(value = "短信记录表", tags = "短信记录表接口")
+public class SmsRecordController extends BladeController {
+
+ private final ISmsRecordService smsRecordService;
+
+ /**
+ * 短信记录表 详情
+ */
+ @GetMapping("/detail")
+ @ApiOperationSupport(order = 1)
+ @ApiOperation(value = "详情", notes = "传入smsRecord")
+ public R<SmsRecordVO> detail(SmsRecordEntity smsRecord) {
+ SmsRecordEntity detail = smsRecordService.getOne(Condition.getQueryWrapper(smsRecord));
+ return R.data(SmsRecordWrapper.build().entityVO(detail));
+ }
+ /**
+ * 短信记录表 分页
+ */
+ @GetMapping("/list")
+ @ApiOperationSupport(order = 2)
+ @ApiOperation(value = "分页", notes = "传入smsRecord")
+ public R<IPage<SmsRecordVO>> list(SmsRecordEntity smsRecord, Query query) {
+ IPage<SmsRecordEntity> pages = smsRecordService.page(Condition.getPage(query), Condition.getQueryWrapper(smsRecord));
+ return R.data(SmsRecordWrapper.build().pageVO(pages));
+ }
+
+ /**
+ * 短信记录表 自定义分页
+ */
+ @GetMapping("/page")
+ @ApiOperationSupport(order = 3)
+ @ApiOperation(value = "分页", notes = "传入smsRecord")
+ public R<IPage<SmsRecordVO>> page(SmsRecordVO smsRecord, Query query) {
+ IPage<SmsRecordVO> pages = smsRecordService.selectSmsRecordPage(Condition.getPage(query), smsRecord);
+ return R.data(pages);
+ }
+
+ /**
+ * 短信记录表 新增
+ */
+ @PostMapping("/save")
+ @ApiOperationSupport(order = 4)
+ @ApiOperation(value = "新增", notes = "传入smsRecord")
+ public R save(@Valid @RequestBody SmsRecordEntity smsRecord) {
+ return R.status(smsRecordService.save(smsRecord));
+ }
+
+ /**
+ * 短信记录表 修改
+ */
+ @PostMapping("/update")
+ @ApiOperationSupport(order = 5)
+ @ApiOperation(value = "修改", notes = "传入smsRecord")
+ public R update(@Valid @RequestBody SmsRecordEntity smsRecord) {
+ return R.status(smsRecordService.updateById(smsRecord));
+ }
+
+ /**
+ * 短信记录表 新增或修改
+ */
+ @PostMapping("/submit")
+ @ApiOperationSupport(order = 6)
+ @ApiOperation(value = "新增或修改", notes = "传入smsRecord")
+ public R submit(@Valid @RequestBody SmsRecordEntity smsRecord) {
+ return R.status(smsRecordService.saveOrUpdate(smsRecord));
+ }
+
+ /**
+ * 短信记录表 删除
+ */
+ @PostMapping("/remove")
+ @ApiOperationSupport(order = 7)
+ @ApiOperation(value = "逻辑删除", notes = "传入ids")
+ public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) {
+ return R.status(smsRecordService.removeBatchByIds(Func.toLongList(ids)));
+ }
+
+
+}
diff --git a/src/main/java/org/springblade/modules/smsRecord/dto/SmsRecordDTO.java b/src/main/java/org/springblade/modules/smsRecord/dto/SmsRecordDTO.java
new file mode 100644
index 0000000..e869aa0
--- /dev/null
+++ b/src/main/java/org/springblade/modules/smsRecord/dto/SmsRecordDTO.java
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * Neither the name of the dreamlu.net developer nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ * Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.modules.smsRecord.dto;
+
+import org.springblade.modules.smsRecord.entity.SmsRecordEntity;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+/**
+ * 短信记录表 数据传输对象实体类
+ *
+ * @author BladeX
+ * @since 2024-04-02
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+public class SmsRecordDTO extends SmsRecordEntity {
+ private static final long serialVersionUID = 1L;
+
+}
diff --git a/src/main/java/org/springblade/modules/smsRecord/entity/SmsRecordEntity.java b/src/main/java/org/springblade/modules/smsRecord/entity/SmsRecordEntity.java
new file mode 100644
index 0000000..518e55e
--- /dev/null
+++ b/src/main/java/org/springblade/modules/smsRecord/entity/SmsRecordEntity.java
@@ -0,0 +1,92 @@
+/*
+ * Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * Neither the name of the dreamlu.net developer nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ * Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.modules.smsRecord.entity;
+
+import com.baomidou.mybatisplus.annotation.*;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.Data;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.EqualsAndHashCode;
+import org.springblade.core.tenant.mp.TenantEntity;
+
+import java.util.Date;
+
+/**
+ * 短信记录表 实体类
+ *
+ * @author BladeX
+ * @since 2024-04-02
+ */
+@Data
+@TableName("blade_sms_record")
+@ApiModel(value = "SmsRecord对象", description = "短信记录表")
+public class SmsRecordEntity {
+
+ /** 主键 */
+ @ApiModelProperty(value = "主键ID", example = "")
+ @TableId(value = "id", type = IdType.ASSIGN_ID)
+ private Long id;
+
+ /** 模板id */
+ @ApiModelProperty(value = "模板id", example = "")
+ @TableField("template_id")
+ private Long templateId;
+
+ /** 接收手机号 */
+ @ApiModelProperty(value = "接收手机号", example = "")
+ @TableField("phone")
+ private String phone;
+
+ /** 短信内容 */
+ @ApiModelProperty(value = "短信内容", example = "")
+ @TableField("content")
+ private String content;
+
+ /** 创建人 */
+ @ApiModelProperty(value = "创建人", example = "")
+ @TableField("create_user")
+ private Long createUser;
+
+ /** 创建部门 */
+ @ApiModelProperty(value = "创建部门", example = "")
+ @TableField("create_dept")
+ private Long createDept;
+
+ /** 创建时间 */
+ @ApiModelProperty(value = "创建时间", example = "")
+ @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+ @TableField(value = "create_time",fill = FieldFill.INSERT)
+ private Date createTime;
+
+ /** 修改时间 */
+ @ApiModelProperty(value = "修改时间", example = "")
+ @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+ @TableField(value = "update_time",fill = FieldFill.DEFAULT)
+ private Date updateTime;
+
+ /** 状态 1:否 2:是 */
+ @ApiModelProperty(value = "状态 1:否 2:是", example = "")
+ @TableField("status")
+ private Integer status;
+
+ /** 是否已删除 */
+ @ApiModelProperty(value = "是否已删除", example = "")
+ @TableField("is_deleted")
+ private Integer isDeleted;
+
+}
diff --git a/src/main/java/org/springblade/modules/smsRecord/mapper/SmsRecordMapper.java b/src/main/java/org/springblade/modules/smsRecord/mapper/SmsRecordMapper.java
new file mode 100644
index 0000000..5000b10
--- /dev/null
+++ b/src/main/java/org/springblade/modules/smsRecord/mapper/SmsRecordMapper.java
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * Neither the name of the dreamlu.net developer nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ * Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.modules.smsRecord.mapper;
+
+import org.springblade.modules.smsRecord.dto.SmsRecordDTO;
+import org.springblade.modules.smsRecord.entity.SmsRecordEntity;
+import org.springblade.modules.smsRecord.vo.SmsRecordVO;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import java.util.List;
+
+/**
+ * 短信记录表 Mapper 接口
+ *
+ * @author BladeX
+ * @since 2024-04-02
+ */
+public interface SmsRecordMapper extends BaseMapper<SmsRecordEntity> {
+
+ /**
+ * 自定义分页
+ *
+ * @param page
+ * @param smsRecord
+ * @return
+ */
+ List<SmsRecordVO> selectSmsRecordPage(IPage page, SmsRecordVO smsRecord);
+
+ /**
+ * 查询短信记录表
+ *
+ * @param id 短信记录表ID
+ * @return 短信记录表
+ */
+ public SmsRecordDTO selectBladeSmsRecordById(Long id);
+
+ /**
+ * 查询短信记录表列表
+ *
+ * @param bladeSmsRecordDTO 短信记录表
+ * @return 短信记录表集合
+ */
+ public List<SmsRecordDTO> selectBladeSmsRecordList(SmsRecordDTO bladeSmsRecordDTO);
+
+
+}
diff --git a/src/main/java/org/springblade/modules/smsRecord/mapper/SmsRecordMapper.xml b/src/main/java/org/springblade/modules/smsRecord/mapper/SmsRecordMapper.xml
new file mode 100644
index 0000000..b64d166
--- /dev/null
+++ b/src/main/java/org/springblade/modules/smsRecord/mapper/SmsRecordMapper.xml
@@ -0,0 +1,66 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="org.springblade.modules.smsRecord.mapper.SmsRecordMapper">
+
+ <!-- 通用查询映射结果 -->
+ <resultMap id="smsRecordResultMap" type="org.springblade.modules.smsRecord.entity.SmsRecordEntity">
+ </resultMap>
+
+
+ <select id="selectSmsRecordPage" resultMap="smsRecordResultMap">
+ select * from blade_sms_record where is_deleted = 0
+ </select>
+
+ <resultMap type="org.springblade.modules.smsRecord.dto.SmsRecordDTO" id="BladeSmsRecordDTOResult">
+ <result property="id" column="id" />
+ <result property="templateId" column="template_id" />
+ <result property="phone" column="phone" />
+ <result property="content" column="content" />
+ <result property="createUser" column="create_user" />
+ <result property="createDept" column="create_dept" />
+ <result property="createTime" column="create_time" />
+ <result property="updateTime" column="update_time" />
+ <result property="status" column="status" />
+ <result property="isDeleted" column="is_deleted" />
+ </resultMap>
+
+ <sql id="selectBladeSmsRecord">
+ select
+ id,
+ template_id,
+ phone,
+ content,
+ create_user,
+ create_dept,
+ create_time,
+ update_time,
+ status,
+ is_deleted
+ from
+ blade_sms_record
+ </sql>
+
+ <select id="selectBladeSmsRecordById" parameterType="long" resultMap="BladeSmsRecordDTOResult">
+ <include refid="selectBladeSmsRecord"/>
+ where
+ id = #{id}
+ </select>
+
+ <select id="selectBladeSmsRecordList" parameterType="org.springblade.modules.smsRecord.dto.SmsRecordDTO" resultMap="BladeSmsRecordDTOResult">
+ <include refid="selectBladeSmsRecord"/>
+ <where>
+ <if test="id != null "> and id = #{id}</if>
+ <if test="templateId != null "> and template_id = #{templateId}</if>
+ <if test="phone != null and phone != ''"> and phone = #{phone}</if>
+ <if test="content != null and content != ''"> and content = #{content}</if>
+ <if test="createUser != null "> and create_user = #{createUser}</if>
+ <if test="createDept != null "> and create_dept = #{createDept}</if>
+ <if test="createTime != null "> and create_time = #{createTime}</if>
+ <if test="updateTime != null "> and update_time = #{updateTime}</if>
+ <if test="status != null "> and status = #{status}</if>
+ <if test="isDeleted != null "> and is_deleted = #{isDeleted}</if>
+ </where>
+ </select>
+
+
+</mapper>
diff --git a/src/main/java/org/springblade/modules/smsRecord/service/ISmsRecordService.java b/src/main/java/org/springblade/modules/smsRecord/service/ISmsRecordService.java
new file mode 100644
index 0000000..009564c
--- /dev/null
+++ b/src/main/java/org/springblade/modules/smsRecord/service/ISmsRecordService.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * Neither the name of the dreamlu.net developer nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ * Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.modules.smsRecord.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import org.springblade.modules.smsRecord.entity.SmsRecordEntity;
+import org.springblade.modules.smsRecord.vo.SmsRecordVO;
+import org.springblade.core.mp.base.BaseService;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+
+/**
+ * 短信记录表 服务类
+ *
+ * @author BladeX
+ * @since 2024-04-02
+ */
+public interface ISmsRecordService extends IService<SmsRecordEntity> {
+
+ /**
+ * 自定义分页
+ *
+ * @param page
+ * @param smsRecord
+ * @return
+ */
+ IPage<SmsRecordVO> selectSmsRecordPage(IPage<SmsRecordVO> page, SmsRecordVO smsRecord);
+
+
+}
diff --git a/src/main/java/org/springblade/modules/smsRecord/service/impl/SmsRecordServiceImpl.java b/src/main/java/org/springblade/modules/smsRecord/service/impl/SmsRecordServiceImpl.java
new file mode 100644
index 0000000..c31d250
--- /dev/null
+++ b/src/main/java/org/springblade/modules/smsRecord/service/impl/SmsRecordServiceImpl.java
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * Neither the name of the dreamlu.net developer nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ * Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.modules.smsRecord.service.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springblade.modules.smsRecord.entity.SmsRecordEntity;
+import org.springblade.modules.smsRecord.vo.SmsRecordVO;
+import org.springblade.modules.smsRecord.mapper.SmsRecordMapper;
+import org.springblade.modules.smsRecord.service.ISmsRecordService;
+import org.springblade.core.mp.base.BaseServiceImpl;
+import org.springframework.stereotype.Service;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+
+/**
+ * 短信记录表 服务实现类
+ *
+ * @author BladeX
+ * @since 2024-04-02
+ */
+@Service
+public class SmsRecordServiceImpl extends ServiceImpl<SmsRecordMapper, SmsRecordEntity> implements ISmsRecordService {
+
+ /**
+ * 分页查询短信记录。
+ *
+ * @param page 分页对象,包含当前页码和每页记录数等信息。
+ * @param smsRecord 短信记录查询条件对象,用于筛选特定的短信记录。
+ * @return 返回经过分页处理的短信记录列表。
+ */
+ @Override
+ public IPage<SmsRecordVO> selectSmsRecordPage(IPage<SmsRecordVO> page, SmsRecordVO smsRecord) {
+ // 调用底层Mapper,查询指定条件的短信记录,并将结果设置到分页对象中
+ return page.setRecords(baseMapper.selectSmsRecordPage(page, smsRecord));
+ }
+
+
+}
diff --git a/src/main/java/org/springblade/modules/smsRecord/vo/SmsRecordVO.java b/src/main/java/org/springblade/modules/smsRecord/vo/SmsRecordVO.java
new file mode 100644
index 0000000..226c7ae
--- /dev/null
+++ b/src/main/java/org/springblade/modules/smsRecord/vo/SmsRecordVO.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * Neither the name of the dreamlu.net developer nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ * Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.modules.smsRecord.vo;
+
+import org.springblade.modules.smsRecord.entity.SmsRecordEntity;
+import org.springblade.core.tool.node.INode;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+/**
+ * 短信记录表 视图实体类
+ *
+ * @author BladeX
+ * @since 2024-04-02
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+public class SmsRecordVO extends SmsRecordEntity {
+ private static final long serialVersionUID = 1L;
+
+}
diff --git a/src/main/java/org/springblade/modules/smsRecord/wrapper/SmsRecordWrapper.java b/src/main/java/org/springblade/modules/smsRecord/wrapper/SmsRecordWrapper.java
new file mode 100644
index 0000000..0424d1f
--- /dev/null
+++ b/src/main/java/org/springblade/modules/smsRecord/wrapper/SmsRecordWrapper.java
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * Neither the name of the dreamlu.net developer nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ * Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.modules.smsRecord.wrapper;
+
+import org.springblade.core.mp.support.BaseEntityWrapper;
+import org.springblade.core.tool.utils.BeanUtil;
+import org.springblade.modules.smsRecord.entity.SmsRecordEntity;
+import org.springblade.modules.smsRecord.vo.SmsRecordVO;
+import java.util.Objects;
+
+/**
+ * 短信记录表 包装类,返回视图层所需的字段
+ *
+ * @author BladeX
+ * @since 2024-04-02
+ */
+public class SmsRecordWrapper extends BaseEntityWrapper<SmsRecordEntity, SmsRecordVO> {
+
+ public static SmsRecordWrapper build() {
+ return new SmsRecordWrapper();
+ }
+
+ @Override
+ public SmsRecordVO entityVO(SmsRecordEntity smsRecord) {
+ SmsRecordVO smsRecordVO = Objects.requireNonNull(BeanUtil.copy(smsRecord, SmsRecordVO.class));
+
+ //User createUser = UserCache.getUser(smsRecord.getCreateUser());
+ //User updateUser = UserCache.getUser(smsRecord.getUpdateUser());
+ //smsRecordVO.setCreateUserName(createUser.getName());
+ //smsRecordVO.setUpdateUserName(updateUser.getName());
+
+ return smsRecordVO;
+ }
+
+
+}
--
Gitblit v1.9.3