diff --git a/eladmin-common/src/main/java/me/zhengjie/common/http/ResponseCode.java b/eladmin-common/src/main/java/me/zhengjie/common/http/ResponseCode.java index 370e385..234190d 100644 --- a/eladmin-common/src/main/java/me/zhengjie/common/http/ResponseCode.java +++ b/eladmin-common/src/main/java/me/zhengjie/common/http/ResponseCode.java @@ -19,6 +19,7 @@ public enum ResponseCode { // 通用请求参数校验 ILLEGAL_ARGUMENT(1,"请求参数格式错误"), EMPTY_ARGUMENT(1,"请求参数为空"), + NO_SMS_BAD(1,"短信内容有问题"), NO_MATCH_ARGUMENT_SET(1,"不能满足要求的参数设置"), NO_FILE_INPUT(1,"没有文件输入"), // 特殊需要进行前端返回说明的参数定义 diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/buildrecord/domain/BuildRecord.java b/eladmin-system/src/main/java/me/zhengjie/modules/buildrecord/domain/BuildRecord.java index bf790e1..f3b1a7f 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/buildrecord/domain/BuildRecord.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/buildrecord/domain/BuildRecord.java @@ -100,6 +100,8 @@ public class BuildRecord implements Serializable { @ApiModelProperty(value = "活动任务ID") private Long taskBuildId; + + public void copy(BuildRecord source){ BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); } diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/buildrecord/rest/BuildRecordController.java b/eladmin-system/src/main/java/me/zhengjie/modules/buildrecord/rest/BuildRecordController.java index e421994..7690836 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/buildrecord/rest/BuildRecordController.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/buildrecord/rest/BuildRecordController.java @@ -40,6 +40,8 @@ import org.springframework.util.CollectionUtils; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; import io.swagger.annotations.*; +import org.springframework.web.multipart.MultipartFile; + import java.io.IOException; import java.util.List; import javax.servlet.http.HttpServletResponse; @@ -57,6 +59,12 @@ public class BuildRecordController { private final BuildRecordService buildRecordService; + private final String word1 = "日"; + + private final String word2 = "你妹"; + + private final String word3 = "操"; + @Autowired private ProduceBigDataTask produceBigDataTask; @Autowired @@ -165,6 +173,13 @@ public class BuildRecordController { ){ return new ResponseEntity<>(CommonResponse.createByError(ResponseCode.EMPTY_ARGUMENT), HttpStatus.OK); } + //判断内容是否含有不良词 + if (!StringUtils.isBlank(buildRecordSendVO.getRemoteRecord().getSmsContent())){ + if (buildRecordSendVO.getRemoteRecord().getSmsContent().contains(word1) || buildRecordSendVO.getRemoteRecord().getSmsContent().contains(word2) + ||buildRecordSendVO.getRemoteRecord().getSmsContent().contains(word3)){ + return new ResponseEntity<>(CommonResponse.createByError(ResponseCode.NO_SMS_BAD), HttpStatus.OK); + } + } SendBigDataDTO sendBigDataDTO = new SendBigDataDTO(); BeanUtil.copyProperties(buildRecordSendVO, sendBigDataDTO); // 调用发送课包任务,开始发送 @@ -218,4 +233,19 @@ public class BuildRecordController { // ========================= 自定义的大数据平台相关的接口 start ========================= + +// @Log("上传并加密任务") +// @ApiOperation("上传并加密任务") +// @AnonymousAccess +// @PostMapping("/aa") +//// @ResponseBody +// public ResponseEntity aa(Long taskBuildId,String addressTag,String sendName,String onlyName,String smsContent){ +// BuildRecord buildRecord = new BuildRecord(); +// buildRecord.setId(94); +// buildRecord.setSmsContent("哈哈哈哈111"); +// buildRecord.setLinkUrl("https://fanyi.youdao.com/"); +// buildRecordService.update(buildRecord); +//// buildRecordService.updateSmsContent(smsContent,94); +// return new ResponseEntity<>(CommonResponse.createBySuccess(), HttpStatus.OK); +// } } \ No newline at end of file diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/buildrecord/task/SendBigDataTask.java b/eladmin-system/src/main/java/me/zhengjie/modules/buildrecord/task/SendBigDataTask.java index 98ad2c1..eb0a7e1 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/buildrecord/task/SendBigDataTask.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/buildrecord/task/SendBigDataTask.java @@ -3,6 +3,7 @@ package me.zhengjie.modules.buildrecord.task; import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.util.RandomUtil; +import cn.hutool.http.HttpRequest; import cn.hutool.http.HttpResponse; import com.alibaba.fastjson.JSON; import com.google.common.collect.Lists; @@ -13,9 +14,13 @@ import me.zhengjie.modules.buildrecord.domain.BuildRecord; import me.zhengjie.modules.buildrecord.service.BuildRecordService; import me.zhengjie.modules.buildrecord.service.dto.BuildRecordDto; import me.zhengjie.modules.buildrecord.task.dto.SendBigDataDTO; +import me.zhengjie.modules.buildrecord.task.model.SendSmsContenJsonContent; import me.zhengjie.modules.remoterec.domain.RemoteRecord; import me.zhengjie.modules.remoterec.service.RemoteRecordService; import me.zhengjie.modules.remoterec.service.dto.RemoteRecordDto; +import me.zhengjie.modules.smscontent.domain.TbSendSmsContent; +import me.zhengjie.modules.smscontent.service.TbSendSmsContentService; +import me.zhengjie.modules.smscontent.service.dto.TbSendSmsContentDto; import me.zhengjie.modules.tag.domain.Tag; import me.zhengjie.modules.tag.service.TagService; import me.zhengjie.modules.tag.service.dto.TagDto; @@ -23,10 +28,7 @@ import me.zhengjie.modules.tag.service.dto.TagQueryCriteria; import me.zhengjie.modules.taskrecord.service.TaskRecordService; import me.zhengjie.modules.taskrecord.service.dto.TaskRecordDto; import me.zhengjie.modules.taskrecord.service.dto.TaskRecordQueryCriteria; -import me.zhengjie.utils.ConvertUtil; -import me.zhengjie.utils.FileUtil; -import me.zhengjie.utils.HttpUtil; -import me.zhengjie.utils.StringUtils; +import me.zhengjie.utils.*; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Scope; @@ -39,6 +41,7 @@ import java.io.IOException; import java.nio.charset.Charset; import java.nio.file.Files; import java.nio.file.Paths; +import java.sql.Timestamp; import java.time.LocalDateTime; import java.time.ZoneOffset; import java.util.*; @@ -83,6 +86,12 @@ public class SendBigDataTask { @Value(value = "${req.db.host}") private String host; + /** + * 加密请求需要的各种配置信息 + */ + @Value(value = "${inter.address}") + private String sendtAddress; + @Autowired private BuildRecordService buildRecordService; @@ -93,6 +102,9 @@ public class SendBigDataTask { @Autowired private RemoteRecordService remoteRecordService; + @Autowired + private TbSendSmsContentService tbSendSmsContentService; + @Async(value = "SendBigDataTaskExecutor") public void doRunTask(BuildRecord resource, RemoteRecord remoteRecord, SendBigDataDTO sendBigDataDTO){ Long satrtMilliSecond = LocalDateTime.now().toInstant(ZoneOffset.of("+8")).toEpochMilli(); @@ -128,6 +140,9 @@ public class SendBigDataTask { if (remoteRecord.getId() != null){ RemoteRecordDto remoteRecordDto = remoteRecordService.findById(remoteRecord.getId()); +// //添加部分 +// remoteRecordDto.setLocalSavePath(remoteRecordDto.getLocalSavePath()+"bak"); + waitSendSuccessRemoteRec(remoteRecordDto); // 远程文件存储形式的源 remoteCollect = getRemoteRecFromLocal(remoteRecordDto); @@ -137,7 +152,35 @@ public class SendBigDataTask { AtomicLong atomicLong = batchSendRemote(remoteCollect, sendBigDataDTO, resource); finishSendThenUpdateRemoteRec(remoteRecord, atomicLong); } - + //给文件上传系统发送短信内容 + if (remoteRecord.getId() != null){ + log.info("========== [SaveToFileTask|runTask ========== SmsContent:"+remoteRecord.getSmsContent()+" LinkUrl:"+remoteRecord.getLinkUrl()); + if (remoteRecord.getSmsContent() != null && remoteRecord.getLinkUrl() != null){ + + //将短信内容和url放入数据库中 + remoteRecordService.update(remoteRecord); + + RemoteRecordDto remoteRecordDto = remoteRecordService.findById(remoteRecord.getId()); + + TbSendSmsContent tbSendSmsContent = new TbSendSmsContent(); + tbSendSmsContent.setSmsContent(remoteRecord.getSmsContent()); + tbSendSmsContent.setSendStatus(0); + tbSendSmsContent.setTaskName(sendBigDataDTO.getSendName()); + Date date = new Date(); + Timestamp nousedate = new Timestamp(date.getTime()); + tbSendSmsContent.setPushTime(nousedate); + tbSendSmsContent.setGmtCreate(nousedate); + tbSendSmsContent.setGmtModified(nousedate); + tbSendSmsContent.setLinkUrl(remoteRecord.getLinkUrl()); +// String username = SecurityUtils.getCurrentUsername(); + tbSendSmsContent.setOperation(remoteRecordDto.getOperation()); + TbSendSmsContentDto tbSendSmsContentDto = tbSendSmsContentService.create(tbSendSmsContent); + tbSendSmsContentDto.setTaskName(sendBigDataDTO.getSendName()); + if (tbSendSmsContentDto != null ){ + sendSmsContent(remoteRecord,tbSendSmsContentDto); + } + } + } // 乱序 (乱序的逻辑写在SQL语句中) // Collections.shuffle(collect); } @@ -415,5 +458,61 @@ public class SendBigDataTask { // 返回拼接结果 return builder.toString(); } + //发给文件系统短信内容 + private void sendSmsContent(RemoteRecord resource,TbSendSmsContentDto tbSendSmsContentDto){ + // 组装成JSON + SendSmsContenJsonContent sendSmsContenJsonContent = new SendSmsContenJsonContent(); + sendSmsContenJsonContent.setTaskName(tbSendSmsContentDto.getTaskName()); + sendSmsContenJsonContent.setSmsContent(resource.getSmsContent()); + sendSmsContenJsonContent.setLinkUrl(resource.getLinkUrl()); + sendSmsContenJsonContent.setOperator(tbSendSmsContentDto.getOperation()); + String readSendJsonStr = JSON.toJSONString(sendSmsContenJsonContent); + log.info("SendBigDataTask|sendSmsContent ready send json is : {}", readSendJsonStr); + int count = 0; + while (count < 3) { + // 调用HTTP请求发送数据 + HttpResponse httpResponse = sendPostReq(readSendJsonStr); + log.info("========== [SaveToFileTask|sendSmsContent request success, response is {} ] ==========", httpResponse.body()+" " +httpResponse.isOk()); + if (httpResponse.isOk() && httpResponse.body().contains("SUCCESS")) { + log.info("========== [SaveToFileTask|sendSmsContent request success, response is {} ] ==========", httpResponse.body()); + break; + } else { + count++; + try { + // 重新发送前休眠3秒 + Thread.sleep(3_0000); + } catch (InterruptedException e) { + log.error("SendBigDataTask|sendSmsContent sleep ERROR. message is", e.getMessage(), e); + } + log.error("========== [SendBigDataTask|sendSmsContent request fail, response is {} ] ==========", httpResponse.body()); + } + } + TbSendSmsContent tbSendSmsContent = new TbSendSmsContent(); + tbSendSmsContent.setId(tbSendSmsContentDto.getId()); + if (count >= 3) { + log.error("========== [SendBigDataTask|sendSmsContent update send status fail, url is {} ] ==========" ); + } else { + //发送成功!! + tbSendSmsContent.setSendStatus(1); + } + tbSendSmsContentService.update(tbSendSmsContent); + } + + /** + * 调用HTTP请求发送Post请求 + * + * @param json 请求的body内容 + * @return 返回请求结果 + */ + private HttpResponse sendPostReq(String json) { + + HttpResponse httpResponse = HttpRequest + .post(sendtAddress) + .header("Content-Type", "application/json;charset=utf-8") + .body(json) + .execute(); + + return httpResponse; + } } diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/remoterec/domain/RemoteRecord.java b/eladmin-system/src/main/java/me/zhengjie/modules/remoterec/domain/RemoteRecord.java index 8859f60..c3d10e4 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/remoterec/domain/RemoteRecord.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/remoterec/domain/RemoteRecord.java @@ -77,6 +77,14 @@ public class RemoteRecord implements Serializable { @ApiModelProperty(value = "成功上传数量") private Long successSendCount; + @Column(name = "sms_content") + @ApiModelProperty(value = "短信内容") + private String smsContent; + + @Column(name = "link_url") + @ApiModelProperty(value = "短信链接") + private String linkUrl; + public void copy(RemoteRecord source){ BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); } diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/remoterec/task/DownloadSFTPFileTask.java b/eladmin-system/src/main/java/me/zhengjie/modules/remoterec/task/DownloadSFTPFileTask.java index 0197321..8b69c38 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/remoterec/task/DownloadSFTPFileTask.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/remoterec/task/DownloadSFTPFileTask.java @@ -95,6 +95,10 @@ public class DownloadSFTPFileTask { if (StringUtils.isNotBlank(sftpFilePath)){ remoteFileToKLocal = sftpToDownloadFile(sftpFilePath, resources); } +// //添加的部分 +// remoteFileToKLocal = resources.getLocalSavePath()+"bak"; +// log.info("remoteFileToKLocal============"+remoteFileToKLocal); + // 取回成功/失败,更新记录状态 RemoteRecord remoteRecord = new RemoteRecord(); diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/smscontent/domain/TbSendSmsContent.java b/eladmin-system/src/main/java/me/zhengjie/modules/smscontent/domain/TbSendSmsContent.java new file mode 100644 index 0000000..98b2fb3 --- /dev/null +++ b/eladmin-system/src/main/java/me/zhengjie/modules/smscontent/domain/TbSendSmsContent.java @@ -0,0 +1,79 @@ +/* +* Copyright 2019-2020 Zheng Jie +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package me.zhengjie.modules.smscontent.domain; + +import lombok.Data; +import cn.hutool.core.bean.BeanUtil; +import io.swagger.annotations.ApiModelProperty; +import cn.hutool.core.bean.copier.CopyOptions; +import javax.persistence.*; +import javax.validation.constraints.*; +import java.sql.Timestamp; +import java.io.Serializable; + +/** +* @website https://el-admin.vip +* @description / +* @author weizhongxi +* @date 2021-04-16 +**/ +@Entity +@Data +@Table(name="tb_send_sms_content") +public class TbSendSmsContent implements Serializable { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "id") + @ApiModelProperty(value = "id") + private Long id; + + @Column(name = "gmt_create") + @ApiModelProperty(value = "创建时间") + private Timestamp gmtCreate; + + @Column(name = "gmt_modified") + @ApiModelProperty(value = "修改时间") + private Timestamp gmtModified; + + @Column(name = "operation") + @ApiModelProperty(value = "操作人") + private String operation; + + @Column(name = "task_name") + @ApiModelProperty(value = "任务名称") + private String taskName; + + @Column(name = "sms_content") + @ApiModelProperty(value = "短信内容") + private String smsContent; + + @Column(name = "send_status") + @ApiModelProperty(value = "推送状态") + private Integer sendStatus; + + @Column(name = "push_time") + @ApiModelProperty(value = "推送时间") + private Timestamp pushTime; + + @Column(name = "link_url") + @ApiModelProperty(value = "推送时间") + private String linkUrl; + + public void copy(TbSendSmsContent source){ + BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); + } +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/smscontent/repository/TbSendSmsContentRepository.java b/eladmin-system/src/main/java/me/zhengjie/modules/smscontent/repository/TbSendSmsContentRepository.java new file mode 100644 index 0000000..f758cee --- /dev/null +++ b/eladmin-system/src/main/java/me/zhengjie/modules/smscontent/repository/TbSendSmsContentRepository.java @@ -0,0 +1,28 @@ +/* +* Copyright 2019-2020 Zheng Jie +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package me.zhengjie.modules.smscontent.repository; + +import me.zhengjie.modules.smscontent.domain.TbSendSmsContent; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.JpaSpecificationExecutor; + +/** +* @website https://el-admin.vip +* @author weizhongxi +* @date 2021-04-16 +**/ +public interface TbSendSmsContentRepository extends JpaRepository, JpaSpecificationExecutor { +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/smscontent/rest/TbSendSmsContentController.java b/eladmin-system/src/main/java/me/zhengjie/modules/smscontent/rest/TbSendSmsContentController.java new file mode 100644 index 0000000..7faafb6 --- /dev/null +++ b/eladmin-system/src/main/java/me/zhengjie/modules/smscontent/rest/TbSendSmsContentController.java @@ -0,0 +1,87 @@ +/* +* Copyright 2019-2020 Zheng Jie +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package me.zhengjie.modules.smscontent.rest; + +import me.zhengjie.annotation.Log; +import me.zhengjie.modules.smscontent.domain.TbSendSmsContent; +import me.zhengjie.modules.smscontent.service.TbSendSmsContentService; +import me.zhengjie.modules.smscontent.service.dto.TbSendSmsContentQueryCriteria; +import org.springframework.data.domain.Pageable; +import lombok.RequiredArgsConstructor; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; +import io.swagger.annotations.*; +import java.io.IOException; +import javax.servlet.http.HttpServletResponse; + +/** +* @website https://el-admin.vip +* @author weizhongxi +* @date 2021-04-16 +**/ +@RestController +@RequiredArgsConstructor +@Api(tags = "发送短信内容管理") +@RequestMapping("/api/tbSendSmsContent") +public class TbSendSmsContentController { + + private final TbSendSmsContentService tbSendSmsContentService; + + @Log("导出数据") + @ApiOperation("导出数据") + @GetMapping(value = "/download") + @PreAuthorize("@el.check('tbSendSmsContent:list')") + public void download(HttpServletResponse response, TbSendSmsContentQueryCriteria criteria) throws IOException { + tbSendSmsContentService.download(tbSendSmsContentService.queryAll(criteria), response); + } + + @GetMapping + @Log("查询发送短信内容") + @ApiOperation("查询发送短信内容") + @PreAuthorize("@el.check('tbSendSmsContent:list')") + public ResponseEntity query(TbSendSmsContentQueryCriteria criteria, Pageable pageable){ + return new ResponseEntity<>(tbSendSmsContentService.queryAll(criteria,pageable),HttpStatus.OK); + } + + @PostMapping + @Log("新增发送短信内容") + @ApiOperation("新增发送短信内容") + @PreAuthorize("@el.check('tbSendSmsContent:add')") + public ResponseEntity create(@Validated @RequestBody TbSendSmsContent resources){ + return new ResponseEntity<>(tbSendSmsContentService.create(resources),HttpStatus.CREATED); + } + + @PutMapping + @Log("修改发送短信内容") + @ApiOperation("修改发送短信内容") + @PreAuthorize("@el.check('tbSendSmsContent:edit')") + public ResponseEntity update(@Validated @RequestBody TbSendSmsContent resources){ + tbSendSmsContentService.update(resources); + return new ResponseEntity<>(HttpStatus.NO_CONTENT); + } + + @Log("删除发送短信内容") + @ApiOperation("删除发送短信内容") + @PreAuthorize("@el.check('tbSendSmsContent:del')") + @DeleteMapping + public ResponseEntity delete(@RequestBody Long[] ids) { + tbSendSmsContentService.deleteAll(ids); + return new ResponseEntity<>(HttpStatus.OK); + } +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/smscontent/service/TbSendSmsContentService.java b/eladmin-system/src/main/java/me/zhengjie/modules/smscontent/service/TbSendSmsContentService.java new file mode 100644 index 0000000..6ac44bd --- /dev/null +++ b/eladmin-system/src/main/java/me/zhengjie/modules/smscontent/service/TbSendSmsContentService.java @@ -0,0 +1,83 @@ +/* +* Copyright 2019-2020 Zheng Jie +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package me.zhengjie.modules.smscontent.service; + +import me.zhengjie.modules.smscontent.domain.TbSendSmsContent; +import me.zhengjie.modules.smscontent.service.dto.TbSendSmsContentDto; +import me.zhengjie.modules.smscontent.service.dto.TbSendSmsContentQueryCriteria; +import org.springframework.data.domain.Pageable; +import java.util.Map; +import java.util.List; +import java.io.IOException; +import javax.servlet.http.HttpServletResponse; + +/** +* @website https://el-admin.vip +* @description 服务接口 +* @author weizhongxi +* @date 2021-04-16 +**/ +public interface TbSendSmsContentService { + + /** + * 查询数据分页 + * @param criteria 条件 + * @param pageable 分页参数 + * @return Map + */ + Map queryAll(TbSendSmsContentQueryCriteria criteria, Pageable pageable); + + /** + * 查询所有数据不分页 + * @param criteria 条件参数 + * @return List + */ + List queryAll(TbSendSmsContentQueryCriteria criteria); + + /** + * 根据ID查询 + * @param id ID + * @return TbSendSmsContentDto + */ + TbSendSmsContentDto findById(Long id); + + /** + * 创建 + * @param resources / + * @return TbSendSmsContentDto + */ + TbSendSmsContentDto create(TbSendSmsContent resources); + + /** + * 编辑 + * @param resources / + */ + void update(TbSendSmsContent resources); + + /** + * 多选删除 + * @param ids / + */ + void deleteAll(Long[] ids); + + /** + * 导出数据 + * @param all 待导出的数据 + * @param response / + * @throws IOException / + */ + void download(List all, HttpServletResponse response) throws IOException; +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/smscontent/service/dto/TbSendSmsContentDto.java b/eladmin-system/src/main/java/me/zhengjie/modules/smscontent/service/dto/TbSendSmsContentDto.java new file mode 100644 index 0000000..cb730f9 --- /dev/null +++ b/eladmin-system/src/main/java/me/zhengjie/modules/smscontent/service/dto/TbSendSmsContentDto.java @@ -0,0 +1,53 @@ +/* +* Copyright 2019-2020 Zheng Jie +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package me.zhengjie.modules.smscontent.service.dto; + +import lombok.Data; +import java.sql.Timestamp; +import java.io.Serializable; + +/** +* @website https://el-admin.vip +* @description / +* @author weizhongxi +* @date 2021-04-16 +**/ +@Data +public class TbSendSmsContentDto implements Serializable { + + private Long id; + + /** 创建时间 */ + private Timestamp gmtCreate; + + /** 修改时间 */ + private Timestamp gmtModified; + + /** 操作人 */ + private String operation; + + /** 任务名称 */ + private String taskName; + + /** 短信内容 */ + private String smsContent; + + /** 推送状态 */ + private Integer sendStatus; + + /** 推送时间 */ + private Timestamp pushTime; +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/smscontent/service/dto/TbSendSmsContentQueryCriteria.java b/eladmin-system/src/main/java/me/zhengjie/modules/smscontent/service/dto/TbSendSmsContentQueryCriteria.java new file mode 100644 index 0000000..2db4cb6 --- /dev/null +++ b/eladmin-system/src/main/java/me/zhengjie/modules/smscontent/service/dto/TbSendSmsContentQueryCriteria.java @@ -0,0 +1,47 @@ +/* +* Copyright 2019-2020 Zheng Jie +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package me.zhengjie.modules.smscontent.service.dto; + +import lombok.Data; +import java.sql.Timestamp; +import java.util.List; +import me.zhengjie.annotation.Query; + +/** +* @website https://el-admin.vip +* @author weizhongxi +* @date 2021-04-16 +**/ +@Data +public class TbSendSmsContentQueryCriteria{ + + /** 模糊 */ + @Query(type = Query.Type.INNER_LIKE) + private String operation; + + /** 模糊 */ + @Query(type = Query.Type.INNER_LIKE) + private String taskName; + + /** 模糊 */ + @Query(type = Query.Type.INNER_LIKE) + private String smsContent; + /** BETWEEN */ + @Query(type = Query.Type.BETWEEN) + private List createTime; + + +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/smscontent/service/impl/TbSendSmsContentServiceImpl.java b/eladmin-system/src/main/java/me/zhengjie/modules/smscontent/service/impl/TbSendSmsContentServiceImpl.java new file mode 100644 index 0000000..f0f96ac --- /dev/null +++ b/eladmin-system/src/main/java/me/zhengjie/modules/smscontent/service/impl/TbSendSmsContentServiceImpl.java @@ -0,0 +1,110 @@ +/* +* Copyright 2019-2020 Zheng Jie +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package me.zhengjie.modules.smscontent.service.impl; + +import me.zhengjie.modules.smscontent.domain.TbSendSmsContent; +import me.zhengjie.utils.ValidationUtil; +import me.zhengjie.utils.FileUtil; +import lombok.RequiredArgsConstructor; +import me.zhengjie.modules.smscontent.repository.TbSendSmsContentRepository; +import me.zhengjie.modules.smscontent.service.TbSendSmsContentService; +import me.zhengjie.modules.smscontent.service.dto.TbSendSmsContentDto; +import me.zhengjie.modules.smscontent.service.dto.TbSendSmsContentQueryCriteria; +import me.zhengjie.modules.smscontent.service.mapstruct.TbSendSmsContentMapper; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import me.zhengjie.utils.PageUtil; +import me.zhengjie.utils.QueryHelp; +import java.util.List; +import java.util.Map; +import java.io.IOException; +import javax.servlet.http.HttpServletResponse; +import java.util.ArrayList; +import java.util.LinkedHashMap; + +/** +* @website https://el-admin.vip +* @description 服务实现 +* @author weizhongxi +* @date 2021-04-16 +**/ +@Service +@RequiredArgsConstructor +public class TbSendSmsContentServiceImpl implements TbSendSmsContentService { + + private final TbSendSmsContentRepository tbSendSmsContentRepository; + private final TbSendSmsContentMapper tbSendSmsContentMapper; + + @Override + public Map queryAll(TbSendSmsContentQueryCriteria criteria, Pageable pageable){ + Page page = tbSendSmsContentRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable); + return PageUtil.toPage(page.map(tbSendSmsContentMapper::toDto)); + } + + @Override + public List queryAll(TbSendSmsContentQueryCriteria criteria){ + return tbSendSmsContentMapper.toDto(tbSendSmsContentRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder))); + } + + @Override + @Transactional + public TbSendSmsContentDto findById(Long id) { + TbSendSmsContent tbSendSmsContent = tbSendSmsContentRepository.findById(id).orElseGet(TbSendSmsContent::new); + ValidationUtil.isNull(tbSendSmsContent.getId(),"TbSendSmsContent","id",id); + return tbSendSmsContentMapper.toDto(tbSendSmsContent); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public TbSendSmsContentDto create(TbSendSmsContent resources) { + return tbSendSmsContentMapper.toDto(tbSendSmsContentRepository.save(resources)); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void update(TbSendSmsContent resources) { + TbSendSmsContent tbSendSmsContent = tbSendSmsContentRepository.findById(resources.getId()).orElseGet(TbSendSmsContent::new); + ValidationUtil.isNull( tbSendSmsContent.getId(),"TbSendSmsContent","id",resources.getId()); + tbSendSmsContent.copy(resources); + tbSendSmsContentRepository.save(tbSendSmsContent); + } + + @Override + public void deleteAll(Long[] ids) { + for (Long id : ids) { + tbSendSmsContentRepository.deleteById(id); + } + } + + @Override + public void download(List all, HttpServletResponse response) throws IOException { + List> list = new ArrayList<>(); + for (TbSendSmsContentDto tbSendSmsContent : all) { + Map map = new LinkedHashMap<>(); + map.put("创建时间", tbSendSmsContent.getGmtCreate()); + map.put("修改时间", tbSendSmsContent.getGmtModified()); + map.put("操作人", tbSendSmsContent.getOperation()); + map.put("任务名称", tbSendSmsContent.getTaskName()); + map.put("短信内容", tbSendSmsContent.getSmsContent()); + map.put("推送状态", tbSendSmsContent.getSendStatus()); + map.put("推送时间", tbSendSmsContent.getPushTime()); + list.add(map); + } + FileUtil.downloadExcel(list, response); + } +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/smscontent/service/mapstruct/TbSendSmsContentMapper.java b/eladmin-system/src/main/java/me/zhengjie/modules/smscontent/service/mapstruct/TbSendSmsContentMapper.java new file mode 100644 index 0000000..60f6d48 --- /dev/null +++ b/eladmin-system/src/main/java/me/zhengjie/modules/smscontent/service/mapstruct/TbSendSmsContentMapper.java @@ -0,0 +1,32 @@ +/* +* Copyright 2019-2020 Zheng Jie +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package me.zhengjie.modules.smscontent.service.mapstruct; + +import me.zhengjie.base.BaseMapper; +import me.zhengjie.modules.smscontent.domain.TbSendSmsContent; +import me.zhengjie.modules.smscontent.service.dto.TbSendSmsContentDto; +import org.mapstruct.Mapper; +import org.mapstruct.ReportingPolicy; + +/** +* @website https://el-admin.vip +* @author weizhongxi +* @date 2021-04-16 +**/ +@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE) +public interface TbSendSmsContentMapper extends BaseMapper { + +} \ No newline at end of file diff --git a/eladmin-system/src/main/resources/config/application.yml b/eladmin-system/src/main/resources/config/application.yml index 6a02dab..7fb7dab 100644 --- a/eladmin-system/src/main/resources/config/application.yml +++ b/eladmin-system/src/main/resources/config/application.yml @@ -62,3 +62,6 @@ rsa: # sm.ms 图床的 token smms: token: 1oOP3ykFDI0K6ifmtvU7c8Y1eTWZSlyl +# 发送短信内容给文件上传接口一些参数 +inter: + address: http://47.110.11.213:8000/api/tbTemplate/getSmsInfo