diff --git a/epmet-auth/deploy/docker-compose-dev.yml b/epmet-auth/deploy/docker-compose-dev.yml index edf73a05cc..b95ceaba5d 100644 --- a/epmet-auth/deploy/docker-compose-dev.yml +++ b/epmet-auth/deploy/docker-compose-dev.yml @@ -2,7 +2,7 @@ version: "3.7" services: epmet-auth-server: container_name: epmet-auth-server-dev - image: 192.168.1.130:10080/epmet-cloud-dev/epmet-auth:0.3.48 + image: 192.168.1.130:10080/epmet-cloud-dev/epmet-auth:0.3.55 ports: - "8081:8081" network_mode: host # 使用现有网络 diff --git a/epmet-auth/deploy/docker-compose-prod.yml b/epmet-auth/deploy/docker-compose-prod.yml index 13ddca93b7..0afba96920 100644 --- a/epmet-auth/deploy/docker-compose-prod.yml +++ b/epmet-auth/deploy/docker-compose-prod.yml @@ -2,7 +2,7 @@ version: "3.7" services: epmet-auth-server: container_name: epmet-auth-server-prod - image: registry-vpc.cn-qingdao.aliyuncs.com/epmet-cloud-master/epmet-auth:0.3.36 + image: registry-vpc.cn-qingdao.aliyuncs.com/epmet-cloud-master/epmet-auth:0.3.55 ports: - "8081:8081" network_mode: host # 使用现有网络 diff --git a/epmet-auth/deploy/docker-compose-test.yml b/epmet-auth/deploy/docker-compose-test.yml index d15b071181..ff10d2224e 100644 --- a/epmet-auth/deploy/docker-compose-test.yml +++ b/epmet-auth/deploy/docker-compose-test.yml @@ -2,7 +2,7 @@ version: "3.7" services: epmet-auth-server: container_name: epmet-auth-server-test - image: registry-vpc.cn-qingdao.aliyuncs.com/epmet-cloud-release/epmet-auth:0.3.36 + image: registry-vpc.cn-qingdao.aliyuncs.com/epmet-cloud-release/epmet-auth:0.3.55 ports: - "8081:8081" network_mode: host # 使用现有网络 diff --git a/epmet-auth/pom.xml b/epmet-auth/pom.xml index fb25b63090..affb22da4d 100644 --- a/epmet-auth/pom.xml +++ b/epmet-auth/pom.xml @@ -2,7 +2,7 @@ 4.0.0 - 0.3.48 + 0.3.55 com.epmet epmet-cloud @@ -122,6 +122,12 @@ 2.0.0 compile + + com.epmet + oper-crm-client + 2.0.0 + compile + diff --git a/epmet-auth/src/main/java/com/epmet/controller/ThirdLoginController.java b/epmet-auth/src/main/java/com/epmet/controller/ThirdLoginController.java index 90be83d3b2..461dd1ab48 100644 --- a/epmet-auth/src/main/java/com/epmet/controller/ThirdLoginController.java +++ b/epmet-auth/src/main/java/com/epmet/controller/ThirdLoginController.java @@ -3,6 +3,7 @@ package com.epmet.controller; import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.validator.ValidatorUtils; import com.epmet.dto.form.LoginFormDTO; +import com.epmet.dto.form.ThirdWxmpEnteOrgFormDTO; import com.epmet.dto.result.UserTokenResultDTO; import com.epmet.service.ThirdLoginService; import org.springframework.beans.factory.annotation.Autowired; @@ -46,4 +47,17 @@ public class ThirdLoginController { return new Result().ok(thirdLoginService.workLogin(formDTO)); } + /** + * @param formDTO + * @return + * @Author sun + * @Description 单客户-选择组织,进入首页 + **/ + @PostMapping(value = "enterorg") + public Result enterOrg(@RequestBody ThirdWxmpEnteOrgFormDTO formDTO) { + ValidatorUtils.validateEntity(formDTO,ThirdWxmpEnteOrgFormDTO.AddUserShowGroup.class,ThirdWxmpEnteOrgFormDTO.AddUserInternalGroup.class); + UserTokenResultDTO userTokenResultDTO=thirdLoginService.enterOrg(formDTO); + return new Result().ok(userTokenResultDTO); + } + } diff --git a/epmet-auth/src/main/java/com/epmet/dto/form/GovWxmpEnteOrgFormDTO.java b/epmet-auth/src/main/java/com/epmet/dto/form/GovWxmpEnteOrgFormDTO.java index 8951235a94..298fa611bc 100644 --- a/epmet-auth/src/main/java/com/epmet/dto/form/GovWxmpEnteOrgFormDTO.java +++ b/epmet-auth/src/main/java/com/epmet/dto/form/GovWxmpEnteOrgFormDTO.java @@ -40,9 +40,9 @@ public class GovWxmpEnteOrgFormDTO implements Serializable { private String rootAgencyId; /** - * 客户appId(exJson文件中获取) + * desc:小程序appId */ - @NotBlank(message = "appId不能为空",groups = {AddUserInternalGroup.class}) private String appId; + } diff --git a/epmet-auth/src/main/java/com/epmet/dto/form/GovWxmpFormDTO.java b/epmet-auth/src/main/java/com/epmet/dto/form/GovWxmpFormDTO.java index 8bab423dec..55abfd3bce 100644 --- a/epmet-auth/src/main/java/com/epmet/dto/form/GovWxmpFormDTO.java +++ b/epmet-auth/src/main/java/com/epmet/dto/form/GovWxmpFormDTO.java @@ -19,5 +19,9 @@ public class GovWxmpFormDTO extends LoginCommonFormDTO implements Serializable { */ @NotBlank(message = "wxCode不能为空",groups = {AddUserInternalGroup.class}) private String wxCode; + /** + * appId + */ + private String appId; } diff --git a/epmet-auth/src/main/java/com/epmet/dto/form/LoginByWxCodeFormDTO.java b/epmet-auth/src/main/java/com/epmet/dto/form/LoginByWxCodeFormDTO.java index 8ddfe9edff..3f59baf4d7 100644 --- a/epmet-auth/src/main/java/com/epmet/dto/form/LoginByWxCodeFormDTO.java +++ b/epmet-auth/src/main/java/com/epmet/dto/form/LoginByWxCodeFormDTO.java @@ -29,4 +29,6 @@ public class LoginByWxCodeFormDTO extends LoginCommonFormDTO implements Serializ * 加密算法的初始向量 */ private String iv; + + private String appId; } diff --git a/epmet-auth/src/main/java/com/epmet/dto/form/ResiWxPhoneFormDTO.java b/epmet-auth/src/main/java/com/epmet/dto/form/ResiWxPhoneFormDTO.java index f0148b3c14..f710be379e 100644 --- a/epmet-auth/src/main/java/com/epmet/dto/form/ResiWxPhoneFormDTO.java +++ b/epmet-auth/src/main/java/com/epmet/dto/form/ResiWxPhoneFormDTO.java @@ -32,4 +32,6 @@ public class ResiWxPhoneFormDTO implements Serializable { */ @NotBlank(message = "iv不能为空",groups = {AddUserInternalGroup.class}) private String iv; + + private String appId; } diff --git a/epmet-auth/src/main/java/com/epmet/dto/form/ThirdWxmpEnteOrgFormDTO.java b/epmet-auth/src/main/java/com/epmet/dto/form/ThirdWxmpEnteOrgFormDTO.java new file mode 100644 index 0000000000..14c7339245 --- /dev/null +++ b/epmet-auth/src/main/java/com/epmet/dto/form/ThirdWxmpEnteOrgFormDTO.java @@ -0,0 +1,47 @@ +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 单客户-选择组织,进入首页入参Dto + * @Author sun + */ +@Data +public class ThirdWxmpEnteOrgFormDTO implements Serializable { + public interface AddUserInternalGroup {} + public interface AddUserShowGroup extends CustomerClientShowGroup {} + /** + * wxCode + */ + @NotBlank(message = "wxCode不能为空",groups = {AddUserInternalGroup.class}) + private String wxCode; + + /** + * 手机号 + */ + @NotBlank(message = "手机号不能为空",groups = {AddUserShowGroup.class}) + private String mobile; + + /** + * 选择的组织所属的id + */ + @NotBlank(message = "客户id不能为空",groups = {AddUserInternalGroup.class}) + private String customerId; + + /** + * 选择的要进入的组织(根组织id) + */ + @NotBlank(message = "组织id不能为空",groups = {AddUserInternalGroup.class}) + private String rootAgencyId; + + /** + * 客户appId(exJson文件中获取) + */ + @NotBlank(message = "appId不能为空",groups = {AddUserInternalGroup.class}) + private String appId; +} + diff --git a/epmet-auth/src/main/java/com/epmet/redis/CustomerAppWxServiceUtil.java b/epmet-auth/src/main/java/com/epmet/redis/CustomerAppWxServiceUtil.java new file mode 100644 index 0000000000..9d74299267 --- /dev/null +++ b/epmet-auth/src/main/java/com/epmet/redis/CustomerAppWxServiceUtil.java @@ -0,0 +1,124 @@ +/** + * Copyright (c) 2018 人人开源 All rights reserved. + *

+ * https://www.renren.io + *

+ * 版权所有,侵权必究! + */ + +package com.epmet.redis; + +import cn.binarywang.wx.miniapp.api.WxMaService; +import cn.binarywang.wx.miniapp.api.impl.WxMaServiceImpl; +import cn.binarywang.wx.miniapp.config.impl.WxMaDefaultConfigImpl; +import com.alibaba.fastjson.JSON; +import com.epmet.commons.tools.redis.RedisKeys; +import com.epmet.commons.tools.redis.RedisUtils; +import com.epmet.commons.tools.utils.Result; +import com.epmet.dto.CustomerAppDTO; +import com.epmet.feign.OperCrmOpenFeignClient; +import com.google.common.collect.Maps; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.ApplicationArguments; +import org.springframework.boot.ApplicationRunner; +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.data.redis.core.SetOperations; +import org.springframework.stereotype.Component; +import org.springframework.util.CollectionUtils; + +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.stream.Collectors; + +/** + * 客户app Redis + * + * @author Mark sunlightcs@gmail.com + * @since 1.0.0 + */ +@Component +public class CustomerAppWxServiceUtil implements ApplicationRunner { + private static Logger logger = LogManager.getLogger(CustomerAppWxServiceUtil.class); + + /** + * 过期时长为30分钟,单位:秒 + */ + private final static long MINUTE_THIRTY_EXPIRE = 60 * 60 * 24 * 7L; + private final static String JSON_STR = "JSON"; + + @Autowired + private RedisUtils redisUtils; + @Autowired + private RedisTemplate redisTemplate; + @Autowired + private OperCrmOpenFeignClient operCrmOpenFeignClient; + + private static Map maServices = Maps.newHashMap(); + + public static WxMaService getWxMaService(String appId) { + WxMaService wxMaService = maServices.get(appId); + if (wxMaService == null){ + logger.error("getMaService appId:{} is not config from customer_app",appId); + } + return wxMaService; + } + /*public String get(String appId) { + String key = RedisKeys.getAppSecretKey(appId); + String secret = (String) redisUtils.get(key); + if (StringUtils.isBlank(secret)) { + CustomerAppSecretFormDTO param = new CustomerAppSecretFormDTO(); + param.setAppId(appId); + Result result = operCrmOpenFeignClient.getSecretByAppId(param); + if (result.success()) { + secret = result.getData(); + if (StringUtils.isNotBlank(secret)) { + redisUtils.set(key, secret, MINUTE_THIRTY_EXPIRE); + } + } + } + return secret; + }*/ + + @Override + public void run(ApplicationArguments args) { + try { + Result> configAllAppResult = operCrmOpenFeignClient.getConfigAllApp(); + logger.info("initWxMa operCrmOpenFeignClient.getConfigAllApp result:{}", JSON.toJSONString(configAllAppResult)); + if (configAllAppResult == null || !configAllAppResult.success()){ + logger.info("initWxMa operCrmOpenFeignClient.getConfigAllApp fail"); + return; + } + String appKey = RedisKeys.getCustomerAppKey(); + SetOperations appSet = redisTemplate.opsForSet(); + Set members = appSet.members(appKey); + + if ( !CollectionUtils.isEmpty(configAllAppResult.getData())) { + //if (!CollectionUtils.isEmpty(members) && CollectionUtils.isEmpty()){ + //todo + //} + maServices = configAllAppResult.getData().stream() + .map(a -> { + WxMaDefaultConfigImpl config = new WxMaDefaultConfigImpl(); + config.setAppid(a.getAppId()); + config.setSecret(a.getSecret()); + config.setMsgDataFormat(JSON_STR); + + WxMaService service = new WxMaServiceImpl(); + service.setWxMaConfig(config); + redisTemplate.opsForSet().add(appKey,a.getSecret()); + return service; + }).collect(Collectors.toMap(s -> s.getWxMaConfig().getAppid(), a -> a)); + + + + } + } catch (Exception e) { + logger.error("init wxMaservice exception",e); + } finally { + logger.info("init wxMaservice end"); + } + } +} diff --git a/epmet-auth/src/main/java/com/epmet/service/LoginService.java b/epmet-auth/src/main/java/com/epmet/service/LoginService.java index 248e7c4d97..a0e429eff9 100644 --- a/epmet-auth/src/main/java/com/epmet/service/LoginService.java +++ b/epmet-auth/src/main/java/com/epmet/service/LoginService.java @@ -45,11 +45,12 @@ public interface LoginService { * @return cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult * @param app * @param wxCode + * @param appId 非必填 * @Author yinzuomei * @Description 解析wxCode * @Date 2020/4/19 0:24 **/ - WxMaJscode2SessionResult getWxMaUser(String app, String wxCode); + WxMaJscode2SessionResult getWxMaUser(String app, String wxCode, String appId); /** * @return java.lang.String diff --git a/epmet-auth/src/main/java/com/epmet/service/ThirdLoginService.java b/epmet-auth/src/main/java/com/epmet/service/ThirdLoginService.java index 4a9d939a93..a532adec56 100644 --- a/epmet-auth/src/main/java/com/epmet/service/ThirdLoginService.java +++ b/epmet-auth/src/main/java/com/epmet/service/ThirdLoginService.java @@ -1,6 +1,7 @@ package com.epmet.service; import com.epmet.dto.form.LoginFormDTO; +import com.epmet.dto.form.ThirdWxmpEnteOrgFormDTO; import com.epmet.dto.result.UserTokenResultDTO; /** @@ -24,4 +25,12 @@ public interface ThirdLoginService { * @Description 单客户-政府端微信小程序登录 **/ UserTokenResultDTO workLogin(LoginFormDTO formDTO); + + /** + * @param formDTO + * @return + * @Author sun + * @Description 单客户-选择组织,进入首页 + **/ + UserTokenResultDTO enterOrg(ThirdWxmpEnteOrgFormDTO formDTO); } diff --git a/epmet-auth/src/main/java/com/epmet/service/impl/GovLoginServiceImpl.java b/epmet-auth/src/main/java/com/epmet/service/impl/GovLoginServiceImpl.java index 406ae0fe6f..d9134aabec 100644 --- a/epmet-auth/src/main/java/com/epmet/service/impl/GovLoginServiceImpl.java +++ b/epmet-auth/src/main/java/com/epmet/service/impl/GovLoginServiceImpl.java @@ -19,7 +19,6 @@ import com.epmet.constant.SmsTemplateConstant; import com.epmet.dto.CustomerAgencyDTO; import com.epmet.dto.CustomerStaffDTO; import com.epmet.dto.GovStaffRoleDTO; -import com.epmet.dto.UserWechatDTO; import com.epmet.dto.form.*; import com.epmet.dto.result.*; import com.epmet.feign.*; @@ -141,7 +140,7 @@ public class GovLoginServiceImpl implements GovLoginService { @Override public UserTokenResultDTO loginByWxCode(GovWxmpFormDTO formDTO) { //1、解析微信用户 - WxMaJscode2SessionResult wxMaJscode2SessionResult = loginService.getWxMaUser(formDTO.getApp(), formDTO.getWxCode()); + WxMaJscode2SessionResult wxMaJscode2SessionResult = loginService.getWxMaUser(formDTO.getApp(), formDTO.getWxCode(), formDTO.getAppId()); if(null!=wxMaJscode2SessionResult){ logger.info(String.format("app=%s,wxCode=%s,openId=%s",formDTO.getApp(),formDTO.getWxCode(),wxMaJscode2SessionResult.getOpenid())); } @@ -272,23 +271,8 @@ public class GovLoginServiceImpl implements GovLoginService { throw new RenException(customerStaffDTOResult.getCode()); } CustomerStaffDTO customerStaff = customerStaffDTOResult.getData(); - /*//2、解析微信用户 - WxMaJscode2SessionResult wxMaJscode2SessionResult = loginService.getWxMaUser(LoginConstant.APP_GOV, formDTO.getWxCode());*/ - //2020.7.24 获取微信信息接口调整,改调用微信api的方式 sun - //2.调用epmet_third服务,校验appId是否有效以及是否授权,校验通过的调用微信API获取用户基本信息 - WxLoginFormDTO resiLoginFormDTO = new WxLoginFormDTO(); - resiLoginFormDTO.setAppId(formDTO.getAppId()); - resiLoginFormDTO.setWxCode(formDTO.getWxCode()); - Result result = epmetThirdFeignClient.resiAndWorkLogin(resiLoginFormDTO); - if (!result.success()) { - logger.error("工作端小程序登陆,调用epmet_third服务获取数据失败"); - throw new RenException(result.getCode()); - } - UserWechatDTO userWechatDTO = result.getData(); - WxMaJscode2SessionResult wxMaJscode2SessionResult = new WxMaJscode2SessionResult(); - wxMaJscode2SessionResult.setOpenid(userWechatDTO.getWxOpenId()); - wxMaJscode2SessionResult.setSessionKey(userWechatDTO.getSessionKey()); - wxMaJscode2SessionResult.setUnionid(""); + //2、解析微信用户 + WxMaJscode2SessionResult wxMaJscode2SessionResult = loginService.getWxMaUser(LoginConstant.APP_GOV, formDTO.getWxCode(), formDTO.getAppId()); //3、记录staff_wechat,并记录用户激活状态,激活时间 this.savestaffwechat(customerStaff.getUserId(), wxMaJscode2SessionResult.getOpenid()); diff --git a/epmet-auth/src/main/java/com/epmet/service/impl/LoginServiceImpl.java b/epmet-auth/src/main/java/com/epmet/service/impl/LoginServiceImpl.java index 5221a30b33..adadb9b626 100644 --- a/epmet-auth/src/main/java/com/epmet/service/impl/LoginServiceImpl.java +++ b/epmet-auth/src/main/java/com/epmet/service/impl/LoginServiceImpl.java @@ -23,6 +23,7 @@ import com.epmet.feign.EpmetUserFeignClient; import com.epmet.feign.OperAccessOpenFeignClient; import com.epmet.jwt.JwtTokenProperties; import com.epmet.jwt.JwtTokenUtils; +import com.epmet.redis.CustomerAppWxServiceUtil; import com.epmet.service.CaptchaService; import com.epmet.service.LoginService; import com.epmet.utils.WxMaServiceUtils; @@ -83,7 +84,7 @@ public class LoginServiceImpl implements LoginService { throw new RenException("参数错误"); } //1、根据wxCode获取微信信息 - WxMaJscode2SessionResult wxMaJscode2SessionResult = this.getWxMaUser(formDTO.getApp(),formDTO.getWxCode()); + WxMaJscode2SessionResult wxMaJscode2SessionResult = this.getWxMaUser(formDTO.getApp(),formDTO.getWxCode(),formDTO.getAppId()); logger.info("openId=[" + wxMaJscode2SessionResult.getOpenid() + "]unionId=[" + wxMaJscode2SessionResult.getUnionid() + "]"); //2、根据openId查询数据库,没有则直接插入一条记录 String userId = this.getUserId(formDTO, wxMaJscode2SessionResult); @@ -110,15 +111,23 @@ public class LoginServiceImpl implements LoginService { * @date 2020/3/14 20:16 */ @Override - public WxMaJscode2SessionResult getWxMaUser(String app,String wxCode) { + public WxMaJscode2SessionResult getWxMaUser(String app,String wxCode,String appId) { WxMaJscode2SessionResult wxMaJscode2SessionResult = null; try { - if (LoginConstant.APP_GOV.equals(app)) { - wxMaJscode2SessionResult = wxMaServiceUtils.govWxMaService().jsCode2SessionInfo(wxCode); - } else if (LoginConstant.APP_OPER.equals(app)) { - wxMaJscode2SessionResult = wxMaServiceUtils.operWxMaService().jsCode2SessionInfo(wxCode); - } else if (LoginConstant.APP_RESI.equals(app)) { - wxMaJscode2SessionResult = wxMaServiceUtils.resiWxMaService().jsCode2SessionInfo(wxCode); + if (StringUtils.isNotBlank(appId)){ + WxMaService wxMaService = CustomerAppWxServiceUtil.getWxMaService(appId); + if (wxMaService == null){ + throw new RenException("解析微信用户信息失败"); + } + wxMaJscode2SessionResult = wxMaService.jsCode2SessionInfo(wxCode); + }else{ + if (LoginConstant.APP_GOV.equals(app)) { + wxMaJscode2SessionResult = wxMaServiceUtils.govWxMaService().jsCode2SessionInfo(wxCode); + } else if (LoginConstant.APP_OPER.equals(app)) { + wxMaJscode2SessionResult = wxMaServiceUtils.operWxMaService().jsCode2SessionInfo(wxCode); + } else if (LoginConstant.APP_RESI.equals(app)) { + wxMaJscode2SessionResult = wxMaServiceUtils.resiWxMaService().jsCode2SessionInfo(wxCode); + } } } catch (WxErrorException e) { log.error("->[getMaOpenId]::error[{}]", "解析微信code失败",e); @@ -138,7 +147,12 @@ public class LoginServiceImpl implements LoginService { String phone=""; try { ValidatorUtils.validateEntity(formDTO, ResiWxPhoneFormDTO.AddUserInternalGroup.class); - WxMaService wxMaService = wxMaServiceUtils.resiWxMaService(); + WxMaService wxMaService = null; + if (StringUtils.isNotBlank(formDTO.getAppId())){ + wxMaService = CustomerAppWxServiceUtil.getWxMaService(formDTO.getAppId()); + }else{ + wxMaService = wxMaServiceUtils.resiWxMaService(); + } WxMaJscode2SessionResult wxMaJscode2SessionResult = wxMaService.jsCode2SessionInfo(formDTO.getWxCode()); WxMaPhoneNumberInfo phoneNoInfo = wxMaService.getUserService().getPhoneNoInfo(wxMaJscode2SessionResult.getSessionKey(), formDTO.getEncryptedData(), 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 f626ec6814..524f475671 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 @@ -101,6 +101,10 @@ public class PublicUserLoginServiceImpl implements PublicUserLoginService { logger.error("wxMpUser is null"); throw new RenException("解析微信用户信息失败 wxMpUser is null"); } + if(StringUtils.isBlank(wxMpUser.getOpenId())){ + logger.error("wxMpUser.getOpenId() is null"); + throw new RenException("解析微信用户信息失败"); + } /*if(StringUtils.isBlank(wxMpUser.getUnionId())){ logger.error("wxMpUser.getUnionId() is null"); // throw new RenException("解析微信用户信息失败"); diff --git a/epmet-auth/src/main/java/com/epmet/service/impl/ThirdLoginServiceImpl.java b/epmet-auth/src/main/java/com/epmet/service/impl/ThirdLoginServiceImpl.java index 4985f4d9e8..df85d0ccd1 100644 --- a/epmet-auth/src/main/java/com/epmet/service/impl/ThirdLoginServiceImpl.java +++ b/epmet-auth/src/main/java/com/epmet/service/impl/ThirdLoginServiceImpl.java @@ -1,5 +1,6 @@ package com.epmet.service.impl; +import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult; import com.epmet.common.token.constant.LoginConstant; import com.epmet.commons.tools.exception.EpmetErrorCode; import com.epmet.commons.tools.exception.ExceptionUtils; @@ -10,10 +11,7 @@ import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.CpUserDetailRedis; import com.epmet.commons.tools.utils.DateUtils; import com.epmet.commons.tools.utils.Result; -import com.epmet.dto.CustomerAgencyDTO; -import com.epmet.dto.GovStaffRoleDTO; -import com.epmet.dto.UserDTO; -import com.epmet.dto.UserWechatDTO; +import com.epmet.dto.*; import com.epmet.dto.form.*; import com.epmet.dto.result.DepartmentListResultDTO; import com.epmet.dto.result.GridByStaffResultDTO; @@ -347,4 +345,100 @@ public class ThirdLoginServiceImpl implements ThirdLoginService { return null; } + /** + * @param formDTO + * @return + * @Author sun + * @Description 单客户-选择组织,进入首页 + **/ + @Override + public UserTokenResultDTO enterOrg(ThirdWxmpEnteOrgFormDTO formDTO) { + //1、需要校验要登录的客户,是否被禁用 + CustomerStaffFormDTO customerStaffFormDTO = new CustomerStaffFormDTO(); + customerStaffFormDTO.setCustomerId(formDTO.getCustomerId()); + customerStaffFormDTO.setMobile(formDTO.getMobile()); + Result customerStaffDTOResult = epmetUserOpenFeignClient.getCustomerStaffInfo(customerStaffFormDTO); + if (!customerStaffDTOResult.success() || null == customerStaffDTOResult.getData()) { + logger.error(String.format("获取工作人员信息失败,手机号[%s],客户id:[%s],code[%s],msg[%s]", formDTO.getMobile(), formDTO.getCustomerId(), customerStaffDTOResult.getCode(), customerStaffDTOResult.getMsg())); + throw new RenException(customerStaffDTOResult.getCode()); + } + CustomerStaffDTO customerStaff = customerStaffDTOResult.getData(); + //2020.7.24 获取微信信息接口调整,改调用微信api的方式 sun start + //2.调用epmet_third服务,校验appId是否有效以及是否授权,校验通过的调用微信API获取用户基本信息 + WxLoginFormDTO resiLoginFormDTO = new WxLoginFormDTO(); + resiLoginFormDTO.setAppId(formDTO.getAppId()); + resiLoginFormDTO.setWxCode(formDTO.getWxCode()); + Result result = epmetThirdFeignClient.resiAndWorkLogin(resiLoginFormDTO); + if (!result.success()) { + logger.error("工作端小程序登陆,调用epmet_third服务获取数据失败"); + throw new RenException(result.getCode()); + } + UserWechatDTO userWechatDTO = result.getData(); + WxMaJscode2SessionResult wxMaJscode2SessionResult = new WxMaJscode2SessionResult(); + wxMaJscode2SessionResult.setOpenid(userWechatDTO.getWxOpenId()); + wxMaJscode2SessionResult.setSessionKey(userWechatDTO.getSessionKey()); + wxMaJscode2SessionResult.setUnionid(""); + // end + + //3、记录staff_wechat,并记录用户激活状态,激活时间 + this.savestaffwechat(customerStaff.getUserId(), wxMaJscode2SessionResult.getOpenid()); + //4、记录登录日志 + this.saveGovStaffLoginRecord(formDTO, customerStaff.getUserId(), wxMaJscode2SessionResult.getOpenid()); + //5.1、获取用户token + String token = this.generateGovWxmpToken(customerStaff.getUserId()); + //5.2、保存到redis + this.saveGovTokenDto(formDTO.getRootAgencyId(), formDTO.getCustomerId(), customerStaff.getUserId(), wxMaJscode2SessionResult, token); + UserTokenResultDTO userTokenResultDTO = new UserTokenResultDTO(); + userTokenResultDTO.setToken(token); + return userTokenResultDTO; + } + + //保存登录日志 + private Result saveGovStaffLoginRecord(ThirdWxmpEnteOrgFormDTO formDTO, String staffId, String openId) { + StaffLoginAgencyRecordFormDTO staffLoginAgencyRecordFormDTO = new StaffLoginAgencyRecordFormDTO(); + staffLoginAgencyRecordFormDTO.setCustomerId(formDTO.getCustomerId()); + staffLoginAgencyRecordFormDTO.setStaffId(staffId); + staffLoginAgencyRecordFormDTO.setWxOpenId(openId); + staffLoginAgencyRecordFormDTO.setMobile(formDTO.getMobile()); + staffLoginAgencyRecordFormDTO.setAgencyId(formDTO.getRootAgencyId()); + Result staffLoginRecordResult = epmetUserOpenFeignClient.saveStaffLoginRecord(staffLoginAgencyRecordFormDTO); + return staffLoginRecordResult; + } + + /** + * @Description 生成token + * @Date 2020/4/18 23:04 + **/ + private void saveGovTokenDto(String orgId, + String customerId, + String staffId, + WxMaJscode2SessionResult wxMaJscode2SessionResult, + String token) { + int expire = jwtTokenProperties.getExpire(); + GovTokenDto govTokenDto = new GovTokenDto(); + govTokenDto.setApp(LoginConstant.APP_GOV); + govTokenDto.setClient(LoginConstant.CLIENT_WXMP); + govTokenDto.setUserId(staffId); + govTokenDto.setOpenId(wxMaJscode2SessionResult.getOpenid()); + govTokenDto.setSessionKey(wxMaJscode2SessionResult.getSessionKey()); + govTokenDto.setUnionId(null == wxMaJscode2SessionResult.getUnionid() ? "" : wxMaJscode2SessionResult.getUnionid()); + govTokenDto.setToken(token); + govTokenDto.setUpdateTime(System.currentTimeMillis()); + govTokenDto.setExpireTime(jwtTokenUtils.getExpiration(token).getTime()); + govTokenDto.setRootAgencyId(orgId); + govTokenDto.setCustomerId(customerId); + + //设置部门,网格,角色列表 + govTokenDto.setDeptIdList(getDeptartmentIdList(staffId)); + govTokenDto.setGridIdList(getGridIdList(staffId)); + CustomerAgencyDTO agency = getAgencyByStaffId(staffId); + if (agency != null) { + govTokenDto.setAgencyId(agency.getId()); + govTokenDto.setRoleList(queryGovStaffRoles(staffId, agency.getId())); + } + govTokenDto.setOrgIdPath(getOrgIdPath(staffId)); + cpUserDetailRedis.set(govTokenDto, expire); + logger.info("截止时间:" + DateUtils.format(jwtTokenUtils.getExpiration(token), "yyyy-MM-dd HH:mm:ss")); + } + } diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java index 0dadd18200..457788f5a9 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java @@ -254,6 +254,14 @@ public class RedisKeys { return rootPrefix.concat("tags:grid:relationTag:").concat(gridId).concat(StrConstant.COLON).concat(tagId); } + /** + * appId secret 缓存Key + * @return + */ + public static String getCustomerAppKey() { + return rootPrefix.concat("oper:crm:app"); + } + /** * 获取生成的用户标识 缓存Key * @param shortUserId diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/DateUtils.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/DateUtils.java index c652bde696..d7c2098221 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/DateUtils.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/DateUtils.java @@ -341,12 +341,12 @@ public class DateUtils { return DateUtils.addDateDays(nextMonth, -1); } - public static void main(String[] args) { - //int weekOfYear = getWeekOfYear(new Date()); - String format = String.format("%02d", 9); - - System.out.println(666); - } +// public static void main(String[] args) { +// //int weekOfYear = getWeekOfYear(new Date()); +// String format = String.format("%02d", 9); +// +// System.out.println(666); +// } /** * 获取日期前一天 @@ -485,7 +485,7 @@ public class DateUtils { public static String formatTimestamp(Long timestamp, String pattern) { //设置格式 SimpleDateFormat format = new SimpleDateFormat(pattern); - return format.format(timestamp); + return format.format(timestamp * 1000); } public static Date minStrToSecondDate(String minStr){ 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 3ac99f4741..151ad8e10d 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 @@ -6,10 +6,10 @@ import com.epmet.commons.tools.exception.EpmetErrorCode; import com.epmet.commons.tools.exception.RenException; 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.*; -import org.apache.http.client.HttpResponseException; +import org.apache.http.HttpEntity; +import org.apache.http.HttpStatus; +import org.apache.http.NameValuePair; import org.apache.http.client.config.RequestConfig; import org.apache.http.client.entity.UrlEncodedFormEntity; import org.apache.http.client.methods.CloseableHttpResponse; @@ -51,7 +51,6 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.Set; -import java.util.UUID; /** * desc: http 工具类 @@ -306,6 +305,7 @@ public class HttpClientManager { return new Result().error(EpmetErrorCode.SERVER_ERROR.getCode(), EpmetErrorCode.SERVER_ERROR.getMsg()); } + /** * desc: 发送get请求 * param:url, params @@ -314,7 +314,7 @@ public class HttpClientManager { * * @author: jianjun liu */ - public Result sendGetFile(String url, Map params) { + public Result getByteArray(String url, Map params) { try { URIBuilder builder = new URIBuilder(url); @@ -329,35 +329,33 @@ public class HttpClientManager { return executeToByte(httpGet); } catch (Exception e) { log.error("sendGet exception", e); - return new Result().error(EpmetErrorCode.SERVER_ERROR.getCode(), EpmetErrorCode.SERVER_ERROR.getMsg()); + return new Result().error(EpmetErrorCode.SERVER_ERROR.getCode(), EpmetErrorCode.SERVER_ERROR.getMsg()); } } - private Result executeToByte(HttpRequestBase httpMethod) { + 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 inputStream = InputStreamResponseHandler.INSTANCE.handleResponse(response); - Header[] contentTypeHeader = response.getHeaders("Content-Type"); - if (contentTypeHeader != null && contentTypeHeader.length > 0) { - // 出错 - if (ContentType.TEXT_PLAIN.getMimeType() - .equals(ContentType.parse(contentTypeHeader[0].getValue()).getMimeType())) { - String responseContent = Utf8ResponseHandler.INSTANCE.handleResponse(response); - } - } - File file = FileUtils.createTmpFile(inputStream, UUID.randomUUID().toString(), "jpg"); - return new Result().ok(file); + 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())); + return new Result().ok(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()); + return new Result().error(EpmetErrorCode.SERVER_ERROR.getCode(), e.getMessage()); } finally { httpMethod.releaseConnection(); try { @@ -367,7 +365,7 @@ public class HttpClientManager { } catch (IOException e) { } } - return new Result().error(EpmetErrorCode.SERVER_ERROR.getCode(), EpmetErrorCode.SERVER_ERROR.getMsg()); + return new Result().error(EpmetErrorCode.SERVER_ERROR.getCode(), EpmetErrorCode.SERVER_ERROR.getMsg()); } /** diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/InputStreamResponseHandler.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/InputStreamResponseHandler.java deleted file mode 100644 index 75c16053fb..0000000000 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/InputStreamResponseHandler.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.epmet.commons.tools.utils; - -import org.apache.http.HttpEntity; -import org.apache.http.HttpResponse; -import org.apache.http.StatusLine; -import org.apache.http.client.HttpResponseException; -import org.apache.http.client.ResponseHandler; -import org.apache.http.util.EntityUtils; - -import java.io.IOException; -import java.io.InputStream; - -/** - * 输入流响应处理器. - * - * @author Daniel Qian - */ -public class InputStreamResponseHandler implements ResponseHandler { - public static final ResponseHandler INSTANCE = new InputStreamResponseHandler(); - private static final int STATUS_CODE_300 = 300; - - @Override - public InputStream handleResponse(final HttpResponse response) throws IOException { - final StatusLine statusLine = response.getStatusLine(); - final HttpEntity entity = response.getEntity(); - if (statusLine.getStatusCode() >= STATUS_CODE_300) { - EntityUtils.consume(entity); - throw new HttpResponseException(statusLine.getStatusCode(), statusLine.getReasonPhrase()); - } - return entity == null ? null : entity.getContent(); - } - -} diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/Utf8ResponseHandler.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/Utf8ResponseHandler.java deleted file mode 100644 index 107dc3cbdf..0000000000 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/Utf8ResponseHandler.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.epmet.commons.tools.utils; - -import org.apache.http.Consts; -import org.apache.http.HttpEntity; -import org.apache.http.HttpResponse; -import org.apache.http.StatusLine; -import org.apache.http.client.HttpResponseException; -import org.apache.http.client.ResponseHandler; -import org.apache.http.util.EntityUtils; - -import java.io.IOException; - -/** - * copy from {@link org.apache.http.impl.client.BasicResponseHandler} - * - * @author Daniel Qian - */ -public class Utf8ResponseHandler implements ResponseHandler { - - public static final ResponseHandler INSTANCE = new Utf8ResponseHandler(); - - @Override - public String handleResponse(final HttpResponse response) throws IOException { - final StatusLine statusLine = response.getStatusLine(); - final HttpEntity entity = response.getEntity(); - if (statusLine.getStatusCode() >= 300) { - EntityUtils.consume(entity); - throw new HttpResponseException(statusLine.getStatusCode(), statusLine.toString()); - } - return entity == null ? null : EntityUtils.toString(entity, Consts.UTF_8); - } - -} diff --git a/epmet-gateway/pom.xml b/epmet-gateway/pom.xml index 7839322d12..543e0e4545 100644 --- a/epmet-gateway/pom.xml +++ b/epmet-gateway/pom.xml @@ -108,7 +108,7 @@ - + lb://epmet-auth-server lb://epmet-admin-server @@ -130,6 +130,7 @@ lb://oper-customize-server lb://oper-crm-server + lb://resi-guide-server diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/StatsPublicityServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/StatsPublicityServiceImpl.java index c0f4b194a9..bcc55ede28 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/StatsPublicityServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/StatsPublicityServiceImpl.java @@ -613,7 +613,7 @@ public class StatsPublicityServiceImpl implements StatsPublicityService { for (ArticleTagsEntity tagEntity : articleTagsList) { ArticleEntity articleEntity = articleMap.get(tagEntity.getArticleId()); if (articleEntity == null) { - log.error("publicitySummary articleMap articleId:{} ", tagEntity.getArticleId()); + log.error("publicitySummary articleMap not contain articleId:{} ", tagEntity.getArticleId()); continue; } DimAgencyEntity dimAgencyEntity = dimAgencyEntityMap.get(articleEntity.getOrgId()); diff --git a/epmet-module/epmet-job/epmet-job-server/deploy/docker-compose-test.yml b/epmet-module/epmet-job/epmet-job-server/deploy/docker-compose-test.yml index 9fc81b43c5..2749306424 100644 --- a/epmet-module/epmet-job/epmet-job-server/deploy/docker-compose-test.yml +++ b/epmet-module/epmet-job/epmet-job-server/deploy/docker-compose-test.yml @@ -2,7 +2,7 @@ version: "3.7" services: epmet-job-server: container_name: epmet-job-server-test - image: registry-vpc.cn-qingdao.aliyuncs.com/epmet-cloud-release/epmet-job-server:0.3.22 + image: registry-vpc.cn-qingdao.aliyuncs.com/epmet-cloud-release/epmet-job-server:0.3.23 ports: - "8084:8084" network_mode: host # 使用现有网络 diff --git a/epmet-module/epmet-oss/epmet-oss-client/pom.xml b/epmet-module/epmet-oss/epmet-oss-client/pom.xml index e88c7004ce..8a27707939 100644 --- a/epmet-module/epmet-oss/epmet-oss-client/pom.xml +++ b/epmet-module/epmet-oss/epmet-oss-client/pom.xml @@ -26,6 +26,21 @@ io.springfox springfox-swagger-ui + + io.github.openfeign.form + feign-form + 3.8.0 + + + io.github.openfeign.form + feign-form-spring + 3.8.0 + + + commons-fileupload + commons-fileupload + 1.3.3 + diff --git a/epmet-module/epmet-oss/epmet-oss-server/deploy/docker-compose-dev.yml b/epmet-module/epmet-oss/epmet-oss-server/deploy/docker-compose-dev.yml index 3cfb7ad834..6460e6170d 100644 --- a/epmet-module/epmet-oss/epmet-oss-server/deploy/docker-compose-dev.yml +++ b/epmet-module/epmet-oss/epmet-oss-server/deploy/docker-compose-dev.yml @@ -3,7 +3,7 @@ services: epmet-oss-server: container_name: epmet-oss-server-dev # image: registry-vpc.cn-qingdao.aliyuncs.com/epmet-cloud-dev/epmet-oss-server:0.3.2 - image: 192.168.1.130:10080/epmet-cloud-dev/epmet-oss-server:0.3.22 + image: 192.168.1.130:10080/epmet-cloud-dev/epmet-oss-server:0.3.23 ports: - "8083:8083" network_mode: host # 使用现有网络 diff --git a/epmet-module/epmet-oss/epmet-oss-server/pom.xml b/epmet-module/epmet-oss/epmet-oss-server/pom.xml index 36377c819b..1b8463505e 100644 --- a/epmet-module/epmet-oss/epmet-oss-server/pom.xml +++ b/epmet-module/epmet-oss/epmet-oss-server/pom.xml @@ -2,7 +2,7 @@ 4.0.0 - 0.3.22 + 0.3.23 com.epmet epmet-oss diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/RegisterByAuthFormDTO.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/RegisterByAuthFormDTO.java index 2d067fd589..c8c1288c12 100644 --- a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/RegisterByAuthFormDTO.java +++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/RegisterByAuthFormDTO.java @@ -2,43 +2,20 @@ package com.epmet.dto.form; import lombok.Data; -import javax.validation.constraints.Min; -import javax.validation.constraints.NotNull; import java.io.Serializable; /** * @Author sun - * @Description 运营端-根据授权状态和初始化状态获取客户列表(不分页)-接口入参 + * @Description 运营端-根据初始化状态获取公众号注册的客户列表-接口入参 */ @Data public class RegisterByAuthFormDTO implements Serializable { private static final long serialVersionUID = -6547893374373422628L; - public interface AddUserInternalGroup { - } - - /** - * 居民端是否授权(0:未授权,1:已授权) - * */ - @NotNull(message = "居民端是否授权不能为空", groups = { AddUserInternalGroup.class }) - private Integer resiAuth; - - /** - * 工作端是否授权(0:未授权,1:已授权) - * */ - @NotNull(message = "工作端是否授权不能为空", groups = { AddUserInternalGroup.class }) - private Integer workAuth; - /** * 初始化状态(0:已初始化、1:未初始化) * */ - @NotNull(message = "初始化状态不能为空", groups = { AddUserInternalGroup.class }) private Integer initState; - /** - * 所属端 resi:居民端 work:工作端 - */ - private String client; - } diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/RemoveBindFormDTO.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/RemoveBindFormDTO.java index c83dbcc97b..773ff2d54e 100644 --- a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/RemoveBindFormDTO.java +++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/RemoveBindFormDTO.java @@ -23,4 +23,6 @@ public class RemoveBindFormDTO implements Serializable { @NotBlank(message = "客户端类型不能为空",groups = {RemoveBindFormDTO.RemoveBind.class}) private String clientType; + private String customerId; + } diff --git a/epmet-module/epmet-third/epmet-third-server/deploy/docker-compose-dev.yml b/epmet-module/epmet-third/epmet-third-server/deploy/docker-compose-dev.yml index cb770c9a05..fffb5e8bb2 100644 --- a/epmet-module/epmet-third/epmet-third-server/deploy/docker-compose-dev.yml +++ b/epmet-module/epmet-third/epmet-third-server/deploy/docker-compose-dev.yml @@ -2,7 +2,7 @@ version: "3.7" services: epmet-third-server: container_name: epmet-third-server-dev - image: 192.168.1.130:10080/epmet-cloud-dev/epmet-third-server:0.0.58 + image: 192.168.1.130:10080/epmet-cloud-dev/epmet-third-server:0.0.64 ports: - "8110:8110" network_mode: host # 使用现有网络 diff --git a/epmet-module/epmet-third/epmet-third-server/deploy/docker-compose-test.yml b/epmet-module/epmet-third/epmet-third-server/deploy/docker-compose-test.yml index 60cf655960..c396270821 100644 --- a/epmet-module/epmet-third/epmet-third-server/deploy/docker-compose-test.yml +++ b/epmet-module/epmet-third/epmet-third-server/deploy/docker-compose-test.yml @@ -2,7 +2,7 @@ version: "3.7" services: epmet-third-server: container_name: epmet-third-server-test - image: registry-vpc.cn-qingdao.aliyuncs.com/epmet-cloud-release/epmet-third-server:0.0.14 + image: registry-vpc.cn-qingdao.aliyuncs.com/epmet-cloud-release/epmet-third-server:0.0.58 ports: - "8110:8110" network_mode: host # 使用现有网络 diff --git a/epmet-module/epmet-third/epmet-third-server/pom.xml b/epmet-module/epmet-third/epmet-third-server/pom.xml index 3677cfa944..9cb62e714d 100644 --- a/epmet-module/epmet-third/epmet-third-server/pom.xml +++ b/epmet-module/epmet-third/epmet-third-server/pom.xml @@ -2,7 +2,7 @@ 4.0.0 - 0.0.58 + 0.0.64 com.epmet 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 4651738fd4..c381b4e2f3 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 @@ -6,10 +6,6 @@ package com.epmet.constant; */ public interface PaConstant { - /** - * 手机号注册 - */ - String PHONE_EXCEPTION = "手机号已存在,不允许再次注册"; /** * 更新用户信息失败 */ @@ -74,4 +70,8 @@ public interface PaConstant { * 获取客户信息失败 */ String SELECT_CUSTOMER_EXCEPTION = "获取客户信息失败"; + /** + * 获取访问记录表数据失败失败 + */ + String SELECT_VISITED_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 8ed2ff7fd9..144b38aace 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 @@ -121,11 +121,11 @@ public class PaCustomerController { * @param formDTO * @return * @Author sun - * @Description 根据授权状态和初始化状态获取客户列表(不分页) + * @Description 根据初始化状态获取公众号注册的客户列表 **/ @PostMapping(value = "registerbyauth") public Result> registerByAuth(@LoginUser TokenDto tokenDTO, @RequestBody RegisterByAuthFormDTO formDTO) { - ValidatorUtils.validateEntity(formDTO, RegisterByAuthFormDTO.AddUserInternalGroup.class); + ValidatorUtils.validateEntity(formDTO); return new Result>().ok( paCustomerService.registerByAuth(formDTO)); } diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/AuthorizationInfoDao.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/AuthorizationInfoDao.java index f4fde172f6..3d26bcffab 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/AuthorizationInfoDao.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/AuthorizationInfoDao.java @@ -81,7 +81,7 @@ public interface AuthorizationInfoDao extends BaseDao { * @param customerId * @author zxc */ - void updateOldAuthorizerAccessToken(@Param("customerId")String customerId,@Param("clientType")String clientType); + void deleteOldAuthorizerAccessToken(@Param("customerId")String customerId,@Param("clientType")String clientType); /** * @Description 根据 authAppId 查询客户ID和客户端类型 diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/BindingAccountDao.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/BindingAccountDao.java index 2d6b624400..9e5571029e 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/BindingAccountDao.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/BindingAccountDao.java @@ -45,6 +45,6 @@ public interface BindingAccountDao extends BaseDao { * @param authAppId * @author zxc */ - void updateBindStatus(@Param("customerId")String customerId,@Param("authAppId")String authAppId); + void updateBindStatus(@Param("customerId")String customerId,@Param("clientType")String clientType); } \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/ComponentAccessTokenDao.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/ComponentAccessTokenDao.java index 67d38d540c..10a5710c6e 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/ComponentAccessTokenDao.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/ComponentAccessTokenDao.java @@ -45,7 +45,7 @@ public interface ComponentAccessTokenDao extends BaseDao { * @param formDTO * @return * @Author sun - * @Description 根据所属端授权状态、初始化状态查询客户列表数据 + * @Description 根据初始化状态获取公众号注册的客户列表 **/ List selectCustomerList(RegisterByAuthFormDTO formDTO); 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 addf9d6d53..a48b2b7d88 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 @@ -158,7 +158,7 @@ public interface PaCustomerService extends BaseService { * @param formDTO * @return * @Author sun - * @Description 根据授权状态和初始化状态获取客户列表(不分页) + * @Description 根据初始化状态获取公众号注册的客户列表 **/ List registerByAuth(RegisterByAuthFormDTO formDTO); } \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/AppLetAuthorizationServiceImpl.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/AppLetAuthorizationServiceImpl.java index ba3c63d941..b28550c54c 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/AppLetAuthorizationServiceImpl.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/AppLetAuthorizationServiceImpl.java @@ -79,7 +79,7 @@ public class AppLetAuthorizationServiceImpl implements AppLetAuthorizationServic */ @Override public void removeBind(TokenDto tokenDto, RemoveBindFormDTO formDTO) { - String customerId = componentVerifyTicketServiceImpl.getLoginUserCustomerId(tokenDto); + String customerId = formDTO.getCustomerId(); String clientType = formDTO.getClientType(); //查询openAppId String openAppId = openPlatformAccountDao.selectOpenAppIdByCustomerId(customerId); @@ -91,12 +91,12 @@ public class AppLetAuthorizationServiceImpl implements AppLetAuthorizationServic jsonObject.put(ModuleConstant.LOW_APP_ID,authAppId); jsonObject.put(ModuleConstant.OPEN_APP_ID,openAppId); String data = HttpClientManager.getInstance().sendPostByJSON(WxMaCodeConstant.UN_BIND + authorizationInfo.getAuthorizer_access_token(), JSON.toJSONString(jsonObject)).getData(); - Map map = JSON.parseObject(data, Map.class); - if (!map.get(ModuleConstant.ERR_CODE).equals(NumConstant.ZERO_STR)){ + Map map = JSON.parseObject(data, Map.class); + if (!map.get(ModuleConstant.ERR_CODE).equals(NumConstant.ZERO)){ log.error("解绑失败" + data); throw new RenException("解绑失败" + data); } - bindingAccountDao.updateBindStatus(customerId,authAppId); + bindingAccountDao.updateBindStatus(customerId,clientType); } 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 index aa2076ec75..18221f298e 100644 --- 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 @@ -373,17 +373,13 @@ public class CodeServiceImpl implements CodeService { //获取小程序调用令牌 AuthorizationInfoDTO authInfo = authorizationInfoDao.getAuthInfoByCustomer(codeCustomerDTO.getCustomerId(), codeCustomerDTO.getClientType()); //调用微信API获取获取体验版二维码 - WxResult wxResult = wxMaCodeService.getQrCode(authInfo.getAuthorizerAccessToken(), formDTO.getPath()); + WxResult wxResult = wxMaCodeService.getQrCode(authInfo.getAuthorizerAccessToken(), formDTO.getPath()); QrCodeDTO qrCodeDTO = new QrCodeDTO(); - try { - qrCodeDTO.setQrCode(Files.readAllBytes(wxResult.getData().toPath())); - Result uploadResult = ossFeignClient.uploadQrCode(qrCodeDTO); - codeCustomerDTO.setQrCode(uploadResult.getData().getUrl()); - codeCustomerService.update(codeCustomerDTO); - result.setQrcode(uploadResult.getData().getUrl()); - } catch (Exception e) { - throw new RenException(e.getMessage()); - } + qrCodeDTO.setQrCode(wxResult.getData()); + Result uploadResult = ossFeignClient.uploadQrCode(qrCodeDTO); + codeCustomerDTO.setQrCode(uploadResult.getData().getUrl()); + codeCustomerService.update(codeCustomerDTO); + result.setQrcode(uploadResult.getData().getUrl()); if (!wxResult.success()) { throw new RenException(wxResult.getErrorCode(), wxResult.getErrorMsg()); } @@ -405,8 +401,8 @@ public class CodeServiceImpl implements CodeService { try { QrCodeDTO dto = new QrCodeDTO(); dto.setMedia(formDTO.getMedia()); - Result uploadDTOResult = ossFeignClient.uploadWxImg(dto); - File file = new File(uploadDTOResult.getData().getUrl()); + Result uploadWxImg = ossFeignClient.uploadWxImg(dto); + File file = new File(uploadWxImg.getData().getUrl()); //获取上传代码信息 CodeCustomerDTO codeCustomerDTO = codeCustomerService.get(formDTO.getCodeId()); //获取小程序调用令牌 diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/ComponentVerifyTicketServiceImpl.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/ComponentVerifyTicketServiceImpl.java index 4bcf98a9e3..d00460d8a0 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/ComponentVerifyTicketServiceImpl.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/ComponentVerifyTicketServiceImpl.java @@ -211,7 +211,7 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe formDTO.setExpiresInTime(expiresInTime); //先逻辑删,在插入 log.info(ThirdRunTimeInfoConstant.START_DELETE_COMPONENT_ACCESS_TOKEN); - componentAccessTokenDao.updateOldComponentAccessToken(); + componentAccessTokenDao.deleteOldComponentAccessToken(); componentAccessTokenDao.insertComponentAccessToken(formDTO); //存缓存 redisThird.setComponentAccessToken(componentAccessToken); @@ -341,20 +341,26 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe Date expiresInTime = this.countExpirationTime(expiresIn); //更新DB AuthorizerAccessTokenFormDTO formDTO = new AuthorizerAccessTokenFormDTO(); - AuthorizationInfoFormDTO authorizationInfo = new AuthorizationInfoFormDTO(); - BeanUtils.copyProperties(formDTO, authorizationInfo); - authorizationInfo.setAuthorizerAppid(authAppId); formDTO.setAuthorizerAccessToken(authorizerAccessToken); formDTO.setAuthorizerRefreshToken(authorizerRefreshToken); formDTO.setExpiresInTime(expiresInTime); formDTO.setCustomerId(customerId); formDTO.setAuthAppid(authAppId); formDTO.setClientType(clientType); + AuthorizationInfoFormDTO authorizationInfo = new AuthorizationInfoFormDTO(); + BeanUtils.copyProperties(formDTO,authorizationInfo); + authorizationInfo.setAuthorizerAppid(authAppId); //先逻辑删除,在插入 - authorizationInfoDao.updateOldAuthorizerAccessToken(customerId, clientType); + authorizationInfoDao.deleteOldAuthorizerAccessToken(customerId, clientType); authorizationInfoDao.insertAuthorizerAccessToken(formDTO); //缓存 refreshAuthorizerAccessToken redisThird.setAuthorizerRefreshToken(authorizationInfo); + AuthorizationInfoResultDTO resultDTO = new AuthorizationInfoResultDTO(); + resultDTO.setAuthorizer_access_token(authorizerAccessToken); + resultDTO.setAuthorizer_refresh_token(authorizerRefreshToken); + resultDTO.setAuthorizer_appid(authAppId); + resultDTO.setExpires_in(7200); + redisThird.setAuthInfo(resultDTO,customerId,clientType); } }); log.info("更新authorizer_access_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 62fdde3a8c..432066c3da 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 @@ -167,7 +167,7 @@ public class PaCustomerServiceImpl extends BaseServiceImpl userList = paUserDao.selectUserByPhone(formDTO.getPhone()); if (null != userList && userList.size() > NumConstant.ZERO) { - throw new RenException(PaConstant.PHONE_EXCEPTION); + throw new RenException(EpmetErrorCode.MOBILE_USED.getCode()); } //2.根据token中的userId查询pa_user表数据,根据手机号是否为空判断后续是新增还是更新user数据 @@ -488,29 +488,12 @@ public class PaCustomerServiceImpl extends BaseServiceImpl registerByAuth(RegisterByAuthFormDTO formDTO) { - List resultList = new ArrayList<>(); - //1.根据是否初始化和居民端授权状态查询客户列表信息 - formDTO.setClient(PaConstant.CLIENT_RESI); - List list1 = baseDao.selectCustomerList(formDTO); - - //2.根据是否初始化和工作端授权状态查询客户列表信息 - formDTO.setClient(PaConstant.CLIENT_WORK); - List list2 = baseDao.selectCustomerList(formDTO); - - //3.取交集数据 - list1.forEach(dto->{ - list2.forEach(cu->{ - if(dto.getCustomerId().equals(cu.getCustomerId())){ - resultList.add(dto); - } - }); - }); - return resultList; + return baseDao.selectCustomerList(formDTO); } } \ 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 680bf4fec4..d5acc59fb5 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,10 +20,12 @@ 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.constant.NumConstant; +import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.page.PageData; 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; @@ -41,6 +43,8 @@ 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.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; @@ -57,7 +61,7 @@ import java.util.Map; */ @Service public class PaUserServiceImpl extends BaseServiceImpl implements PaUserService { - + private Logger logger = LogManager.getLogger(PaUserServiceImpl.class); @Autowired private PaUserRedis paUserRedis; @Autowired @@ -170,6 +174,10 @@ public class PaUserServiceImpl extends BaseServiceImpl //2.4、根据openid查询用户登陆访问记录表数据,按登陆时间倒序 PaUserVisitedDTO visitedDTO = paUserVisitedDao.selectByOpenId(wxMpUser.getOpenId()); + if (null == visitedDTO || "".equals(visitedDTO.getUserId())) { + logger.error("根据openid查询用户访问记录表数据失败,openid->"+wxMpUser.getOpenId()); + throw new RenException(PaConstant.SELECT_VISITED_EXCEPTION); + } resultDTO.setUserId(visitedDTO.getUserId()); } diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/param/WxExtJson.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/param/WxExtJson.java new file mode 100644 index 0000000000..13441e4573 --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/param/WxExtJson.java @@ -0,0 +1,66 @@ +package com.epmet.wxapi.param; + +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +/** + * @author zhaoqifeng + * @dscription + * @date 2020/7/27 9:19 + */ +@NoArgsConstructor +@Data +public class WxExtJson implements Serializable { + + private static final long serialVersionUID = -559311391779774945L; + + private boolean extEnable; + private String extAppid; + private boolean directCommit; + private ExtBean ext; + + @NoArgsConstructor + @Data + private static class ExtBean { + private String extAppid; + private FootbarBean footbar; + @NoArgsConstructor + @Data + private static class FootbarBean { + private WorkBean work; + private OrgBean org; + private DataBean data; + private FindBean find; + + @NoArgsConstructor + @Data + private static class WorkBean { + private String name; + private String pageTile; + } + + @NoArgsConstructor + @Data + private static class OrgBean { + private String name; + private String pageTile; + } + + @NoArgsConstructor + @Data + private static class DataBean { + private String name; + private String pageTile; + } + + @NoArgsConstructor + @Data + private static class FindBean { + private String name; + private String pageTile; + } + } + } +} 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 eea4649219..dca678a55e 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 @@ -48,7 +48,7 @@ public interface WxMaCodeService { * @author zhaoqifeng * @date 2020/7/10 15:25 */ - WxResult getQrCode(String accessToken, String path); + WxResult getQrCode(String accessToken, String path); /** * 获取授权小程序帐号的可选类目. 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 5808634523..97f7cac543 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 @@ -70,17 +70,18 @@ public class WxMaCodeServiceImpl implements WxMaCodeService { } @Override - public WxResult getQrCode(String accessToken, String path) { - WxResult result = new WxResult<>(); - StringBuilder url = new StringBuilder(WxMaCodeConstant.GET_QRCODE_URL).append("?access_token").append(accessToken); + public WxResult getQrCode(String accessToken, String path) { + 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())); + url.append("&path=").append(URLEncoder.encode(path, StandardCharsets.UTF_8.name())); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } } - Result qrCodeResult = HttpClientManager.getInstance().sendGetFile(url.toString(), null); + Result qrCodeResult = HttpClientManager.getInstance().getByteArray(url.toString(), null); + if (!qrCodeResult.success()) { result.setErrorCode(qrCodeResult.getCode()); result.setErrorMsg(WxMaErrorMsgEnum.findMsgByCode(qrCodeResult.getCode())); diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/AuthorizationInfoDao.xml b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/AuthorizationInfoDao.xml index d8ab9821eb..ec104db583 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/AuthorizationInfoDao.xml +++ b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/AuthorizationInfoDao.xml @@ -65,9 +65,9 @@ - - update authorization_info set del_flag = 1 where customer_id = #{customerId} AND client_type = #{clientType} - + + delete from authorization_info where customer_id = #{customerId} AND client_type = #{clientType} + SELECT COMPONENT_ACCESS_TOKEN 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 9c3c48b996..2024c79005 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 @@ -21,7 +21,7 @@ SELECT - pc.id AS "customerId", - pc.customer_name AS "customerName" + id AS "customerId", + customer_name AS "customerName" FROM - pa_customer pc - INNER JOIN customer_mp cm ON pc.id = cm.customer_id + pa_customer WHERE - pc.del_flag = '0' - AND cm.del_flag = '0' - AND pc.is_initialize = #{initState} - - AND cm.client = #{client} - AND cm.AUTHORIZATION_FLAG = #{resiAuth} - - - AND cm.client = #{client} - AND cm.AUTHORIZATION_FLAG = #{workAuth} + del_flag = '0' + + AND is_initialize = #{initState} diff --git a/epmet-module/gov-org/gov-org-server/deploy/docker-compose-test.yml b/epmet-module/gov-org/gov-org-server/deploy/docker-compose-test.yml index a6e6dd4760..a912b71cc2 100644 --- a/epmet-module/gov-org/gov-org-server/deploy/docker-compose-test.yml +++ b/epmet-module/gov-org/gov-org-server/deploy/docker-compose-test.yml @@ -2,7 +2,7 @@ version: "3.7" services: gov-org-server: container_name: gov-org-server-test - image: registry-vpc.cn-qingdao.aliyuncs.com/epmet-cloud-release/gov-org-server:0.3.74 + image: registry-vpc.cn-qingdao.aliyuncs.com/epmet-cloud-release/gov-org-server:0.3.76 ports: - "8092:8092" network_mode: host # 使用现有网络 diff --git a/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/dto/CustomerAppDTO.java b/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/dto/CustomerAppDTO.java new file mode 100644 index 0000000000..5a58975a7d --- /dev/null +++ b/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/dto/CustomerAppDTO.java @@ -0,0 +1,97 @@ +/** + * 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 lombok.Data; + +import java.io.Serializable; +import java.util.Date; + + +/** + * 客户表 appId表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-07-27 + */ +@Data +public class CustomerAppDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 主键 + */ + private String id; + + /** + * 客户Id + */ + private String customerId; + + /** + * 小程序的appId + */ + private String appId; + + /** + * resi,work + */ + private String client; + + /** + * app的secret + */ + private String secret; + + /** + * 0:停用,1:启用 + */ + private Integer enableFlag; + + /** + * 删除标识:0.未删除 1.已删除 + */ + private Integer delFlag; + + /** + * 乐观锁 + */ + private Integer revision; + + /** + * 创建人 + */ + private String createdBy; + + /** + * 创建时间 + */ + private Date createdTime; + + /** + * 更新人 + */ + private String updatedBy; + + /** + * 更新时间 + */ + private Date updatedTime; + +} \ No newline at end of file diff --git a/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/dto/form/CustomerAppSecretFormDTO.java b/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/dto/form/CustomerAppSecretFormDTO.java new file mode 100644 index 0000000000..bed538b63b --- /dev/null +++ b/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/dto/form/CustomerAppSecretFormDTO.java @@ -0,0 +1,42 @@ +/** + * 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.form; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + + +/** + * 客户表 appId表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-07-27 + */ +@Data +public class CustomerAppSecretFormDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 小程序的appId + */ + @NotBlank(message = "小程序Id不能为空") + private String appId; +} \ No newline at end of file diff --git a/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/feign/OperCrmOpenFeignClient.java b/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/feign/OperCrmOpenFeignClient.java index 5b220aa698..59a01476e7 100644 --- a/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/feign/OperCrmOpenFeignClient.java +++ b/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/feign/OperCrmOpenFeignClient.java @@ -1,13 +1,16 @@ package com.epmet.feign; +import com.epmet.commons.tools.constant.ServiceConstant; import com.epmet.commons.tools.utils.Result; +import com.epmet.dto.CustomerAppDTO; import com.epmet.dto.CustomerDTO; -import org.springframework.cloud.openfeign.FeignClient; - -import com.epmet.commons.tools.constant.ServiceConstant; +import com.epmet.dto.form.CustomerAppSecretFormDTO; import com.epmet.feign.fallback.OperCrmOpenFeignClientFallback; +import org.springframework.cloud.openfeign.FeignClient; import org.springframework.web.bind.annotation.PostMapping; +import java.util.List; + /** * 本服务对外开放的API,其他服务通过引用此client调用该服务 * @@ -23,4 +26,19 @@ public interface OperCrmOpenFeignClient { */ @PostMapping("/oper/crm/customer/getcostomerInfo") Result getCustomerInfo(CustomerDTO dto); + + /** + * 获取客户appId信息 + * @param dto + * @return + */ + @PostMapping("/oper/crm/customerapp/getsecretbyappid") + Result getSecretByAppId(CustomerAppSecretFormDTO dto); + + /** + * 获取所有已配置的app信息 + * @return + */ + @PostMapping("/oper/crm/customerapp/getconfigallapp") + Result> getConfigAllApp(); } diff --git a/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/feign/fallback/OperCrmOpenFeignClientFallback.java b/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/feign/fallback/OperCrmOpenFeignClientFallback.java index 39594aa4fe..81b74a4f7c 100644 --- a/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/feign/fallback/OperCrmOpenFeignClientFallback.java +++ b/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/feign/fallback/OperCrmOpenFeignClientFallback.java @@ -3,10 +3,14 @@ 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.CustomerAppDTO; import com.epmet.dto.CustomerDTO; +import com.epmet.dto.form.CustomerAppSecretFormDTO; import com.epmet.feign.OperCrmOpenFeignClient; import org.springframework.stereotype.Component; +import java.util.List; + /** * 本服务对外开放的API,其他服务通过引用此client调用该服务 * @@ -19,4 +23,20 @@ public class OperCrmOpenFeignClientFallback implements OperCrmOpenFeignClient { public Result getCustomerInfo(CustomerDTO dto) { return ModuleUtils.feignConError(ServiceConstant.OPER_CRM_SERVER, "getCustomerInfo", dto); } + + /** + * 获取客户appId信息 + * + * @param dto + * @return + */ + @Override + public Result getSecretByAppId(CustomerAppSecretFormDTO dto) { + return ModuleUtils.feignConError(ServiceConstant.OPER_CRM_SERVER, "getSecretByAppId", dto); + } + + @Override + public Result> getConfigAllApp() { + return ModuleUtils.feignConError(ServiceConstant.OPER_CRM_SERVER, "getConfigAllApp", null); + } } diff --git a/epmet-module/oper-crm/oper-crm-server/deploy/docker-compose-dev.yml b/epmet-module/oper-crm/oper-crm-server/deploy/docker-compose-dev.yml index c401ef7909..9aed49d3e4 100644 --- a/epmet-module/oper-crm/oper-crm-server/deploy/docker-compose-dev.yml +++ b/epmet-module/oper-crm/oper-crm-server/deploy/docker-compose-dev.yml @@ -2,7 +2,7 @@ version: "3.7" services: oper-crm-server: container_name: oper-crm-server-dev - image: 192.168.1.130:10080/epmet-cloud-dev/oper-crm-server:0.3.30 + image: 192.168.1.130:10080/epmet-cloud-dev/oper-crm-server:0.3.54 ports: - "8090:8090" network_mode: host # 使用现有网络 diff --git a/epmet-module/oper-crm/oper-crm-server/deploy/docker-compose-prod.yml b/epmet-module/oper-crm/oper-crm-server/deploy/docker-compose-prod.yml index f2e667a0b5..baaa5112e5 100644 --- a/epmet-module/oper-crm/oper-crm-server/deploy/docker-compose-prod.yml +++ b/epmet-module/oper-crm/oper-crm-server/deploy/docker-compose-prod.yml @@ -2,7 +2,7 @@ version: "3.7" services: oper-crm-server: container_name: oper-crm-server-prod - image: registry-vpc.cn-qingdao.aliyuncs.com/epmet-cloud-master/oper-crm-server:0.3.25 + image: registry-vpc.cn-qingdao.aliyuncs.com/epmet-cloud-master/oper-crm-server:0.3.54 ports: - "8090:8090" network_mode: host # 使用现有网络 diff --git a/epmet-module/oper-crm/oper-crm-server/deploy/docker-compose-test.yml b/epmet-module/oper-crm/oper-crm-server/deploy/docker-compose-test.yml index ef1e3d8974..5140018c27 100644 --- a/epmet-module/oper-crm/oper-crm-server/deploy/docker-compose-test.yml +++ b/epmet-module/oper-crm/oper-crm-server/deploy/docker-compose-test.yml @@ -2,7 +2,7 @@ version: "3.7" services: oper-crm-server: container_name: oper-crm-server-test - image: registry-vpc.cn-qingdao.aliyuncs.com/epmet-cloud-release/oper-crm-server:0.3.29 + image: registry-vpc.cn-qingdao.aliyuncs.com/epmet-cloud-release/oper-crm-server:0.3.54 ports: - "8090:8090" network_mode: host # 使用现有网络 diff --git a/epmet-module/oper-crm/oper-crm-server/pom.xml b/epmet-module/oper-crm/oper-crm-server/pom.xml index 6f9b5a7942..e06a4dda09 100644 --- a/epmet-module/oper-crm/oper-crm-server/pom.xml +++ b/epmet-module/oper-crm/oper-crm-server/pom.xml @@ -2,7 +2,7 @@ 4.0.0 - 0.3.30 + 0.3.54 com.epmet oper-crm diff --git a/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/controller/CustomerAppController.java b/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/controller/CustomerAppController.java new file mode 100644 index 0000000000..4403ea0120 --- /dev/null +++ b/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/controller/CustomerAppController.java @@ -0,0 +1,89 @@ +/** + * 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.ValidatorUtils; +import com.epmet.commons.tools.validator.group.AddGroup; +import com.epmet.commons.tools.validator.group.DefaultGroup; +import com.epmet.commons.tools.validator.group.UpdateGroup; +import com.epmet.dto.CustomerAppDTO; +import com.epmet.dto.form.CustomerAppSecretFormDTO; +import com.epmet.service.CustomerAppIdService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.List; +import java.util.Map; + + +/** + * 客户表 app表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-07-27 + */ +@RestController +@RequestMapping("customerapp") +public class CustomerAppController { + + @Autowired + private CustomerAppIdService customerAppIdService; + + @GetMapping("page") + public Result> page(@RequestParam Map params){ + PageData page = customerAppIdService.page(params); + return new Result>().ok(page); + } + + @GetMapping("{id}") + public Result get(@PathVariable("id") String id){ + CustomerAppDTO data = customerAppIdService.get(id); + return new Result().ok(data); + } + + @PostMapping + public Result save(@RequestBody CustomerAppDTO dto){ + //效验数据 + ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); + customerAppIdService.save(dto); + return new Result(); + } + + @PutMapping + public Result update(@RequestBody CustomerAppDTO dto){ + //效验数据 + ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); + customerAppIdService.update(dto); + return new Result(); + } + @PostMapping("getsecretbyappid") + public Result getSecretByAppId(@RequestBody CustomerAppSecretFormDTO dto){ + //效验数据 + ValidatorUtils.validateEntity(dto, DefaultGroup.class); + return new Result().ok(customerAppIdService.selectSecretByAppId(dto.getAppId())); + } + @PostMapping("getconfigallapp") + public Result> getConfigAllApp(){ + List configAllApp = customerAppIdService.getConfigAllApp(); + return new Result>().ok(configAllApp); + } + + +} \ No newline at end of file diff --git a/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/dao/CustomerAppDao.java b/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/dao/CustomerAppDao.java new file mode 100644 index 0000000000..b69ea9fe11 --- /dev/null +++ b/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/dao/CustomerAppDao.java @@ -0,0 +1,35 @@ +/** + * 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.CustomerAppEntity; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +/** + * 客户表 appId表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-07-27 + */ +@Mapper +public interface CustomerAppDao extends BaseDao { + + String selectSecretByAppId(@Param("appId") String appId); +} \ No newline at end of file diff --git a/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/entity/CustomerAppEntity.java b/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/entity/CustomerAppEntity.java new file mode 100644 index 0000000000..89d62c233d --- /dev/null +++ b/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/entity/CustomerAppEntity.java @@ -0,0 +1,63 @@ +/** + * 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; + +/** + * 客户表 appId表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-07-27 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("customer_app") +public class CustomerAppEntity extends BaseEpmetEntity { + + private static final long serialVersionUID = 1L; + + /** + * 客户Id + */ + private String customerId; + + /** + * 小程序的appId + */ + private String appId; + + /** + * resi,work + */ + private String client; + + /** + * app的secret + */ + private String secret; + + /** + * 0:停用,1:启用 + */ + private Integer enableFlag; + +} diff --git a/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/CustomerAppIdService.java b/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/CustomerAppIdService.java new file mode 100644 index 0000000000..f8036db8cd --- /dev/null +++ b/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/CustomerAppIdService.java @@ -0,0 +1,94 @@ +/** + * 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.CustomerAppDTO; +import com.epmet.entity.CustomerAppEntity; + +import java.util.List; +import java.util.Map; + +/** + * 客户表 appId表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-07-27 + */ +public interface CustomerAppIdService extends BaseService { + + /** + * 默认分页 + * + * @param params + * @return PageData + * @author generator + * @date 2020-07-27 + */ + PageData page(Map params); + + /** + * 默认查询 + * + * @param params + * @return java.util.List + * @author generator + * @date 2020-07-27 + */ + List list(Map params); + + /** + * 单条查询 + * + * @param id + * @return CustomerAppIdDTO + * @author generator + * @date 2020-07-27 + */ + CustomerAppDTO get(String id); + + /** + * 默认保存 + * + * @param dto + * @return void + * @author generator + * @date 2020-07-27 + */ + void save(CustomerAppDTO dto); + + /** + * 默认更新 + * + * @param dto + * @return void + * @author generator + * @date 2020-07-27 + */ + void update(CustomerAppDTO dto); + + /** + * desc:获取客户app secret + * @param appId + * @return + */ + String selectSecretByAppId(String appId); + + List getConfigAllApp(); +} \ No newline at end of file diff --git a/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/impl/CustomerAppIdServiceImpl.java b/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/impl/CustomerAppIdServiceImpl.java new file mode 100644 index 0000000000..86c5689b64 --- /dev/null +++ b/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/impl/CustomerAppIdServiceImpl.java @@ -0,0 +1,103 @@ +/** + * 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.constant.FieldConstant; +import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.utils.ConvertUtils; +import com.epmet.dao.CustomerAppDao; +import com.epmet.dto.CustomerAppDTO; +import com.epmet.entity.CustomerAppEntity; +import com.epmet.service.CustomerAppIdService; +import org.apache.commons.lang3.StringUtils; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.List; +import java.util.Map; + +/** + * 客户表 appId表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-07-27 + */ +@Service +public class CustomerAppIdServiceImpl extends BaseServiceImpl implements CustomerAppIdService { + + @Override + public PageData page(Map params) { + IPage page = baseDao.selectPage( + getPage(params, FieldConstant.CREATED_TIME, false), + getWrapper(params) + ); + return getPageData(page, CustomerAppDTO.class); + } + + @Override + public List list(Map params) { + List entityList = baseDao.selectList(getWrapper(params)); + + return ConvertUtils.sourceToTarget(entityList, CustomerAppDTO.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 CustomerAppDTO get(String id) { + CustomerAppEntity entity = baseDao.selectById(id); + return ConvertUtils.sourceToTarget(entity, CustomerAppDTO.class); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void save(CustomerAppDTO dto) { + CustomerAppEntity entity = ConvertUtils.sourceToTarget(dto, CustomerAppEntity.class); + insert(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void update(CustomerAppDTO dto) { + CustomerAppEntity entity = ConvertUtils.sourceToTarget(dto, CustomerAppEntity.class); + updateById(entity); + } + + @Override + public String selectSecretByAppId(String appId) { + return baseDao.selectSecretByAppId(appId); + } + + @Override + public List getConfigAllApp() { + List entities = baseDao.selectList(null); + List customerAppDTOS = ConvertUtils.sourceToTarget(entities, CustomerAppDTO.class); + return customerAppDTOS; + } + +} \ No newline at end of file diff --git a/epmet-module/oper-crm/oper-crm-server/src/main/resources/CustomerAppDao.xml b/epmet-module/oper-crm/oper-crm-server/src/main/resources/CustomerAppDao.xml new file mode 100644 index 0000000000..599ef18c59 --- /dev/null +++ b/epmet-module/oper-crm/oper-crm-server/src/main/resources/CustomerAppDao.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/epmet-module/resi-guide/resi-guide-server/deploy/docker-compose-test.yml b/epmet-module/resi-guide/resi-guide-server/deploy/docker-compose-test.yml index 3aef647382..3fde6f4ec8 100644 --- a/epmet-module/resi-guide/resi-guide-server/deploy/docker-compose-test.yml +++ b/epmet-module/resi-guide/resi-guide-server/deploy/docker-compose-test.yml @@ -2,7 +2,7 @@ version: "3.7" services: resi-guide-server: container_name: resi-guide-server-test - image: registry-vpc.cn-qingdao.aliyuncs.com/epmet-cloud-release/resi-guide-server:0.3.17 + image: registry-vpc.cn-qingdao.aliyuncs.com/epmet-cloud-release/resi-guide-server:0.3.18 ports: - "8091:8091" network_mode: host # 使用现有网络 diff --git a/epmet-openapi/epmet-openapi-scan/deploy/docker-compose-dev.yml b/epmet-openapi/epmet-openapi-scan/deploy/docker-compose-dev.yml index 5137c630ed..a9f630c5e0 100644 --- a/epmet-openapi/epmet-openapi-scan/deploy/docker-compose-dev.yml +++ b/epmet-openapi/epmet-openapi-scan/deploy/docker-compose-dev.yml @@ -2,7 +2,7 @@ version: "3.7" services: epmet-openapi-scan: container_name: epmet-openapi-scan-dev - image: 192.168.1.130:10080/epmet-cloud-dev/epmet-openapi-scan:0.3.23 + image: 192.168.1.130:10080/epmet-cloud-dev/epmet-openapi-scan:0.3.24 ports: - "8107:8107" network_mode: host # 不会创建新的网络 diff --git a/epmet-openapi/epmet-openapi-scan/deploy/docker-compose-prod.yml b/epmet-openapi/epmet-openapi-scan/deploy/docker-compose-prod.yml index 15c4000109..41652ae4d5 100644 --- a/epmet-openapi/epmet-openapi-scan/deploy/docker-compose-prod.yml +++ b/epmet-openapi/epmet-openapi-scan/deploy/docker-compose-prod.yml @@ -2,7 +2,7 @@ version: "3.7" services: epmet-openapi-scan: container_name: epmet-openapi-scan-prod - image: registry-vpc.cn-qingdao.aliyuncs.com/epmet-cloud-master/epmet-openapi-scan:0.3.23 + image: registry-vpc.cn-qingdao.aliyuncs.com/epmet-cloud-master/epmet-openapi-scan:0.3.24 ports: - "8107:8107" network_mode: host # 不会创建新的网络 diff --git a/epmet-openapi/epmet-openapi-scan/deploy/docker-compose-test.yml b/epmet-openapi/epmet-openapi-scan/deploy/docker-compose-test.yml index be5e1ee040..20bfb7607a 100644 --- a/epmet-openapi/epmet-openapi-scan/deploy/docker-compose-test.yml +++ b/epmet-openapi/epmet-openapi-scan/deploy/docker-compose-test.yml @@ -2,7 +2,7 @@ version: "3.7" services: epmet-openapi-scan: container_name: epmet-openapi-scan-test - image: registry-vpc.cn-qingdao.aliyuncs.com/epmet-cloud-release/epmet-openapi-scan:0.3.23 + image: registry-vpc.cn-qingdao.aliyuncs.com/epmet-cloud-release/epmet-openapi-scan:0.3.24 ports: - "8107:8107" network_mode: host # 不会创建新的网络 diff --git a/epmet-openapi/epmet-openapi-scan/pom.xml b/epmet-openapi/epmet-openapi-scan/pom.xml index 747107e901..97029c52f2 100644 --- a/epmet-openapi/epmet-openapi-scan/pom.xml +++ b/epmet-openapi/epmet-openapi-scan/pom.xml @@ -4,7 +4,7 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - 0.3.23 + 0.3.24 epmet-openapi-scan jar diff --git a/epmet-openapi/epmet-openapi-scan/src/main/java/com/epmet/openapi/scan/common/constant/SysConstant.java b/epmet-openapi/epmet-openapi-scan/src/main/java/com/epmet/openapi/scan/common/constant/SysConstant.java index a23795e538..8d7aa5d4d0 100644 --- a/epmet-openapi/epmet-openapi-scan/src/main/java/com/epmet/openapi/scan/common/constant/SysConstant.java +++ b/epmet-openapi/epmet-openapi-scan/src/main/java/com/epmet/openapi/scan/common/constant/SysConstant.java @@ -9,9 +9,15 @@ package com.epmet.openapi.scan.common.constant; public class SysConstant { public static final String UTF8 = "utf-8"; + /** + * 文本审核最大任务数 + */ + public static final Integer MAX_TASK_SIZE = 100; - public static final Integer MAX_TEXT_TASKS = 100; - public static final Integer MAX_IMG_TASKS = 10; + /** + * 图片审核最大任务数 + */ + public static final Integer MAX_SCAN_IMG_TASK_SIZE = 10; public static final String CODE = "code"; public static final String DATA = "data"; diff --git a/epmet-openapi/epmet-openapi-scan/src/main/java/com/epmet/openapi/scan/service/impl/ScanServiceImpl.java b/epmet-openapi/epmet-openapi-scan/src/main/java/com/epmet/openapi/scan/service/impl/ScanServiceImpl.java index 3756eb1764..2a5db725e2 100644 --- a/epmet-openapi/epmet-openapi-scan/src/main/java/com/epmet/openapi/scan/service/impl/ScanServiceImpl.java +++ b/epmet-openapi/epmet-openapi-scan/src/main/java/com/epmet/openapi/scan/service/impl/ScanServiceImpl.java @@ -24,6 +24,7 @@ import com.epmet.openapi.scan.support.result.ScanTaskResult; import com.epmet.openapi.scan.support.result.SceneDetailResult; import com.epmet.openapi.scan.support.result.SyncScanResult; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.ListUtils; import org.apache.http.HttpStatus; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; @@ -53,29 +54,19 @@ public class ScanServiceImpl implements ScanService { textScanParam.setBizType(bizType); List textTasks = textScanParam.getTasks(); - if (CollectionUtils.isEmpty(textTasks) || textTasks.size() > SysConstant.MAX_TEXT_TASKS) { - return new Result().error(SysResponseEnum.SCAN_TASK_LIST_PARAM_ERROR.getCode(), SysResponseEnum.SCAN_TASK_LIST_PARAM_ERROR.getMsg()); + if (CollectionUtils.isEmpty(textTasks) || textTasks.size() > SysConstant.MAX_TASK_SIZE) { + return new Result().error(SysResponseEnum.SCAN_TASK_LIST_PARAM_ERROR.getCode(), SysResponseEnum.SCAN_TASK_LIST_PARAM_ERROR.getMsg().concat(SysConstant.MAX_TASK_SIZE.toString())); } - TextScanRequest textScanRequest = new TextScanRequest(); - textScanRequest.setAcceptFormat(FormatType.JSON); // 指定api返回格式 - textScanRequest.setMethod(com.aliyuncs.http.MethodType.POST); // 指定请求方法 - textScanRequest.setEncoding(SysConstant.UTF8); - textScanRequest.setRegionId(regionId); + TextScanRequest textScanRequest = getTextScanRequest(); try { textScanRequest.setHttpContent(JSON.toJSONString(textScanParam).getBytes(SysConstant.UTF8), SysConstant.UTF8, FormatType.JSON); } catch (UnsupportedEncodingException e) { log.error("sendTextScan parse param exception", e); + return new Result().error(SysResponseEnum.SCAN_PARAM_ERROR.getCode(), SysResponseEnum.SCAN_PARAM_ERROR.getMsg()); } - - /** - * 请务必设置超时时间 - */ - textScanRequest.setConnectTimeout(3000); - textScanRequest.setReadTimeout(6000); - try { SyncScanResult textScanResult = executeSyncText(textScanRequest); return new Result().ok(textScanResult); @@ -85,24 +76,63 @@ public class ScanServiceImpl implements ScanService { } } + private TextScanRequest getTextScanRequest() { + TextScanRequest textScanRequest = new TextScanRequest(); + textScanRequest.setAcceptFormat(FormatType.JSON); // 指定api返回格式 + textScanRequest.setMethod(com.aliyuncs.http.MethodType.POST); // 指定请求方法 + textScanRequest.setEncoding(SysConstant.UTF8); + textScanRequest.setRegionId(regionId); + textScanRequest.setConnectTimeout(3000); + textScanRequest.setReadTimeout(6000); + return textScanRequest; + } + @Override public Result sendSyncImgScan(ImgScanParam imgScanParam) { - ImageSyncScanRequest imageSyncScanRequest = new ImageSyncScanRequest(); - imageSyncScanRequest.setAcceptFormat(FormatType.JSON); // 指定api返回格式 - imageSyncScanRequest.setMethod(com.aliyuncs.http.MethodType.POST); // 指定请求方法 - imageSyncScanRequest.setEncoding(SysConstant.UTF8); - imageSyncScanRequest.setRegionId(regionId); - //默认参数 // 鉴黄 暴恐涉政 imgScanParam.setScenes(ImgSceneEnum.getImgSceneList()); imgScanParam.setBizType(bizType); List imgTasks = imgScanParam.getTasks(); - if (CollectionUtils.isEmpty(imgTasks) || imgTasks.size() > SysConstant.MAX_IMG_TASKS) { - return new Result().error(SysResponseEnum.SCAN_TASK_LIST_PARAM_ERROR.getCode(), SysResponseEnum.SCAN_TASK_LIST_PARAM_ERROR.getMsg()); + if (CollectionUtils.isEmpty(imgTasks) || imgTasks.size() > SysConstant.MAX_TASK_SIZE) { + return new Result().error(SysResponseEnum.SCAN_TASK_LIST_PARAM_ERROR.getCode(), SysResponseEnum.SCAN_TASK_LIST_PARAM_ERROR.getMsg().concat(SysConstant.MAX_TASK_SIZE.toString())); + } + if (imgTasks.size() <= SysConstant.MAX_SCAN_IMG_TASK_SIZE) { + return doScanImg(imgScanParam); } + log.info("sendSyncImgScan tasks size:{} over 10", imgTasks.size()); + List> partition = ListUtils.partition(imgTasks, SysConstant.MAX_SCAN_IMG_TASK_SIZE); + SyncScanResult finalResult = new SyncScanResult(); + for (List tasks : partition) { + ImgScanParam scanParam = new ImgScanParam(); + scanParam.setBizType(imgScanParam.getBizType()); + scanParam.setScenes(imgScanParam.getScenes()); + scanParam.setTasks(tasks); + scanParam.setCallback(imgScanParam.getCallback()); + scanParam.setSeed(imgScanParam.getSeed()); + Result partResult = doScanImg(scanParam); + try { + Thread.sleep(5L); + } catch (InterruptedException e) { + log.error("sendSyncImgScan InterruptedException"); + } + if (partResult.success()) { + SyncScanResult data = partResult.getData(); + finalResult.getSuccessDataIds().addAll(data.getSuccessDataIds()); + finalResult.getFailDataIds().addAll(data.getFailDataIds()); + finalResult.getDetails().addAll(data.getDetails()); + } else { + return partResult; + } + } + return new Result().ok(finalResult); + + } + + private Result doScanImg(ImgScanParam imgScanParam) { + ImageSyncScanRequest imageSyncScanRequest = getImgScanRequest(); try { imageSyncScanRequest.setHttpContent(JSON.toJSONString(imgScanParam).getBytes(SysConstant.UTF8), SysConstant.UTF8, FormatType.JSON); } catch (UnsupportedEncodingException e) { @@ -110,12 +140,6 @@ public class ScanServiceImpl implements ScanService { return new Result().error(SysResponseEnum.SCAN_PARAM_ERROR.getCode(), SysResponseEnum.SCAN_PARAM_ERROR.getMsg()); } - /** - * 请务必设置超时时间 - */ - imageSyncScanRequest.setConnectTimeout(3000); - imageSyncScanRequest.setReadTimeout(6000); - try { SyncScanResult scanResult = executeSyncImg(imageSyncScanRequest); return new Result().ok(scanResult); @@ -125,6 +149,17 @@ public class ScanServiceImpl implements ScanService { } } + private ImageSyncScanRequest getImgScanRequest() { + ImageSyncScanRequest imageSyncScanRequest = new ImageSyncScanRequest(); + imageSyncScanRequest.setAcceptFormat(FormatType.JSON); // 指定api返回格式 + imageSyncScanRequest.setMethod(com.aliyuncs.http.MethodType.POST); // 指定请求方法 + imageSyncScanRequest.setEncoding(SysConstant.UTF8); + imageSyncScanRequest.setRegionId(regionId); + imageSyncScanRequest.setConnectTimeout(3000); + imageSyncScanRequest.setReadTimeout(6000); + return imageSyncScanRequest; + } + public SyncScanResult executeSyncText(AcsRequest textScanRequest) { SyncScanResult result = new SyncScanResult(); try { diff --git a/epmet-openapi/epmet-openapi-scan/src/main/java/com/epmet/openapi/scan/support/result/SyncScanResult.java b/epmet-openapi/epmet-openapi-scan/src/main/java/com/epmet/openapi/scan/support/result/SyncScanResult.java index c50589d7ce..8dcb757f64 100644 --- a/epmet-openapi/epmet-openapi-scan/src/main/java/com/epmet/openapi/scan/support/result/SyncScanResult.java +++ b/epmet-openapi/epmet-openapi-scan/src/main/java/com/epmet/openapi/scan/support/result/SyncScanResult.java @@ -39,8 +39,4 @@ public class SyncScanResult implements Serializable { } return isAllPass; } - - public void setAllPass(boolean allPass) { - isAllPass = allPass; - } } diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/EpmetUserOpenFeignClient.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/EpmetUserOpenFeignClient.java index 1e1fa0e9e8..89632db823 100644 --- a/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/EpmetUserOpenFeignClient.java +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/EpmetUserOpenFeignClient.java @@ -139,6 +139,15 @@ public interface EpmetUserOpenFeignClient { @PostMapping("/epmetuser/staffrole/staffroles") Result> getRolesOfStaff(StaffRoleFormDTO staffRoleFormDTO); + /** + * @param customerStaffFormDTO + * @return + * @Author sun + * @Description 根据手机号+客户id获取工作人员基本信息 + **/ + @PostMapping(value = "epmetuser/customerstaff/getcustomerstaffinfo", consumes = MediaType.APPLICATION_JSON_VALUE) + Result getCustomerStaffInfo(@RequestBody CustomerStaffFormDTO customerStaffFormDTO); + /** * @param userIdList * @return com.epmet.commons.tools.utils.Result> diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/fallback/EpmetUserOpenFeignClientFallback.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/fallback/EpmetUserOpenFeignClientFallback.java index 4bf31e518b..1020220db8 100644 --- a/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/fallback/EpmetUserOpenFeignClientFallback.java +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/fallback/EpmetUserOpenFeignClientFallback.java @@ -87,6 +87,11 @@ public class EpmetUserOpenFeignClientFallback implements EpmetUserOpenFeignClien return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "getRolesOfStaff", staffRoleFormDTO); } + @Override + public Result getCustomerStaffInfo(CustomerStaffFormDTO customerStaffFormDTO) { + return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "getCustomerStaffInfo", customerStaffFormDTO); + } + /** * @param userIdList * @return com.epmet.commons.tools.utils.Result> diff --git a/epmet-user/epmet-user-server/deploy/docker-compose-dev.yml b/epmet-user/epmet-user-server/deploy/docker-compose-dev.yml index f6cc6fc0ea..4523fe51aa 100644 --- a/epmet-user/epmet-user-server/deploy/docker-compose-dev.yml +++ b/epmet-user/epmet-user-server/deploy/docker-compose-dev.yml @@ -2,7 +2,7 @@ version: "3.7" services: epmet-user-server: container_name: epmet-user-server-dev - image: 192.168.1.130:10080/epmet-cloud-dev/epmet-user-server:0.3.79 + image: 192.168.1.130:10080/epmet-cloud-dev/epmet-user-server:0.3.81 ports: - "8087:8087" network_mode: host # 不会创建新的网络 diff --git a/epmet-user/epmet-user-server/deploy/docker-compose-prod.yml b/epmet-user/epmet-user-server/deploy/docker-compose-prod.yml index 9aaabd5324..e1725c6df6 100644 --- a/epmet-user/epmet-user-server/deploy/docker-compose-prod.yml +++ b/epmet-user/epmet-user-server/deploy/docker-compose-prod.yml @@ -2,7 +2,7 @@ version: "3.7" services: epmet-user-server: container_name: epmet-user-server-prod - image: registry-vpc.cn-qingdao.aliyuncs.com/epmet-cloud-master/epmet-user-server:0.3.75 + image: registry-vpc.cn-qingdao.aliyuncs.com/epmet-cloud-master/epmet-user-server:0.3.81 ports: - "8087:8087" network_mode: host # 不会创建新的网络 diff --git a/epmet-user/epmet-user-server/deploy/docker-compose-test.yml b/epmet-user/epmet-user-server/deploy/docker-compose-test.yml index c0efd1fb64..3a291ea73e 100644 --- a/epmet-user/epmet-user-server/deploy/docker-compose-test.yml +++ b/epmet-user/epmet-user-server/deploy/docker-compose-test.yml @@ -2,7 +2,7 @@ version: "3.7" services: epmet-user-server: container_name: epmet-user-server-test - image: registry-vpc.cn-qingdao.aliyuncs.com/epmet-cloud-release/epmet-user-server:0.3.79 + image: registry-vpc.cn-qingdao.aliyuncs.com/epmet-cloud-release/epmet-user-server:0.3.81 ports: - "8087:8087" network_mode: host # 不会创建新的网络 diff --git a/epmet-user/epmet-user-server/pom.xml b/epmet-user/epmet-user-server/pom.xml index bf248b8b05..067c4cfdf9 100644 --- a/epmet-user/epmet-user-server/pom.xml +++ b/epmet-user/epmet-user-server/pom.xml @@ -2,7 +2,7 @@ 4.0.0 - 0.3.79 + 0.3.81 com.epmet epmet-user