From 13b316c232c10f8c439439ce751eee7cb4a93eda Mon Sep 17 00:00:00 2001 From: zxc <954985706@qq.com> Date: Fri, 10 Jul 2020 13:56:16 +0800 Subject: [PATCH 1/6] =?UTF-8?q?=E5=BE=AE=E4=BF=A1=E7=AC=AC=E4=B8=89?= =?UTF-8?q?=E6=96=B9=E5=B9=B3=E5=8F=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/epmet/controller/WarrantController.java | 5 ----- 1 file changed, 5 deletions(-) diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/WarrantController.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/WarrantController.java index dfd324ccee..1acb7a60ab 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/WarrantController.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/WarrantController.java @@ -3,11 +3,7 @@ package com.epmet.controller; import com.epmet.exception.AesException; import com.epmet.service.WarrantService; import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.StringUtils; -import org.dom4j.Document; import org.dom4j.DocumentException; -import org.dom4j.DocumentHelper; -import org.dom4j.Element; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; @@ -15,7 +11,6 @@ import org.springframework.web.bind.annotation.RestController; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import java.io.BufferedReader; import java.io.IOException; /** From ff42246de768d551105478befaab6b9aed387703 Mon Sep 17 00:00:00 2001 From: sunyuchao Date: Mon, 13 Jul 2020 16:47:04 +0800 Subject: [PATCH 2/6] =?UTF-8?q?=E5=85=AC=E4=BC=97=E5=8F=B7=E6=9C=8D?= =?UTF-8?q?=E5=8A=A1=E9=83=A8=E5=88=86=E6=8E=A5=E5=8F=A3=E9=A6=96=E6=AC=A1?= =?UTF-8?q?=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- epmet-auth/pom.xml | 6 + .../constant/PublicUserLoginConstant.java | 30 +++ .../controller/PublicUserLoginController.java | 50 ++++- .../epmet/dto/form/LoginByPhoneFormDTO.java | 38 ++++ .../dto/form/PublicSendSmsCodeFormDTO.java | 28 +++ .../java/com/epmet/redis/CaptchaRedis.java | 25 +++ .../epmet/service/PublicUserLoginService.java | 32 ++- .../impl/PublicUserLoginServiceImpl.java | 193 +++++++++++++++++- .../common/token/constant/LoginConstant.java | 10 + .../epmet-third/epmet-third-client/pom.xml | 6 + .../java/com/epmet/dto/CustomerMpDTO.java | 7 +- .../main/java/com/epmet/dto/PaUserDTO.java | 4 +- .../java/com/epmet/dto/PaUserVisitedDTO.java | 4 +- .../java/com/epmet/dto/PaUserWechatDTO.java | 14 +- .../epmet/dto/form/CreateAgencyFormDTO.java | 56 +++++ .../com/epmet/dto/form/RegisterFormDTO.java | 54 +++++ .../dto/form/SaveUserVisitedFormDTO.java | 34 +++ .../dto/result/CreateAgencyResultDTO.java | 23 +++ .../dto/result/CustomerUserResultDTO.java | 25 +++ .../epmet/dto/result/SaveUserResultDTO.java | 21 ++ .../epmet/feign/EpmetThirdFeignClient.java | 36 ++++ .../EpmetThirdFeignClientFallback.java | 22 ++ .../epmet-third/epmet-third-server/pom.xml | 6 + .../java/com/epmet/constant/PaConstant.java | 19 ++ .../controller/PaCustomerController.java | 63 ++++++ .../epmet/controller/PaUserController.java | 37 +++- .../controller/PaUserVisitedController.java | 15 +- .../java/com/epmet/dao/PaCustomerDao.java | 13 +- .../main/java/com/epmet/dao/PaUserDao.java | 13 +- .../java/com/epmet/dao/PaUserWechatDao.java | 19 +- .../com/epmet/entity/CustomerMpEntity.java | 7 +- .../com/epmet/entity/PaUserWechatEntity.java | 10 - .../java/com/epmet/excel/CustomerMpExcel.java | 5 +- .../com/epmet/excel/PaUserWechatExcel.java | 6 - .../com/epmet/service/PaCustomerService.java | 29 +++ .../java/com/epmet/service/PaUserService.java | 19 ++ .../epmet/service/PaUserVisitedService.java | 9 + .../epmet/service/PaUserWechatService.java | 8 + .../service/impl/PaCustomerServiceImpl.java | 109 +++++++++- .../epmet/service/impl/PaUserServiceImpl.java | 89 ++++++++ .../impl/PaUserVisitedServiceImpl.java | 39 +++- .../service/impl/PaUserWechatServiceImpl.java | 11 + .../main/resources/mapper/PaCustomerDao.xml | 12 ++ .../src/main/resources/mapper/PaUserDao.xml | 12 ++ .../main/resources/mapper/PaUserWechatDao.xml | 43 ++++ 45 files changed, 1231 insertions(+), 80 deletions(-) create mode 100644 epmet-auth/src/main/java/com/epmet/constant/PublicUserLoginConstant.java create mode 100644 epmet-auth/src/main/java/com/epmet/dto/form/LoginByPhoneFormDTO.java create mode 100644 epmet-auth/src/main/java/com/epmet/dto/form/PublicSendSmsCodeFormDTO.java create mode 100644 epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/CreateAgencyFormDTO.java create mode 100644 epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/RegisterFormDTO.java create mode 100644 epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/SaveUserVisitedFormDTO.java create mode 100644 epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/CreateAgencyResultDTO.java create mode 100644 epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/CustomerUserResultDTO.java create mode 100644 epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/SaveUserResultDTO.java create mode 100644 epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/constant/PaConstant.java diff --git a/epmet-auth/pom.xml b/epmet-auth/pom.xml index de5d22524a..6794c2a2b4 100644 --- a/epmet-auth/pom.xml +++ b/epmet-auth/pom.xml @@ -116,6 +116,12 @@ 3.6.0 compile + + com.epmet + epmet-third-client + 2.0.0 + compile + diff --git a/epmet-auth/src/main/java/com/epmet/constant/PublicUserLoginConstant.java b/epmet-auth/src/main/java/com/epmet/constant/PublicUserLoginConstant.java new file mode 100644 index 0000000000..f2a2462e6a --- /dev/null +++ b/epmet-auth/src/main/java/com/epmet/constant/PublicUserLoginConstant.java @@ -0,0 +1,30 @@ +package com.epmet.constant; + +/** + * @author sun + * @dscription + */ +public interface PublicUserLoginConstant { + + /** + * 初始化用户信息失败 + */ + String SAVE_USER_EXCEPTION = "初始化用户信息失败"; + /** + * 是否登陆(true false) + */ + String PARAMETER_EXCEPTION = "是否登陆值错误"; + /** + * 登陆验证 + */ + String LOGON_EXCEPTION = "该手机号未注册"; + /** + * 注册验证 + */ + String ZHU_CE_EXCEPTION = "该手机号已注册"; + /** + * 用户登陆 新增访问记录 + */ + String SAVE_VISITED_EXCEPTION = "用户登陆,新增访问记录失败"; + +} diff --git a/epmet-auth/src/main/java/com/epmet/controller/PublicUserLoginController.java b/epmet-auth/src/main/java/com/epmet/controller/PublicUserLoginController.java index 9a48be046c..d083b2a26b 100644 --- a/epmet-auth/src/main/java/com/epmet/controller/PublicUserLoginController.java +++ b/epmet-auth/src/main/java/com/epmet/controller/PublicUserLoginController.java @@ -1,8 +1,15 @@ package com.epmet.controller; +import com.epmet.commons.tools.annotation.LoginUser; +import com.epmet.commons.tools.exception.RenException; +import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.validator.ValidatorUtils; +import com.epmet.constant.PublicUserLoginConstant; +import com.epmet.dto.form.LoginByPhoneFormDTO; import com.epmet.dto.form.PaWxCodeFormDTO; +import com.epmet.dto.form.PublicSendSmsCodeFormDTO; +import com.epmet.dto.result.UserTokenResultDTO; import com.epmet.service.PublicUserLoginService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PostMapping; @@ -10,8 +17,6 @@ import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; -import java.util.Map; - /** * 描述一下 * @@ -28,15 +33,42 @@ public class PublicUserLoginController { /** * @return com.epmet.commons.tools.utils.Result * @param formDTO - * @author yinzuomei - * @description 测试是否能正常解析wxcode - * @Date 2020/7/9 17:00 + * @author sun + * @description 解析wxcode获取用户信息并生成token **/ - @PostMapping(value = "/testwxcode") - public Result loginByWxCode(@RequestBody PaWxCodeFormDTO formDTO) { + @PostMapping(value = "/wxcodetotoken") + public Result wxCodeToToken(@RequestBody PaWxCodeFormDTO formDTO) { ValidatorUtils.validateEntity(formDTO, PaWxCodeFormDTO.AddUserInternalGroup.class); - Map map = publicUserLoginService.loginByWxCode(formDTO); - return new Result().ok(map); + return new Result().ok(publicUserLoginService.wxCodeToToken(formDTO)); } + /** + * @param formDTO 手机号 + * @return com.epmet.commons.tools.utils.Result + * @Author sun + * @Description 公众号登录-发送验证码 + **/ + @PostMapping(value = "/sendsmscode") + public Result sendSmsCode(@RequestBody PublicSendSmsCodeFormDTO formDTO) { + ValidatorUtils.validateEntity(formDTO,PublicSendSmsCodeFormDTO.AddUserShowGroup.class); + if(formDTO.getIsLogon()!=true&&formDTO.getIsLogon()!=false){ + throw new RenException(PublicUserLoginConstant.PARAMETER_EXCEPTION); + } + publicUserLoginService.sendSmsCode(formDTO); + return new Result(); + } + + /** + * @param formDTO + * @return com.epmet.commons.tools.utils.Result + * @Author sun + * @Description 公众号-手机验证码登陆 + **/ + @PostMapping(value = "/loginbyphone") + public Result loginByPhone(@LoginUser TokenDto tokenDTO, @RequestBody LoginByPhoneFormDTO formDTO) { + ValidatorUtils.validateEntity(formDTO, LoginByPhoneFormDTO.AddUserShowGroup.class, LoginByPhoneFormDTO.LoginByPhone.class); + return new Result().ok(publicUserLoginService.loginByPhone(tokenDTO, formDTO)); + } + + } diff --git a/epmet-auth/src/main/java/com/epmet/dto/form/LoginByPhoneFormDTO.java b/epmet-auth/src/main/java/com/epmet/dto/form/LoginByPhoneFormDTO.java new file mode 100644 index 0000000000..8b09d458d9 --- /dev/null +++ b/epmet-auth/src/main/java/com/epmet/dto/form/LoginByPhoneFormDTO.java @@ -0,0 +1,38 @@ +package com.epmet.dto.form; + +import com.epmet.commons.tools.validator.group.CustomerClientShowGroup; +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + +/** + * @Description 手机验证码登陆接口入参 + * @Author sun + */ +@Data +public class LoginByPhoneFormDTO implements Serializable { + private static final long serialVersionUID = 4193133227120225342L; + /** + * 添加用户操作的用户可见异常分组 + * 该分组用于校验需要返回给前端错误信息提示的列,需要继承CustomerClientShowGroup + * 返回错误码为8999,提示信息为DTO中具体的列的校验注解message的内容 + */ + public interface AddUserShowGroup extends CustomerClientShowGroup { + } + + public interface LoginByPhone extends CustomerClientShowGroup{} + /** + * 手机号 + */ + @NotBlank(message = "手机号不能为空", groups = {AddUserShowGroup.class}) + private String phone; + + /** + * 验证码 + */ + @NotBlank(message="验证码不能为空", groups = {LoginByPhone.class}) + private String smsCode; + +} + diff --git a/epmet-auth/src/main/java/com/epmet/dto/form/PublicSendSmsCodeFormDTO.java b/epmet-auth/src/main/java/com/epmet/dto/form/PublicSendSmsCodeFormDTO.java new file mode 100644 index 0000000000..b3e9558600 --- /dev/null +++ b/epmet-auth/src/main/java/com/epmet/dto/form/PublicSendSmsCodeFormDTO.java @@ -0,0 +1,28 @@ +package com.epmet.dto.form; + +import com.epmet.commons.tools.validator.group.CustomerClientShowGroup; +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + +/** + * @Description 公众号手机号+验证码登录接口入参 + * @Author sun + */ +@Data +public class PublicSendSmsCodeFormDTO implements Serializable { + private static final long serialVersionUID = -1852541457359282018L; + /** + * 添加用户操作的用户可见异常分组 + * 该分组用于校验需要返回给前端错误信息提示的列,需要继承CustomerClientShowGroup + * 返回错误码为8999,提示信息为DTO中具体的列的校验注解message的内容 + */ + public interface AddUserShowGroup extends CustomerClientShowGroup { + } + + @NotBlank(message = "手机号不能为空", groups = {AddUserShowGroup.class}) + private String phone; + @NotBlank(message = "是否登陆不能为空", groups = {AddUserShowGroup.class}) + private Boolean isLogon; +} diff --git a/epmet-auth/src/main/java/com/epmet/redis/CaptchaRedis.java b/epmet-auth/src/main/java/com/epmet/redis/CaptchaRedis.java index acdd85f490..50433bdaf0 100644 --- a/epmet-auth/src/main/java/com/epmet/redis/CaptchaRedis.java +++ b/epmet-auth/src/main/java/com/epmet/redis/CaptchaRedis.java @@ -11,6 +11,7 @@ package com.epmet.redis; import com.epmet.common.token.constant.LoginConstant; import com.epmet.commons.tools.redis.RedisKeys; import com.epmet.commons.tools.redis.RedisUtils; +import com.epmet.dto.form.PublicSendSmsCodeFormDTO; import com.epmet.dto.form.SendSmsCodeFormDTO; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -82,4 +83,28 @@ public class CaptchaRedis { String smsCode = (String) redisUtils.get(smsCodeKey); return smsCode; } + + /** + * @param sendSmsCodeFormDTO app、client、phone + * @param smsCode 验证码 + * @return void + * @Author sun + * @Description 公众号-短信验证码存入redis + **/ + public void savePublicSmsCode(PublicSendSmsCodeFormDTO sendSmsCodeFormDTO, String smsCode) { + String smsCodeKey = RedisKeys.getLoginSmsCodeKey(LoginConstant.APP_PUBLIC, LoginConstant.CLIENT_MP, sendSmsCodeFormDTO.getPhone()); + logger.info(String.format("短信验证码key=%s", smsCodeKey)); + redisUtils.set(smsCodeKey, smsCode, MINUTE_THIRTY_EXPIRE); + } + /** + * @param phone + * @return java.lang.String + * @Author sun + * @Description 公众号-获取登录时发送的验证码 + **/ + public String getPublicSmsCode(String phone) { + String smsCodeKey = RedisKeys.getLoginSmsCodeKey(LoginConstant.APP_PUBLIC, LoginConstant.CLIENT_MP, phone); + String smsCode = (String) redisUtils.get(smsCodeKey); + return smsCode; + } } diff --git a/epmet-auth/src/main/java/com/epmet/service/PublicUserLoginService.java b/epmet-auth/src/main/java/com/epmet/service/PublicUserLoginService.java index 20091381c0..0ee6449c90 100644 --- a/epmet-auth/src/main/java/com/epmet/service/PublicUserLoginService.java +++ b/epmet-auth/src/main/java/com/epmet/service/PublicUserLoginService.java @@ -1,8 +1,10 @@ package com.epmet.service; +import com.epmet.commons.tools.security.dto.TokenDto; +import com.epmet.dto.form.LoginByPhoneFormDTO; import com.epmet.dto.form.PaWxCodeFormDTO; - -import java.util.Map; +import com.epmet.dto.form.PublicSendSmsCodeFormDTO; +import com.epmet.dto.result.UserTokenResultDTO; /** * 描述一下 @@ -11,5 +13,29 @@ import java.util.Map; * @date 2020/7/8 18:31 */ public interface PublicUserLoginService { - Map loginByWxCode(PaWxCodeFormDTO formDTO); + + /** + * @return + * @param formDTO + * @author sun + * @description 解析wxcode获取用户信息并生成token + **/ + UserTokenResultDTO wxCodeToToken(PaWxCodeFormDTO formDTO); + + /** + * @param formDTO 手机号 + * @return com.epmet.commons.tools.utils.Result + * @Author sun + * @Description 公众号登录-发送验证码 + **/ + void sendSmsCode(PublicSendSmsCodeFormDTO formDTO); + + /** + * @param formDTO + * @return com.epmet.commons.tools.utils.Result + * @Author sun + * @Description 公众号-手机验证码登陆 + **/ + UserTokenResultDTO loginByPhone(TokenDto tokenDTO, LoginByPhoneFormDTO formDTO); + } diff --git a/epmet-auth/src/main/java/com/epmet/service/impl/PublicUserLoginServiceImpl.java b/epmet-auth/src/main/java/com/epmet/service/impl/PublicUserLoginServiceImpl.java index e6386e757b..a5e0a48d3f 100644 --- a/epmet-auth/src/main/java/com/epmet/service/impl/PublicUserLoginServiceImpl.java +++ b/epmet-auth/src/main/java/com/epmet/service/impl/PublicUserLoginServiceImpl.java @@ -1,7 +1,27 @@ package com.epmet.service.impl; +import com.epmet.common.token.constant.LoginConstant; +import com.epmet.commons.tools.exception.EpmetErrorCode; import com.epmet.commons.tools.exception.RenException; -import com.epmet.dto.form.PaWxCodeFormDTO; +import com.epmet.commons.tools.security.dto.TokenDto; +import com.epmet.commons.tools.utils.CpUserDetailRedis; +import com.epmet.commons.tools.utils.DateUtils; +import com.epmet.commons.tools.utils.Result; +import com.epmet.commons.tools.validator.PhoneValidatorUtils; +import com.epmet.constant.PublicUserLoginConstant; +import com.epmet.constant.SmsTemplateConstant; +import com.epmet.dto.PaCustomerDTO; +import com.epmet.dto.PaUserDTO; +import com.epmet.dto.form.*; +import com.epmet.dto.result.CustomerUserResultDTO; +import com.epmet.dto.result.SaveUserResultDTO; +import com.epmet.dto.result.SendVerificationCodeResultDTO; +import com.epmet.dto.result.UserTokenResultDTO; +import com.epmet.feign.EpmetMessageOpenFeignClient; +import com.epmet.feign.EpmetThirdFeignClient; +import com.epmet.jwt.JwtTokenProperties; +import com.epmet.jwt.JwtTokenUtils; +import com.epmet.redis.CaptchaRedis; import com.epmet.service.PublicUserLoginService; import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.mp.api.WxMpService; @@ -25,16 +45,42 @@ import java.util.Map; @Service public class PublicUserLoginServiceImpl implements PublicUserLoginService { private static final Logger logger = LoggerFactory.getLogger(PublicUserLoginServiceImpl.class); + private static final String SEND_SMS_CODE_ERROR = "发送短信验证码异常,手机号[%s],code[%s],msg[%s]"; @Autowired private WxMpService wxMpService; + @Autowired + private EpmetThirdFeignClient epmetThirdFeignClient; + @Autowired + private JwtTokenUtils jwtTokenUtils; + @Autowired + private JwtTokenProperties jwtTokenProperties; + @Autowired + private CpUserDetailRedis cpUserDetailRedis; + @Autowired + private EpmetMessageOpenFeignClient epmetMessageOpenFeignClient; + @Autowired + private CaptchaRedis captchaRedis; @Override - public Map loginByWxCode(PaWxCodeFormDTO formDTO) { - WxMpUser wxMpUser=this.getWxMpUser(formDTO.getWxCode()); - Map map =new HashMap(); - map.put("微信用户信息",wxMpUser); - return map; + public UserTokenResultDTO wxCodeToToken(PaWxCodeFormDTO formDTO) { + //1.通过微信code获取用户基本信息 + WxMpUser wxMpUser = this.getWxMpUser(formDTO.getWxCode()); + + //2.将获取的用户基本信息初始化到数据库 + Result result = epmetThirdFeignClient.saveUser(wxMpUser); + if (!result.success()) { + throw new RenException(PublicUserLoginConstant.SAVE_USER_EXCEPTION); + } + SaveUserResultDTO resultDTO = result.getData(); + + //3.获取用户token + String token = this.generateGovWxmpToken(resultDTO.getUserId()); + //4.保存到redis + this.saveLatestGovTokenDto(resultDTO, wxMpUser, token); + UserTokenResultDTO userTokenResultDTO = new UserTokenResultDTO(); + userTokenResultDTO.setToken(token); + return userTokenResultDTO; } private WxMpUser getWxMpUser(String wxCode) { @@ -43,13 +89,144 @@ public class PublicUserLoginServiceImpl implements PublicUserLoginService { WxMpOAuth2AccessToken wxMpOAuth2AccessToken = wxMpService.oauth2getAccessToken(wxCode); wxMpUser = wxMpService.oauth2getUserInfo(wxMpOAuth2AccessToken, null); } catch (WxErrorException e) { - logger.error("->[getWxMpUser]::error[{}]", "解析微信用户信息失败",e.getMessage()); + logger.error("->[getWxMpUser]::error[{}]", "解析微信用户信息失败", e.getMessage()); e.printStackTrace(); - throw new RenException("解析微信用户信息失败"+e.getMessage()); + throw new RenException("解析微信用户信息失败" + e.getMessage()); } if (null == wxMpUser || StringUtils.isBlank(wxMpUser.getUnionId())) { throw new RenException("解析微信用户信息失败"); } return wxMpUser; } + + /** + * @Description 生成token + **/ + private String generateGovWxmpToken(String userId) { + Map map = new HashMap<>(); + map.put("app", LoginConstant.APP_PUBLIC); + map.put("client", LoginConstant.CLIENT_MP); + map.put("userId", userId); + String token = jwtTokenUtils.createToken(map); + logger.info("app:" + LoginConstant.APP_PUBLIC + ";client:" + LoginConstant.CLIENT_MP + ";userId:" + userId + ";生成token[" + token + "]"); + return token; + } + + //保存tokenDto到redis + private void saveLatestGovTokenDto(SaveUserResultDTO resultDTO, WxMpUser wxMpUser, String token) { + TokenDto tokenDTO = new TokenDto(); + int expire = jwtTokenProperties.getExpire(); + tokenDTO.setOpenId(wxMpUser.getOpenId()); + tokenDTO.setUnionId(wxMpUser.getUnionId()); + tokenDTO.setToken(token); + //首次初始化时还没有客户 + tokenDTO.setCustomerId(""); + tokenDTO.setUserId(resultDTO.getUserId()); + tokenDTO.setExpireTime(jwtTokenUtils.getExpiration(token).getTime()); + tokenDTO.setUpdateTime(System.currentTimeMillis()); + cpUserDetailRedis.set(tokenDTO, expire); + logger.info("截止时间:" + DateUtils.format(jwtTokenUtils.getExpiration(token), "yyyy-MM-dd HH:mm:ss")); + } + + /** + * @param formDTO 手机号 + * @return com.epmet.commons.tools.utils.Result + * @Author sun + * @Description 公众号登录-发送验证码 + **/ + @Override + public void sendSmsCode(PublicSendSmsCodeFormDTO formDTO) { + //1、校验手机号是否符合规范 + if (!PhoneValidatorUtils.isMobile(formDTO.getPhone())) { + logger.error(String.format(SEND_SMS_CODE_ERROR, formDTO.getPhone(), EpmetErrorCode.ERROR_PHONE.getCode(), EpmetErrorCode.ERROR_PHONE.getMsg())); + throw new RenException(EpmetErrorCode.ERROR_PHONE.getCode()); + } + //2、根据手机号校验用户是否存在 + Result Result = epmetThirdFeignClient.checkPaUser(formDTO.getPhone()); + if (!Result.success()) { + logger.error(String.format(SEND_SMS_CODE_ERROR, formDTO.getPhone(), Result.getCode(), Result.getMsg())); + throw new RenException(Result.getCode()); + } + CustomerUserResultDTO ResultDTO = Result.getData(); + //登陆 + if (formDTO.getIsLogon() && null == ResultDTO.getPaUserResult()) { + throw new RenException(PublicUserLoginConstant.LOGON_EXCEPTION); + } + //注册 + if (!formDTO.getIsLogon() && null != ResultDTO.getPaUserResult()) { + throw new RenException(PublicUserLoginConstant.ZHU_CE_EXCEPTION); + } + //3、发送短信验证码 + SendVerificationCodeFormDTO sendVerificationCodeFormDTO = new SendVerificationCodeFormDTO(); + sendVerificationCodeFormDTO.setMobile(formDTO.getPhone()); + //登陆或注册对应的短息模板 + sendVerificationCodeFormDTO.setAliyunTemplateCode(formDTO.getIsLogon() ? SmsTemplateConstant.LGOIN_CONFIRM : SmsTemplateConstant.USER_REGISTER); + Result smsCodeResult = epmetMessageOpenFeignClient.sendVerificationCode(sendVerificationCodeFormDTO); + if (!smsCodeResult.success()) { + logger.error(String.format(SEND_SMS_CODE_ERROR, formDTO.getPhone(), smsCodeResult.getCode(), smsCodeResult.getMsg())); + throw new RenException(smsCodeResult.getCode()); + } + //4、保存短信验证码(删除现有短信验证码、将新的短信验证码存入Redis) + captchaRedis.savePublicSmsCode(formDTO, smsCodeResult.getData().getCode()); + logger.info(String.format("发送短信验证码成功,手机号[%s]", formDTO.getPhone())); + } + + /** + * @param formDTO + * @return com.epmet.commons.tools.utils.Result + * @Author sun + * @Description 公众号-手机验证码登陆 + **/ + @Override + public UserTokenResultDTO loginByPhone(TokenDto tokenDTO, LoginByPhoneFormDTO formDTO) { + //1.根据手机号查询到用户、客户信息 + Result result = epmetThirdFeignClient.checkPaUser(formDTO.getPhone()); + if (!result.success()) { + logger.error(String.format("手机验证码登录异常,手机号[%s],code[%s],msg[%s]", formDTO.getPhone(), result.getCode(), result.getMsg())); + throw new RenException(result.getCode()); + } + CustomerUserResultDTO resultDTO = result.getData(); + + //2.用户不存在时不允许登陆 + PaUserDTO userDTO = resultDTO.getPaUserResult(); + if (null == resultDTO || StringUtils.isBlank(userDTO.getId())) { + throw new RenException(PublicUserLoginConstant.LOGON_EXCEPTION); + } + + //3.校验验证码是否正确 + String rightSmsCode = captchaRedis.getPublicSmsCode(formDTO.getPhone()); + if (!formDTO.getSmsCode().equals(rightSmsCode)) { + logger.error(String.format("验证码错误code[%s],msg[%s]", EpmetErrorCode.MOBILE_CODE_ERROR.getCode(), EpmetErrorCode.MOBILE_CODE_ERROR.getMsg())); + throw new RenException(EpmetErrorCode.MOBILE_CODE_ERROR.getCode()); + } + //获取缓存中的token + TokenDto redisTokenDTO = cpUserDetailRedis.get(LoginConstant.APP_PUBLIC, LoginConstant.CLIENT_MP, userDTO.getId(), TokenDto.class); + if (redisTokenDTO == null) { + return null; + } + + //4.判断是否存在客户信息,是否需要生成新的token + PaCustomerDTO customerDTO = resultDTO.getPaCustomerResult(); + if (null != customerDTO && !StringUtils.isBlank(customerDTO.getId())) { + redisTokenDTO.setCustomerId(customerDTO.getId()); + int expire = jwtTokenProperties.getExpire(); + cpUserDetailRedis.set(redisTokenDTO, expire); + } + + //5.登陆成功,访问记录表新增访问记录(访问记录新增失败不应影响用户登陆) + SaveUserVisitedFormDTO visited = new SaveUserVisitedFormDTO(); + visited.setUserId(userDTO.getId()); + visited.setLogonUserId(tokenDTO.getUserId()); + visited.setPhone(formDTO.getPhone()); + Result visitedResult = epmetThirdFeignClient.saveUserVisited(visited); + if(!visitedResult.success()){ + logger.error(PublicUserLoginConstant.SAVE_VISITED_EXCEPTION); + } + + //6.返回token + UserTokenResultDTO userTokenResultDTO = new UserTokenResultDTO(); + userTokenResultDTO.setToken(redisTokenDTO.getToken()); + return userTokenResultDTO; + } + } diff --git a/epmet-commons/epmet-common-clienttoken/src/main/java/com/epmet/common/token/constant/LoginConstant.java b/epmet-commons/epmet-common-clienttoken/src/main/java/com/epmet/common/token/constant/LoginConstant.java index b546108bc8..17cb456a1a 100644 --- a/epmet-commons/epmet-common-clienttoken/src/main/java/com/epmet/common/token/constant/LoginConstant.java +++ b/epmet-commons/epmet-common-clienttoken/src/main/java/com/epmet/common/token/constant/LoginConstant.java @@ -21,6 +21,11 @@ public interface LoginConstant { */ String APP_OPER = "oper"; + /** + * 公众号 + */ + String APP_PUBLIC = "public"; + /** * web */ @@ -30,4 +35,9 @@ public interface LoginConstant { * 微信小程序 */ String CLIENT_WXMP = "wxmp"; + + /** + * E事通服务号 + */ + String CLIENT_MP = "mp"; } diff --git a/epmet-module/epmet-third/epmet-third-client/pom.xml b/epmet-module/epmet-third/epmet-third-client/pom.xml index f9e61c9c99..3a2173aa25 100644 --- a/epmet-module/epmet-third/epmet-third-client/pom.xml +++ b/epmet-module/epmet-third/epmet-third-client/pom.xml @@ -20,6 +20,12 @@ epmet-commons-tools 2.0.0 + + com.github.binarywang + weixin-java-mp + 3.6.0 + compile + diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/CustomerMpDTO.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/CustomerMpDTO.java index fd7db9bb2d..014fbe6678 100644 --- a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/CustomerMpDTO.java +++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/CustomerMpDTO.java @@ -54,15 +54,10 @@ public class CustomerMpDTO implements Serializable { private Integer appId; /** - * 是否已经授权 + * 是否已经授权 0:未授权,1:已授权 */ private Integer authorizationFlag; - /** - * 公众账号信息id - */ - private String authorizerInfoId; - /** * 删除标识:0.未删除 1.已删除 */ diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/PaUserDTO.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/PaUserDTO.java index 1491066d85..1a61724055 100644 --- a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/PaUserDTO.java +++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/PaUserDTO.java @@ -34,9 +34,9 @@ public class PaUserDTO implements Serializable { private static final long serialVersionUID = 1L; /** - * 本主键会用作customer_staff里的user_id,user表的id + * user表的id */ - private Integer id; + private String id; /** * 手机号 diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/PaUserVisitedDTO.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/PaUserVisitedDTO.java index 7755dc1182..84f9601199 100644 --- a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/PaUserVisitedDTO.java +++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/PaUserVisitedDTO.java @@ -34,9 +34,9 @@ public class PaUserVisitedDTO implements Serializable { private static final long serialVersionUID = 1L; /** - * 本主键会用作customer_staff里的user_id,user表的id + * user表的id */ - private Integer id; + private String id; /** * 用户Id pa_user.id diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/PaUserWechatDTO.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/PaUserWechatDTO.java index 9f11eab524..29106ab239 100644 --- a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/PaUserWechatDTO.java +++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/PaUserWechatDTO.java @@ -34,9 +34,9 @@ public class PaUserWechatDTO implements Serializable { private static final long serialVersionUID = 1L; /** - * 本主键会用作customer_staff里的user_id,user表的id + * user表的id */ - private Integer id; + private String id; /** * 用户Id user.id @@ -53,11 +53,6 @@ public class PaUserWechatDTO implements Serializable { */ private String unionId; - /** - * 手机号 - */ - private String phone; - /** * 1男2女0未知 */ @@ -88,11 +83,6 @@ public class PaUserWechatDTO implements Serializable { */ private String city; - /** - * 用户特权信息,json 数组,如微信沃卡用户为(chinaunicom) - */ - private String privilege; - /** * 语言 */ diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/CreateAgencyFormDTO.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/CreateAgencyFormDTO.java new file mode 100644 index 0000000000..dec52622c8 --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/CreateAgencyFormDTO.java @@ -0,0 +1,56 @@ +package com.epmet.dto.form; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + +/** + * @Author sun + * @Description 公众号-创建组织-接口入参 + */ +@Data +public class CreateAgencyFormDTO implements Serializable { + + private static final long serialVersionUID = -6547893374373422628L; + + public interface AddUserInternalGroup {} + + /** + * 根组织名称 + */ + @NotBlank(message = "组织名称不能为空") + private String agencyName; + + /** + * 级别 + */ + @NotBlank(message = "组织级别不能为空") + private String level; + + /** + * 地区编码 + */ + @NotBlank(message = "地区编码不能为空") + private String areaCode; + + /** + * 省(中国字) + */ + private String province; + + /** + * 市(中国字) + */ + private String city; + + /** + * 区(中国字) + */ + private String district; + + /** + * 党支部数量 + */ + private Integer partyBranchNum = 0; +} diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/RegisterFormDTO.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/RegisterFormDTO.java new file mode 100644 index 0000000000..fe16eaab4c --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/RegisterFormDTO.java @@ -0,0 +1,54 @@ +package com.epmet.dto.form; + +import com.epmet.commons.tools.validator.group.CustomerClientShowGroup; +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import java.io.Serializable; + +/** + * @Author sun + * @Description 公众号-手机号注册-接口入参 + */ +@Data +public class RegisterFormDTO implements Serializable { + + private static final long serialVersionUID = -6547893374373422628L; + + public interface AddUserInternalGroup { + } + + public interface AddUserShowGroup extends CustomerClientShowGroup { + } + + /** + * 手机号 + */ + @NotBlank(message = "手机号不能为空", groups = {AddUserInternalGroup.class, AddUserShowGroup.class}) + private String phone; + + /** + * 手机短信验证码 + */ + @NotBlank(message = "验证码不能为空", groups = {AddUserShowGroup.class}) + private String smsCode; + + /** + * 姓氏 + */ + @NotBlank(message = "姓氏不能为空", groups = {AddUserShowGroup.class}) + private String surName; + + /** + * 性别 1男2女0未知 + */ + @NotNull(message = "用户性别不能为空", groups = {AddUserShowGroup.class}) + private Integer gender; + + /** + * token中userId + */ + private String userId; + +} diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/SaveUserVisitedFormDTO.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/SaveUserVisitedFormDTO.java new file mode 100644 index 0000000000..eecf8da6d0 --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/SaveUserVisitedFormDTO.java @@ -0,0 +1,34 @@ +package com.epmet.dto.form; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + +/** + * @Author sun + * @Description 公众号-用户登陆新增访问记录-接口入参 + */ +@Data +public class SaveUserVisitedFormDTO implements Serializable { + + private static final long serialVersionUID = -6547893374373422628L; + + public interface AddUserInternalGroup {} + + /** + * 登陆手机号对应的userId + */ + private String userId; + + /** + * 登陆人userId + */ + private String logonUserId; + + /** + * 登陆手机号 + */ + private String phone; + +} diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/CreateAgencyResultDTO.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/CreateAgencyResultDTO.java new file mode 100644 index 0000000000..f344e5c062 --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/CreateAgencyResultDTO.java @@ -0,0 +1,23 @@ +package com.epmet.dto.result; + +import lombok.Data; + +import java.io.Serializable; +import java.util.List; +import java.util.Map; + +/** + * @Author sun + * @Description 公众号-创建组织-接口返参 + */ +@Data +public class CreateAgencyResultDTO implements Serializable { + + private static final long serialVersionUID = 3253989119352850315L; + + /** + * 新增客户Id + */ + private String customerId; + +} diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/CustomerUserResultDTO.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/CustomerUserResultDTO.java new file mode 100644 index 0000000000..3b8d20f9e9 --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/CustomerUserResultDTO.java @@ -0,0 +1,25 @@ +package com.epmet.dto.result; + +import com.epmet.dto.PaCustomerDTO; +import com.epmet.dto.PaUserDTO; +import lombok.Data; + +import java.io.Serializable; + +/** + * @Description 根据手机号查询用户信息、客户信息-接口返参 + * @Author sun + */ +@Data +public class CustomerUserResultDTO implements Serializable { + private static final long serialVersionUID = 5214475907074876716L; + + /** + * 用户信息 + */ + private PaUserDTO paUserResult; + /** + * 用户对应的客户信息 + */ + private PaCustomerDTO paCustomerResult; +} diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/SaveUserResultDTO.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/SaveUserResultDTO.java new file mode 100644 index 0000000000..bd2ce393a4 --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/SaveUserResultDTO.java @@ -0,0 +1,21 @@ +package com.epmet.dto.result; + +import lombok.Data; + +import java.io.Serializable; + +/** + * @Author sun + * @Description 授权用户信息时新增或更新用户信息-接口返参 + */ +@Data +public class SaveUserResultDTO implements Serializable { + + private static final long serialVersionUID = 3253989119352850315L; + + /** + * 新增或已有用户的Id + */ + private String userId; + +} diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/feign/EpmetThirdFeignClient.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/feign/EpmetThirdFeignClient.java index db762abafa..4b038324ac 100644 --- a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/feign/EpmetThirdFeignClient.java +++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/feign/EpmetThirdFeignClient.java @@ -1,8 +1,17 @@ package com.epmet.feign; import com.epmet.commons.tools.constant.ServiceConstant; +import com.epmet.commons.tools.utils.Result; +import com.epmet.dto.form.SaveUserVisitedFormDTO; +import com.epmet.dto.result.CustomerUserResultDTO; +import com.epmet.dto.result.SaveUserResultDTO; import com.epmet.feign.fallback.EpmetThirdFeignClientFallback; +import me.chanjar.weixin.mp.bean.result.WxMpUser; import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.http.MediaType; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; /** * 本服务对外开放的API,其他服务通过引用此client调用该服务 @@ -13,4 +22,31 @@ import org.springframework.cloud.openfeign.FeignClient; @FeignClient(name = ServiceConstant.EPMET_THIRD_SERVER, fallback = EpmetThirdFeignClientFallback.class) public interface EpmetThirdFeignClient { + + /** + * @param wxMpUser + * @return + * @Author sun + * @Description 根据openId新增或更新用户信息 + **/ + @PostMapping(value = "third/pauser/saveuser", consumes = MediaType.APPLICATION_JSON_UTF8_VALUE) + Result saveUser(@RequestBody WxMpUser wxMpUser); + + /** + * @param phone + * @return + * @Author sun + * @Description 根据手机号查询公众号用户基本信息,校验用户是否存在 + **/ + @PostMapping(value = "third/pauser/checkpauser/{phone}") + Result checkPaUser(@PathVariable("phone") String phone); + + /** + * @param visited + * @return + * @Author sun + * @Description 用户登陆,新增访问记录数据 + **/ + @PostMapping(value = "third/pauservisited/saveuservisited") + Result saveUserVisited(@RequestBody SaveUserVisitedFormDTO visited); } diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/feign/fallback/EpmetThirdFeignClientFallback.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/feign/fallback/EpmetThirdFeignClientFallback.java index 7e58be23e7..b1965cad5a 100644 --- a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/feign/fallback/EpmetThirdFeignClientFallback.java +++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/feign/fallback/EpmetThirdFeignClientFallback.java @@ -1,6 +1,13 @@ package com.epmet.feign.fallback; +import com.epmet.commons.tools.constant.ServiceConstant; +import com.epmet.commons.tools.utils.ModuleUtils; +import com.epmet.commons.tools.utils.Result; +import com.epmet.dto.form.SaveUserVisitedFormDTO; +import com.epmet.dto.result.CustomerUserResultDTO; +import com.epmet.dto.result.SaveUserResultDTO; import com.epmet.feign.EpmetThirdFeignClient; +import me.chanjar.weixin.mp.bean.result.WxMpUser; import org.springframework.stereotype.Component; /** @@ -9,4 +16,19 @@ import org.springframework.stereotype.Component; */ @Component public class EpmetThirdFeignClientFallback implements EpmetThirdFeignClient { + + @Override + public Result saveUser(WxMpUser wxMpUser) { + return ModuleUtils.feignConError(ServiceConstant.EPMET_THIRD_SERVER, "saveUser", wxMpUser); + } + + @Override + public Result checkPaUser(String phone) { + return ModuleUtils.feignConError(ServiceConstant.EPMET_THIRD_SERVER, "checkPaUser", phone); + } + + @Override + public Result saveUserVisited(SaveUserVisitedFormDTO visited) { + return ModuleUtils.feignConError(ServiceConstant.EPMET_THIRD_SERVER, "saveUserVisited", visited); + } } diff --git a/epmet-module/epmet-third/epmet-third-server/pom.xml b/epmet-module/epmet-third/epmet-third-server/pom.xml index a8bba9e38c..438272e2c6 100644 --- a/epmet-module/epmet-third/epmet-third-server/pom.xml +++ b/epmet-module/epmet-third/epmet-third-server/pom.xml @@ -123,6 +123,12 @@ 3.6.0 compile + + com.epmet + epmet-common-clienttoken + 2.0.0 + compile + diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/constant/PaConstant.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/constant/PaConstant.java new file mode 100644 index 0000000000..ee15ddf636 --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/constant/PaConstant.java @@ -0,0 +1,19 @@ +package com.epmet.constant; + +/** + * @Description 公众号-常量 + * @author sun + */ +public interface PaConstant { + + /** + * 手机号注册 + */ + String PHONE_EXCEPTION = "手机号已存在,不允许再次注册"; + /** + * 根据userId查询pa_user_wechat表失败 + */ + String SELECT_WECHAT_EXCEPTION = "获取用户微信信息失败"; + + +} diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/PaCustomerController.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/PaCustomerController.java index 7cc03af30e..5f8f9f5660 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/PaCustomerController.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/PaCustomerController.java @@ -1,5 +1,17 @@ package com.epmet.controller; +import com.epmet.commons.tools.annotation.LoginUser; +import com.epmet.commons.tools.security.dto.TokenDto; +import com.epmet.commons.tools.utils.Result; +import com.epmet.commons.tools.validator.ValidatorUtils; +import com.epmet.commons.tools.validator.group.DefaultGroup; +import com.epmet.dto.form.CreateAgencyFormDTO; +import com.epmet.dto.form.RegisterFormDTO; +import com.epmet.dto.result.CreateAgencyResultDTO; +import com.epmet.service.*; +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; @@ -12,4 +24,55 @@ import org.springframework.web.bind.annotation.RestController; @RestController @RequestMapping("pacustomer") public class PaCustomerController { + + @Autowired + private PaUserService paUserService; + @Autowired + private PaCustomerService paCustomerService; + @Autowired + private PaCustomerAgencyService paCustomerAgencyService; + @Autowired + private PaCustomerUserAgencyService paCustomerUserAgencyService; + @Autowired + private CustomerMpService customerMpService; + + /** + * @param formDTO + * @return + * @Author sun + * @Description 公众号-手机号注册 + **/ + @PostMapping("register") + public Result register(@LoginUser TokenDto tokenDTO, @RequestBody RegisterFormDTO formDTO) { + ValidatorUtils.validateEntity(formDTO, RegisterFormDTO.AddUserInternalGroup.class, RegisterFormDTO.AddUserShowGroup.class); + formDTO.setUserId(tokenDTO.getUserId()); + paCustomerService.register(formDTO); + return new Result(); + } + + /** + * @param formDTO + * @return + * @Author sun + * @Description 公众号-创建组织 + **/ + @PostMapping("createagency") + public Result createAgency(@LoginUser TokenDto tokenDTO, @RequestBody CreateAgencyFormDTO formDTO) { + ValidatorUtils.validateEntity(formDTO, DefaultGroup.class); + return new Result().ok(paCustomerService.createAgency(tokenDTO, formDTO)); + } + + /** + * @param formDTO + * @return + * @Author sun + * @Description 公众号-查询我的信息 + **/ + @PostMapping("myinfo") + public Result myInfo(@LoginUser TokenDto tokenDTO, @RequestBody CreateAgencyFormDTO formDTO) { + ValidatorUtils.validateEntity(formDTO, DefaultGroup.class); + return new Result().ok(paCustomerService.myInfo(formDTO)); + } + + } diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/PaUserController.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/PaUserController.java index 8f447b191e..d7c07bc506 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/PaUserController.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/PaUserController.java @@ -26,8 +26,11 @@ import com.epmet.commons.tools.validator.group.AddGroup; import com.epmet.commons.tools.validator.group.UpdateGroup; import com.epmet.commons.tools.validator.group.DefaultGroup; import com.epmet.dto.PaUserDTO; +import com.epmet.dto.result.CustomerUserResultDTO; +import com.epmet.dto.result.SaveUserResultDTO; import com.epmet.excel.PaUserExcel; import com.epmet.service.PaUserService; +import me.chanjar.weixin.mp.bean.result.WxMpUser; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; @@ -45,24 +48,24 @@ import java.util.Map; @RestController @RequestMapping("pauser") public class PaUserController { - + @Autowired private PaUserService paUserService; @GetMapping("page") - public Result> page(@RequestParam Map params){ + public Result> page(@RequestParam Map params) { PageData page = paUserService.page(params); return new Result>().ok(page); } @GetMapping("{id}") - public Result get(@PathVariable("id") String id){ + public Result get(@PathVariable("id") String id) { PaUserDTO data = paUserService.get(id); return new Result().ok(data); } @PostMapping - public Result save(@RequestBody PaUserDTO dto){ + public Result save(@RequestBody PaUserDTO dto) { //效验数据 ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); paUserService.save(dto); @@ -70,7 +73,7 @@ public class PaUserController { } @PutMapping - public Result update(@RequestBody PaUserDTO dto){ + public Result update(@RequestBody PaUserDTO dto) { //效验数据 ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); paUserService.update(dto); @@ -78,7 +81,7 @@ public class PaUserController { } @DeleteMapping - public Result delete(@RequestBody String[] ids){ + public Result delete(@RequestBody String[] ids) { //效验数据 AssertUtils.isArrayEmpty(ids, "id"); paUserService.delete(ids); @@ -91,4 +94,26 @@ public class PaUserController { ExcelUtils.exportExcelToTarget(response, null, list, PaUserExcel.class); } + /** + * @param wxMpUser + * @return + * @Author sun + * @Description 根据openId新增或更新用户信息 + **/ + @PostMapping(value = "/saveuser") + public Result saveUser(@RequestBody WxMpUser wxMpUser) { + return new Result().ok(paUserService.saveUser(wxMpUser)); + } + + /** + * @param phone + * @return + * @Author sun + * @Description 根据手机号查询公众号用户基本信息,校验用户是否存在 + **/ + @PostMapping(value = "/checkpauser/{phone}") + public Result checkPaUser(@PathVariable("phone") String phone) { + return new Result().ok(paUserService.checkPaUser(phone)); + } + } \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/PaUserVisitedController.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/PaUserVisitedController.java index c89fee64a4..16f5caab3a 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/PaUserVisitedController.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/PaUserVisitedController.java @@ -23,9 +23,10 @@ import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.validator.AssertUtils; import com.epmet.commons.tools.validator.ValidatorUtils; import com.epmet.commons.tools.validator.group.AddGroup; -import com.epmet.commons.tools.validator.group.UpdateGroup; import com.epmet.commons.tools.validator.group.DefaultGroup; +import com.epmet.commons.tools.validator.group.UpdateGroup; import com.epmet.dto.PaUserVisitedDTO; +import com.epmet.dto.form.SaveUserVisitedFormDTO; import com.epmet.excel.PaUserVisitedExcel; import com.epmet.service.PaUserVisitedService; import org.springframework.beans.factory.annotation.Autowired; @@ -91,4 +92,16 @@ public class PaUserVisitedController { ExcelUtils.exportExcelToTarget(response, null, list, PaUserVisitedExcel.class); } + /** + * @param visited + * @return + * @Author sun + * @Description 用户登陆,新增访问记录数据 + **/ + @PostMapping(value = "/saveuservisited") + public Result saveUserVisited(@RequestBody SaveUserVisitedFormDTO visited) { + paUserVisitedService.saveUserVisited(visited); + return new Result(); + } + } \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/PaCustomerDao.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/PaCustomerDao.java index 7dc41a284b..ac4f9cd20f 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/PaCustomerDao.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/PaCustomerDao.java @@ -18,8 +18,12 @@ package com.epmet.dao; import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.dto.PaCustomerDTO; import com.epmet.entity.PaCustomerEntity; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; /** * 客户信息 @@ -29,5 +33,12 @@ import org.apache.ibatis.annotations.Mapper; */ @Mapper public interface PaCustomerDao extends BaseDao { - + + /** + * @param userId + * @return + * @Author sun + * @Description 公众号-根据userId查询用户对应的客户信息 + **/ + List selectCustomerByUserId(@Param("userId") String userId); } \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/PaUserDao.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/PaUserDao.java index 858ac17cb2..2ced9f5760 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/PaUserDao.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/PaUserDao.java @@ -18,8 +18,12 @@ package com.epmet.dao; import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.dto.PaUserDTO; import com.epmet.entity.PaUserEntity; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; /** * 公众号用户信息 @@ -29,5 +33,12 @@ import org.apache.ibatis.annotations.Mapper; */ @Mapper public interface PaUserDao extends BaseDao { - + + /** + * @param phone + * @return + * @Author sun + * @Description 根据手机号查询公众号用户基本信息,校验用户是否存在 + **/ + List selectUserByPhone(@Param("phone") String phone); } \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/PaUserWechatDao.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/PaUserWechatDao.java index 29e11cb876..8d3f6a6351 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/PaUserWechatDao.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/PaUserWechatDao.java @@ -18,8 +18,10 @@ package com.epmet.dao; import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.dto.PaUserWechatDTO; import com.epmet.entity.PaUserWechatEntity; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; /** * 公众号用户信息 @@ -29,5 +31,20 @@ import org.apache.ibatis.annotations.Mapper; */ @Mapper public interface PaUserWechatDao extends BaseDao { - + + /** + * @param openId + * @return + * @Author sun + * @Description 根据openId查询user_wechat表信息 + **/ + PaUserWechatDTO selectWechatByOpenId(@Param("openId") String openId); + + /** + * @param dto + * @return + * @Author sun + * @Description 根据userId查询user_wechat表信息 + **/ + PaUserWechatEntity selectWechatByUserId(PaUserWechatDTO dto); } \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/entity/CustomerMpEntity.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/entity/CustomerMpEntity.java index f5773ca85f..30ba4b4b15 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/entity/CustomerMpEntity.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/entity/CustomerMpEntity.java @@ -54,13 +54,8 @@ public class CustomerMpEntity extends BaseEpmetEntity { private Integer appId; /** - * 是否已经授权 + * 是否已经授权 0:未授权,1:已授权 */ private Integer authorizationFlag; - /** - * 公众账号信息id - */ - private String authorizerInfoId; - } diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/entity/PaUserWechatEntity.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/entity/PaUserWechatEntity.java index 61cb92e0b8..c618051cb8 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/entity/PaUserWechatEntity.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/entity/PaUserWechatEntity.java @@ -53,11 +53,6 @@ public class PaUserWechatEntity extends BaseEpmetEntity { */ private String unionId; - /** - * 手机号 - */ - private String phone; - /** * 1男2女0未知 */ @@ -88,11 +83,6 @@ public class PaUserWechatEntity extends BaseEpmetEntity { */ private String city; - /** - * 用户特权信息,json 数组,如微信沃卡用户为(chinaunicom) - */ - private String privilege; - /** * 语言 */ diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/excel/CustomerMpExcel.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/excel/CustomerMpExcel.java index b4f62eb57f..5c9549a265 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/excel/CustomerMpExcel.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/excel/CustomerMpExcel.java @@ -43,12 +43,9 @@ public class CustomerMpExcel { @Excel(name = "小程序的appId") private Integer appId; - @Excel(name = "是否已经授权") + @Excel(name = "是否已经授权:0.未授权 1.已授权") private Integer authorizationFlag; - @Excel(name = "公众账号信息id") - private String authorizerInfoId; - @Excel(name = "删除标识:0.未删除 1.已删除") private Integer delFlag; diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/excel/PaUserWechatExcel.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/excel/PaUserWechatExcel.java index 2e7b5ba12d..1ddb2bf024 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/excel/PaUserWechatExcel.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/excel/PaUserWechatExcel.java @@ -43,9 +43,6 @@ public class PaUserWechatExcel { @Excel(name = "") private String unionId; - @Excel(name = "手机号") - private String phone; - @Excel(name = "1男2女0未知") private String gender; @@ -64,9 +61,6 @@ public class PaUserWechatExcel { @Excel(name = "城市") private String city; - @Excel(name = "用户特权信息,json 数组,如微信沃卡用户为(chinaunicom)") - private String privilege; - @Excel(name = "语言") private String language; diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/PaCustomerService.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/PaCustomerService.java index 65586defbf..9bb1547dcf 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/PaCustomerService.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/PaCustomerService.java @@ -19,7 +19,11 @@ package com.epmet.service; import com.epmet.commons.mybatis.service.BaseService; import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.dto.PaCustomerDTO; +import com.epmet.dto.form.CreateAgencyFormDTO; +import com.epmet.dto.form.RegisterFormDTO; +import com.epmet.dto.result.CreateAgencyResultDTO; import com.epmet.entity.PaCustomerEntity; import java.util.List; @@ -92,4 +96,29 @@ public interface PaCustomerService extends BaseService { * @date 2020-07-09 */ void delete(String[] ids); + + /** + * @param formDTO + * @return + * @Author sun + * @Description 公众号-手机号注册 + **/ + void register(RegisterFormDTO formDTO); + + /** + * @param formDTO + * @return + * @Author sun + * @Description 公众号-创建组织 + **/ + CreateAgencyResultDTO createAgency(TokenDto tokenDTO, CreateAgencyFormDTO formDTO); + + /** + * @param formDTO + * @return + * @Author sun + * @Description 公众号-查询我的信息 + **/ + CreateAgencyResultDTO myInfo(CreateAgencyFormDTO formDTO); + } \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/PaUserService.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/PaUserService.java index b55098f052..c9208eef81 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/PaUserService.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/PaUserService.java @@ -20,7 +20,10 @@ package com.epmet.service; import com.epmet.commons.mybatis.service.BaseService; import com.epmet.commons.tools.page.PageData; import com.epmet.dto.PaUserDTO; +import com.epmet.dto.result.CustomerUserResultDTO; +import com.epmet.dto.result.SaveUserResultDTO; import com.epmet.entity.PaUserEntity; +import me.chanjar.weixin.mp.bean.result.WxMpUser; import java.util.List; import java.util.Map; @@ -92,4 +95,20 @@ public interface PaUserService extends BaseService { * @date 2020-07-09 */ void delete(String[] ids); + + /** + * @param wxMpUser + * @return + * @Author sun + * @Description 根据openId新增或更新用户信息 + **/ + SaveUserResultDTO saveUser(WxMpUser wxMpUser); + + /** + * @param phone + * @return + * @Author sun + * @Description 根据手机号查询公众号用户基本信息,校验用户是否存在 + **/ + CustomerUserResultDTO checkPaUser(String phone); } \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/PaUserVisitedService.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/PaUserVisitedService.java index 130e9d693c..d67c581dea 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/PaUserVisitedService.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/PaUserVisitedService.java @@ -20,6 +20,7 @@ package com.epmet.service; import com.epmet.commons.mybatis.service.BaseService; import com.epmet.commons.tools.page.PageData; import com.epmet.dto.PaUserVisitedDTO; +import com.epmet.dto.form.SaveUserVisitedFormDTO; import com.epmet.entity.PaUserVisitedEntity; import java.util.List; @@ -92,4 +93,12 @@ public interface PaUserVisitedService extends BaseService { * @date 2020-07-09 */ void delete(String[] ids); + + /** + * @param visited + * @return + * @Author sun + * @Description 用户登陆,新增访问记录数据 + **/ + void saveUserVisited(SaveUserVisitedFormDTO visited); } \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/PaUserWechatService.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/PaUserWechatService.java index 1a613c796d..31c520d793 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/PaUserWechatService.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/PaUserWechatService.java @@ -92,4 +92,12 @@ public interface PaUserWechatService extends BaseService { * @date 2020-07-09 */ void delete(String[] ids); + + /** + * @param openId + * @return + * @Author sun + * @Description 根据openId查询user_wechat表信息 + **/ + PaUserWechatDTO getWechatByOpenId(String openId); } \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/PaCustomerServiceImpl.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/PaCustomerServiceImpl.java index c1dc9b68f5..7c51bfadc2 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/PaCustomerServiceImpl.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/PaCustomerServiceImpl.java @@ -19,16 +19,37 @@ package com.epmet.service.impl; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; +import com.epmet.common.token.constant.LoginConstant; import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; +import com.epmet.commons.tools.constant.FieldConstant; +import com.epmet.commons.tools.constant.NumConstant; +import com.epmet.commons.tools.exception.EpmetErrorCode; +import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.redis.RedisKeys; +import com.epmet.commons.tools.redis.RedisUtils; +import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.utils.ConvertUtils; -import com.epmet.commons.tools.constant.FieldConstant; +import com.epmet.constant.PaConstant; import com.epmet.dao.PaCustomerDao; +import com.epmet.dao.PaUserDao; +import com.epmet.dao.PaUserVisitedDao; +import com.epmet.dao.PaUserWechatDao; import com.epmet.dto.PaCustomerDTO; +import com.epmet.dto.PaUserDTO; +import com.epmet.dto.PaUserWechatDTO; +import com.epmet.dto.form.CreateAgencyFormDTO; +import com.epmet.dto.form.RegisterFormDTO; +import com.epmet.dto.result.CreateAgencyResultDTO; import com.epmet.entity.PaCustomerEntity; +import com.epmet.entity.PaUserEntity; +import com.epmet.entity.PaUserVisitedEntity; +import com.epmet.entity.PaUserWechatEntity; import com.epmet.redis.PaCustomerRedis; import com.epmet.service.PaCustomerService; import org.apache.commons.lang3.StringUtils; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -46,8 +67,17 @@ import java.util.Map; @Service public class PaCustomerServiceImpl extends BaseServiceImpl implements PaCustomerService { + private Logger logger = LogManager.getLogger(PaCustomerServiceImpl.class); @Autowired private PaCustomerRedis paCustomerRedis; + @Autowired + private PaUserDao paUserDao; + @Autowired + private PaUserWechatDao paUserWechatDao; + @Autowired + private PaUserVisitedDao paUserVisitedDao; + @Autowired + private RedisUtils redisUtils; @Override public PageData page(Map params) { @@ -101,4 +131,81 @@ public class PaCustomerServiceImpl extends BaseServiceImpl userList = paUserDao.selectUserByPhone(formDTO.getPhone()); + if (null != userList || userList.size() > NumConstant.ZERO) { + throw new RenException(PaConstant.PHONE_EXCEPTION); + } + + //2.校验验证码是否正确 + String smsCodeKey = RedisKeys.getLoginSmsCodeKey(LoginConstant.APP_PUBLIC, LoginConstant.CLIENT_MP, formDTO.getPhone()); + String rightSmsCode = (String) redisUtils.get(smsCodeKey); + if (!formDTO.getSmsCode().equals(rightSmsCode)) { + logger.error(String.format("验证码错误code[%s],msg[%s]", EpmetErrorCode.MOBILE_CODE_ERROR.getCode(), EpmetErrorCode.MOBILE_CODE_ERROR.getMsg())); + throw new RenException(EpmetErrorCode.MOBILE_CODE_ERROR.getCode()); + } + + //3.pa_user表更新数据 + PaUserEntity userEntity = new PaUserEntity(); + userEntity.setId(formDTO.getUserId()); + userEntity.setPhone(formDTO.getPhone()); + userEntity.setRealName(formDTO.getSurName()); + userEntity.setGender(formDTO.getGender().toString()); + paUserDao.updateById(userEntity); + + //2.访问记录表新增数据 + PaUserWechatDTO dto = new PaUserWechatDTO(); + dto.setUserId(formDTO.getUserId()); + PaUserWechatEntity wechatEntity = paUserWechatDao.selectWechatByUserId(dto); + if (null == wechatEntity) { + throw new RenException(PaConstant.SELECT_WECHAT_EXCEPTION); + } + PaUserVisitedEntity visitedEntity = new PaUserVisitedEntity(); + visitedEntity.setUserId(formDTO.getUserId()); + visitedEntity.setWxOpenId(wechatEntity.getWxOpenId()); + visitedEntity.setOpenId(wechatEntity.getWxOpenId()); + visitedEntity.setPhone(formDTO.getPhone()); + paUserVisitedDao.insert(visitedEntity); + } + + /** + * @param formDTO + * @return + * @Author sun + * @Description 公众号-创建组织 + **/ + @Override + public CreateAgencyResultDTO createAgency(TokenDto tokenDTO, CreateAgencyFormDTO formDTO) { + //1.客户表初始化数据 + //2.客户组织表初始化数据 + //3. + //4. + //5. + + + return null; + } + + /** + * @param formDTO + * @return + * @Author sun + * @Description 公众号-查询我的信息 + **/ + @Override + public CreateAgencyResultDTO myInfo(CreateAgencyFormDTO formDTO) { + return null; + } + + + } \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/PaUserServiceImpl.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/PaUserServiceImpl.java index d902604396..30cd0baed0 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/PaUserServiceImpl.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/PaUserServiceImpl.java @@ -20,14 +20,23 @@ package com.epmet.service.impl; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; +import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.constant.FieldConstant; +import com.epmet.dao.PaCustomerDao; import com.epmet.dao.PaUserDao; +import com.epmet.dto.PaCustomerDTO; import com.epmet.dto.PaUserDTO; +import com.epmet.dto.PaUserWechatDTO; +import com.epmet.dto.result.CustomerUserResultDTO; +import com.epmet.dto.result.SaveUserResultDTO; import com.epmet.entity.PaUserEntity; +import com.epmet.entity.PaUserWechatEntity; import com.epmet.redis.PaUserRedis; import com.epmet.service.PaUserService; +import com.epmet.service.PaUserWechatService; +import me.chanjar.weixin.mp.bean.result.WxMpUser; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -48,6 +57,10 @@ public class PaUserServiceImpl extends BaseServiceImpl @Autowired private PaUserRedis paUserRedis; + @Autowired + private PaUserWechatService paUserWechatService; + @Autowired + private PaCustomerDao paCustomerDao; @Override public PageData page(Map params) { @@ -101,4 +114,80 @@ public class PaUserServiceImpl extends BaseServiceImpl baseDao.deleteBatchIds(Arrays.asList(ids)); } + /** + * @param wxMpUser + * @return + * @Author sun + * @Description 根据openId新增或更新用户信息 + **/ + @Override + @Transactional(rollbackFor = Exception.class) + public SaveUserResultDTO saveUser(WxMpUser wxMpUser) { + SaveUserResultDTO resultDTO = new SaveUserResultDTO(); + //1.根据openId查询user_wechat表是否存在用户信息 + PaUserWechatDTO wechatDTO = paUserWechatService.getWechatByOpenId(wxMpUser.getOpenId()); + + //2.不存在则新增用户信息,存在则更新user_wechat表信息 + if (null == wechatDTO || null == wechatDTO.getId()) { + //2.1、user表新增数据 + PaUserEntity userEntity = new PaUserEntity(); + baseDao.insert(userEntity); + //2.2、user_wechat表新增数据 + PaUserWechatEntity wechatEntity = new PaUserWechatEntity(); + wechatEntity.setUserId(userEntity.getId()); + wechatEntity.setWxOpenId(wxMpUser.getOpenId()); + wechatEntity.setUnionId(wxMpUser.getUnionId()); + wechatEntity.setGender(wxMpUser.getSex().toString()); + wechatEntity.setNickname(wxMpUser.getNickname()); + wechatEntity.setHeadImgUrl(wxMpUser.getHeadImgUrl()); + wechatEntity.setCountry(wxMpUser.getCountry()); + wechatEntity.setProvince(wxMpUser.getProvince()); + wechatEntity.setCity(wxMpUser.getCity()); + wechatEntity.setLanguage(wxMpUser.getLanguage()); + paUserWechatService.insert(wechatEntity); + + resultDTO.setUserId(userEntity.getId()); + } else { + //2.3、更新user_wechat表数据 + PaUserWechatEntity wechatEntity = ConvertUtils.sourceToTarget(wechatDTO, PaUserWechatEntity.class); + wechatEntity.setGender(wxMpUser.getSex().toString()); + wechatEntity.setNickname(wxMpUser.getNickname()); + wechatEntity.setHeadImgUrl(wxMpUser.getHeadImgUrl()); + wechatEntity.setCountry(wxMpUser.getCountry()); + wechatEntity.setProvince(wxMpUser.getProvince()); + wechatEntity.setCity(wxMpUser.getCity()); + wechatEntity.setLanguage(wxMpUser.getLanguage()); + paUserWechatService.updateById(wechatEntity); + + resultDTO.setUserId(wechatDTO.getUserId()); + } + + //3.返回userId + return resultDTO; + } + + /** + * @param phone + * @return + * @Author sun + * @Description 根据手机号查询公众号用户基本信息,校验用户是否存在 + **/ + @Override + public CustomerUserResultDTO checkPaUser(String phone) { + CustomerUserResultDTO resultDTO = new CustomerUserResultDTO(); + List userList = baseDao.selectUserByPhone(phone); + if (null == userList || userList.size() < NumConstant.ONE) { + resultDTO.setPaUserResult(new PaUserDTO()); + resultDTO.setPaCustomerResult(new PaCustomerDTO()); + return resultDTO; + } + PaUserDTO dto = userList.get(NumConstant.ZERO); + List customerList = paCustomerDao.selectCustomerByUserId(dto.getId()); + + resultDTO.setPaUserResult(dto); + resultDTO.setPaCustomerResult(customerList.size() > NumConstant.ZERO ? customerList.get(NumConstant.ZERO) : new PaCustomerDTO()); + + return resultDTO; + } + } \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/PaUserVisitedServiceImpl.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/PaUserVisitedServiceImpl.java index fd00039467..2071fde88f 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/PaUserVisitedServiceImpl.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/PaUserVisitedServiceImpl.java @@ -20,12 +20,16 @@ package com.epmet.service.impl; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; +import com.epmet.commons.tools.constant.FieldConstant; import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.utils.ConvertUtils; -import com.epmet.commons.tools.constant.FieldConstant; import com.epmet.dao.PaUserVisitedDao; +import com.epmet.dao.PaUserWechatDao; import com.epmet.dto.PaUserVisitedDTO; +import com.epmet.dto.PaUserWechatDTO; +import com.epmet.dto.form.SaveUserVisitedFormDTO; import com.epmet.entity.PaUserVisitedEntity; +import com.epmet.entity.PaUserWechatEntity; import com.epmet.redis.PaUserVisitedRedis; import com.epmet.service.PaUserVisitedService; import org.apache.commons.lang3.StringUtils; @@ -48,6 +52,8 @@ public class PaUserVisitedServiceImpl extends BaseServiceImpl page(Map params) { @@ -101,4 +107,35 @@ public class PaUserVisitedServiceImpl extends BaseServiceImpl + \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/PaUserDao.xml b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/PaUserDao.xml index 505b33576c..56db230fa9 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/PaUserDao.xml +++ b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/PaUserDao.xml @@ -3,5 +3,17 @@ + \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/PaUserWechatDao.xml b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/PaUserWechatDao.xml index a6e8b4ce94..8f77d5598e 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/PaUserWechatDao.xml +++ b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/PaUserWechatDao.xml @@ -3,5 +3,48 @@ + + + \ No newline at end of file From 1314f96d17f92d1f11e7d54f1a3b4c1f0ed7235c Mon Sep 17 00:00:00 2001 From: sunyuchao Date: Tue, 14 Jul 2020 13:36:53 +0800 Subject: [PATCH 3/6] =?UTF-8?q?=E5=85=AC=E4=BC=97=E5=8F=B7=E6=9C=8D?= =?UTF-8?q?=E5=8A=A1-=E5=88=9B=E5=BB=BA=E7=BB=84=E7=BB=87=E3=80=81?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E7=BB=84=E7=BB=87=E7=BA=A7=E5=88=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../epmet/dto/form/CreateAgencyFormDTO.java | 6 +- .../dto/result/AgencyLevelListResultDTO.java | 25 ++++ .../dto/result/CreateAgencyResultDTO.java | 4 + .../java/com/epmet/constant/PaConstant.java | 18 +++ .../controller/PaCustomerController.java | 13 +++ .../com/epmet/service/PaCustomerService.java | 7 ++ .../service/impl/PaCustomerServiceImpl.java | 108 ++++++++++++++++-- 7 files changed, 167 insertions(+), 14 deletions(-) create mode 100644 epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/AgencyLevelListResultDTO.java diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/CreateAgencyFormDTO.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/CreateAgencyFormDTO.java index dec52622c8..4ab159bb59 100644 --- a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/CreateAgencyFormDTO.java +++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/CreateAgencyFormDTO.java @@ -37,17 +37,17 @@ public class CreateAgencyFormDTO implements Serializable { /** * 省(中国字) */ - private String province; + private String province = ""; /** * 市(中国字) */ - private String city; + private String city = ""; /** * 区(中国字) */ - private String district; + private String district = ""; /** * 党支部数量 diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/AgencyLevelListResultDTO.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/AgencyLevelListResultDTO.java new file mode 100644 index 0000000000..6f879233f3 --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/AgencyLevelListResultDTO.java @@ -0,0 +1,25 @@ +package com.epmet.dto.result; + +import lombok.Data; + +import java.io.Serializable; + +/** + * @Author sun + * @Description 公众号-查询组织级别-接口返参 + */ +@Data +public class AgencyLevelListResultDTO implements Serializable { + + private static final long serialVersionUID = 3253989119352850315L; + + /** + * 机关级别(社区级:community, 乡(镇、街道)级:street, 区县级: district, 市级: city 省级:province) + */ + private String levelKey; + /** + * 级别对应的名称 + */ + private String levelName; + +} diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/CreateAgencyResultDTO.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/CreateAgencyResultDTO.java index f344e5c062..285b662e40 100644 --- a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/CreateAgencyResultDTO.java +++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/CreateAgencyResultDTO.java @@ -19,5 +19,9 @@ public class CreateAgencyResultDTO implements Serializable { * 新增客户Id */ private String customerId; + /** + * 包含customerId的token + */ + private String token; } diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/constant/PaConstant.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/constant/PaConstant.java index ee15ddf636..80ed388deb 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/constant/PaConstant.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/constant/PaConstant.java @@ -10,10 +10,28 @@ public interface PaConstant { * 手机号注册 */ String PHONE_EXCEPTION = "手机号已存在,不允许再次注册"; + /** * 根据userId查询pa_user_wechat表失败 */ String SELECT_WECHAT_EXCEPTION = "获取用户微信信息失败"; + /** + * 组织级别对应的key、name + */ + String PROVINCE_KEY = "province"; + String PROVINCE_NAME = "省级"; + String CITY_KEY = "city"; + String CITY_NAME = "区县级"; + String STREET_KEY = "street"; + String STREET_NAME = "乡(镇、街道)级"; + String COMMUNITY_KEY = "community"; + String COMMUNITY_NAME = "社区级"; + + /** + * 客户小程序关系表小程序所属端 + */ + String RESI_CLIENT = "resi"; + String WORK_CLIENT = "work"; } diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/PaCustomerController.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/PaCustomerController.java index 5f8f9f5660..4f0443c376 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/PaCustomerController.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/PaCustomerController.java @@ -7,6 +7,7 @@ import com.epmet.commons.tools.validator.ValidatorUtils; import com.epmet.commons.tools.validator.group.DefaultGroup; import com.epmet.dto.form.CreateAgencyFormDTO; import com.epmet.dto.form.RegisterFormDTO; +import com.epmet.dto.result.AgencyLevelListResultDTO; import com.epmet.dto.result.CreateAgencyResultDTO; import com.epmet.service.*; import org.springframework.beans.factory.annotation.Autowired; @@ -15,6 +16,8 @@ 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; + /** * 公众号用户的注册、客户创建、跟组织创建 ,查询我的详情等等...api写在这 * @@ -50,6 +53,16 @@ public class PaCustomerController { return new Result(); } + /** + * @return + * @Author sun + * @Description 公众号-查询组织级别 + **/ + @PostMapping("agencylevellist") + public Result> agencyLevelList() { + return new Result>().ok(paCustomerService.agencyLevelList()); + } + /** * @param formDTO * @return diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/PaCustomerService.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/PaCustomerService.java index 9bb1547dcf..08d5c88373 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/PaCustomerService.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/PaCustomerService.java @@ -23,6 +23,7 @@ import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.dto.PaCustomerDTO; import com.epmet.dto.form.CreateAgencyFormDTO; import com.epmet.dto.form.RegisterFormDTO; +import com.epmet.dto.result.AgencyLevelListResultDTO; import com.epmet.dto.result.CreateAgencyResultDTO; import com.epmet.entity.PaCustomerEntity; @@ -121,4 +122,10 @@ public interface PaCustomerService extends BaseService { **/ CreateAgencyResultDTO myInfo(CreateAgencyFormDTO formDTO); + /** + * @return + * @Author sun + * @Description 公众号-查询组织级别 + **/ + List agencyLevelList(); } \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/PaCustomerServiceImpl.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/PaCustomerServiceImpl.java index 7c51bfadc2..766973bc4a 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/PaCustomerServiceImpl.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/PaCustomerServiceImpl.java @@ -30,6 +30,7 @@ import com.epmet.commons.tools.redis.RedisKeys; import com.epmet.commons.tools.redis.RedisUtils; import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.utils.ConvertUtils; +import com.epmet.commons.tools.utils.CpUserDetailRedis; import com.epmet.constant.PaConstant; import com.epmet.dao.PaCustomerDao; import com.epmet.dao.PaUserDao; @@ -40,13 +41,14 @@ import com.epmet.dto.PaUserDTO; import com.epmet.dto.PaUserWechatDTO; import com.epmet.dto.form.CreateAgencyFormDTO; import com.epmet.dto.form.RegisterFormDTO; +import com.epmet.dto.result.AgencyLevelListResultDTO; import com.epmet.dto.result.CreateAgencyResultDTO; -import com.epmet.entity.PaCustomerEntity; -import com.epmet.entity.PaUserEntity; -import com.epmet.entity.PaUserVisitedEntity; -import com.epmet.entity.PaUserWechatEntity; +import com.epmet.entity.*; import com.epmet.redis.PaCustomerRedis; +import com.epmet.service.CustomerMpService; +import com.epmet.service.PaCustomerAgencyService; import com.epmet.service.PaCustomerService; +import com.epmet.service.PaCustomerUserAgencyService; import org.apache.commons.lang3.StringUtils; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -54,6 +56,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Map; @@ -78,6 +81,14 @@ public class PaCustomerServiceImpl extends BaseServiceImpl page(Map params) { @@ -95,8 +106,8 @@ public class PaCustomerServiceImpl extends BaseServiceImpl getWrapper(Map params){ - String id = (String)params.get(FieldConstant.ID_HUMP); + private QueryWrapper getWrapper(Map params) { + String id = (String) params.get(FieldConstant.ID_HUMP); QueryWrapper wrapper = new QueryWrapper<>(); wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); @@ -177,6 +188,33 @@ public class PaCustomerServiceImpl extends BaseServiceImpl agencyLevelList() { + List list = new ArrayList<>(); + AgencyLevelListResultDTO dto1 = new AgencyLevelListResultDTO(); + dto1.setLevelKey(PaConstant.PROVINCE_KEY); + dto1.setLevelName(PaConstant.PROVINCE_NAME); + list.add(dto1); + AgencyLevelListResultDTO dto2 = new AgencyLevelListResultDTO(); + dto2.setLevelKey(PaConstant.CITY_KEY); + dto2.setLevelName(PaConstant.CITY_NAME); + list.add(dto2); + AgencyLevelListResultDTO dto3 = new AgencyLevelListResultDTO(); + dto3.setLevelKey(PaConstant.STREET_KEY); + dto3.setLevelName(PaConstant.STREET_NAME); + list.add(dto3); + AgencyLevelListResultDTO dto4 = new AgencyLevelListResultDTO(); + dto4.setLevelKey(PaConstant.COMMUNITY_KEY); + dto4.setLevelName(PaConstant.COMMUNITY_NAME); + list.add(dto4); + return list; + } + /** * @param formDTO * @return @@ -184,15 +222,64 @@ public class PaCustomerServiceImpl extends BaseServiceImpl listEntity = new ArrayList<>(); + CustomerMpEntity mpEntity1 = new CustomerMpEntity(); + mpEntity1.setCustomerId(entity.getId()); + mpEntity1.setAuthorizationFlag(NumConstant.ZERO); + mpEntity1.setClient(PaConstant.RESI_CLIENT); + listEntity.add(mpEntity1); + CustomerMpEntity mpEntity2 = ConvertUtils.sourceToTarget(mpEntity1, CustomerMpEntity.class); + mpEntity2.setClient(PaConstant.WORK_CLIENT); + listEntity.add(mpEntity2); + customerMpService.insertBatch(listEntity); + + //5.token中添加customerId + //5-1.获取redis中的token + //获取缓存中的token + TokenDto redisTokenDTO = cpUserDetailRedis.get(LoginConstant.APP_PUBLIC, LoginConstant.CLIENT_MP, tokenDTO.getUserId(), TokenDto.class); + if (redisTokenDTO == null) { + return null; + } + //5-2.添加customerId + redisTokenDTO.setCustomerId(entity.getId()); + //获取key的剩余过期时间 + String key = RedisKeys.getCpUserKey(LoginConstant.APP_PUBLIC, LoginConstant.CLIENT_MP, tokenDTO.getUserId()); + long expire = redisUtils.getExpire(key); + cpUserDetailRedis.set(redisTokenDTO, expire); + + //6.接口返参 + CreateAgencyResultDTO resultDTO = new CreateAgencyResultDTO(); + resultDTO.setCustomerId(entity.getId()); + resultDTO.setToken(redisTokenDTO.getToken()); + + return resultDTO; } /** @@ -207,5 +294,4 @@ public class PaCustomerServiceImpl extends BaseServiceImpl Date: Tue, 14 Jul 2020 14:30:55 +0800 Subject: [PATCH 4/6] =?UTF-8?q?=E5=85=AC=E4=BC=97=E5=8F=B7=E6=9C=8D?= =?UTF-8?q?=E5=8A=A1-=E6=9F=A5=E8=AF=A2=E6=88=91=E7=9A=84=E4=BF=A1?= =?UTF-8?q?=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/epmet/dto/form/MyInfoFormDTO.java | 26 +++++++++ .../com/epmet/dto/result/MyInfoResultDTO.java | 53 +++++++++++++++++++ .../java/com/epmet/constant/PaConstant.java | 15 ++++++ .../controller/PaCustomerController.java | 8 +-- .../java/com/epmet/dao/CustomerMpDao.java | 13 ++++- .../com/epmet/dao/PaCustomerAgencyDao.java | 8 +++ .../com/epmet/service/PaCustomerService.java | 17 +++--- .../service/impl/PaCustomerServiceImpl.java | 43 +++++++++++---- .../main/resources/mapper/CustomerMpDao.xml | 15 ++++++ .../resources/mapper/PaCustomerAgencyDao.xml | 18 +++++++ 10 files changed, 196 insertions(+), 20 deletions(-) create mode 100644 epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/MyInfoFormDTO.java create mode 100644 epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/MyInfoResultDTO.java diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/MyInfoFormDTO.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/MyInfoFormDTO.java new file mode 100644 index 0000000000..78cafaa63b --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/MyInfoFormDTO.java @@ -0,0 +1,26 @@ +package com.epmet.dto.form; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + +/** + * @Author sun + * @Description 公众号-查询我的信息-接口入参 + */ +@Data +public class MyInfoFormDTO implements Serializable { + + private static final long serialVersionUID = -6547893374373422628L; + + public interface AddUserInternalGroup { + } + + /** + * 客户Id + */ + @NotBlank(message = "客户Id不能为空", groups = {MyInfoFormDTO.AddUserInternalGroup.class}) + private String customerId; + +} diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/MyInfoResultDTO.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/MyInfoResultDTO.java new file mode 100644 index 0000000000..3d75eaed38 --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/MyInfoResultDTO.java @@ -0,0 +1,53 @@ +package com.epmet.dto.result; + +import lombok.Data; + +import java.io.Serializable; + +/** + * @Author sun + * @Description 公众号-查询我的信息-接口返参 + */ +@Data +public class MyInfoResultDTO implements Serializable { + + private static final long serialVersionUID = 3253989119352850315L; + + /** + * 客户Id + */ + private String customerId = ""; + /** + * 组织名称 + */ + private String agencyName = ""; + /** + * 新增客户Id + */ + private String level = ""; + /** + * 包含customerId的token + */ + private String province = ""; + /** + * 新增客户Id + */ + private String city = ""; + /** + * 包含customerId的token + */ + private String district = ""; + /** + * 新增客户Id + */ + private Integer partyBranchNum; + /** + * 包含customerId的token + */ + private Integer resiAuthorization; + /** + * 新增客户Id + */ + private Integer workAuthorization; + +} diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/constant/PaConstant.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/constant/PaConstant.java index 80ed388deb..e523ba6fbd 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/constant/PaConstant.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/constant/PaConstant.java @@ -34,4 +34,19 @@ public interface PaConstant { String RESI_CLIENT = "resi"; String WORK_CLIENT = "work"; + /** + * 查询客户组织信息失败 + */ + String SELECT_AGENCY_EXCEPTION = "获取客户组织信息失败"; + /** + * 查询客户小程序授权信息失败 + */ + String CUSTOMER_MP_EXCEPTION = "获取客户小程序授权信息失败"; + + /** + * 客户小程序所属端key值 + */ + String CLIENT_RESI = "resi"; + String CLIENT_WORK = "work"; + } diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/PaCustomerController.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/PaCustomerController.java index 4f0443c376..0b32a836a7 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/PaCustomerController.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/PaCustomerController.java @@ -6,9 +6,11 @@ import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.validator.ValidatorUtils; import com.epmet.commons.tools.validator.group.DefaultGroup; import com.epmet.dto.form.CreateAgencyFormDTO; +import com.epmet.dto.form.MyInfoFormDTO; import com.epmet.dto.form.RegisterFormDTO; import com.epmet.dto.result.AgencyLevelListResultDTO; import com.epmet.dto.result.CreateAgencyResultDTO; +import com.epmet.dto.result.MyInfoResultDTO; import com.epmet.service.*; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PostMapping; @@ -82,9 +84,9 @@ public class PaCustomerController { * @Description 公众号-查询我的信息 **/ @PostMapping("myinfo") - public Result myInfo(@LoginUser TokenDto tokenDTO, @RequestBody CreateAgencyFormDTO formDTO) { - ValidatorUtils.validateEntity(formDTO, DefaultGroup.class); - return new Result().ok(paCustomerService.myInfo(formDTO)); + public Result myInfo(@LoginUser TokenDto tokenDTO, @RequestBody MyInfoFormDTO formDTO) { + ValidatorUtils.validateEntity(formDTO, MyInfoFormDTO.AddUserInternalGroup.class); + return new Result().ok(paCustomerService.myInfo(formDTO)); } diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/CustomerMpDao.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/CustomerMpDao.java index 2c7d386261..e868d6c4d5 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/CustomerMpDao.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/CustomerMpDao.java @@ -18,8 +18,12 @@ package com.epmet.dao; import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.dto.CustomerMpDTO; import com.epmet.entity.CustomerMpEntity; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; /** * 客户小程序关系表 @@ -29,5 +33,12 @@ import org.apache.ibatis.annotations.Mapper; */ @Mapper public interface CustomerMpDao extends BaseDao { - + + /** + * @param customerId + * @return + * @Author sun + * @Description 查询客户小程序授权结果信息 + **/ + List selectByCustomerId(@Param("customerId") String customerId); } \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/PaCustomerAgencyDao.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/PaCustomerAgencyDao.java index 179a27459d..219d88fd83 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/PaCustomerAgencyDao.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/PaCustomerAgencyDao.java @@ -18,6 +18,7 @@ package com.epmet.dao; import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.dto.PaCustomerAgencyDTO; import com.epmet.entity.PaCustomerAgencyEntity; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; @@ -38,4 +39,11 @@ public interface PaCustomerAgencyDao extends BaseDao { */ String getCustomerIdByUserId(@Param("userId")String userId); + /** + * @param customerId + * @return + * @Author sun + * @Description 公众号-查询客户组织信息 + **/ + PaCustomerAgencyDTO selectCustomerAgency(@Param("customerId") String customerId); } \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/PaCustomerService.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/PaCustomerService.java index 08d5c88373..765f4fd94d 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/PaCustomerService.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/PaCustomerService.java @@ -22,9 +22,11 @@ import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.dto.PaCustomerDTO; import com.epmet.dto.form.CreateAgencyFormDTO; +import com.epmet.dto.form.MyInfoFormDTO; import com.epmet.dto.form.RegisterFormDTO; import com.epmet.dto.result.AgencyLevelListResultDTO; import com.epmet.dto.result.CreateAgencyResultDTO; +import com.epmet.dto.result.MyInfoResultDTO; import com.epmet.entity.PaCustomerEntity; import java.util.List; @@ -107,25 +109,26 @@ public interface PaCustomerService extends BaseService { void register(RegisterFormDTO formDTO); /** - * @param formDTO * @return * @Author sun - * @Description 公众号-创建组织 + * @Description 公众号-查询组织级别 **/ - CreateAgencyResultDTO createAgency(TokenDto tokenDTO, CreateAgencyFormDTO formDTO); + List agencyLevelList(); /** * @param formDTO * @return * @Author sun - * @Description 公众号-查询我的信息 + * @Description 公众号-创建组织 **/ - CreateAgencyResultDTO myInfo(CreateAgencyFormDTO formDTO); + CreateAgencyResultDTO createAgency(TokenDto tokenDTO, CreateAgencyFormDTO formDTO); /** + * @param formDTO * @return * @Author sun - * @Description 公众号-查询组织级别 + * @Description 公众号-查询我的信息 **/ - List agencyLevelList(); + MyInfoResultDTO myInfo(MyInfoFormDTO formDTO); + } \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/PaCustomerServiceImpl.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/PaCustomerServiceImpl.java index 766973bc4a..84b676eb78 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/PaCustomerServiceImpl.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/PaCustomerServiceImpl.java @@ -32,17 +32,14 @@ import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.CpUserDetailRedis; import com.epmet.constant.PaConstant; -import com.epmet.dao.PaCustomerDao; -import com.epmet.dao.PaUserDao; -import com.epmet.dao.PaUserVisitedDao; -import com.epmet.dao.PaUserWechatDao; -import com.epmet.dto.PaCustomerDTO; -import com.epmet.dto.PaUserDTO; -import com.epmet.dto.PaUserWechatDTO; +import com.epmet.dao.*; +import com.epmet.dto.*; import com.epmet.dto.form.CreateAgencyFormDTO; +import com.epmet.dto.form.MyInfoFormDTO; import com.epmet.dto.form.RegisterFormDTO; import com.epmet.dto.result.AgencyLevelListResultDTO; import com.epmet.dto.result.CreateAgencyResultDTO; +import com.epmet.dto.result.MyInfoResultDTO; import com.epmet.entity.*; import com.epmet.redis.PaCustomerRedis; import com.epmet.service.CustomerMpService; @@ -80,6 +77,10 @@ public class PaCustomerServiceImpl extends BaseServiceImpl listMpDTO = customerMpDao.selectByCustomerId(formDTO.getCustomerId()); + if (null == agencyDTO || listMpDTO.size() != NumConstant.TWO) { + throw new RenException(PaConstant.CUSTOMER_MP_EXCEPTION); + } + + //3.封装结果信息 + MyInfoResultDTO resultDTO = ConvertUtils.sourceToTarget(agencyDTO, MyInfoResultDTO.class); + for (CustomerMpDTO mp : listMpDTO) { + if (PaConstant.CLIENT_RESI.equals(mp.getClient())) { + resultDTO.setResiAuthorization(mp.getAuthorizationFlag()); + } + if (PaConstant.CLIENT_WORK.equals(mp.getClient())) { + resultDTO.setWorkAuthorization(mp.getAuthorizationFlag()); + } + } + + return resultDTO; } diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/CustomerMpDao.xml b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/CustomerMpDao.xml index a348e795ed..14d322bee1 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/CustomerMpDao.xml +++ b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/CustomerMpDao.xml @@ -3,5 +3,20 @@ + \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/PaCustomerAgencyDao.xml b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/PaCustomerAgencyDao.xml index 420dfac6ad..486519d844 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/PaCustomerAgencyDao.xml +++ b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/PaCustomerAgencyDao.xml @@ -15,4 +15,22 @@ AND pcua.user_id = #{userId} + + \ No newline at end of file From 3b404b89c4e98aae0144c7f7bf94c0d16cb75cfa Mon Sep 17 00:00:00 2001 From: zhaoqifeng Date: Tue, 14 Jul 2020 14:50:02 +0800 Subject: [PATCH 5/6] =?UTF-8?q?=E7=AC=AC=E4=B8=89=E6=96=B9=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E4=B8=8A=E4=BC=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tools/utils/HttpClientManager.java | 65 +++++++ .../com/epmet/dto/CodeAuditResultDTO.java | 96 ++++++++++ .../java/com/epmet/dto/CodeCustomerDTO.java | 121 ++++++++++++ .../main/java/com/epmet/dto/CodeMediaDTO.java | 91 +++++++++ .../dto/CustomerCodeOperationHistoryDTO.java | 96 ++++++++++ .../com/epmet/dto/form/CodeUploadFormDTO.java | 46 +++++ .../controller/CodeAuditResultController.java | 84 ++++++++ .../com/epmet/controller/CodeController.java | 30 +++ .../controller/CodeCustomerController.java | 84 ++++++++ .../epmet/controller/CodeMediaController.java | 84 ++++++++ ...ustomerCodeOperationHistoryController.java | 84 ++++++++ .../com/epmet/dao/CodeAuditResultDao.java | 33 ++++ .../java/com/epmet/dao/CodeCustomerDao.java | 33 ++++ .../main/java/com/epmet/dao/CodeMediaDao.java | 33 ++++ .../dao/CustomerCodeOperationHistoryDao.java | 33 ++++ .../epmet/entity/CodeAuditResultEntity.java | 66 +++++++ .../com/epmet/entity/CodeCustomerEntity.java | 91 +++++++++ .../com/epmet/entity/CodeMediaEntity.java | 61 ++++++ .../CustomerCodeOperationHistoryEntity.java | 66 +++++++ .../com/epmet/redis/CodeAuditResultRedis.java | 47 +++++ .../com/epmet/redis/CodeCustomerRedis.java | 47 +++++ .../java/com/epmet/redis/CodeMediaRedis.java | 47 +++++ .../CustomerCodeOperationHistoryRedis.java | 47 +++++ .../epmet/service/CodeAuditResultService.java | 95 ++++++++++ .../epmet/service/CodeCustomerService.java | 95 ++++++++++ .../com/epmet/service/CodeMediaService.java | 95 ++++++++++ .../java/com/epmet/service/CodeService.java | 12 ++ .../CustomerCodeOperationHistoryService.java | 95 ++++++++++ .../impl/CodeAuditResultServiceImpl.java | 104 ++++++++++ .../service/impl/CodeCustomerServiceImpl.java | 104 ++++++++++ .../service/impl/CodeMediaServiceImpl.java | 104 ++++++++++ .../epmet/service/impl/CodeServiceImpl.java | 17 ++ ...stomerCodeOperationHistoryServiceImpl.java | 104 ++++++++++ .../wxapi/constant/WxMaCodeConstant.java | 2 +- .../wxapi/param/WxMaCodeAuditStatus.java | 9 + .../wxapi/param/WxMaCodeAuditStatusReq.java | 18 ++ .../epmet/wxapi/param/WxMaCodeCommitReq.java | 10 +- .../param/WxMaCodeSubmitAuditRequest.java | 145 ++++++++++++++ .../wxapi/result/WxMaAuditStatusResult.java | 36 ++++ .../wxapi/result/WxMaCategoryResult.java | 52 +++++ .../wxapi/result/WxMaGetCategoryResult.java | 28 +++ .../epmet/wxapi/result/WxMaGetPageResult.java | 28 +++ .../epmet/wxapi/service/WxMaCodeService.java | 76 +++++++- .../service/impl/WxMaCodeServiceImpl.java | 179 +++++++++++++++++- .../resources/mapper/CodeAuditResultDao.xml | 22 +++ .../main/resources/mapper/CodeCustomerDao.xml | 27 +++ .../main/resources/mapper/CodeMediaDao.xml | 21 ++ .../CustomerCodeOperationHistoryDao.xml | 22 +++ 48 files changed, 2975 insertions(+), 10 deletions(-) create mode 100644 epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/CodeAuditResultDTO.java create mode 100644 epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/CodeCustomerDTO.java create mode 100644 epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/CodeMediaDTO.java create mode 100644 epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/CustomerCodeOperationHistoryDTO.java create mode 100644 epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/CodeUploadFormDTO.java create mode 100644 epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/CodeAuditResultController.java create mode 100644 epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/CodeController.java create mode 100644 epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/CodeCustomerController.java create mode 100644 epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/CodeMediaController.java create mode 100644 epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/CustomerCodeOperationHistoryController.java create mode 100644 epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/CodeAuditResultDao.java create mode 100644 epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/CodeCustomerDao.java create mode 100644 epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/CodeMediaDao.java create mode 100644 epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/CustomerCodeOperationHistoryDao.java create mode 100644 epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/entity/CodeAuditResultEntity.java create mode 100644 epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/entity/CodeCustomerEntity.java create mode 100644 epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/entity/CodeMediaEntity.java create mode 100644 epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/entity/CustomerCodeOperationHistoryEntity.java create mode 100644 epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/redis/CodeAuditResultRedis.java create mode 100644 epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/redis/CodeCustomerRedis.java create mode 100644 epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/redis/CodeMediaRedis.java create mode 100644 epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/redis/CustomerCodeOperationHistoryRedis.java create mode 100644 epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/CodeAuditResultService.java create mode 100644 epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/CodeCustomerService.java create mode 100644 epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/CodeMediaService.java create mode 100644 epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/CodeService.java create mode 100644 epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/CustomerCodeOperationHistoryService.java create mode 100644 epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/CodeAuditResultServiceImpl.java create mode 100644 epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/CodeCustomerServiceImpl.java create mode 100644 epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/CodeMediaServiceImpl.java create mode 100644 epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/CodeServiceImpl.java create mode 100644 epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/CustomerCodeOperationHistoryServiceImpl.java create mode 100644 epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/param/WxMaCodeAuditStatus.java create mode 100644 epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/param/WxMaCodeAuditStatusReq.java create mode 100644 epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/param/WxMaCodeSubmitAuditRequest.java create mode 100644 epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/result/WxMaAuditStatusResult.java create mode 100644 epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/result/WxMaCategoryResult.java create mode 100644 epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/result/WxMaGetCategoryResult.java create mode 100644 epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/result/WxMaGetPageResult.java create mode 100644 epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/CodeAuditResultDao.xml create mode 100644 epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/CodeCustomerDao.xml create mode 100644 epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/CodeMediaDao.xml create mode 100644 epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/CustomerCodeOperationHistoryDao.xml diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/HttpClientManager.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/HttpClientManager.java index 2cfaed7588..261153eea7 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/HttpClientManager.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/HttpClientManager.java @@ -8,6 +8,7 @@ import com.epmet.commons.tools.scan.param.TextScanParamDTO; import com.epmet.commons.tools.scan.param.TextTaskDTO; import lombok.extern.slf4j.Slf4j; import org.apache.commons.codec.binary.Base64; +import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.StringUtils; import org.apache.http.HttpStatus; import org.apache.http.NameValuePair; @@ -27,7 +28,10 @@ import org.springframework.util.CollectionUtils; import javax.crypto.Mac; import javax.crypto.spec.SecretKeySpec; +import java.io.ByteArrayOutputStream; +import java.io.File; import java.io.IOException; +import java.io.InputStream; import java.net.URLEncoder; import java.util.ArrayList; import java.util.List; @@ -204,6 +208,67 @@ public class HttpClientManager { return new Result().error(EpmetErrorCode.SERVER_ERROR.getCode(), EpmetErrorCode.SERVER_ERROR.getMsg()); } + /** + * desc: 发送get请求 + * param:url, params + * return: CallResult + * date: 2019/2/21 9:16 + * + * @author: jianjun liu + */ + public Result sendGetFile(String url, Map params) { + + try { + URIBuilder builder = new URIBuilder(url); + if (!CollectionUtils.isEmpty(params)) { + Set set = params.keySet(); + for (String key : set) { + builder.setParameter(key, params.get(key) == null ? "" : String.valueOf(params.get(key))); + } + } + HttpGet httpGet = new HttpGet(builder.build()); + httpGet.setConfig(requestConfig); + return executeToByte(httpGet); + } catch (Exception e) { + log.error("sendGet exception", e); + return new Result().error(EpmetErrorCode.SERVER_ERROR.getCode(), EpmetErrorCode.SERVER_ERROR.getMsg()); + } + } + + private Result executeToByte(HttpRequestBase httpMethod) { + CloseableHttpResponse response = null; + try { + response = httpclient.execute(httpMethod); + log.debug("http send response:{}", JSON.toJSONString(response)); + if (response != null && response.getStatusLine() != null) { + if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) { + InputStream in = response.getEntity().getContent(); + ByteArrayOutputStream output = new ByteArrayOutputStream(); + byte[] buffer = new byte[4096]; + int n = 0; + while (-1 != (n = in.read(buffer))) { + output.write(buffer, 0, n); + } + return new Result().ok(ArrayUtils.toObject(output.toByteArray())); + } else { + log.warn("execute http method fail,httpStatus:{0}", response.getStatusLine().getStatusCode()); + } + } + } catch (Exception e) { + log.error("execute exception", e); + return new Result().error(EpmetErrorCode.SERVER_ERROR.getCode(), e.getMessage()); + } finally { + httpMethod.releaseConnection(); + try { + if (response != null) { + response.close(); + } + } catch (IOException e) { + } + } + return new Result().error(EpmetErrorCode.SERVER_ERROR.getCode(), EpmetErrorCode.SERVER_ERROR.getMsg()); + } + public static void main(String[] args) { String url = "http://localhost:8107/epmetscan/api/textSyncScan"; TextTaskDTO p = new TextTaskDTO(); diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/CodeAuditResultDTO.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/CodeAuditResultDTO.java new file mode 100644 index 0000000000..8068f8f07b --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/CodeAuditResultDTO.java @@ -0,0 +1,96 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.dto; + +import java.io.Serializable; +import java.util.Date; +import lombok.Data; + + +/** + * 代码审核j结果 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-07-09 + */ +@Data +public class CodeAuditResultDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 主键 + */ + private String id; + + /** + * 客户ID + */ + private String customerId; + + /** + * 代码ID + */ + private String codeId; + + /** + * 审核ID + */ + private String auditId; + + /** + * 审核结果 审核中:auditing,审核成功audit_success,审核被拒绝audit_failed,已撤回:withdrawn,审核延后:delay + */ + private String result; + + /** + * 原因 + */ + private String reason; + + /** + * 乐观锁 + */ + private Integer revision; + + /** + * 是否删除 + */ + private String delFlag; + + /** + * 创建人 + */ + private String createdBy; + + /** + * 创建时间 + */ + private Date createdTime; + + /** + * 更新人 + */ + private String updatedBy; + + /** + * 更新时间 + */ + private Date updatedTime; + +} \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/CodeCustomerDTO.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/CodeCustomerDTO.java new file mode 100644 index 0000000000..960b9035cb --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/CodeCustomerDTO.java @@ -0,0 +1,121 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.dto; + +import java.io.Serializable; +import java.util.Date; +import lombok.Data; + + +/** + * 客户代码关联表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-07-09 + */ +@Data +public class CodeCustomerDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 主键 + */ + private String id; + + /** + * 客户ID + */ + private String customerId; + + /** + * 客户名 + */ + private String customerName; + + /** + * 小程序接口调用令牌ID + */ + private String accessTokenId; + + /** + * 模板ID + */ + private String templateId; + + /** + * 小程序类型 居民端resi,工作端work + */ + private String type; + + /** + * APPID + */ + private String appId; + + /** + * 自定义配置 + */ + private String extJson; + + /** + * 代码版本号 + */ + private String userVersion; + + /** + * 代码描述 + */ + private String userDesc; + + /** + * 状态 未审核:unaudited,审核中:auditing,审核成功audit_success,审核被拒绝audit_failed,已撤回:withdrawn,审核延后:delay,发布成功release_success, 发布失败release_failed + */ + private String status; + + /** + * 乐观锁 + */ + private Integer revision; + + /** + * 是否删除 + */ + private String delFlag; + + /** + * 创建人 + */ + private String createdBy; + + /** + * 创建时间 + */ + private Date createdTime; + + /** + * 更新人 + */ + private String updatedBy; + + /** + * 更新时间 + */ + private Date updatedTime; + +} \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/CodeMediaDTO.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/CodeMediaDTO.java new file mode 100644 index 0000000000..09332ac8a3 --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/CodeMediaDTO.java @@ -0,0 +1,91 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.dto; + +import java.io.Serializable; +import java.util.Date; +import lombok.Data; + + +/** + * 代码素材 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-07-09 + */ +@Data +public class CodeMediaDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 主键 + */ + private String id; + + /** + * 代码ID + */ + private String codeId; + + /** + * 素材ID + */ + private String mediaId; + + /** + * 素材名 + */ + private String mediaName; + + /** + * 素材类型 图片(image)、语音(voice)、视频(video)和缩略图(thumb) + */ + private String mediaType; + + /** + * 乐观锁 + */ + private Integer revision; + + /** + * 更新人 + */ + private String updatedBy; + + /** + * 创建人 + */ + private String createdBy; + + /** + * 创建时间 + */ + private Date createdTime; + + /** + * 是否删除 + */ + private String delFlag; + + /** + * 更新时间 + */ + private Date updatedTime; + +} \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/CustomerCodeOperationHistoryDTO.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/CustomerCodeOperationHistoryDTO.java new file mode 100644 index 0000000000..9d400efb40 --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/CustomerCodeOperationHistoryDTO.java @@ -0,0 +1,96 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.dto; + +import java.io.Serializable; +import java.util.Date; +import lombok.Data; + + +/** + * 客户代码操作历史 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-07-09 + */ +@Data +public class CustomerCodeOperationHistoryDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * ID + */ + private String id; + + /** + * 客户ID + */ + private String customerId; + + /** + * 代码ID + */ + private String codeId; + + /** + * 版本 + */ + private String version; + + /** + * 操作类型 操作 上传upload,审核audit,撤回undo,发布release + */ + private String operation; + + /** + * 描述 + */ + private String describe; + + /** + * 乐观锁 + */ + private Integer revision; + + /** + * 是否删除 + */ + private String delFlag; + + /** + * 创建人 + */ + private String createdBy; + + /** + * 创建时间 + */ + private Date createdTime; + + /** + * 更新人 + */ + private String updatedBy; + + /** + * 更新时间 + */ + private Date updatedTime; + +} \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/CodeUploadFormDTO.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/CodeUploadFormDTO.java new file mode 100644 index 0000000000..a2740c321d --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/CodeUploadFormDTO.java @@ -0,0 +1,46 @@ +package com.epmet.dto.form; + +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +/** + * @author zhaoqifeng + * @dscription + * @date 2020/7/9 14:24 + */ +@NoArgsConstructor +@Data +public class CodeUploadFormDTO implements Serializable { + + private static final long serialVersionUID = 1295337818281424509L; + /** + * 小程序接口调用令牌ID + */ + private String accessTokenId; + /** + * 小程序类型 居民端resi, 工作段work + */ + private String type; + /** + * 客户ID + */ + private String customerId; + /** + * 代码库中的代码模板 ID + */ + private String templateId; + /** + * 第三方自定义的配置 + */ + private String extJson; + /** + * 代码版本号 + */ + private String userVersion; + /** + * 代码描述 + */ + private String userDesc; +} diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/CodeAuditResultController.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/CodeAuditResultController.java new file mode 100644 index 0000000000..a0524c1b48 --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/CodeAuditResultController.java @@ -0,0 +1,84 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.controller; + +import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.utils.Result; +import com.epmet.commons.tools.validator.AssertUtils; +import com.epmet.commons.tools.validator.ValidatorUtils; +import com.epmet.commons.tools.validator.group.AddGroup; +import com.epmet.commons.tools.validator.group.UpdateGroup; +import com.epmet.commons.tools.validator.group.DefaultGroup; +import com.epmet.dto.CodeAuditResultDTO; +import com.epmet.service.CodeAuditResultService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.Map; + + +/** + * 代码审核j结果 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-07-09 + */ +@RestController +@RequestMapping("codeauditresult") +public class CodeAuditResultController { + + @Autowired + private CodeAuditResultService codeAuditResultService; + + @GetMapping("page") + public Result> page(@RequestParam Map params){ + PageData page = codeAuditResultService.page(params); + return new Result>().ok(page); + } + + @GetMapping("{id}") + public Result get(@PathVariable("id") String id){ + CodeAuditResultDTO data = codeAuditResultService.get(id); + return new Result().ok(data); + } + + @PostMapping + public Result save(@RequestBody CodeAuditResultDTO dto){ + //效验数据 + ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); + codeAuditResultService.save(dto); + return new Result(); + } + + @PutMapping + public Result update(@RequestBody CodeAuditResultDTO dto){ + //效验数据 + ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); + codeAuditResultService.update(dto); + return new Result(); + } + + @DeleteMapping + public Result delete(@RequestBody String[] ids){ + //效验数据 + AssertUtils.isArrayEmpty(ids, "id"); + codeAuditResultService.delete(ids); + return new Result(); + } + +} \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/CodeController.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/CodeController.java new file mode 100644 index 0000000000..1e97bf9ab1 --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/CodeController.java @@ -0,0 +1,30 @@ +package com.epmet.controller; + +import com.epmet.commons.tools.utils.Result; +import com.epmet.dto.form.CodeUploadFormDTO; +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; + +/** + * @author zhaoqifeng + * @dscription 代码管理 + * @date 2020/7/9 11:02 + */ +@RestController +@RequestMapping("code") +public class CodeController { + + /** + * 代码上传 + * @author zhaoqifeng + * @date 2020/7/9 14:23 + * @param + * @return com.epmet.commons.tools.utils.Result + */ + @PostMapping("upload") + public Result upload(@RequestBody CodeUploadFormDTO formDTO) { + return new Result<>(); + } +} diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/CodeCustomerController.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/CodeCustomerController.java new file mode 100644 index 0000000000..d4a193821c --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/CodeCustomerController.java @@ -0,0 +1,84 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.controller; + +import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.utils.Result; +import com.epmet.commons.tools.validator.AssertUtils; +import com.epmet.commons.tools.validator.ValidatorUtils; +import com.epmet.commons.tools.validator.group.AddGroup; +import com.epmet.commons.tools.validator.group.UpdateGroup; +import com.epmet.commons.tools.validator.group.DefaultGroup; +import com.epmet.dto.CodeCustomerDTO; +import com.epmet.service.CodeCustomerService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.Map; + + +/** + * 客户代码关联表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-07-09 + */ +@RestController +@RequestMapping("codecustomer") +public class CodeCustomerController { + + @Autowired + private CodeCustomerService codeCustomerService; + + @GetMapping("page") + public Result> page(@RequestParam Map params){ + PageData page = codeCustomerService.page(params); + return new Result>().ok(page); + } + + @GetMapping("{id}") + public Result get(@PathVariable("id") String id){ + CodeCustomerDTO data = codeCustomerService.get(id); + return new Result().ok(data); + } + + @PostMapping + public Result save(@RequestBody CodeCustomerDTO dto){ + //效验数据 + ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); + codeCustomerService.save(dto); + return new Result(); + } + + @PutMapping + public Result update(@RequestBody CodeCustomerDTO dto){ + //效验数据 + ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); + codeCustomerService.update(dto); + return new Result(); + } + + @DeleteMapping + public Result delete(@RequestBody String[] ids){ + //效验数据 + AssertUtils.isArrayEmpty(ids, "id"); + codeCustomerService.delete(ids); + return new Result(); + } + +} \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/CodeMediaController.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/CodeMediaController.java new file mode 100644 index 0000000000..c8ad829979 --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/CodeMediaController.java @@ -0,0 +1,84 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.controller; + +import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.utils.Result; +import com.epmet.commons.tools.validator.AssertUtils; +import com.epmet.commons.tools.validator.ValidatorUtils; +import com.epmet.commons.tools.validator.group.AddGroup; +import com.epmet.commons.tools.validator.group.UpdateGroup; +import com.epmet.commons.tools.validator.group.DefaultGroup; +import com.epmet.dto.CodeMediaDTO; +import com.epmet.service.CodeMediaService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.Map; + + +/** + * 代码素材 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-07-09 + */ +@RestController +@RequestMapping("codemedia") +public class CodeMediaController { + + @Autowired + private CodeMediaService codeMediaService; + + @GetMapping("page") + public Result> page(@RequestParam Map params){ + PageData page = codeMediaService.page(params); + return new Result>().ok(page); + } + + @GetMapping("{id}") + public Result get(@PathVariable("id") String id){ + CodeMediaDTO data = codeMediaService.get(id); + return new Result().ok(data); + } + + @PostMapping + public Result save(@RequestBody CodeMediaDTO dto){ + //效验数据 + ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); + codeMediaService.save(dto); + return new Result(); + } + + @PutMapping + public Result update(@RequestBody CodeMediaDTO dto){ + //效验数据 + ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); + codeMediaService.update(dto); + return new Result(); + } + + @DeleteMapping + public Result delete(@RequestBody String[] ids){ + //效验数据 + AssertUtils.isArrayEmpty(ids, "id"); + codeMediaService.delete(ids); + return new Result(); + } + +} \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/CustomerCodeOperationHistoryController.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/CustomerCodeOperationHistoryController.java new file mode 100644 index 0000000000..a764889ed6 --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/CustomerCodeOperationHistoryController.java @@ -0,0 +1,84 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.controller; + +import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.utils.Result; +import com.epmet.commons.tools.validator.AssertUtils; +import com.epmet.commons.tools.validator.ValidatorUtils; +import com.epmet.commons.tools.validator.group.AddGroup; +import com.epmet.commons.tools.validator.group.UpdateGroup; +import com.epmet.commons.tools.validator.group.DefaultGroup; +import com.epmet.dto.CustomerCodeOperationHistoryDTO; +import com.epmet.service.CustomerCodeOperationHistoryService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.Map; + + +/** + * 客户代码操作历史 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-07-09 + */ +@RestController +@RequestMapping("customercodeoperationhistory") +public class CustomerCodeOperationHistoryController { + + @Autowired + private CustomerCodeOperationHistoryService customerCodeOperationHistoryService; + + @GetMapping("page") + public Result> page(@RequestParam Map params){ + PageData page = customerCodeOperationHistoryService.page(params); + return new Result>().ok(page); + } + + @GetMapping("{id}") + public Result get(@PathVariable("id") String id){ + CustomerCodeOperationHistoryDTO data = customerCodeOperationHistoryService.get(id); + return new Result().ok(data); + } + + @PostMapping + public Result save(@RequestBody CustomerCodeOperationHistoryDTO dto){ + //效验数据 + ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); + customerCodeOperationHistoryService.save(dto); + return new Result(); + } + + @PutMapping + public Result update(@RequestBody CustomerCodeOperationHistoryDTO dto){ + //效验数据 + ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); + customerCodeOperationHistoryService.update(dto); + return new Result(); + } + + @DeleteMapping + public Result delete(@RequestBody String[] ids){ + //效验数据 + AssertUtils.isArrayEmpty(ids, "id"); + customerCodeOperationHistoryService.delete(ids); + return new Result(); + } + +} \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/CodeAuditResultDao.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/CodeAuditResultDao.java new file mode 100644 index 0000000000..efbb43e81e --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/CodeAuditResultDao.java @@ -0,0 +1,33 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.dao; + +import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.entity.CodeAuditResultEntity; +import org.apache.ibatis.annotations.Mapper; + +/** + * 代码审核j结果 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-07-09 + */ +@Mapper +public interface CodeAuditResultDao extends BaseDao { + +} \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/CodeCustomerDao.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/CodeCustomerDao.java new file mode 100644 index 0000000000..fe783081fd --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/CodeCustomerDao.java @@ -0,0 +1,33 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.dao; + +import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.entity.CodeCustomerEntity; +import org.apache.ibatis.annotations.Mapper; + +/** + * 客户代码关联表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-07-09 + */ +@Mapper +public interface CodeCustomerDao extends BaseDao { + +} \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/CodeMediaDao.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/CodeMediaDao.java new file mode 100644 index 0000000000..ef06035847 --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/CodeMediaDao.java @@ -0,0 +1,33 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.dao; + +import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.entity.CodeMediaEntity; +import org.apache.ibatis.annotations.Mapper; + +/** + * 代码素材 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-07-09 + */ +@Mapper +public interface CodeMediaDao extends BaseDao { + +} \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/CustomerCodeOperationHistoryDao.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/CustomerCodeOperationHistoryDao.java new file mode 100644 index 0000000000..63ca70fb2b --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/CustomerCodeOperationHistoryDao.java @@ -0,0 +1,33 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.dao; + +import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.entity.CustomerCodeOperationHistoryEntity; +import org.apache.ibatis.annotations.Mapper; + +/** + * 客户代码操作历史 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-07-09 + */ +@Mapper +public interface CustomerCodeOperationHistoryDao extends BaseDao { + +} \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/entity/CodeAuditResultEntity.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/entity/CodeAuditResultEntity.java new file mode 100644 index 0000000000..6226a7b08b --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/entity/CodeAuditResultEntity.java @@ -0,0 +1,66 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.entity; + +import com.baomidou.mybatisplus.annotation.TableName; + +import com.epmet.commons.mybatis.entity.BaseEpmetEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.Date; + +/** + * 代码审核j结果 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-07-09 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("code_audit_result") +public class CodeAuditResultEntity extends BaseEpmetEntity { + + private static final long serialVersionUID = 1L; + + /** + * 客户ID + */ + private String customerId; + + /** + * 代码ID + */ + private String codeId; + + /** + * 审核ID + */ + private String auditId; + + /** + * 审核结果 审核中:auditing,审核成功audit_success,审核被拒绝audit_failed,已撤回:withdrawn,审核延后:delay + */ + private String result; + + /** + * 原因 + */ + private String reason; + +} diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/entity/CodeCustomerEntity.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/entity/CodeCustomerEntity.java new file mode 100644 index 0000000000..496aeacbc5 --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/entity/CodeCustomerEntity.java @@ -0,0 +1,91 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.entity; + +import com.baomidou.mybatisplus.annotation.TableName; + +import com.epmet.commons.mybatis.entity.BaseEpmetEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.Date; + +/** + * 客户代码关联表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-07-09 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("code_customer") +public class CodeCustomerEntity extends BaseEpmetEntity { + + private static final long serialVersionUID = 1L; + + /** + * 客户ID + */ + private String customerId; + + /** + * 客户名 + */ + private String customerName; + + /** + * 小程序接口调用令牌ID + */ + private String accessTokenId; + + /** + * 模板ID + */ + private String templateId; + + /** + * 小程序类型 居民端resi,工作端work + */ + private String type; + + /** + * APPID + */ + private String appId; + + /** + * 自定义配置 + */ + private String extJson; + + /** + * 代码版本号 + */ + private String userVersion; + + /** + * 代码描述 + */ + private String userDesc; + + /** + * 状态 未审核:unaudited,审核中:auditing,审核成功audit_success,审核被拒绝audit_failed,已撤回:withdrawn,审核延后:delay,发布成功release_success, 发布失败release_failed + */ + private String status; + +} diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/entity/CodeMediaEntity.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/entity/CodeMediaEntity.java new file mode 100644 index 0000000000..51202ed323 --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/entity/CodeMediaEntity.java @@ -0,0 +1,61 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.entity; + +import com.baomidou.mybatisplus.annotation.TableName; + +import com.epmet.commons.mybatis.entity.BaseEpmetEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.Date; + +/** + * 代码素材 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-07-09 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("code_media") +public class CodeMediaEntity extends BaseEpmetEntity { + + private static final long serialVersionUID = 1L; + + /** + * 代码ID + */ + private String codeId; + + /** + * 素材ID + */ + private String mediaId; + + /** + * 素材名 + */ + private String mediaName; + + /** + * 素材类型 图片(image)、语音(voice)、视频(video)和缩略图(thumb) + */ + private String mediaType; + +} diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/entity/CustomerCodeOperationHistoryEntity.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/entity/CustomerCodeOperationHistoryEntity.java new file mode 100644 index 0000000000..e747bb57d4 --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/entity/CustomerCodeOperationHistoryEntity.java @@ -0,0 +1,66 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.entity; + +import com.baomidou.mybatisplus.annotation.TableName; + +import com.epmet.commons.mybatis.entity.BaseEpmetEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.Date; + +/** + * 客户代码操作历史 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-07-09 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("customer_code_operation_history") +public class CustomerCodeOperationHistoryEntity extends BaseEpmetEntity { + + private static final long serialVersionUID = 1L; + + /** + * 客户ID + */ + private String customerId; + + /** + * 代码ID + */ + private String codeId; + + /** + * 版本 + */ + private String version; + + /** + * 操作类型 操作 上传upload,审核audit,撤回undo,发布release + */ + private String operation; + + /** + * 描述 + */ + private String describe; + +} diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/redis/CodeAuditResultRedis.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/redis/CodeAuditResultRedis.java new file mode 100644 index 0000000000..0b66bbd2b3 --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/redis/CodeAuditResultRedis.java @@ -0,0 +1,47 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.redis; + +import com.epmet.commons.tools.redis.RedisUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +/** + * 代码审核j结果 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-07-09 + */ +@Component +public class CodeAuditResultRedis { + @Autowired + private RedisUtils redisUtils; + + public void delete(Object[] ids) { + + } + + public void set(){ + + } + + public String get(String id){ + return null; + } + +} \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/redis/CodeCustomerRedis.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/redis/CodeCustomerRedis.java new file mode 100644 index 0000000000..6b5901d833 --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/redis/CodeCustomerRedis.java @@ -0,0 +1,47 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.redis; + +import com.epmet.commons.tools.redis.RedisUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +/** + * 客户代码关联表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-07-09 + */ +@Component +public class CodeCustomerRedis { + @Autowired + private RedisUtils redisUtils; + + public void delete(Object[] ids) { + + } + + public void set(){ + + } + + public String get(String id){ + return null; + } + +} \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/redis/CodeMediaRedis.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/redis/CodeMediaRedis.java new file mode 100644 index 0000000000..99d1257967 --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/redis/CodeMediaRedis.java @@ -0,0 +1,47 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.redis; + +import com.epmet.commons.tools.redis.RedisUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +/** + * 代码素材 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-07-09 + */ +@Component +public class CodeMediaRedis { + @Autowired + private RedisUtils redisUtils; + + public void delete(Object[] ids) { + + } + + public void set(){ + + } + + public String get(String id){ + return null; + } + +} \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/redis/CustomerCodeOperationHistoryRedis.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/redis/CustomerCodeOperationHistoryRedis.java new file mode 100644 index 0000000000..247e724de9 --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/redis/CustomerCodeOperationHistoryRedis.java @@ -0,0 +1,47 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.redis; + +import com.epmet.commons.tools.redis.RedisUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +/** + * 客户代码操作历史 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-07-09 + */ +@Component +public class CustomerCodeOperationHistoryRedis { + @Autowired + private RedisUtils redisUtils; + + public void delete(Object[] ids) { + + } + + public void set(){ + + } + + public String get(String id){ + return null; + } + +} \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/CodeAuditResultService.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/CodeAuditResultService.java new file mode 100644 index 0000000000..016a6e5abc --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/CodeAuditResultService.java @@ -0,0 +1,95 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.service; + +import com.epmet.commons.mybatis.service.BaseService; +import com.epmet.commons.tools.page.PageData; +import com.epmet.dto.CodeAuditResultDTO; +import com.epmet.entity.CodeAuditResultEntity; + +import java.util.List; +import java.util.Map; + +/** + * 代码审核j结果 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-07-09 + */ +public interface CodeAuditResultService extends BaseService { + + /** + * 默认分页 + * + * @param params + * @return PageData + * @author generator + * @date 2020-07-09 + */ + PageData page(Map params); + + /** + * 默认查询 + * + * @param params + * @return java.util.List + * @author generator + * @date 2020-07-09 + */ + List list(Map params); + + /** + * 单条查询 + * + * @param id + * @return CodeAuditResultDTO + * @author generator + * @date 2020-07-09 + */ + CodeAuditResultDTO get(String id); + + /** + * 默认保存 + * + * @param dto + * @return void + * @author generator + * @date 2020-07-09 + */ + void save(CodeAuditResultDTO dto); + + /** + * 默认更新 + * + * @param dto + * @return void + * @author generator + * @date 2020-07-09 + */ + void update(CodeAuditResultDTO dto); + + /** + * 批量删除 + * + * @param ids + * @return void + * @author generator + * @date 2020-07-09 + */ + void delete(String[] ids); +} \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/CodeCustomerService.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/CodeCustomerService.java new file mode 100644 index 0000000000..18ed92c92a --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/CodeCustomerService.java @@ -0,0 +1,95 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.service; + +import com.epmet.commons.mybatis.service.BaseService; +import com.epmet.commons.tools.page.PageData; +import com.epmet.dto.CodeCustomerDTO; +import com.epmet.entity.CodeCustomerEntity; + +import java.util.List; +import java.util.Map; + +/** + * 客户代码关联表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-07-09 + */ +public interface CodeCustomerService extends BaseService { + + /** + * 默认分页 + * + * @param params + * @return PageData + * @author generator + * @date 2020-07-09 + */ + PageData page(Map params); + + /** + * 默认查询 + * + * @param params + * @return java.util.List + * @author generator + * @date 2020-07-09 + */ + List list(Map params); + + /** + * 单条查询 + * + * @param id + * @return CodeCustomerDTO + * @author generator + * @date 2020-07-09 + */ + CodeCustomerDTO get(String id); + + /** + * 默认保存 + * + * @param dto + * @return void + * @author generator + * @date 2020-07-09 + */ + void save(CodeCustomerDTO dto); + + /** + * 默认更新 + * + * @param dto + * @return void + * @author generator + * @date 2020-07-09 + */ + void update(CodeCustomerDTO dto); + + /** + * 批量删除 + * + * @param ids + * @return void + * @author generator + * @date 2020-07-09 + */ + void delete(String[] ids); +} \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/CodeMediaService.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/CodeMediaService.java new file mode 100644 index 0000000000..a4caade450 --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/CodeMediaService.java @@ -0,0 +1,95 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.service; + +import com.epmet.commons.mybatis.service.BaseService; +import com.epmet.commons.tools.page.PageData; +import com.epmet.dto.CodeMediaDTO; +import com.epmet.entity.CodeMediaEntity; + +import java.util.List; +import java.util.Map; + +/** + * 代码素材 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-07-09 + */ +public interface CodeMediaService extends BaseService { + + /** + * 默认分页 + * + * @param params + * @return PageData + * @author generator + * @date 2020-07-09 + */ + PageData page(Map params); + + /** + * 默认查询 + * + * @param params + * @return java.util.List + * @author generator + * @date 2020-07-09 + */ + List list(Map params); + + /** + * 单条查询 + * + * @param id + * @return CodeMediaDTO + * @author generator + * @date 2020-07-09 + */ + CodeMediaDTO get(String id); + + /** + * 默认保存 + * + * @param dto + * @return void + * @author generator + * @date 2020-07-09 + */ + void save(CodeMediaDTO dto); + + /** + * 默认更新 + * + * @param dto + * @return void + * @author generator + * @date 2020-07-09 + */ + void update(CodeMediaDTO dto); + + /** + * 批量删除 + * + * @param ids + * @return void + * @author generator + * @date 2020-07-09 + */ + void delete(String[] ids); +} \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/CodeService.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/CodeService.java new file mode 100644 index 0000000000..1761ecf725 --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/CodeService.java @@ -0,0 +1,12 @@ +package com.epmet.service; + +import java.util.List; + +/** + * @author zhaoqifeng + * @dscription + * @date 2020/7/10 10:27 + */ +public interface CodeService { + +} diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/CustomerCodeOperationHistoryService.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/CustomerCodeOperationHistoryService.java new file mode 100644 index 0000000000..986fce9c09 --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/CustomerCodeOperationHistoryService.java @@ -0,0 +1,95 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.service; + +import com.epmet.commons.mybatis.service.BaseService; +import com.epmet.commons.tools.page.PageData; +import com.epmet.dto.CustomerCodeOperationHistoryDTO; +import com.epmet.entity.CustomerCodeOperationHistoryEntity; + +import java.util.List; +import java.util.Map; + +/** + * 客户代码操作历史 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-07-09 + */ +public interface CustomerCodeOperationHistoryService extends BaseService { + + /** + * 默认分页 + * + * @param params + * @return PageData + * @author generator + * @date 2020-07-09 + */ + PageData page(Map params); + + /** + * 默认查询 + * + * @param params + * @return java.util.List + * @author generator + * @date 2020-07-09 + */ + List list(Map params); + + /** + * 单条查询 + * + * @param id + * @return CustomerCodeOperationHistoryDTO + * @author generator + * @date 2020-07-09 + */ + CustomerCodeOperationHistoryDTO get(String id); + + /** + * 默认保存 + * + * @param dto + * @return void + * @author generator + * @date 2020-07-09 + */ + void save(CustomerCodeOperationHistoryDTO dto); + + /** + * 默认更新 + * + * @param dto + * @return void + * @author generator + * @date 2020-07-09 + */ + void update(CustomerCodeOperationHistoryDTO dto); + + /** + * 批量删除 + * + * @param ids + * @return void + * @author generator + * @date 2020-07-09 + */ + void delete(String[] ids); +} \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/CodeAuditResultServiceImpl.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/CodeAuditResultServiceImpl.java new file mode 100644 index 0000000000..7a4a7193cc --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/CodeAuditResultServiceImpl.java @@ -0,0 +1,104 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; +import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.utils.ConvertUtils; +import com.epmet.commons.tools.constant.FieldConstant; +import com.epmet.dao.CodeAuditResultDao; +import com.epmet.dto.CodeAuditResultDTO; +import com.epmet.entity.CodeAuditResultEntity; +import com.epmet.redis.CodeAuditResultRedis; +import com.epmet.service.CodeAuditResultService; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +/** + * 代码审核j结果 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-07-09 + */ +@Service +public class CodeAuditResultServiceImpl extends BaseServiceImpl implements CodeAuditResultService { + + @Autowired + private CodeAuditResultRedis codeAuditResultRedis; + + @Override + public PageData page(Map params) { + IPage page = baseDao.selectPage( + getPage(params, FieldConstant.CREATED_TIME, false), + getWrapper(params) + ); + return getPageData(page, CodeAuditResultDTO.class); + } + + @Override + public List list(Map params) { + List entityList = baseDao.selectList(getWrapper(params)); + + return ConvertUtils.sourceToTarget(entityList, CodeAuditResultDTO.class); + } + + private QueryWrapper getWrapper(Map params){ + String id = (String)params.get(FieldConstant.ID_HUMP); + + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); + + return wrapper; + } + + @Override + public CodeAuditResultDTO get(String id) { + CodeAuditResultEntity entity = baseDao.selectById(id); + return ConvertUtils.sourceToTarget(entity, CodeAuditResultDTO.class); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void save(CodeAuditResultDTO dto) { + CodeAuditResultEntity entity = ConvertUtils.sourceToTarget(dto, CodeAuditResultEntity.class); + insert(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void update(CodeAuditResultDTO dto) { + CodeAuditResultEntity entity = ConvertUtils.sourceToTarget(dto, CodeAuditResultEntity.class); + updateById(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void delete(String[] ids) { + // 逻辑删除(@TableLogic 注解) + baseDao.deleteBatchIds(Arrays.asList(ids)); + } + +} \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/CodeCustomerServiceImpl.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/CodeCustomerServiceImpl.java new file mode 100644 index 0000000000..1ccf7d1f28 --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/CodeCustomerServiceImpl.java @@ -0,0 +1,104 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; +import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.utils.ConvertUtils; +import com.epmet.commons.tools.constant.FieldConstant; +import com.epmet.dao.CodeCustomerDao; +import com.epmet.dto.CodeCustomerDTO; +import com.epmet.entity.CodeCustomerEntity; +import com.epmet.redis.CodeCustomerRedis; +import com.epmet.service.CodeCustomerService; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +/** + * 客户代码关联表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-07-09 + */ +@Service +public class CodeCustomerServiceImpl extends BaseServiceImpl implements CodeCustomerService { + + @Autowired + private CodeCustomerRedis codeCustomerRedis; + + @Override + public PageData page(Map params) { + IPage page = baseDao.selectPage( + getPage(params, FieldConstant.CREATED_TIME, false), + getWrapper(params) + ); + return getPageData(page, CodeCustomerDTO.class); + } + + @Override + public List list(Map params) { + List entityList = baseDao.selectList(getWrapper(params)); + + return ConvertUtils.sourceToTarget(entityList, CodeCustomerDTO.class); + } + + private QueryWrapper getWrapper(Map params){ + String id = (String)params.get(FieldConstant.ID_HUMP); + + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); + + return wrapper; + } + + @Override + public CodeCustomerDTO get(String id) { + CodeCustomerEntity entity = baseDao.selectById(id); + return ConvertUtils.sourceToTarget(entity, CodeCustomerDTO.class); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void save(CodeCustomerDTO dto) { + CodeCustomerEntity entity = ConvertUtils.sourceToTarget(dto, CodeCustomerEntity.class); + insert(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void update(CodeCustomerDTO dto) { + CodeCustomerEntity entity = ConvertUtils.sourceToTarget(dto, CodeCustomerEntity.class); + updateById(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void delete(String[] ids) { + // 逻辑删除(@TableLogic 注解) + baseDao.deleteBatchIds(Arrays.asList(ids)); + } + +} \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/CodeMediaServiceImpl.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/CodeMediaServiceImpl.java new file mode 100644 index 0000000000..4447d8ed66 --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/CodeMediaServiceImpl.java @@ -0,0 +1,104 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; +import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.utils.ConvertUtils; +import com.epmet.commons.tools.constant.FieldConstant; +import com.epmet.dao.CodeMediaDao; +import com.epmet.dto.CodeMediaDTO; +import com.epmet.entity.CodeMediaEntity; +import com.epmet.redis.CodeMediaRedis; +import com.epmet.service.CodeMediaService; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +/** + * 代码素材 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-07-09 + */ +@Service +public class CodeMediaServiceImpl extends BaseServiceImpl implements CodeMediaService { + + @Autowired + private CodeMediaRedis codeMediaRedis; + + @Override + public PageData page(Map params) { + IPage page = baseDao.selectPage( + getPage(params, FieldConstant.CREATED_TIME, false), + getWrapper(params) + ); + return getPageData(page, CodeMediaDTO.class); + } + + @Override + public List list(Map params) { + List entityList = baseDao.selectList(getWrapper(params)); + + return ConvertUtils.sourceToTarget(entityList, CodeMediaDTO.class); + } + + private QueryWrapper getWrapper(Map params){ + String id = (String)params.get(FieldConstant.ID_HUMP); + + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); + + return wrapper; + } + + @Override + public CodeMediaDTO get(String id) { + CodeMediaEntity entity = baseDao.selectById(id); + return ConvertUtils.sourceToTarget(entity, CodeMediaDTO.class); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void save(CodeMediaDTO dto) { + CodeMediaEntity entity = ConvertUtils.sourceToTarget(dto, CodeMediaEntity.class); + insert(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void update(CodeMediaDTO dto) { + CodeMediaEntity entity = ConvertUtils.sourceToTarget(dto, CodeMediaEntity.class); + updateById(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void delete(String[] ids) { + // 逻辑删除(@TableLogic 注解) + baseDao.deleteBatchIds(Arrays.asList(ids)); + } + +} \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/CodeServiceImpl.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/CodeServiceImpl.java new file mode 100644 index 0000000000..728852e30c --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/CodeServiceImpl.java @@ -0,0 +1,17 @@ +package com.epmet.service.impl; + +import com.epmet.service.CodeService; +import me.chanjar.weixin.common.error.WxErrorException; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * @author zhaoqifeng + * @dscription + * @date 2020/7/10 10:27 + */ +@Service +public class CodeServiceImpl implements CodeService { + +} diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/CustomerCodeOperationHistoryServiceImpl.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/CustomerCodeOperationHistoryServiceImpl.java new file mode 100644 index 0000000000..fc424619cc --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/CustomerCodeOperationHistoryServiceImpl.java @@ -0,0 +1,104 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; +import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.utils.ConvertUtils; +import com.epmet.commons.tools.constant.FieldConstant; +import com.epmet.dao.CustomerCodeOperationHistoryDao; +import com.epmet.dto.CustomerCodeOperationHistoryDTO; +import com.epmet.entity.CustomerCodeOperationHistoryEntity; +import com.epmet.redis.CustomerCodeOperationHistoryRedis; +import com.epmet.service.CustomerCodeOperationHistoryService; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +/** + * 客户代码操作历史 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-07-09 + */ +@Service +public class CustomerCodeOperationHistoryServiceImpl extends BaseServiceImpl implements CustomerCodeOperationHistoryService { + + @Autowired + private CustomerCodeOperationHistoryRedis customerCodeOperationHistoryRedis; + + @Override + public PageData page(Map params) { + IPage page = baseDao.selectPage( + getPage(params, FieldConstant.CREATED_TIME, false), + getWrapper(params) + ); + return getPageData(page, CustomerCodeOperationHistoryDTO.class); + } + + @Override + public List list(Map params) { + List entityList = baseDao.selectList(getWrapper(params)); + + return ConvertUtils.sourceToTarget(entityList, CustomerCodeOperationHistoryDTO.class); + } + + private QueryWrapper getWrapper(Map params){ + String id = (String)params.get(FieldConstant.ID_HUMP); + + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); + + return wrapper; + } + + @Override + public CustomerCodeOperationHistoryDTO get(String id) { + CustomerCodeOperationHistoryEntity entity = baseDao.selectById(id); + return ConvertUtils.sourceToTarget(entity, CustomerCodeOperationHistoryDTO.class); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void save(CustomerCodeOperationHistoryDTO dto) { + CustomerCodeOperationHistoryEntity entity = ConvertUtils.sourceToTarget(dto, CustomerCodeOperationHistoryEntity.class); + insert(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void update(CustomerCodeOperationHistoryDTO dto) { + CustomerCodeOperationHistoryEntity entity = ConvertUtils.sourceToTarget(dto, CustomerCodeOperationHistoryEntity.class); + updateById(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void delete(String[] ids) { + // 逻辑删除(@TableLogic 注解) + baseDao.deleteBatchIds(Arrays.asList(ids)); + } + +} \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/constant/WxMaCodeConstant.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/constant/WxMaCodeConstant.java index 2aae2d8234..3fe8d49f7e 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/constant/WxMaCodeConstant.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/constant/WxMaCodeConstant.java @@ -6,7 +6,7 @@ package com.epmet.wxapi.constant; * @author yinzuomei@elink-cn.com * @date 2020/7/10 12:57 */ -public class WxMaCodeConstant { +public interface WxMaCodeConstant { /** * 为授权的小程序帐号上传小程序代码. */ diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/param/WxMaCodeAuditStatus.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/param/WxMaCodeAuditStatus.java new file mode 100644 index 0000000000..0115b8d9d2 --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/param/WxMaCodeAuditStatus.java @@ -0,0 +1,9 @@ +package com.epmet.wxapi.param; + +/** + * @author zhaoqifeng + * @dscription + * @date 2020/7/10 18:05 + */ +public class WxMaCodeAuditStatus { +} diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/param/WxMaCodeAuditStatusReq.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/param/WxMaCodeAuditStatusReq.java new file mode 100644 index 0000000000..b2fdf65fae --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/param/WxMaCodeAuditStatusReq.java @@ -0,0 +1,18 @@ +package com.epmet.wxapi.param; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; + +import java.io.Serializable; + +/** + * @author zhaoqifeng + * @dscription + * @date 2020/7/13 15:49 + */ +@Data +public class WxMaCodeAuditStatusReq implements Serializable { + private static final long serialVersionUID = -504705519949598098L; + @SerializedName("auditid") + private String auditId; +} diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/param/WxMaCodeCommitReq.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/param/WxMaCodeCommitReq.java index 3054446c7f..9e24a99689 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/param/WxMaCodeCommitReq.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/param/WxMaCodeCommitReq.java @@ -1,5 +1,6 @@ package com.epmet.wxapi.param; +import com.google.gson.annotations.SerializedName; import lombok.Data; import java.io.Serializable; @@ -17,18 +18,23 @@ public class WxMaCodeCommitReq implements Serializable { /** * 代码库中的代码模版ID */ - private Long templateId; + @SerializedName("template_id") + private String templateId; /** * 第三方自定义的配置 */ - private WxMaCodeExtConfigReq extConfig; + @SerializedName("ext_json") + private String extJson; /** * 代码版本号,开发者可自定义 */ + @SerializedName("user_version") private String userVersion; /** * 代码描述,开发者可自定义 */ + + @SerializedName("user_desc") private String userDesc; } diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/param/WxMaCodeSubmitAuditRequest.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/param/WxMaCodeSubmitAuditRequest.java new file mode 100644 index 0000000000..c9fa07b8e4 --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/param/WxMaCodeSubmitAuditRequest.java @@ -0,0 +1,145 @@ +package com.epmet.wxapi.param; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; +import java.util.List; + +/** + * @author zhaoqifeng + * @dscription + * @date 2020/7/10 18:04 + */ +@NoArgsConstructor +@Data +public class WxMaCodeSubmitAuditRequest implements Serializable { + + private static final long serialVersionUID = -3919598581372634816L; + /** + * 小程序版本说明和功能解释 + */ + @SerializedName("version_desc") + private String versionDesc; + /** + * 反馈内容,至多 200 字 + */ + @SerializedName("feedback_info") + private String feedbackInfo; + /** + * 用 | 分割的 media_id 列表,至多 5 张图片, 可以通过新增临时素材接口上传而得到 + */ + @SerializedName("feedback_stuff") + private String feedbackStuff; + /** + * 审核项列表(选填,至多填写 5 项) + */ + @SerializedName("item_list") + private List itemList; + /** + * 预览信息(小程序页面截图和操作录屏) + */ + @SerializedName("preview_info") + private List previewInfo; + /** + * 用户生成内容场景(UGC)信息安全声明 + */ + @SerializedName("ugc_declare") + private List ugcDeclare; + + @NoArgsConstructor + @Data + private static class ItemListBean { + /** + * 小程序的页面,可通过获取小程序的页面列表接口获得 + */ + @SerializedName("address") + private String address; + /** + * 小程序的标签,用空格分隔,标签至多 10 个,标签长度至多 20 + */ + @SerializedName("tag") + private String tag; + /** + * 一级类目名称 + */ + @SerializedName("first_class") + private String firstClass; + /** + * 二级类目名称 + */ + @SerializedName("second_class") + private String secondClass; + /** + * 三级类目名称 + */ + @SerializedName("third_class") + private String thirdClass; + /** + * 一级类目的 ID + */ + @SerializedName("first_id") + private String firstId; + /** + * 二级类目的 ID + */ + @SerializedName("second_id") + private String secondId; + /** + * 三级类目的 ID + */ + @SerializedName("third_id") + private String thirdId; + /** + * 小程序页面的标题,标题长度至多 32 + */ + @SerializedName("title") + private String title; + } + + @NoArgsConstructor + @Data + private static class PreviewInfoBean { + /** + * 录屏mediaid列表,可以通过提审素材上传接口获得 + */ + @SerializedName("Video_id_list") + private List videoIdList; + /** + * 截屏mediaid列表,可以通过提审素材上传接口获得 + */ + @SerializedName("pic_id_list") + private List picIdList; + } + + @NoArgsConstructor + @Data + private static class UgcDeclareBean { + /** + * UGC场景 0,不涉及用户生成内容, 1.用户资料,2.图片,3.视频,4.文本,5其他, 可多选,当scene填0时无需填写下列字段 + */ + @SerializedName("scene") + private List scene; + /** + * 当scene选其他时的说明,不超时256字 + */ + @SerializedName("other_scene_desc") + private String otherSceneDesc; + /** + * 内容安全机制 1.使用平台建议的内容安全API,2.使用其他的内容审核产品,3.通过人工审核把关,4.未做内容审核把关 + */ + @SerializedName("method") + private List method; + /** + * 是否有审核团队, 0.无,1.有,默认0 + */ + @SerializedName("has_audit_team") + private Integer hasAuditTeam; + /** + * 说明当前对UGC内容的审核机制,不超过256字 + */ + @SerializedName("audit_desc") + private String auditDesc; + } +} diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/result/WxMaAuditStatusResult.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/result/WxMaAuditStatusResult.java new file mode 100644 index 0000000000..ea39ebae7e --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/result/WxMaAuditStatusResult.java @@ -0,0 +1,36 @@ +package com.epmet.wxapi.result; + +import lombok.Data; + +import java.io.Serializable; + +/** + * @author zhaoqifeng + * @dscription + * @date 2020/7/13 15:53 + */ +@Data +public class WxMaAuditStatusResult implements Serializable { + private static final long serialVersionUID = 3461409352381952089L; + /** + * 返回码 + */ + private String errcode; + /** + * 错误信息 + */ + private String errmsg; + /** + * 审核状态 + */ + private Integer status; + /** + * 当 status = 1 时,返回的拒绝原因; status = 4 时,返回的延后原因 + */ + private String reason; + /** + * 当 status = 1 时,会返回审核失败的小程序截图示例。用 | 分隔的 media_id 的列表,可通过获取永久素材接口拉取截图内容 + */ + private String screenshot; + +} diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/result/WxMaCategoryResult.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/result/WxMaCategoryResult.java new file mode 100644 index 0000000000..a8bbb25e5e --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/result/WxMaCategoryResult.java @@ -0,0 +1,52 @@ +package com.epmet.wxapi.result; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; + +import java.io.Serializable; + +/** + * @author zhaoqifeng + * @dscription + * @date 2020/7/10 16:51 + */ +@Data +public class WxMaCategoryResult implements Serializable { + /** + * 一级类目名称 + */ + private String firstClass; + /** + * 二级类目名称 + */ + private String secondClass; + /** + * 三级类目名称 + */ + private String thirdClass; + /** + * 一级类目的ID编号 + */ + private String firstId; + /** + * 二级类目的ID编号 + */ + private String secondId; + /** + * 三级类目的ID编号 + */ + private String thirdId; + + /** + * 小程序的页面,可通过“获取小程序的第三方提交代码的页面配置”接口获得 + */ + private String address; + /** + * 小程序的标签,多个标签用空格分隔,标签不能多于10个,标签长度不超过20 + */ + private String tag; + /** + * 小程序页面的标题,标题长度不超过32 + */ + private String title; +} diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/result/WxMaGetCategoryResult.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/result/WxMaGetCategoryResult.java new file mode 100644 index 0000000000..b120ad55df --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/result/WxMaGetCategoryResult.java @@ -0,0 +1,28 @@ +package com.epmet.wxapi.result; + +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + +/** + * @author zhaoqifeng + * @dscription + * @date 2020/7/13 10:17 + */ +@Data +public class WxMaGetCategoryResult implements Serializable { + private static final long serialVersionUID = -2665257152145041516L; + /** + * 返回码 + */ + private Integer errcode; + /** + * 错误信息 + */ + private String errmsg; + /** + * 可填选的类目信息列表 + */ + private List categoryList; +} diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/result/WxMaGetPageResult.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/result/WxMaGetPageResult.java new file mode 100644 index 0000000000..5305288c88 --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/result/WxMaGetPageResult.java @@ -0,0 +1,28 @@ +package com.epmet.wxapi.result; + +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + +/** + * @author zhaoqifeng + * @dscription + * @date 2020/7/13 13:38 + */ +@Data +public class WxMaGetPageResult implements Serializable { + private static final long serialVersionUID = -3057343239059623208L; + /** + * 返回码 + */ + private Integer errcode; + /** + * 错误信息 + */ + private String errmsg; + /** + * 错误信息 + */ + private List pageList; +} diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/service/WxMaCodeService.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/service/WxMaCodeService.java index f34511cfec..b329dabe14 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/service/WxMaCodeService.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/service/WxMaCodeService.java @@ -1,9 +1,15 @@ package com.epmet.wxapi.service; +import com.epmet.wxapi.param.WxMaCodeAuditStatus; +import com.epmet.wxapi.param.WxMaCodeAuditStatusReq; import com.epmet.wxapi.param.WxMaCodeCommitReq; +import com.epmet.wxapi.param.WxMaCodeSubmitAuditRequest; +import com.epmet.wxapi.result.WxMaCategoryResult; import com.epmet.wxapi.result.WxResult; import me.chanjar.weixin.common.error.WxErrorException; +import java.util.List; + /** * 小程序代码管理相关 API(大部分只能是第三方平台调用) * 文档:https://open.weixin.qq.com/cgi-bin/showdocument?action=dir_list&t=resource/res_list&verify=1&id=open1489140610_Uavc4&token=&lang=zh_CN @@ -14,9 +20,73 @@ import me.chanjar.weixin.common.error.WxErrorException; public interface WxMaCodeService { /** * 为授权的小程序帐号上传小程序代码(仅仅支持第三方开放平台). - * - * @param commitRequest 参数 + * @author zhaoqifeng + * @date 2020/7/10 14:11 + * @param accessToken 小程序接口调用令牌 + * @param commitRequest 请求参数 + * @return com.epmet.wxapi.result.WxResult * @throws WxErrorException 上传失败时抛出,具体错误码请看类注释文档 */ - WxResult commit(String access_token, WxMaCodeCommitReq commitRequest) throws WxErrorException; + WxResult commit(String accessToken, WxMaCodeCommitReq commitRequest) throws WxErrorException; + + /** + * 获取体验小程序的体验二维码. + * @author zhaoqifeng + * @date 2020/7/10 15:25 + * @param accessToken 小程序接口调用令牌 + * @param path 指定体验版二维码跳转到某个具体页面 + * @return com.epmet.wxapi.result.WxResult + * @throws WxErrorException 抛出异常 + */ + WxResult getQrCode(String accessToken, String path) throws WxErrorException; + + /** + * 获取授权小程序帐号的可选类目. + * + * @param accessToken 提交审核参数 + * @return List + */ + WxResult getCategory(String accessToken); + + /** + * 获取小程序的第三方提交代码的页面配置(仅供第三方开发者代小程序调用). + * + * @param accessToken 提交审核参数 + * @return page_list 页面配置列表 + */ + WxResult getPage(String accessToken); + + /** + * 将第三方提交的代码包提交审核(仅供第三方开发者代小程序调用). + * + * @param accessToken 提交审核参数 + * @param auditRequest 提交审核参数 + * @return 审核编号 + */ + WxResult submitAudit(String accessToken, WxMaCodeSubmitAuditRequest auditRequest); + + /** + * 查询指定版本审核状态(仅供第三方代小程序调用). + * + * @param accessToken 提交审核参数 + * @return 审核状态 + */ + WxResult getAuditStatus(String accessToken, WxMaCodeAuditStatusReq request); + + /** + * 发布已通过审核的小程序(仅供第三方代小程序调用). + * + * @param accessToken 提交审核参数 + * @return 发布结果 + */ + WxResult release(String accessToken); + + /** + * 小程序审核撤回. + * 单个帐号每天审核撤回次数最多不超过1次,一个月不超过10次 + * + * @param accessToken 提交审核参数 + * @return 撤回结果 + */ + WxResult undoCodeAudit(String accessToken); } diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/service/impl/WxMaCodeServiceImpl.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/service/impl/WxMaCodeServiceImpl.java index 99860706eb..2ae3ff2443 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/service/impl/WxMaCodeServiceImpl.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/service/impl/WxMaCodeServiceImpl.java @@ -1,11 +1,30 @@ package com.epmet.wxapi.service.impl; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.epmet.commons.tools.utils.HttpClientManager; +import com.epmet.commons.tools.utils.Result; +import com.epmet.wxapi.constant.WxMaCodeConstant; +import com.epmet.wxapi.param.WxMaCodeAuditStatus; +import com.epmet.wxapi.param.WxMaCodeAuditStatusReq; import com.epmet.wxapi.param.WxMaCodeCommitReq; -import com.epmet.wxapi.result.WxResult; +import com.epmet.wxapi.param.WxMaCodeSubmitAuditRequest; +import com.epmet.wxapi.result.*; import com.epmet.wxapi.service.WxMaCodeService; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import io.micrometer.core.instrument.util.JsonUtils; +import lombok.Data; import me.chanjar.weixin.common.error.WxErrorException; +import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.util.ArrayList; +import java.util.List; + /** * 描述一下 * @@ -14,9 +33,161 @@ import org.springframework.stereotype.Service; */ @Service public class WxMaCodeServiceImpl implements WxMaCodeService { + private static final String ERR_CODE = "errcode"; + private static final String ERR_MSG = "errmsg"; + + @Override + public WxResult commit(String accessToken, WxMaCodeCommitReq commitRequest) throws WxErrorException { + WxResult result = new WxResult(); + String url = WxMaCodeConstant.COMMIT_URL + "?" + "access_token=" + accessToken; + Result commitResult = HttpClientManager.getInstance().sendPostByJSON(url, toJson(commitRequest)); + if(!commitResult.success()) { + result.setErrorCode(commitResult.getCode()); + result.setErrorMsg(commitResult.getMsg()); + return result; + } + JSONObject jsonObject = JSONObject.parseObject(commitResult.getData()); + result.setErrorCode(jsonObject.getInteger(ERR_CODE)); + result.setErrorMsg(jsonObject.getString(ERR_MSG)); + return result; + } + + @Override + public WxResult getQrCode(String accessToken, String path) throws WxErrorException{ + WxResult result = new WxResult<>(); + StringBuilder url = new StringBuilder(WxMaCodeConstant.GET_QRCODE_URL).append("?access_token").append(accessToken); + if (StringUtils.isNotBlank(path)) { + try { + url.append("?path=").append(URLEncoder.encode(path, StandardCharsets.UTF_8.name())); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + } + Result qrCodeResult = HttpClientManager.getInstance().sendGetFile(url.toString(), null); + if(!qrCodeResult.success()) { + result.setErrorCode(qrCodeResult.getCode()); + result.setErrorMsg(qrCodeResult.getMsg()); + return result; + } + + result.setData(qrCodeResult.getData()); + + return result; + } + @Override - public WxResult commit(String access_token, WxMaCodeCommitReq commitRequest) throws WxErrorException { + public WxResult getCategory(String accessToken) { + WxResult> result = new WxResult<>(); + String url = WxMaCodeConstant.GET_CATEGORY_URL + "?" + "access_token=" + accessToken; + Result getCategoryResult = HttpClientManager.getInstance().sendGet(url, null); + if(!getCategoryResult.success()) { + result.setErrorCode(getCategoryResult.getCode()); + result.setErrorMsg(getCategoryResult.getMsg()); + return result; + } + WxMaGetCategoryResult categoryResult = JSONObject.parseObject(getCategoryResult.getData(), WxMaGetCategoryResult.class); + result.setErrorCode(categoryResult.getErrcode()); + result.setErrorMsg(categoryResult.getErrmsg()); + result.setData(categoryResult.getCategoryList()); + return result; + } + + @Override + public WxResult getPage(String accessToken) { + WxResult> result = new WxResult<>(); + String url = WxMaCodeConstant.GET_PAGE_URL + "?" + "access_token=" + accessToken; + Result getPageResult = HttpClientManager.getInstance().sendGet(url, null); + if(!getPageResult.success()) { + result.setErrorCode(getPageResult.getCode()); + result.setErrorMsg(getPageResult.getMsg()); + return result; + } + WxMaGetPageResult pageResult = JSONObject.parseObject(getPageResult.getData(), WxMaGetPageResult.class); + result.setErrorCode(pageResult.getErrcode()); + result.setErrorMsg(pageResult.getErrmsg()); + result.setData(pageResult.getPageList()); + return result; + } - return null; + @Override + public WxResult submitAudit(String accessToken, WxMaCodeSubmitAuditRequest auditRequest) { + WxResult result = new WxResult(); + String url = WxMaCodeConstant.SUBMIT_AUDIT_URL + "?" + "access_token=" + accessToken; + Result submitResult = HttpClientManager.getInstance().sendPostByJSON(url, toJson(auditRequest)); + if(!submitResult.success()) { + result.setErrorCode(submitResult.getCode()); + result.setErrorMsg(submitResult.getMsg()); + return result; + } + JSONObject jsonObject = JSONObject.parseObject(submitResult.getData()); + result.setErrorCode(jsonObject.getInteger(ERR_CODE)); + result.setErrorMsg(jsonObject.getString(ERR_MSG)); + return result; + } + + @Override + public WxResult getAuditStatus(String accessToken, WxMaCodeAuditStatusReq request) { + WxResult result = new WxResult<>(); + String url = WxMaCodeConstant.COMMIT_URL + "?" + "access_token=" + accessToken; + Result statusResult = HttpClientManager.getInstance().sendPostByJSON(url, toJson(request)); + if(!statusResult.success()) { + result.setErrorCode(statusResult.getCode()); + result.setErrorMsg(statusResult.getMsg()); + return result; + } + WxMaAuditStatusResult auditStatusResult = JSONObject.parseObject(statusResult.getData(), WxMaAuditStatusResult.class); + result.ok(auditStatusResult); + return result; + } + + @Override + public WxResult release(String accessToken) { + WxResult result = new WxResult(); + String url = WxMaCodeConstant.RELEASE_URL + "?" + "access_token=" + accessToken; + Result releaseResult = HttpClientManager.getInstance().sendPostByJSON(url, null); + if(!releaseResult.success()) { + result.setErrorCode(releaseResult.getCode()); + result.setErrorMsg(releaseResult.getMsg()); + return result; + } + JSONObject jsonObject = JSONObject.parseObject(releaseResult.getData()); + result.setErrorCode(jsonObject.getInteger(ERR_CODE)); + result.setErrorMsg(jsonObject.getString(ERR_MSG)); + return result; + } + + @Override + public WxResult undoCodeAudit(String accessToken) { + WxResult result = new WxResult(); + String url = WxMaCodeConstant.UNDO_CODE_AUDIT_URL + "?" + "access_token=" + accessToken; + Result undoResult = HttpClientManager.getInstance().sendGet(url, null); + if(!undoResult.success()) { + result.setErrorCode(undoResult.getCode()); + result.setErrorMsg(undoResult.getMsg()); + return result; + } + JSONObject jsonObject = JSONObject.parseObject(undoResult.getData()); + result.setErrorCode(jsonObject.getInteger(ERR_CODE)); + result.setErrorMsg(jsonObject.getString(ERR_MSG)); + return result; + } + + public static void main(String[] args) { + String url = "{\"errcode\":0,\"errmsg\":\"ok\",\"category_list\":[{\"first_class\":\"工具\",\"second_class\":\"备忘录\",\"first_id\":1,\"second_id\":2,}\n" + + "{\"first_class\":\"教育\",\"second_class\":\"学历教育\",\"third_class\":\"高等\",\"first_id\":3,\"second_id\":4,\"third_id\":5,}]}"; + WxMaGetCategoryResult video = JSONObject.parseObject(url, WxMaGetCategoryResult.class); + WxResult> result = new WxResult<>(); + result.setErrorCode(video.getErrcode()); + result.setErrorMsg(video.getErrmsg()); + result.setData(video.getCategoryList()); + System.out.println(result); + WxMaCodeSubmitAuditRequest request = new WxMaCodeSubmitAuditRequest(); + request.setVersionDesc("aasdf"); + } + private String toJson(Object object) { + GsonBuilder gsonBuilder = new GsonBuilder(); + gsonBuilder.setPrettyPrinting(); + Gson gson = gsonBuilder.create(); + return gson.toJson(object); } -} +} \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/CodeAuditResultDao.xml b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/CodeAuditResultDao.xml new file mode 100644 index 0000000000..f393abeb44 --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/CodeAuditResultDao.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/CodeCustomerDao.xml b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/CodeCustomerDao.xml new file mode 100644 index 0000000000..e6d65e78e4 --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/CodeCustomerDao.xml @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/CodeMediaDao.xml b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/CodeMediaDao.xml new file mode 100644 index 0000000000..c89b8a54d3 --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/CodeMediaDao.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/CustomerCodeOperationHistoryDao.xml b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/CustomerCodeOperationHistoryDao.xml new file mode 100644 index 0000000000..09ae8b2e78 --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/CustomerCodeOperationHistoryDao.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file From b70f6a308291b5ecafd6f1c28005ac1fa4a3043d Mon Sep 17 00:00:00 2001 From: sunyuchao Date: Tue, 14 Jul 2020 16:06:38 +0800 Subject: [PATCH 6/6] =?UTF-8?q?=E5=85=AC=E4=BC=97=E5=8F=B7=E6=9C=8D?= =?UTF-8?q?=E5=8A=A1=E6=8E=A5=E5=8F=A3=E8=87=AA=E6=B5=8B=E9=97=AE=E9=A2=98?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../epmet/dto/form/PublicSendSmsCodeFormDTO.java | 7 ++++++- .../service/impl/PublicUserLoginServiceImpl.java | 2 +- .../java/com/epmet/dto/result/MyInfoResultDTO.java | 14 +++++++------- .../main/java/com/epmet/constant/PaConstant.java | 13 ++++++++++++- .../epmet/service/impl/PaCustomerServiceImpl.java | 14 +++++++++----- .../com/epmet/service/impl/PaUserServiceImpl.java | 6 +++--- .../src/main/resources/mapper/PaUserWechatDao.xml | 2 -- 7 files changed, 38 insertions(+), 20 deletions(-) diff --git a/epmet-auth/src/main/java/com/epmet/dto/form/PublicSendSmsCodeFormDTO.java b/epmet-auth/src/main/java/com/epmet/dto/form/PublicSendSmsCodeFormDTO.java index b3e9558600..22b096ca6a 100644 --- a/epmet-auth/src/main/java/com/epmet/dto/form/PublicSendSmsCodeFormDTO.java +++ b/epmet-auth/src/main/java/com/epmet/dto/form/PublicSendSmsCodeFormDTO.java @@ -21,8 +21,13 @@ public class PublicSendSmsCodeFormDTO implements Serializable { public interface AddUserShowGroup extends CustomerClientShowGroup { } + /** + * 手机号 + */ @NotBlank(message = "手机号不能为空", groups = {AddUserShowGroup.class}) private String phone; - @NotBlank(message = "是否登陆不能为空", groups = {AddUserShowGroup.class}) + /** + * 是否登陆(登陆:true 注册:false) + */ private Boolean isLogon; } diff --git a/epmet-auth/src/main/java/com/epmet/service/impl/PublicUserLoginServiceImpl.java b/epmet-auth/src/main/java/com/epmet/service/impl/PublicUserLoginServiceImpl.java index a5e0a48d3f..c4b973b0fd 100644 --- a/epmet-auth/src/main/java/com/epmet/service/impl/PublicUserLoginServiceImpl.java +++ b/epmet-auth/src/main/java/com/epmet/service/impl/PublicUserLoginServiceImpl.java @@ -189,7 +189,7 @@ public class PublicUserLoginServiceImpl implements PublicUserLoginService { //2.用户不存在时不允许登陆 PaUserDTO userDTO = resultDTO.getPaUserResult(); - if (null == resultDTO || StringUtils.isBlank(userDTO.getId())) { + if (null == userDTO || StringUtils.isBlank(userDTO.getId())) { throw new RenException(PublicUserLoginConstant.LOGON_EXCEPTION); } diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/MyInfoResultDTO.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/MyInfoResultDTO.java index 3d75eaed38..62dd3471db 100644 --- a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/MyInfoResultDTO.java +++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/MyInfoResultDTO.java @@ -22,31 +22,31 @@ public class MyInfoResultDTO implements Serializable { */ private String agencyName = ""; /** - * 新增客户Id + * 组织级别 */ private String level = ""; /** - * 包含customerId的token + * 省 */ private String province = ""; /** - * 新增客户Id + * 市 */ private String city = ""; /** - * 包含customerId的token + * 区 */ private String district = ""; /** - * 新增客户Id + * 党支部数量 */ private Integer partyBranchNum; /** - * 包含customerId的token + * 居民端授权状态(0:未授权,1:已授权) */ private Integer resiAuthorization; /** - * 新增客户Id + * 政府端授权状态(0:未授权,1:已授权) */ private Integer workAuthorization; diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/constant/PaConstant.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/constant/PaConstant.java index e523ba6fbd..9f43dface4 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/constant/PaConstant.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/constant/PaConstant.java @@ -10,11 +10,18 @@ public interface PaConstant { * 手机号注册 */ String PHONE_EXCEPTION = "手机号已存在,不允许再次注册"; - + /** + * 更新用户信息失败 + */ + String UPDATE_USER_EXCEPTION = "更新用户信息失败"; /** * 根据userId查询pa_user_wechat表失败 */ String SELECT_WECHAT_EXCEPTION = "获取用户微信信息失败"; + /** + * 保存用户访问记录数据失败 + */ + String SAVE_VISITED_EXCEPTION = "保存用户访问记录数据失败"; /** * 组织级别对应的key、name @@ -49,4 +56,8 @@ public interface PaConstant { String CLIENT_RESI = "resi"; String CLIENT_WORK = "work"; + /** + * 获取缓存中token信息失败 + */ + String TOKEN_EXCEPTION = "token已过期"; } diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/PaCustomerServiceImpl.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/PaCustomerServiceImpl.java index 84b676eb78..3dd016aaf8 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/PaCustomerServiceImpl.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/PaCustomerServiceImpl.java @@ -154,7 +154,7 @@ public class PaCustomerServiceImpl extends BaseServiceImpl userList = paUserDao.selectUserByPhone(formDTO.getPhone()); - if (null != userList || userList.size() > NumConstant.ZERO) { + if (null != userList && userList.size() > NumConstant.ZERO) { throw new RenException(PaConstant.PHONE_EXCEPTION); } @@ -172,7 +172,9 @@ public class PaCustomerServiceImpl extends BaseServiceImpl CustomerUserResultDTO resultDTO = new CustomerUserResultDTO(); List userList = baseDao.selectUserByPhone(phone); if (null == userList || userList.size() < NumConstant.ONE) { - resultDTO.setPaUserResult(new PaUserDTO()); - resultDTO.setPaCustomerResult(new PaCustomerDTO()); + resultDTO.setPaUserResult(null); + resultDTO.setPaCustomerResult(null); return resultDTO; } PaUserDTO dto = userList.get(NumConstant.ZERO); List customerList = paCustomerDao.selectCustomerByUserId(dto.getId()); resultDTO.setPaUserResult(dto); - resultDTO.setPaCustomerResult(customerList.size() > NumConstant.ZERO ? customerList.get(NumConstant.ZERO) : new PaCustomerDTO()); + resultDTO.setPaCustomerResult(customerList.size() > NumConstant.ZERO ? customerList.get(NumConstant.ZERO) : null); return resultDTO; } diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/PaUserWechatDao.xml b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/PaUserWechatDao.xml index 8f77d5598e..6afbc70806 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/PaUserWechatDao.xml +++ b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/PaUserWechatDao.xml @@ -31,14 +31,12 @@ user_id, wx_open_id, union_id, - phone, gender, nickname, head_img_url, country, province, city, - privilege, `language` FROM pa_user_wechat