diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/wisdomarbitrate/sendrecord/ShortMessageController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/wisdomarbitrate/sendrecord/ShortMessageController.java index 9ebd03b..905dbc6 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/wisdomarbitrate/sendrecord/ShortMessageController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/wisdomarbitrate/sendrecord/ShortMessageController.java @@ -4,12 +4,9 @@ import com.ruoyi.common.annotation.Anonymous; import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.wisdomarbitrate.domain.dto.sendrecord.SmsSendRecord; import com.ruoyi.wisdomarbitrate.mapper.sendrecord.SmsRecordMapper; -import com.ruoyi.wisdomarbitrate.service.sendrecord.ShortMessageService; +import com.ruoyi.wisdomarbitrate.service.shortmessage.ShortMessageService; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; import java.util.Date; @@ -46,4 +43,17 @@ public class ShortMessageController { } return AjaxResult.error("发送失败"); } + + /** + * 查询UID好的密钥 + */ + @Anonymous + @GetMapping("/getMeetingInfo") + public Object getEncryptInfoByUid(@RequestParam(name = "authId", required = true) String authId) { + if (authId != null) { + Object result = shortMessageService.getMeetingInfo(authId); + return result; + } + return AjaxResult.error("查询失败"); + } } diff --git a/ruoyi-admin/src/main/resources/application.yml b/ruoyi-admin/src/main/resources/application.yml index c0a1dad..fa7d84e 100644 --- a/ruoyi-admin/src/main/resources/application.yml +++ b/ruoyi-admin/src/main/resources/application.yml @@ -217,4 +217,4 @@ BMConfig: # max-tasks-per-process: 100 beimingapihost: https://zj.odrcloud.cn beimingapiprefix: /onestop/sync -beimingprivatekey: d7724e72c4be93196a35203e8379ded5 \ No newline at end of file +beimingprivatekey: d7724e72c4be93196a35203e8379ded5 diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/constant/Constants.java b/ruoyi-common/src/main/java/com/ruoyi/common/constant/Constants.java index b1b5c79..a185090 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/constant/Constants.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/constant/Constants.java @@ -4,11 +4,10 @@ import io.jsonwebtoken.Claims; /** * 通用常量信息 - * + * * @author ruoyi */ -public class Constants -{ +public class Constants { /** * UTF-8 字符集 */ @@ -71,7 +70,7 @@ public class Constants * 登录失败 */ public static final String LOGIN_FAIL = "Error"; - + /** * 验证码有效期(分钟) */ @@ -95,6 +94,10 @@ public class Constants * 令牌前缀 */ public static final String LOGIN_USER_KEY = "login_user_key"; + /** + * 会议主键Id + */ + public static final String MEETING_KEY = "meeting_key"; /** * 用户ID @@ -142,23 +145,22 @@ public class Constants public static final String LOOKUP_LDAPS = "ldaps:"; public static final String DEFAULT_PASSWORD = "123456"; // 英文逗号分隔符 - public static final String SPLIT_COMMA =","; + public static final String SPLIT_COMMA = ","; // 中文逗号分隔符 - public static final String CN_SPLIT_COMMA =","; + public static final String CN_SPLIT_COMMA = ","; /** * 自动识别json对象白名单配置(仅允许解析的包名,范围越小越安全) */ - public static final String[] JSON_WHITELIST_STR = { "org.springframework", "com.ruoyi" }; + public static final String[] JSON_WHITELIST_STR = {"org.springframework", "com.ruoyi"}; /** * 定时任务白名单配置(仅允许访问的包名,如其他需要可以自行添加) */ - public static final String[] JOB_WHITELIST_STR = { "com.ruoyi" }; + public static final String[] JOB_WHITELIST_STR = {"com.ruoyi"}; /** * 定时任务违规的字符 */ - public static final String[] JOB_ERROR_STR = { "java.net.URL", "javax.naming.InitialContext", "org.yaml.snakeyaml", - "org.springframework", "org.apache", "com.ruoyi.common.utils.file", "com.ruoyi.common.config" }; + public static final String[] JOB_ERROR_STR = {"java.net.URL", "javax.naming.InitialContext", "org.yaml.snakeyaml", "org.springframework", "org.apache", "com.ruoyi.common.utils.file", "com.ruoyi.common.config"}; } diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/EncryptUtils.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/EncryptUtils.java index 579e6be..455ec3f 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/utils/EncryptUtils.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/EncryptUtils.java @@ -112,10 +112,17 @@ public class EncryptUtils { public static void main(String[] args) { String privateKey = "936df5fd9aba3b86adc3c1a1c52dcde1"; ObjectNode param = new ObjectMapper().createObjectNode(); - param.put("name", "姓名"); + param.put("userName", "张三"); + param.put("caseNo", "ZC1234125"); + param.put("userId", "124124"); + param.put("roomId", "124125"); + param.put("systemType", "tiaojiexitong"); String encryptString = sm4Encrypt(param.toString(), privateKey); System.out.println("加密后的字符串:" + encryptString); + String uid = UUID.randomUUID().toString().replace("-", ""); + System.out.println("uid:" + uid); System.out.println("解密后的字符串:" + sm4Decrypt(encryptString, privateKey)); + } } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/domain/entity/shortmessage/MeetingInfo.java b/ruoyi-system/src/main/java/com/ruoyi/system/domain/entity/shortmessage/MeetingInfo.java new file mode 100644 index 0000000..3a3c1df --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/domain/entity/shortmessage/MeetingInfo.java @@ -0,0 +1,60 @@ +package com.ruoyi.system.domain.entity.shortmessage; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import javax.persistence.Column; +import javax.persistence.Id; +import javax.persistence.Table; +import java.util.Date; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@Table(name = "meeting_info") +public class MeetingInfo { + /** + * 主键Id + */ + @Id + private String uid; + + /** + * 案件Id + */ + @Column(name = "case_id") + private Long caseId; + + /** + * 用户Id + */ + @Column(name = "user_id") + private Long userId; + + /** + * 用户名称 + */ + @Column(name = "user_name") + private String userName; + + /** + * 房间Id + */ + @Column(name = "room_id") + private String roomId; + + /** + * 系统类型 + */ + @Column(name = "system_type") + private String systemType; + + /** + * 创建时间 + */ + @Column(name = "create_time") + private Date createTime; +} \ No newline at end of file diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/shortmessage/MeetingInfoMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/shortmessage/MeetingInfoMapper.java new file mode 100644 index 0000000..19a4a9c --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/shortmessage/MeetingInfoMapper.java @@ -0,0 +1,7 @@ +package com.ruoyi.system.mapper.shortmessage; + +import com.ruoyi.system.domain.entity.shortmessage.MeetingInfo; +import tk.mybatis.mapper.common.Mapper; + +public interface MeetingInfoMapper extends Mapper { +} \ No newline at end of file diff --git a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/vo/shortmessage/MeetingInfoVO.java b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/vo/shortmessage/MeetingInfoVO.java new file mode 100644 index 0000000..0f30ac8 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/vo/shortmessage/MeetingInfoVO.java @@ -0,0 +1,41 @@ +package com.ruoyi.wisdomarbitrate.domain.vo.shortmessage; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class MeetingInfoVO { + /** + * 案件Id + */ + private Long caseId; + + /** + * 用户Id + */ + private Long userId; + + /** + * 用户名称 + */ + private String userName; + + /** + * 房间Id + */ + private String roomId; + + /** + * 系统类型 + */ + private String systemType; + /** + * 登录认证令牌 + */ + private String token; +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/mscase/impl/MsCaseApplicationServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/mscase/impl/MsCaseApplicationServiceImpl.java index 27db354..8af6a6e 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/mscase/impl/MsCaseApplicationServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/mscase/impl/MsCaseApplicationServiceImpl.java @@ -2277,6 +2277,9 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService { } // 电话号不为空,发送短信,否则发邮箱 if (StrUtil.isNotEmpty(sysUser.getPhonenumber())) { + //TODO 发送调解时视频会议链接地址,模板id为2125909 + //短信模板:尊敬的{1}用户,您的{2}会议链接https://txroom.xayunmei.com/#/home?{3},请点击链接参加会议,如非本人操作,请忽略本短信 + // todo 短信 // cn.hutool.json.JSONObject jsonObject = SmsUtils.sendSms(application.getId(), templateId, sysUser.getPhonenumber(), // new String[]{caseApplication.getCaseNum(), application.getHearDate()}); diff --git a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/sendrecord/ShortMessageService.java b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/sendrecord/ShortMessageService.java deleted file mode 100644 index bd9f290..0000000 --- a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/sendrecord/ShortMessageService.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.ruoyi.wisdomarbitrate.service.sendrecord; - -import com.ruoyi.common.core.domain.AjaxResult; -import com.ruoyi.system.domain.entity.shortmessage.MsSmsSendHistoryRecord; -import com.ruoyi.system.mapper.shortmessage.MsSmsSendHistoryRecordMapper; -import com.ruoyi.wisdomarbitrate.domain.dto.sendrecord.SmsSendRecord; - -public interface ShortMessageService { - /** - * 新增发送历史记录 - */ - void insertShortMessageHistoryRecord(SmsSendRecord smsSendRecord); - - /** - * 重新发送短信 - * @param smsSendRecord - */ - AjaxResult reSendShortMessage(SmsSendRecord smsSendRecord); -} diff --git a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/sendrecord/impl/ShortMessageServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/sendrecord/impl/ShortMessageServiceImpl.java deleted file mode 100644 index 16290df..0000000 --- a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/sendrecord/impl/ShortMessageServiceImpl.java +++ /dev/null @@ -1,54 +0,0 @@ -package com.ruoyi.wisdomarbitrate.service.sendrecord.impl; - -import cn.hutool.json.JSONObject; -import com.ruoyi.common.core.domain.AjaxResult; -import com.ruoyi.common.enums.SMSStatusEnum; -import com.ruoyi.common.utils.SmsUtils; -import com.ruoyi.system.domain.entity.shortmessage.MsSmsSendHistoryRecord; -import com.ruoyi.system.mapper.shortmessage.MsSmsSendHistoryRecordMapper; -import com.ruoyi.wisdomarbitrate.domain.dto.sendrecord.SmsSendRecord; -import com.ruoyi.wisdomarbitrate.service.sendrecord.ShortMessageService; -import org.springframework.beans.BeanUtils; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -@Service -public class ShortMessageServiceImpl implements ShortMessageService { - @Autowired - MsSmsSendHistoryRecordMapper msSmsSendHistoryRecordMapper; - /** - * 新增发送历史记录 - * - * @param smsSendRecord - */ - @Override - public void insertShortMessageHistoryRecord(SmsSendRecord smsSendRecord) { - if(smsSendRecord!=null){ - MsSmsSendHistoryRecord historyRecord=new MsSmsSendHistoryRecord(); - BeanUtils.copyProperties(smsSendRecord,historyRecord); - historyRecord.setId(null); - historyRecord.setParentId(smsSendRecord.getId()); - msSmsSendHistoryRecordMapper.insert(historyRecord); - } - } - - /** - * 重新发送短信 - * - * @param smsSendRecord - */ - @Override - public AjaxResult reSendShortMessage(SmsSendRecord smsSendRecord) { - SmsUtils.SendSmsRequest request = new SmsUtils.SendSmsRequest(); - //TODO 模版id待替换 - request.setTemplateId("1955047"); - request.setPhone(smsSendRecord.getPhone()); - request.setTemplateParamSet(new String[]{ smsSendRecord.getSendContent()}); - JSONObject resultObj = SmsUtils.sendSms(request); - if(resultObj.get("status")!=null && !resultObj.get("status").equals(SMSStatusEnum.FAIL.getCode())){ - return AjaxResult.success("短信发送成功"); - }else { - return AjaxResult.warn("短信发送失败"); - } - } -} diff --git a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/shortmessage/ShortMessageService.java b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/shortmessage/ShortMessageService.java new file mode 100644 index 0000000..ba91508 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/shortmessage/ShortMessageService.java @@ -0,0 +1,32 @@ +package com.ruoyi.wisdomarbitrate.service.shortmessage; + +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.wisdomarbitrate.domain.dto.sendrecord.SmsSendRecord; +import com.ruoyi.wisdomarbitrate.domain.vo.shortmessage.MeetingInfoVO; + +public interface ShortMessageService { + /** + * 新增发送历史记录 + */ + void insertShortMessageHistoryRecord(SmsSendRecord smsSendRecord); + + /** + * 重新发送短信 + * + * @param smsSendRecord + */ + AjaxResult reSendShortMessage(SmsSendRecord smsSendRecord); + + /** + * 根据信息生成加密信息记录 + * + * @param meetingInfoVO + * @return + */ + String buildMeetingInfoRecord(MeetingInfoVO meetingInfoVO); + + /** + * 通过UID查询加密信息并解密成明文对象 + */ + Object getMeetingInfo(String uid); +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/shortmessage/impl/ShortMessageServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/shortmessage/impl/ShortMessageServiceImpl.java new file mode 100644 index 0000000..05b891b --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/shortmessage/impl/ShortMessageServiceImpl.java @@ -0,0 +1,117 @@ +package com.ruoyi.wisdomarbitrate.service.shortmessage.impl; + +import cn.hutool.json.JSONObject; +import com.ruoyi.common.constant.Constants; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.enums.SMSStatusEnum; +import com.ruoyi.common.utils.SmsUtils; +import com.ruoyi.system.domain.entity.shortmessage.MeetingInfo; +import com.ruoyi.system.domain.entity.shortmessage.MsSmsSendHistoryRecord; +import com.ruoyi.system.mapper.shortmessage.MeetingInfoMapper; +import com.ruoyi.system.mapper.shortmessage.MsSmsSendHistoryRecordMapper; +import com.ruoyi.wisdomarbitrate.domain.dto.sendrecord.SmsSendRecord; +import com.ruoyi.wisdomarbitrate.domain.vo.shortmessage.MeetingInfoVO; +import com.ruoyi.wisdomarbitrate.service.shortmessage.ShortMessageService; +import io.jsonwebtoken.Jwts; +import io.jsonwebtoken.SignatureAlgorithm; +import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Service; + +import java.util.Date; +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; + +@Service +public class ShortMessageServiceImpl implements ShortMessageService { + @Autowired + MsSmsSendHistoryRecordMapper msSmsSendHistoryRecordMapper; + @Autowired + MeetingInfoMapper meetingInfoMapper; + + /** + * 新增发送历史记录 + * + * @param smsSendRecord + */ + @Override + public void insertShortMessageHistoryRecord(SmsSendRecord smsSendRecord) { + if (smsSendRecord != null) { + MsSmsSendHistoryRecord historyRecord = new MsSmsSendHistoryRecord(); + BeanUtils.copyProperties(smsSendRecord, historyRecord); + historyRecord.setId(null); + historyRecord.setParentId(smsSendRecord.getId()); + msSmsSendHistoryRecordMapper.insert(historyRecord); + } + } + + /** + * 重新发送短信 + * + * @param smsSendRecord + */ + @Override + public AjaxResult reSendShortMessage(SmsSendRecord smsSendRecord) { + SmsUtils.SendSmsRequest request = new SmsUtils.SendSmsRequest(); + //TODO 模版id待替换 + request.setTemplateId("1955047"); + request.setPhone(smsSendRecord.getPhone()); + request.setTemplateParamSet(new String[]{smsSendRecord.getSendContent()}); + JSONObject resultObj = SmsUtils.sendSms(request); + if (resultObj.get("status") != null && !resultObj.get("status").equals(SMSStatusEnum.FAIL.getCode())) { + return AjaxResult.success("短信发送成功"); + } else { + return AjaxResult.warn("短信发送失败"); + } + } + + /** + * 根据信息生成加密信息记录 + * + * @param meetingInfoVO + * @return + */ + @Override + public String buildMeetingInfoRecord(MeetingInfoVO meetingInfoVO) { + String uid = UUID.randomUUID().toString().replace("-", ""); + MeetingInfo meetingInfo = MeetingInfo.builder().userId(meetingInfoVO.getUserId()).userName(meetingInfoVO.getUserName()).caseId(meetingInfoVO.getCaseId()).roomId(meetingInfoVO.getRoomId()).systemType(meetingInfoVO.getSystemType()).createTime(new Date()).uid(uid).build(); + meetingInfo.setUid(uid); + meetingInfoMapper.insertSelective(meetingInfo); + return uid; + } + + /** + * 通过UID查询加密信息并解密成明文对象 + * + * @param uid + */ + @Override + public Object getMeetingInfo(String uid) { + MeetingInfoVO result = new MeetingInfoVO(); + MeetingInfo meetingInfo = meetingInfoMapper.selectByPrimaryKey(uid); + if (meetingInfo != null) { + BeanUtils.copyProperties(meetingInfo, result); + if (result != null) { + Map claims = new HashMap<>(); + claims.put("userName", meetingInfo.getUserName()); + claims.put("userId", meetingInfo.getUserId()); + claims.put(Constants.MEETING_KEY, uid); + String createToken = createToken(claims); + result.setToken(createToken); + } + return result; + } + return null; + } + + // 令牌秘钥 + @Value("${token.secret}") + private String secret; + + private String createToken(Map claims) { + String token = Jwts.builder().setClaims(claims).signWith(SignatureAlgorithm.HS512, secret).compact(); + return token; + } +} diff --git a/ruoyi-system/src/main/resources/com/ruoyi/system/mapper/shortmessage/MeetingInfoMapper.xml b/ruoyi-system/src/main/resources/com/ruoyi/system/mapper/shortmessage/MeetingInfoMapper.xml new file mode 100644 index 0000000..d3bdf9e --- /dev/null +++ b/ruoyi-system/src/main/resources/com/ruoyi/system/mapper/shortmessage/MeetingInfoMapper.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tkgenerator/src/main/resources/generator/config.properties b/tkgenerator/src/main/resources/generator/config.properties index 4fbfe55..66e8621 100644 --- a/tkgenerator/src/main/resources/generator/config.properties +++ b/tkgenerator/src/main/resources/generator/config.properties @@ -7,6 +7,6 @@ targetprojectpath=D:/WorkCode/TJ/Mediation-Backend/ruoyi-system #模块名称 moduleName=shortmessage #表名 -tableName=ms_sms_send_history_record +tableName=encryptend_info #主键 premaryId=id