Commit eee34240 by lzy

Merge branch 'dev' of git.xmmakeit.com:huangjiay/iot-platform-server into dev

parents be8c9835 6a0ce7d1
Showing with 748 additions and 74 deletions
...@@ -9,6 +9,7 @@ import com.makeit.common.page.PageVO; ...@@ -9,6 +9,7 @@ import com.makeit.common.page.PageVO;
import com.makeit.common.response.ApiResponseEntity; import com.makeit.common.response.ApiResponseEntity;
import com.makeit.common.response.ApiResponseUtils; import com.makeit.common.response.ApiResponseUtils;
import com.makeit.common.vo.ExcelImportVo; import com.makeit.common.vo.ExcelImportVo;
import com.makeit.enums.CodeMessageEnum;
import com.makeit.exception.BusinessException; import com.makeit.exception.BusinessException;
import com.makeit.global.annotation.Action; import com.makeit.global.annotation.Action;
import com.makeit.module.admin.dto.plat.PlatUserDTOVO; import com.makeit.module.admin.dto.plat.PlatUserDTOVO;
...@@ -161,7 +162,7 @@ public class PlatUserController { ...@@ -161,7 +162,7 @@ public class PlatUserController {
@PostMapping("import") @PostMapping("import")
public ApiResponseEntity<ExcelImportVo> importExcel(@RequestParam(value = "excelFile", required = false) MultipartFile excelFile) throws Exception { public ApiResponseEntity<ExcelImportVo> importExcel(@RequestParam(value = "excelFile", required = false) MultipartFile excelFile) throws Exception {
if(excelFile == null ){ if(excelFile == null ){
throw new BusinessException("请上传excel"); throw new BusinessException(CodeMessageEnum.SYSTEM_ERROR_EXCEL_UPLOAD_EXIT);
} }
ExcelImportVo excelImportVo = platUserService.importExcel(excelFile); ExcelImportVo excelImportVo = platUserService.importExcel(excelFile);
return ApiResponseUtils.success(excelImportVo); return ApiResponseUtils.success(excelImportVo);
......
package com.makeit.config; package com.makeit.config;
import com.makeit.global.inteceptor.RequestIdInterceptor; import com.makeit.global.inteceptor.*;
import com.makeit.global.inteceptor.SaasAuthenticationInterceptor;
import com.makeit.global.inteceptor.SaasAuthorizationInterceptor;
import com.makeit.global.inteceptor.PlatAuthenticationInterceptor;
import com.makeit.global.inteceptor.PlatAuthorizationInterceptor;
import com.makeit.utils.old.StringUtils; import com.makeit.utils.old.StringUtils;
import lombok.Data; import lombok.Data;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -34,6 +30,9 @@ public class WebInterceptorConfig implements WebMvcConfigurer { ...@@ -34,6 +30,9 @@ public class WebInterceptorConfig implements WebMvcConfigurer {
@Autowired @Autowired
private SaasAuthorizationInterceptor saasAuthorizationInterceptor; private SaasAuthorizationInterceptor saasAuthorizationInterceptor;
@Autowired
private WechatAuthenticationInterceptor wechatAuthenticationInterceptor;
private String authenticationSaasPath; private String authenticationSaasPath;
private String authenticationSaasPathIgnore; private String authenticationSaasPathIgnore;
...@@ -48,6 +47,9 @@ public class WebInterceptorConfig implements WebMvcConfigurer { ...@@ -48,6 +47,9 @@ public class WebInterceptorConfig implements WebMvcConfigurer {
private String authorizationTntPath; private String authorizationTntPath;
private String authorizationTntPathIgnore; private String authorizationTntPathIgnore;
private String authenticationWechatPath;
private String authenticationWechatPathIgnore;
@Override @Override
public void addInterceptors(InterceptorRegistry registry) { public void addInterceptors(InterceptorRegistry registry) {
...@@ -62,6 +64,8 @@ public class WebInterceptorConfig implements WebMvcConfigurer { ...@@ -62,6 +64,8 @@ public class WebInterceptorConfig implements WebMvcConfigurer {
addInterceptor(registry.addInterceptor(saasAuthenticationInterceptor), authenticationSaasPath, authenticationSaasPathIgnore); addInterceptor(registry.addInterceptor(saasAuthenticationInterceptor), authenticationSaasPath, authenticationSaasPathIgnore);
//saas 授权 //saas 授权
addInterceptor(registry.addInterceptor(saasAuthorizationInterceptor), authorizationSaasPath, authorizationSaasPathIgnore); addInterceptor(registry.addInterceptor(saasAuthorizationInterceptor), authorizationSaasPath, authorizationSaasPathIgnore);
//微信 认证
addInterceptor(registry.addInterceptor(wechatAuthenticationInterceptor), authenticationWechatPath, authenticationWechatPathIgnore);
} }
......
...@@ -69,6 +69,7 @@ public enum CodeMessageEnum { ...@@ -69,6 +69,7 @@ public enum CodeMessageEnum {
SYSTEM_ERROR_AUTH_USER_PAY_PASSWORD_BLANK(500, "SYSTEM.ERROR.AUTH.USER.PAY.PASSWORD.BLANK"), SYSTEM_ERROR_AUTH_USER_PAY_PASSWORD_BLANK(500, "SYSTEM.ERROR.AUTH.USER.PAY.PASSWORD.BLANK"),
SYSTEM_ERROR_WECHAT_USER_NOT_EXIST(520, "SYSTEM.ERROR.WECHAT.USER.NOT.EXIST"), SYSTEM_ERROR_WECHAT_USER_NOT_EXIST(520, "SYSTEM.ERROR.WECHAT.USER.NOT.EXIST"),
SYSTEM_ERROR_AUTH_USER_MAIL_NOT_SET(500, "SYSTEM.ERROR.AUTH.USER.MAIL.NOT.SET"), SYSTEM_ERROR_AUTH_USER_MAIL_NOT_SET(500, "SYSTEM.ERROR.AUTH.USER.MAIL.NOT.SET"),
SYSTEM_ERROR_AUTH_USER_PASSWORD_NOT_EQUALS(500, "SYSTEM.ERROR.AUTH.USER.PASSWORD.NOT.EQUALS"),
SYSTEM_ERROR_EXCEL_UPLOAD_EXIT(10001, "SYSTEM.ERROR.EXCEL.UPLOAD.EXIT"), SYSTEM_ERROR_EXCEL_UPLOAD_EXIT(10001, "SYSTEM.ERROR.EXCEL.UPLOAD.EXIT"),
SYSTEM_ERROR_EXCEL_NOT_DATA(10002, "SYSTEM.ERROR.EXCEL.NOT.DATA"), SYSTEM_ERROR_EXCEL_NOT_DATA(10002, "SYSTEM.ERROR.EXCEL.NOT.DATA"),
...@@ -108,7 +109,11 @@ public enum CodeMessageEnum { ...@@ -108,7 +109,11 @@ public enum CodeMessageEnum {
SYSTEM_ERROR_TENANT_NOT_EXIST(510, "SYSTEM.ERROR.TENANT.NOT.EXIST"), SYSTEM_ERROR_TENANT_NOT_EXIST(510, "SYSTEM.ERROR.TENANT.NOT.EXIST"),
SYSTEM_ERROR_ROLE_ADMIN_CANT_ADD(500, "SYSTEM.ERROR.ROLE.ADMIN.CANT.ADD"), SYSTEM_ERROR_ROLE_ADMIN_CANT_ADD(500, "SYSTEM.ERROR.ROLE.ADMIN.CANT.ADD"),
SYSTEM_ERROR_ROLE_ADMIN_CANT_EDIT(500, "SYSTEM.ERROR.ROLE.ADMIN.CANT.EDIT"), SYSTEM_ERROR_ROLE_ADMIN_CANT_EDIT(500, "SYSTEM.ERROR.ROLE.ADMIN.CANT.EDIT"),
;
PLATFORM_ERROR_ALARM_NOT_FOUND_SPACE(500,"PLATFORM.ERROR.ALARM.NOT.FOUND.SPACE"),
PLATFORM_ERROR_ALARM_NOT_FOUND_ELDER(500,"PLATFORM.ERROR.ALARM.NOT.FOUND.ELDER"),
; ;
/** /**
......
...@@ -2,7 +2,6 @@ package com.makeit.global.bodyadvice; ...@@ -2,7 +2,6 @@ package com.makeit.global.bodyadvice;
import com.makeit.common.page.PageReqDTO; import com.makeit.common.page.PageReqDTO;
import com.makeit.utils.data.ReflectionUtil; import com.makeit.utils.data.ReflectionUtil;
import com.makeit.utils.old.StringUtils;
import org.springframework.core.MethodParameter; import org.springframework.core.MethodParameter;
import org.springframework.http.HttpInputMessage; import org.springframework.http.HttpInputMessage;
import org.springframework.http.converter.HttpMessageConverter; import org.springframework.http.converter.HttpMessageConverter;
...@@ -13,6 +12,7 @@ import java.io.IOException; ...@@ -13,6 +12,7 @@ import java.io.IOException;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.lang.reflect.Type; import java.lang.reflect.Type;
import java.util.List; import java.util.List;
import java.util.Objects;
@RestControllerAdvice @RestControllerAdvice
public class StringTrimRequestBodyAdvice implements RequestBodyAdvice { public class StringTrimRequestBodyAdvice implements RequestBodyAdvice {
...@@ -50,7 +50,8 @@ public class StringTrimRequestBodyAdvice implements RequestBodyAdvice { ...@@ -50,7 +50,8 @@ public class StringTrimRequestBodyAdvice implements RequestBodyAdvice {
try { try {
Object o = e.get(body); Object o = e.get(body);
String s = (String) o; String s = (String) o;
if (StringUtils.isNotBlank(s)) { //前端如果传"" 字段无法更新成功
if (Objects.nonNull(s)) {
e.set(body, s.trim()); e.set(body, s.trim());
} else { } else {
e.set(body, null); e.set(body, null);
......
package com.makeit.utils.msg; package com.makeit.utils.msg;
import com.makeit.utils.msg.dto.MsgDTO;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.Collection;
@Component @Component
public class MsgUtil { public class MsgUtil {
/** /**
* 发送消息并保存记录 * 发送消息并保存记录
*/ */
public void send(MsgDTO msgDTO){ public void send(SendTypeEnum sendTypeEnum, Collection<String> receiverList, String content){
switch (sendTypeEnum){
case SMS:
break;
case MAIL:
break;
case VOICE_SMS:
break;
case JINGQI:
break;
case YUNLING:
break;
}
} }
} }
...@@ -8,12 +8,14 @@ import lombok.Getter; ...@@ -8,12 +8,14 @@ import lombok.Getter;
@AllArgsConstructor @AllArgsConstructor
@Getter @Getter
public enum SendTypeEnum implements BaseEnum { public enum SendTypeEnum implements BaseEnum {
//1-短信 2-邮件 3-语音短信 4-云龄工单 5-晶奇工单 //1-短信 2-邮件 3-语音短信 4-云龄工单 5-晶奇工单 6-子女端小程序
SMS("alarm.sendType.sms"), SMS("alarm.sendType.sms"),
MAIL("alarm.sendType.mail"), MAIL("alarm.sendType.mail"),
VOICE_SMS("alarm.sendType.voiceSms"), VOICE_SMS("alarm.sendType.voiceSms"),
YUNLING("alarm.sendType.yunling"), YUNLING("alarm.sendType.yunling"),
JINGQI("alarm.sendType.jingqi"); JINGQI("alarm.sendType.jingqi"),
CHILD_WECHAT("alarm.sendType.childWechat")
;
private String code; private String code;
...@@ -21,4 +23,9 @@ public enum SendTypeEnum implements BaseEnum { ...@@ -21,4 +23,9 @@ public enum SendTypeEnum implements BaseEnum {
public String getValue() { public String getValue() {
return SysDictUtil.getValue(code); return SysDictUtil.getValue(code);
} }
public static SendTypeEnum getByValue(String value){
SendTypeEnum byValue =(SendTypeEnum)BaseEnum.getByValue(SendTypeEnum.class, value);
return byValue;
}
} }
package com.makeit.utils.msg.config;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
@Data
@ConfigurationProperties("sms.send")
@Configuration
public class SmsConfig {
private String url;
private String uid;
private String pwd;
}
...@@ -33,11 +33,6 @@ public class MsgDTO { ...@@ -33,11 +33,6 @@ public class MsgDTO {
this.param = param; this.param = param;
} }
public String getSendContent() {
replaceParam();
return sendContent;
}
private void replaceParam(){ private void replaceParam(){
if(StringUtils.isNotBlank(sendContent)){ if(StringUtils.isNotBlank(sendContent)){
return; return;
......
package com.makeit.utils.msg.sender; package com.makeit.utils.msg.sender;
import com.makeit.utils.msg.dto.MsgDTO; import com.makeit.utils.msg.dto.MsgDTO;
import com.makeit.utils.msg.dto.SendResult;
public interface IMsgSender { public interface IMsgSender {
...@@ -9,5 +8,5 @@ public interface IMsgSender { ...@@ -9,5 +8,5 @@ public interface IMsgSender {
* 发送消息 * 发送消息
* @param msgData 消息数据 * @param msgData 消息数据
*/ */
SendResult send(MsgDTO MsgDTO); void send(MsgDTO MsgDTO) throws Exception;
} }
package com.makeit.utils.msg.sender; package com.makeit.utils.msg.sender;
import com.makeit.exception.BusinessException;
import com.makeit.utils.msg.dto.MsgDTO; import com.makeit.utils.msg.dto.MsgDTO;
import com.makeit.utils.msg.dto.SendResult;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
...@@ -25,23 +25,18 @@ public class MailMsgSender implements IMsgSender { ...@@ -25,23 +25,18 @@ public class MailMsgSender implements IMsgSender {
@Override @Override
public SendResult send(MsgDTO msgDTO) { public void send(MsgDTO msgDTO) {
SendResult sendResult = new SendResult();
try { try {
MimeMessage message = mailSender.createMimeMessage(); MimeMessage message = mailSender.createMimeMessage();
MimeMessageHelper helper = new MimeMessageHelper(message, true); MimeMessageHelper helper = new MimeMessageHelper(message, true);
helper.setFrom(from); helper.setFrom(from);
helper.setTo(msgDTO.getReceiverList().toArray(new String[msgDTO.getReceiverList().size()])); helper.setTo(msgDTO.getReceiverList().toArray(new String[msgDTO.getReceiverList().size()]));
helper.setSubject(msgDTO.getSubject()); helper.setSubject(msgDTO.getSubject());
helper.setText(msgDTO.getSendContent(), false); helper.setText(msgDTO.getOriContent(), false);
mailSender.send(message); mailSender.send(message);
} catch (Exception e) { } catch (Exception e) {
sendResult.setSuccess(false); throw new BusinessException(e.getMessage());
sendResult.setInfo(e.getMessage());
} }
sendResult.setSuccess(true);
return sendResult;
} }
} }
package com.makeit.utils.msg.sender;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.makeit.exception.BusinessException;
import com.makeit.utils.msg.config.SmsConfig;
import com.makeit.utils.msg.dto.MsgDTO;
import com.makeit.utils.old.encode.CryptoUtil;
import com.makeit.utils.third.HttpClient;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpHeaders;
import org.springframework.stereotype.Component;
import java.net.URLEncoder;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.stream.Collectors;
@Component
public class SmsMsgSender implements IMsgSender{
@Autowired
private SmsConfig smsConfig;
/**
* 发送消息
*
* @param msgDTO
*/
@Override
public void send(MsgDTO msgDTO) throws Exception {
try {
Date now = new Date();
String time = String.valueOf(now.getTime());
List<String> receiverList = msgDTO.getReceiverList();
String receiverJoin = receiverList.stream().collect(Collectors.joining(","));
HashMap<String, String> paramMap = new HashMap<>();
paramMap.put("uid", smsConfig.getUid() + 1000);
//md5-32位( md5-16位(登录密码)+ time )
String md16 = CryptoUtil.md5_16(smsConfig.getPwd());
String md32 = CryptoUtil.md5(md16 + time);
paramMap.put("pwd", md32);
paramMap.put("time", time);
paramMap.put("mobile", receiverJoin);
paramMap.put("content", URLEncoder.encode(msgDTO.getOriContent(), "UTF-8"));
String resStr = HttpClient.sendJSONPostRequest(smsConfig.getUrl(), paramMap, new HttpHeaders(), String.class);
JSONObject jsonObject = JSON.parseObject(resStr);
String status = (String) jsonObject.get("status");
if (!StringUtils.equals(status, "0")) {
throw new BusinessException((String) jsonObject.get("status_code"));
}
}catch (Exception e){
throw new BusinessException(e.getMessage());
}
}
}
...@@ -301,7 +301,8 @@ public class CryptoUtil { ...@@ -301,7 +301,8 @@ public class CryptoUtil {
// 3 计算后获得字节数组,这就是那128位了 // 3 计算后获得字节数组,这就是那128位了
byte[] buff = md.digest(input); byte[] buff = md.digest(input);
// 4 把数组每一字节(一个字节占八位)换成16进制连成md5字符串 // 4 把数组每一字节(一个字节占八位)换成16进制连成md5字符串
return bytesToHex(buff).substring(8, 24); String bytesToHex = bytesToHex(buff);
return bytesToHex.substring(8, 24);
} catch (Exception e) { } catch (Exception e) {
throw ExceptionUtil.unchecked(e); throw ExceptionUtil.unchecked(e);
} }
...@@ -330,6 +331,6 @@ public class CryptoUtil { ...@@ -330,6 +331,6 @@ public class CryptoUtil {
} }
md5str.append(Integer.toHexString(digital)); md5str.append(Integer.toHexString(digital));
} }
return md5str.toString().toUpperCase(); return md5str.toString();
} }
} }
package com.makeit.utils.third.mail;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
@Data
@ConfigurationProperties(prefix = "spring.mail")
@Component
public class MailConfig {
private String username;
private String template;
private String title;
}
...@@ -14,7 +14,7 @@ import org.springframework.stereotype.Component; ...@@ -14,7 +14,7 @@ import org.springframework.stereotype.Component;
@Component @Component
@ConfigurationProperties(prefix = "sms.config") @ConfigurationProperties(prefix = "sms.config")
@Data @Data
public class SmsConfig { public class SmsConfigOld {
private String templateCode; private String templateCode;
private String signName; private String signName;
private String keys; private String keys;
......
...@@ -75,7 +75,7 @@ public class SmsSendUtil { ...@@ -75,7 +75,7 @@ public class SmsSendUtil {
} }
public static void sendSMS(String phone, SmsConfig smsConfig, String templateParam) throws Exception { public static void sendSMS(String phone, SmsConfigOld smsConfig, String templateParam) throws Exception {
try { try {
sendSMS(phone, smsConfig.getSignName(), smsConfig.getTemplateCode(), templateParam); sendSMS(phone, smsConfig.getSignName(), smsConfig.getTemplateCode(), templateParam);
} catch (Exception ex) { } catch (Exception ex) {
...@@ -95,7 +95,7 @@ public class SmsSendUtil { ...@@ -95,7 +95,7 @@ public class SmsSendUtil {
String token = IdGen.getUUID(); String token = IdGen.getUUID();
Map<String, Object> param = new HashMap<>(16); Map<String, Object> param = new HashMap<>(16);
param.put("code", code); param.put("code", code);
SmsSendUtil.sendSMS(phone, SpringContextHolder.getBean(SmsConfig.class), JsonUtil.toJson(param)); SmsSendUtil.sendSMS(phone, SpringContextHolder.getBean(SmsConfigOld.class), JsonUtil.toJson(param));
TokenUtil.setMobileCode(phone, token, code, 5); TokenUtil.setMobileCode(phone, token, code, 5);
return token; return token;
} }
......
...@@ -65,6 +65,7 @@ SYSTEM.ERROR.AUTH.USER.ACCOUNT.PASSWORD=账号或者密码错误! ...@@ -65,6 +65,7 @@ SYSTEM.ERROR.AUTH.USER.ACCOUNT.PASSWORD=账号或者密码错误!
SYSTEM.ERROR.AUTH.USER.PASSWORD=密码错误 SYSTEM.ERROR.AUTH.USER.PASSWORD=密码错误
SYSTEM.ERROR.AUTH.USER.PAY.PASSWORD.BLANK=支付密码未设置 SYSTEM.ERROR.AUTH.USER.PAY.PASSWORD.BLANK=支付密码未设置
SYSTEM.ERROR.AUTH.USER.MAIL.NOT.SET=邮箱未设置 SYSTEM.ERROR.AUTH.USER.MAIL.NOT.SET=邮箱未设置
SYSTEM.ERROR.AUTH.USER.PASSWORD.NOT.EQUALS=新密码与确认密码不一致
SYSTEM.ERROR.WECHAT.USER.NOT.EXIST=该企微账号对应的用户不存在 SYSTEM.ERROR.WECHAT.USER.NOT.EXIST=该企微账号对应的用户不存在
...@@ -102,3 +103,7 @@ PLATFORM.ERROR.ROOM.OTHER.USED.NOT.DEL=该房间下有床位有其他长者入 ...@@ -102,3 +103,7 @@ PLATFORM.ERROR.ROOM.OTHER.USED.NOT.DEL=该房间下有床位有其他长者入
SYSTEM.ERROR.ROLE.ADMIN.CANT.ADD=不能在该节点下新增非管理员角色 SYSTEM.ERROR.ROLE.ADMIN.CANT.ADD=不能在该节点下新增非管理员角色
SYSTEM.ERROR.ROLE.ADMIN.CANT.EDIT=管理员角色不能修改 SYSTEM.ERROR.ROLE.ADMIN.CANT.EDIT=管理员角色不能修改
PLATFORM.ERROR.ALARM.NOT.FOUND.SPACE=设备未绑定空间
PLATFORM.ERROR.ALARM.NOT.FOUND.ELDER=设备空间下无长者
...@@ -10,6 +10,7 @@ import com.makeit.dto.platform.alarm.PlatAlarmRecordQueryDTO; ...@@ -10,6 +10,7 @@ import com.makeit.dto.platform.alarm.PlatAlarmRecordQueryDTO;
import com.makeit.service.platform.alarm.PlatAlarmRecordService; import com.makeit.service.platform.alarm.PlatAlarmRecordService;
import com.makeit.utils.msg.dto.MsgDTO; import com.makeit.utils.msg.dto.MsgDTO;
import com.makeit.utils.msg.sender.MailMsgSender; import com.makeit.utils.msg.sender.MailMsgSender;
import com.makeit.utils.msg.sender.SmsMsgSender;
import com.makeit.vo.platform.alarm.PlatAlarmRecordVO; import com.makeit.vo.platform.alarm.PlatAlarmRecordVO;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
...@@ -48,16 +49,18 @@ public class PlatAlarmRecordController { ...@@ -48,16 +49,18 @@ public class PlatAlarmRecordController {
@ApiOperation("通知家属") @ApiOperation("通知家属")
@PostMapping("notice") @PostMapping("notice")
public ApiResponseEntity<Void> notice(@RequestBody BaseIdDTO dto) { public ApiResponseEntity<Void> notice(@RequestBody BaseIdDTO dto) {
platAlarmRecordService.notice(dto.getId()); platAlarmRecordService.noticeRelation(dto.getId());
return ApiResponseUtils.success(); return ApiResponseUtils.success();
} }
@Autowired @Autowired
private MailMsgSender mailMsgSender; private MailMsgSender mailMsgSender;
@Autowired
private SmsMsgSender smsMsgSender;
@ApiOperation("测试消息") @ApiOperation("测试邮箱")
@PostMapping("testMsg") @PostMapping("testMail")
public ApiResponseEntity<Void> testMsg(@RequestBody BaseIdDTO dto) { public ApiResponseEntity<Void> testMail(@RequestBody BaseIdDTO dto) {
MsgDTO msgDTO = new MsgDTO(); MsgDTO msgDTO = new MsgDTO();
msgDTO.setSubject("测试消息"); msgDTO.setSubject("测试消息");
msgDTO.setReceiverList(Collections.singletonList("994997968@qq.com")); msgDTO.setReceiverList(Collections.singletonList("994997968@qq.com"));
...@@ -65,5 +68,15 @@ public class PlatAlarmRecordController { ...@@ -65,5 +68,15 @@ public class PlatAlarmRecordController {
mailMsgSender.send(msgDTO); mailMsgSender.send(msgDTO);
return ApiResponseUtils.success(); return ApiResponseUtils.success();
} }
@ApiOperation("测试短信")
@PostMapping("testMsg")
public ApiResponseEntity<Void> testMsg(@RequestBody BaseIdDTO dto) throws Exception {
MsgDTO msgDTO = new MsgDTO();
msgDTO.setReceiverList(Collections.singletonList("18850503603"));
msgDTO.setOriContent("测试短信test");
smsMsgSender.send(msgDTO);
return ApiResponseUtils.success();
}
} }
...@@ -48,7 +48,7 @@ public class WechatPlatAlarmRecordController { ...@@ -48,7 +48,7 @@ public class WechatPlatAlarmRecordController {
@ApiOperation("通知家属") @ApiOperation("通知家属")
@PostMapping("notice") @PostMapping("notice")
public ApiResponseEntity<Void> notice(@RequestBody BaseIdDTO dto) { public ApiResponseEntity<Void> notice(@RequestBody BaseIdDTO dto) {
platAlarmRecordService.notice(dto.getId()); platAlarmRecordService.noticeRelation(dto.getId());
return ApiResponseUtils.success(); return ApiResponseUtils.success();
} }
......
package com.makeit.module.controller.wechat.auth;
import com.makeit.common.dto.LoginDTO;
import com.makeit.common.response.ApiResponseEntity;
import com.makeit.common.response.ApiResponseUtils;
import com.makeit.module.admin.vo.plat.PlatUserLoginVO;
import com.makeit.service.platform.auth.PlatUserService;
import com.makeit.service.wechat.PlatLoginWechatService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
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;
/**
* Controller
*
* @author zm
* @version 2023/9/6
*/
@Api(tags = "平台端小程序-登录")
@RestController
@RequestMapping("/wechat/plat/login")
public class PlatLoginWechatController {
@Autowired
private PlatLoginWechatService platLoginWechatService;
@ApiOperation("登录")
@PostMapping("login")
public ApiResponseEntity<PlatUserLoginVO> login(@RequestBody LoginDTO loginDTO) {
return ApiResponseUtils.success(platLoginWechatService.wechatLogin(loginDTO));
}
}
package com.makeit.module.controller.wechat.auth;
import com.makeit.common.response.ApiResponseEntity;
import com.makeit.common.response.ApiResponseUtils;
import com.makeit.dto.platform.auth.PlatUserChangePasswordDTO;
import com.makeit.service.wechat.PlatUserWechatService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
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;
/**
* Controller
*
* @author zm
* @version 2023/9/7
*/
@Api(tags = "平台端小程序-我的")
@RestController
@RequestMapping("/wechat/plat/user")
public class PlatUserWechatController {
@Autowired
private PlatUserWechatService platUserWechatService;
@ApiOperation("修改密码")
@PostMapping("changePassword")
public ApiResponseEntity<Void> changePassword(@RequestBody PlatUserChangePasswordDTO dto) {
platUserWechatService.changePassword(dto);
return ApiResponseUtils.success();
}
}
package com.makeit.module.controller.wechat.space;
import com.makeit.common.dto.BaseIdDTO;
import com.makeit.common.page.PageReqDTO;
import com.makeit.common.page.PageVO;
import com.makeit.common.response.ApiResponseEntity;
import com.makeit.common.response.ApiResponseUtils;
import com.makeit.dto.platform.space.PlatBedEditDTO;
import com.makeit.dto.platform.space.PlatBedQueryDTO;
import com.makeit.entity.platform.space.PlatBed;
import com.makeit.service.platform.space.PlatBedService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
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;
/**
* Controller
*
* @author zm
* @version 2023/9/7
*/
@Api(tags = "平台端小程序-管理床位")
@RestController
@RequestMapping("/wechat/plat/bed")
public class PlatBedWechatController {
@Autowired
private PlatBedService platBedService;
@ApiOperation("列表")
@PostMapping("page")
public ApiResponseEntity<PageVO<PlatBed>> page(@RequestBody PageReqDTO<PlatBedQueryDTO> page) {
PageVO<PlatBed> data = platBedService.page(page);
return ApiResponseUtils.success(data);
}
@ApiOperation("详情")
@PostMapping("view")
public ApiResponseEntity<PlatBed> view(@RequestBody BaseIdDTO baseIdDTO) {
PlatBed data = platBedService.view(baseIdDTO.getId());
return ApiResponseUtils.success(data);
}
@ApiOperation("编辑")
@PostMapping("edit")
public ApiResponseEntity<?> edit(@Validated @RequestBody PlatBedEditDTO dto) {
platBedService.edit(dto);
return ApiResponseUtils.success();
}
@ApiOperation("删除")
@PostMapping("del")
public ApiResponseEntity<?> del(@RequestBody BaseIdDTO baseIdDTO) {
platBedService.del(baseIdDTO.getId());
return ApiResponseUtils.success();
}
}
package com.makeit.module.controller.wechat.space;
import com.makeit.common.dto.BaseBatchIdDTO;
import com.makeit.common.dto.BaseIdDTO;
import com.makeit.common.page.PageReqDTO;
import com.makeit.common.page.PageVO;
import com.makeit.common.response.ApiResponseEntity;
import com.makeit.common.response.ApiResponseUtils;
import com.makeit.dto.platform.space.PlatRoomDTO;
import com.makeit.dto.platform.space.PlatRoomQueryDTO;
import com.makeit.entity.platform.space.PlatRoom;
import com.makeit.service.platform.space.PlatRoomService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
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;
/**
* Controller
*
* @author zm
* @version 2023/9/7
*/
@Api(tags = "平台端小程序-房间管理")
@RestController
@RequestMapping("/wechat/plat/room")
public class PlatRoomWechatController {
@Autowired
private PlatRoomService platRoomService;
@ApiOperation("新增")
@PostMapping("add")
public ApiResponseEntity<?> add(@Validated @RequestBody PlatRoomDTO dto) {
platRoomService.add(dto);
return ApiResponseUtils.success();
}
@ApiOperation("编辑")
@PostMapping("edit")
public ApiResponseEntity<?> edit(@Validated @RequestBody PlatRoomDTO dto) {
platRoomService.edit(dto);
return ApiResponseUtils.success();
}
@ApiOperation("详情")
@PostMapping("view")
public ApiResponseEntity<PlatRoomDTO> edit(@RequestBody BaseIdDTO baseIdDTO) {
PlatRoomDTO data = platRoomService.view(baseIdDTO.getId());
return ApiResponseUtils.success(data);
}
@ApiOperation("删除")
@PostMapping("del")
public ApiResponseEntity<PlatRoomDTO> del(@RequestBody BaseBatchIdDTO baseBatchIdDTO) {
platRoomService.del(baseBatchIdDTO.getIdList());
return ApiResponseUtils.success();
}
@ApiOperation("列表")
@PostMapping("page")
public ApiResponseEntity<PageVO<PlatRoom>> page(@RequestBody PageReqDTO<PlatRoomQueryDTO> page) {
PageVO<PlatRoom> data = platRoomService.page(page);
return ApiResponseUtils.success(data);
}
}
package com.makeit.module.controller.wechat.space;
import com.makeit.common.dto.BaseIdDTO;
import com.makeit.common.response.ApiResponseEntity;
import com.makeit.common.response.ApiResponseUtils;
import com.makeit.dto.platform.space.PlatSpaceAddDTO;
import com.makeit.dto.platform.space.PlatSpaceQueryDTO;
import com.makeit.dto.platform.space.PlatSpaceVO;
import com.makeit.service.platform.space.PlatSpaceService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
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 java.util.List;
/**
* Controller
*
* @author zm
* @version 2023/9/7
*/
@Api(tags = "平台端小程序-空间管理")
@RestController
@RequestMapping("/wechat/plat/space")
public class PlatSpaceWechatController {
@Autowired
private PlatSpaceService spaceService;
@ApiOperation("新增")
@PostMapping("add")
public ApiResponseEntity<?> add(@Validated @RequestBody PlatSpaceAddDTO dto) {
spaceService.add(dto);
return ApiResponseUtils.success();
}
@ApiOperation("编辑")
@PostMapping("edit")
public ApiResponseEntity<?> edit(@Validated @RequestBody PlatSpaceAddDTO dto) {
spaceService.edit(dto);
return ApiResponseUtils.success();
}
@ApiOperation("详情")
@PostMapping("view")
public ApiResponseEntity<PlatSpaceAddDTO> view(@RequestBody BaseIdDTO baseIdDTO) {
PlatSpaceAddDTO data = spaceService.view(baseIdDTO.getId());
return ApiResponseUtils.success(data);
}
@ApiOperation("删除")
@PostMapping("del")
public ApiResponseEntity<?> del(@RequestBody BaseIdDTO baseIdDTO) {
spaceService.del(baseIdDTO.getId());
return ApiResponseUtils.success();
}
@ApiOperation("树")
@PostMapping("tree")
public ApiResponseEntity<List<PlatSpaceVO>> tree(@RequestBody PlatSpaceQueryDTO dto) {
List<PlatSpaceVO> data = spaceService.tree(dto);
return ApiResponseUtils.success(data);
}
}
package com.makeit.dto.platform.auth;
import com.makeit.common.dto.BaseIdDTO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotBlank;
/**
* Controller
*
* @author zm
* @version 2023/9/7
*/
@ApiModel("平台端小程序修改密码DTO")
@Data
public class PlatUserChangePasswordDTO extends BaseIdDTO {
@NotBlank(message = "旧密码不能为空")
@ApiModelProperty(value = "旧密码")
private String oldPassword;
@NotBlank(message = "新密码不能为空")
@ApiModelProperty(value = "新密码")
private String newPassword;
@NotBlank(message = "确认密码不能为空")
@ApiModelProperty(value = "确认密码")
private String queryPassword;
}
package com.makeit.entity.saas; package com.makeit.entity.saas;
import com.baomidou.mybatisplus.annotation.FieldStrategy;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import com.makeit.common.entity.BaseEntity; import com.makeit.common.entity.BaseEntity;
import lombok.Data; import lombok.Data;
...@@ -30,11 +32,13 @@ public class SaasMenu extends BaseEntity { ...@@ -30,11 +32,13 @@ public class SaasMenu extends BaseEntity {
/** /**
* 图标 * 图标
*/ */
@TableField(updateStrategy = FieldStrategy.IGNORED)
private String icon; private String icon;
/** /**
* 排序 * 排序
*/ */
@TableField
private Integer sort; private Integer sort;
/** /**
......
...@@ -20,5 +20,5 @@ public interface PlatAlarmRecordService extends IService<PlatAlarmRecord> { ...@@ -20,5 +20,5 @@ public interface PlatAlarmRecordService extends IService<PlatAlarmRecord> {
void deal(String recordId); void deal(String recordId);
void notice(String recordId); void noticeRelation(String recordId);
} }
...@@ -9,16 +9,27 @@ import com.makeit.common.page.PageVO; ...@@ -9,16 +9,27 @@ import com.makeit.common.page.PageVO;
import com.makeit.dto.platform.alarm.PlatAlarmRecordQueryDTO; import com.makeit.dto.platform.alarm.PlatAlarmRecordQueryDTO;
import com.makeit.entity.platform.alarm.PlatAlarmConfig; import com.makeit.entity.platform.alarm.PlatAlarmConfig;
import com.makeit.entity.platform.alarm.PlatAlarmRecord; import com.makeit.entity.platform.alarm.PlatAlarmRecord;
import com.makeit.entity.platform.elder.PlatElder;
import com.makeit.entity.platform.elder.PlatElderSocialRelation;
import com.makeit.entity.platform.space.PlatRoomBedDevice;
import com.makeit.enums.CodeMessageEnum;
import com.makeit.enums.CommonEnum; import com.makeit.enums.CommonEnum;
import com.makeit.exception.BusinessException;
import com.makeit.mapper.platform.alarm.PlatAlarmRecordMapper; import com.makeit.mapper.platform.alarm.PlatAlarmRecordMapper;
import com.makeit.service.platform.alarm.PlatAlarmConfigService; import com.makeit.service.platform.alarm.PlatAlarmConfigService;
import com.makeit.service.platform.alarm.PlatAlarmRecordService; import com.makeit.service.platform.alarm.PlatAlarmRecordService;
import com.makeit.service.platform.elder.PlatElderService;
import com.makeit.service.platform.elder.PlatElderSocialRelationService;
import com.makeit.service.platform.space.PlatRoomBedDeviceService;
import com.makeit.utils.data.convert.BeanDtoVoUtils; import com.makeit.utils.data.convert.BeanDtoVoUtils;
import com.makeit.utils.data.convert.PageUtil; import com.makeit.utils.data.convert.PageUtil;
import com.makeit.utils.msg.MsgUtil;
import com.makeit.utils.msg.SendTypeEnum;
import com.makeit.utils.sql.join.JoinUtil; import com.makeit.utils.sql.join.JoinUtil;
import com.makeit.utils.user.common.CommonUserUtil; import com.makeit.utils.user.common.CommonUserUtil;
import com.makeit.utils.user.common.CommonUserVO; import com.makeit.utils.user.common.CommonUserVO;
import com.makeit.vo.platform.alarm.PlatAlarmRecordVO; import com.makeit.vo.platform.alarm.PlatAlarmRecordVO;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -28,6 +39,9 @@ import java.time.LocalDateTime; ...@@ -28,6 +39,9 @@ import java.time.LocalDateTime;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;
/** /**
* @author lixl * @author lixl
...@@ -39,6 +53,15 @@ public class PlatAlarmRecordServiceImpl extends ServiceImpl<PlatAlarmRecordMappe ...@@ -39,6 +53,15 @@ public class PlatAlarmRecordServiceImpl extends ServiceImpl<PlatAlarmRecordMappe
implements PlatAlarmRecordService{ implements PlatAlarmRecordService{
@Autowired @Autowired
private PlatAlarmConfigService platAlarmConfigService; private PlatAlarmConfigService platAlarmConfigService;
@Autowired
private PlatRoomBedDeviceService platRoomBedDeviceService;
@Autowired
private PlatElderService platElderService;
@Autowired
private PlatElderSocialRelationService platElderSocialRelationService;
@Autowired
private MsgUtil msgUtil;
@Override @Override
public PageVO<PlatAlarmRecordVO> page(PageReqDTO<PlatAlarmRecordQueryDTO> dto) { public PageVO<PlatAlarmRecordVO> page(PageReqDTO<PlatAlarmRecordQueryDTO> dto) {
...@@ -92,7 +115,7 @@ implements PlatAlarmRecordService{ ...@@ -92,7 +115,7 @@ implements PlatAlarmRecordService{
@Override @Override
@Transactional @Transactional
public void notice(String recordId) { public void noticeRelation(String recordId) {
//todo //todo
PlatAlarmRecord platAlarmRecord = this.getById(recordId); PlatAlarmRecord platAlarmRecord = this.getById(recordId);
...@@ -100,5 +123,37 @@ implements PlatAlarmRecordService{ ...@@ -100,5 +123,37 @@ implements PlatAlarmRecordService{
String deviceId = platAlarmRecord.getDeviceId(); String deviceId = platAlarmRecord.getDeviceId();
LambdaQueryWrapper<PlatRoomBedDevice> roomBedDeviceLambdaQueryWrapper = new LambdaQueryWrapper<PlatRoomBedDevice>()
.eq(PlatRoomBedDevice::getEquipmentId, deviceId).orderByDesc(BaseEntity::getUpdateDate);
PlatRoomBedDevice platRoomBedDevice = platRoomBedDeviceService.getOne(roomBedDeviceLambdaQueryWrapper, false);
//绑定房间的设备要通知 全部长者的家属
//绑定床位的设备要通知对应的长者的家属
if(platRoomBedDevice == null){
throw new BusinessException(CodeMessageEnum.PLATFORM_ERROR_ALARM_NOT_FOUND_SPACE);
}
String bedId = platRoomBedDevice.getBedId();
String roomId = platRoomBedDevice.getRoomId();
LambdaQueryWrapper<PlatElder> elderLambdaQueryWrapper = new LambdaQueryWrapper<PlatElder>().eq(StringUtils.isNotBlank(bedId), PlatElder::getBedId, bedId)
.eq(PlatElder::getRoomId, roomId);
List<PlatElder> elderList = platElderService.list(elderLambdaQueryWrapper);
if(CollectionUtils.isEmpty(elderList)){
throw new BusinessException(CodeMessageEnum.PLATFORM_ERROR_ALARM_NOT_FOUND_ELDER);
}
Set<String> elderIdSet = elderList.stream().map(BaseEntity::getId).collect(Collectors.toSet());
List<PlatElderSocialRelation> relations = platElderSocialRelationService.list(new LambdaQueryWrapper<PlatElderSocialRelation>().in(PlatElderSocialRelation::getElderId, elderIdSet));
Set<String> phoneList = relations.stream().map(PlatElderSocialRelation::getPhone).collect(Collectors.toSet());
String notifyChannel = platAlarmConfig.getNotifyChannel();
String[] split = notifyChannel.split(",");
List<String> notifyChannelList = Arrays.asList(SendTypeEnum.SMS.getValue(), SendTypeEnum.VOICE_SMS.getValue(),SendTypeEnum.CHILD_WECHAT.getValue());
Set<String> sendTypeList = Stream.of(split).filter(vo -> notifyChannelList.contains(vo)).collect(Collectors.toSet());
for (String sendType: sendTypeList) {
SendTypeEnum sendTypeEnum = SendTypeEnum.getByValue(sendType);
msgUtil.send(sendTypeEnum,phoneList,platAlarmRecord.getContent());
}
platAlarmRecord.setNoticeStatus(CommonEnum.YES.getValue());
updateById(platAlarmRecord);
} }
} }
...@@ -50,6 +50,8 @@ public interface PlatUserService extends IService<PlatUser> { ...@@ -50,6 +50,8 @@ public interface PlatUserService extends IService<PlatUser> {
PlatUserLoginVO login(LoginDTO loginDTO); PlatUserLoginVO login(LoginDTO loginDTO);
void setTenantList(PlatUserLoginVO tntUserLoginVO);
void logout(); void logout();
List<PlatMenu> getMenuListByTenantId(String tenantId); List<PlatMenu> getMenuListByTenantId(String tenantId);
......
...@@ -308,7 +308,8 @@ public class PlatUserServiceImpl extends ServiceImpl<PlatUserMapper, PlatUser> ...@@ -308,7 +308,8 @@ public class PlatUserServiceImpl extends ServiceImpl<PlatUserMapper, PlatUser>
updateById(user); updateById(user);
} }
private void setTenantList(PlatUserLoginVO tntUserLoginVO) { @Override
public void setTenantList(PlatUserLoginVO tntUserLoginVO) {
if (IsTenantAccountEnum.YES.getValue().equals(tntUserLoginVO.getIsTenant())) { if (IsTenantAccountEnum.YES.getValue().equals(tntUserLoginVO.getIsTenant())) {
List<PlatTenant> tntTenantList = platTenantService.list(new QueryWrapper<PlatTenant>().lambda() List<PlatTenant> tntTenantList = platTenantService.list(new QueryWrapper<PlatTenant>().lambda()
.eq(PlatTenant::getStatus, CommonEnum.YES.getValue()) .eq(PlatTenant::getStatus, CommonEnum.YES.getValue())
...@@ -420,7 +421,7 @@ public class PlatUserServiceImpl extends ServiceImpl<PlatUserMapper, PlatUser> ...@@ -420,7 +421,7 @@ public class PlatUserServiceImpl extends ServiceImpl<PlatUserMapper, PlatUser>
buttonList.add(e); buttonList.add(e);
} }
if (catalogue.equals(e.getResourceType()) || menu.equals(e.getResourceType())) { if (catalogue.equals(e.getResourceType()) || menu.equals(e.getResourceType())||button.equals(e.getResourceType())) {
nonButtonList.add(e); nonButtonList.add(e);
} }
......
...@@ -187,6 +187,27 @@ public class PlatElderServiceImpl extends ServiceImpl<PlatElderMapper, PlatElder ...@@ -187,6 +187,27 @@ public class PlatElderServiceImpl extends ServiceImpl<PlatElderMapper, PlatElder
return vo; return vo;
}); });
JoinUtil.join(list, platSpaceService, Arrays.asList(
PlatElderExportVO::getStreetSpaceId,
PlatElderExportVO::getBuildingSpaceId,
PlatElderExportVO::getUnitSpaceId,
PlatElderExportVO::getFloorSpaceId
), Arrays.asList(
(e, s) -> e.setStreetSpaceName(s.getName()),
(e, s) -> e.setBuildingSpaceName(s.getName()),
(e, s) -> e.setUnitSpaceName(s.getName()),
(e, s) -> e.setFloorSpaceName(s.getName())
));
JoinUtil.join(list, platRoomService, PlatElderExportVO::getRoomId, (e, l) -> {
e.setRoomName(l.getName());
});
JoinUtil.join(list, platBedService, PlatElderExportVO::getBedId, (e, l) -> {
e.setBedName(l.getName());
});
ExcelUtil.export(response, "长者信息" + FileSuffixEnum.EXCEL.getSuffix(), PlatElderExportVO.class, list); ExcelUtil.export(response, "长者信息" + FileSuffixEnum.EXCEL.getSuffix(), PlatElderExportVO.class, list);
} }
......
...@@ -328,7 +328,12 @@ implements SaasUserService{ ...@@ -328,7 +328,12 @@ implements SaasUserService{
private void fillMenuList(List<SaasMenu> menuList, SaasUserLoginVO userLoginVO) { private void fillMenuList(List<SaasMenu> menuList, SaasUserLoginVO userLoginVO) {
List<SaasMenu> buttonList = StreamUtil.filter(menuList, e -> SysEnum.MenuTypeEnum.MENU.getValue().equals(e.getCategory()) || SysEnum.MenuTypeEnum.BUTTON.getValue().equals(e.getCategory())); List<SaasMenu> buttonList = StreamUtil.filter(menuList, e -> SysEnum.MenuTypeEnum.MENU.getValue().equals(e.getCategory()) || SysEnum.MenuTypeEnum.BUTTON.getValue().equals(e.getCategory()));
List<SaasMenu> nonButtonList = StreamUtil.filter(menuList, e -> SysEnum.MenuTypeEnum.CATALOGUE.getValue().equals(e.getCategory()) || SysEnum.MenuTypeEnum.MENU.getValue().equals(e.getCategory())); List<SaasMenu> nonButtonList = StreamUtil.filter(menuList, e ->
SysEnum.MenuTypeEnum.CATALOGUE.getValue().equals(e.getCategory())
|| SysEnum.MenuTypeEnum.MENU.getValue().equals(e.getCategory())
|| SysEnum.MenuTypeEnum.BUTTON.getValue().equals(e.getCategory())
);
List<SaasMenuDTOVO> menuVOList = saasMenuService.tree(BeanDtoVoUtils.listVo(nonButtonList, SaasMenuDTOVO.class)); List<SaasMenuDTOVO> menuVOList = saasMenuService.tree(BeanDtoVoUtils.listVo(nonButtonList, SaasMenuDTOVO.class));
userLoginVO.setButtonList(BeanDtoVoUtils.listVo(buttonList, SaasMenuDTOVO.class)); userLoginVO.setButtonList(BeanDtoVoUtils.listVo(buttonList, SaasMenuDTOVO.class));
...@@ -345,15 +350,15 @@ implements SaasUserService{ ...@@ -345,15 +350,15 @@ implements SaasUserService{
} }
private void setRoleMenuToRedis(SaasUserLoginVO userLoginVO) { private void setRoleMenuToRedis(SaasUserLoginVO userLoginVO) {
SaasUserRoleMenuRedisVO platUserRoleMenuRedisVO = new SaasUserRoleMenuRedisVO(); SaasUserRoleMenuRedisVO saasUserRoleMenuRedisVO = new SaasUserRoleMenuRedisVO();
platUserRoleMenuRedisVO.setId(userLoginVO.getId()); saasUserRoleMenuRedisVO.setId(userLoginVO.getId());
if (userLoginVO.getRoleList() != null) { if (userLoginVO.getRoleList() != null) {
platUserRoleMenuRedisVO.setRoleCodeList(StreamUtil.map(userLoginVO.getRoleList(), SaasRoleDTOVO::getCode)); saasUserRoleMenuRedisVO.setRoleCodeList(StreamUtil.map(userLoginVO.getRoleList(), SaasRoleDTOVO::getCode));
} }
if (userLoginVO.getButtonList() != null) { if (userLoginVO.getButtonList() != null) {
platUserRoleMenuRedisVO.setButtonCodeList(StreamUtil.map(userLoginVO.getButtonList(), SaasMenuDTOVO::getCode)); saasUserRoleMenuRedisVO.setButtonCodeList(StreamUtil.map(userLoginVO.getButtonList(), SaasMenuDTOVO::getCode));
} }
TokenUtil.platLoginRoleMenu(platUserRoleMenuRedisVO); TokenUtil.platLoginRoleMenu(saasUserRoleMenuRedisVO);
} }
......
package com.makeit.service.wechat;
import com.makeit.common.dto.LoginDTO;
import com.makeit.module.admin.vo.plat.PlatUserLoginVO;
/**
* Controller
*
* @author zm
* @version 2023/9/7
*/
public interface PlatLoginWechatService {
PlatUserLoginVO wechatLogin(LoginDTO loginDTO);
}
package com.makeit.service.wechat;
import com.makeit.dto.platform.auth.PlatUserChangePasswordDTO;
/**
* Controller
*
* @author zm
* @version 2023/9/7
*/
public interface PlatUserWechatService {
void changePassword(PlatUserChangePasswordDTO dto);
}
package com.makeit.service.wechat.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.makeit.common.dto.LoginDTO;
import com.makeit.entity.platform.auth.PlatUser;
import com.makeit.enums.CodeMessageEnum;
import com.makeit.enums.CommonEnum;
import com.makeit.exception.BusinessException;
import com.makeit.global.aspect.tenant.TenantIdIgnore;
import com.makeit.module.admin.vo.plat.PlatUserLoginVO;
import com.makeit.service.platform.auth.PlatUserService;
import com.makeit.service.wechat.PlatLoginWechatService;
import com.makeit.utils.data.convert.BeanDtoVoUtils;
import com.makeit.utils.data.id.IdGen;
import com.makeit.utils.user.PasswordUtils;
import com.makeit.utils.user.TokenUtil;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* Controller
*
* @author zm
* @version 2023/9/7
*/
@Service
public class PlatLoginWechatServiceImpl implements PlatLoginWechatService {
@Autowired
private PlatUserService platUserService;
@Override
@TenantIdIgnore
public PlatUserLoginVO wechatLogin(LoginDTO loginDTO) {
if (StringUtils.isBlank(loginDTO.getAccount())) {
throw new BusinessException(CodeMessageEnum.SYSTEM_ERROR);
}
if (StringUtils.isBlank(loginDTO.getPassword())) {
throw new BusinessException(CodeMessageEnum.SYSTEM_ERROR);
}
PlatUser platUser = platUserService.getOne(new QueryWrapper<PlatUser>().lambda()
.eq(PlatUser::getAccount, loginDTO.getAccount())
.or()
.eq(PlatUser::getMobile, loginDTO.getAccount())
);
if (platUser == null) {
throw new BusinessException(CodeMessageEnum.SYSTEM_ERROR_AUTH_USER_PASSWORD);
}
if (CommonEnum.NO.getValue().equals(platUser.getStatus())) {
throw new BusinessException(CodeMessageEnum.SYSTEM_ERROR_AUTH_USER_HAS_DISABLED);
}
if (!PasswordUtils.validatePassword(loginDTO.getPassword(), platUser.getPassword())) {
throw new BusinessException(CodeMessageEnum.SYSTEM_ERROR_AUTH_USER_PASSWORD);
}
PlatUserLoginVO userLoginVO = BeanDtoVoUtils.convert(platUser, PlatUserLoginVO.class);
String token = IdGen.getUUID();
userLoginVO.setToken(token);
TokenUtil.wechatLogin(token, userLoginVO);
platUserService.setTenantList(userLoginVO);
return userLoginVO;
}
}
package com.makeit.service.wechat.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.makeit.dto.platform.auth.PlatUserChangePasswordDTO;
import com.makeit.entity.platform.auth.PlatUser;
import com.makeit.enums.CodeMessageEnum;
import com.makeit.exception.BusinessException;
import com.makeit.service.platform.auth.PlatUserService;
import com.makeit.service.wechat.PlatUserWechatService;
import com.makeit.utils.user.PasswordUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
/**
* Controller
*
* @author zm
* @version 2023/9/7
*/
@Service
public class PlatUserWechatServiceImpl implements PlatUserWechatService {
@Autowired
private PlatUserService platUserService;
@Override
@Transactional
public void changePassword(PlatUserChangePasswordDTO dto) {
PlatUser platUser = platUserService.getById(dto.getId());
if (platUser == null) {
throw new BusinessException(CodeMessageEnum.SYSTEM_ERROR_AUTH_USER_PASSWORD);
}
if (!PasswordUtils.validatePassword(dto.getOldPassword(), platUser.getPassword())) {
throw new BusinessException(CodeMessageEnum.SYSTEM_ERROR_AUTH_USER_PASSWORD);
}
if(dto.getNewPassword()!=null && !dto.getNewPassword().equals(dto.getQueryPassword())){
throw new BusinessException(CodeMessageEnum.SYSTEM_ERROR_AUTH_USER_PASSWORD_NOT_EQUALS);
}
platUser.setPassword(dto.getNewPassword());
platUserService.setPassword(platUser);
platUserService.updateById(platUser);
}
}
...@@ -90,6 +90,7 @@ public class IotSyncTask { ...@@ -90,6 +90,7 @@ public class IotSyncTask {
if(platDevice==null){ if(platDevice==null){
platDevice=new PlatDevice(); platDevice=new PlatDevice();
platDevice.setTenantId(tenantId); platDevice.setTenantId(tenantId);
deviceMap.put(iotDevice.getId(),platDevice);
} }
platDevice.setOriDeviceId(iotDevice.getId()); platDevice.setOriDeviceId(iotDevice.getId());
platDevice.setName(iotDevice.getName()); platDevice.setName(iotDevice.getName());
...@@ -100,6 +101,9 @@ public class IotSyncTask { ...@@ -100,6 +101,9 @@ public class IotSyncTask {
platDevice.setDescription(iotDevice.getDescribe()); platDevice.setDescription(iotDevice.getDescribe());
String state = iotDevice.getState(); String state = iotDevice.getState();
platDevice.setStatus(StringUtils.equals("online",state)?CommonEnum.YES.getValue() : CommonEnum.NO.getValue()); platDevice.setStatus(StringUtils.equals("online",state)?CommonEnum.YES.getValue() : CommonEnum.NO.getValue());
//todo 根据类型名称来匹配
// platDevice.setCategory();
// platDevice.setFirmwareVersion(); // platDevice.setFirmwareVersion();
// platDevice.setLastOnlineData(); // platDevice.setLastOnlineData();
// platDevice.setOrgId(); // platDevice.setOrgId();
...@@ -114,7 +118,7 @@ public class IotSyncTask { ...@@ -114,7 +118,7 @@ public class IotSyncTask {
// platDevice.setCreateBy(); // platDevice.setCreateBy();
// platDevice.setUpdateBy(); // platDevice.setUpdateBy();
deviceMap.put(iotDevice.getId(),platDevice);
}); });
return deviceMap.values(); return deviceMap.values();
} }
......
...@@ -124,7 +124,28 @@ wx: ...@@ -124,7 +124,28 @@ wx:
miniapp: miniapp:
config: config:
appid: wx48720402e3fdbe0f #微信小程序的appid appid: wx48720402e3fdbe0f #微信小程序的appid
secret: 2cdf04b11dce20f48402a1fef1cc9842 #微信小程序的Secret secret: 2ebae648f45716e70c75b7d78d0660cc #微信小程序的Secret
token: #微信小程序消息服务器配置的token token: #微信小程序消息服务器配置的token
aesKey: #微信小程序消息服务器配置的EncodingAESKey aesKey: #微信小程序消息服务器配置的EncodingAESKey
msgDataFormat: JSON msgDataFormat: JSON
sms:
send:
url: http://www.aozoneyun.com/message/message/send
uid: 357
pwd: xmks123456
rec:
url:
query:
url: http://www.aozoneyun.com/message/message/balance
voiceSms:
url: http://www.aozoneyun.com/Message/Message/video_send
uid: 362
pwd: xmksyy123456
...@@ -121,7 +121,23 @@ wx: ...@@ -121,7 +121,23 @@ wx:
miniapp: miniapp:
config: config:
appid: wx48720402e3fdbe0f #微信小程序的appid appid: wx48720402e3fdbe0f #微信小程序的appid
secret: 2cdf04b11dce20f48402a1fef1cc9842 #微信小程序的Secret secret: 2ebae648f45716e70c75b7d78d0660cc #微信小程序的Secret
token: #微信小程序消息服务器配置的token token: #微信小程序消息服务器配置的token
aesKey: #微信小程序消息服务器配置的EncodingAESKey aesKey: #微信小程序消息服务器配置的EncodingAESKey
msgDataFormat: JSON msgDataFormat: JSON
sms:
send:
url: http://www.aozoneyun.com/message/message/send
uid: 357
pwd: xmks123456
rec:
url:
query:
url: http://www.aozoneyun.com/message/message/balance
voiceSms:
url: http://www.aozoneyun.com/Message/Message/video_send
uid: 362
pwd: xmksyy123456
\ No newline at end of file
...@@ -110,11 +110,11 @@ sa-token: ...@@ -110,11 +110,11 @@ sa-token:
interceptor: interceptor:
## 登录拦截路径 ## 登录拦截路径
authenticationTntPath: /** authenticationTntPath: /**
authenticationTntPathIgnore: /error,/swagger-resources/**,/v2/api-docs/**,/doc.html,/plat/login/**,/sys/dictionaryCategory/getDictionaryCategoryByList,/children/**,/saas/** authenticationTntPathIgnore: /error,/swagger-resources/**,/v2/api-docs/**,/doc.html,/plat/login/**,/sys/dictionaryCategory/getDictionaryCategoryByList,/children/**,/saas/**,/wechat/**
## 权限拦截路径 ## 权限拦截路径
authorizationTntPath: /** authorizationTntPath: /**
authorizationTntPathIgnore: /error,/swagger-resources/**,/v2/api-docs/**,/doc.html,/plat/login/**,/sys/dictionaryCategory/getDictionaryCategoryByList,/children/**,/saas/** authorizationTntPathIgnore: /error,/swagger-resources/**,/v2/api-docs/**,/doc.html,/plat/login/**,/sys/dictionaryCategory/getDictionaryCategoryByList,/children/**,/saas/**,/wechat/**
## saas端登录拦截路径 ## saas端登录拦截路径
authenticationSaasPath: /saas/** authenticationSaasPath: /saas/**
...@@ -124,8 +124,8 @@ interceptor: ...@@ -124,8 +124,8 @@ interceptor:
authorizationSaasPath: /saas/** authorizationSaasPath: /saas/**
authorizationSaasPathIgnore: /saas/login/login authorizationSaasPathIgnore: /saas/login/login
authenticationWechatPath: /children/** authenticationWechatPath: /children/**,/wechat/**
authenticationWechatPathIgnore: /children/login/login authenticationWechatPathIgnore: /children/login/login,/wechat/plat/login/login
sign: sign:
flag: true flag: true
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment