diff --git a/epmet-auth/src/main/java/com/epmet/controller/ThirdLoginController.java b/epmet-auth/src/main/java/com/epmet/controller/ThirdLoginController.java new file mode 100644 index 0000000000..90be83d3b2 --- /dev/null +++ b/epmet-auth/src/main/java/com/epmet/controller/ThirdLoginController.java @@ -0,0 +1,49 @@ +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.result.UserTokenResultDTO; +import com.epmet.service.ThirdLoginService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * @Description 第三方-居民端、政府端登陆服务 + * @author sun + */ +@RestController +@RequestMapping("thirdlogin") +public class ThirdLoginController { + + @Autowired + private ThirdLoginService thirdLoginService; + + /** + * @param formDTO + * @return + * @Author sun + * @Description 单客户-居民端微信小程序登录 + **/ + @PostMapping("resilogin") + public Result resiLogin(@RequestBody LoginFormDTO formDTO) { + ValidatorUtils.validateEntity(formDTO); + return new Result().ok(thirdLoginService.resiLogin(formDTO)); + } + + /** + * @param formDTO + * @return + * @Author sun + * @Description 单客户-政府端微信小程序登录 + **/ + @PostMapping("worklogin") + public Result workLogin(@RequestBody LoginFormDTO formDTO) { + ValidatorUtils.validateEntity(formDTO); + return new Result().ok(thirdLoginService.workLogin(formDTO)); + } + +} diff --git a/epmet-auth/src/main/java/com/epmet/dto/form/LoginFormDTO.java b/epmet-auth/src/main/java/com/epmet/dto/form/LoginFormDTO.java new file mode 100644 index 0000000000..f370a728dc --- /dev/null +++ b/epmet-auth/src/main/java/com/epmet/dto/form/LoginFormDTO.java @@ -0,0 +1,28 @@ +package com.epmet.dto.form; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + +/** + * @Description 单客户-居民端微信小程序登录 + * @Author sun + */ +@Data +public class LoginFormDTO extends LoginCommonFormDTO implements Serializable { + private static final long serialVersionUID = 7950477424010655108L; + + /** + * 小程序appId + */ + @NotBlank(message = "appId不能为空",groups = {AddUserInternalGroup.class}) + private String appId; + + /** + * 用户微信code + */ + @NotBlank(message = "wxCode不能为空",groups = {AddUserInternalGroup.class}) + private String wxCode; + +} diff --git a/epmet-auth/src/main/java/com/epmet/service/ThirdLoginService.java b/epmet-auth/src/main/java/com/epmet/service/ThirdLoginService.java new file mode 100644 index 0000000000..4a9d939a93 --- /dev/null +++ b/epmet-auth/src/main/java/com/epmet/service/ThirdLoginService.java @@ -0,0 +1,27 @@ +package com.epmet.service; + +import com.epmet.dto.form.LoginFormDTO; +import com.epmet.dto.result.UserTokenResultDTO; + +/** + * @Description 第三方-居民端、政府端登陆服务 + * @author sun + */ +public interface ThirdLoginService { + + /** + * @param formDTO + * @return + * @Author sun + * @Description 单客户-居民端微信小程序登录 + **/ + UserTokenResultDTO resiLogin(LoginFormDTO formDTO); + + /** + * @param formDTO + * @return + * @Author sun + * @Description 单客户-政府端微信小程序登录 + **/ + UserTokenResultDTO workLogin(LoginFormDTO formDTO); +} diff --git a/epmet-auth/src/main/java/com/epmet/service/impl/PublicUserLoginServiceImpl.java b/epmet-auth/src/main/java/com/epmet/service/impl/PublicUserLoginServiceImpl.java index 21c0bc8c53..6d0e615944 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 @@ -12,6 +12,7 @@ import com.epmet.constant.PublicUserLoginConstant; import com.epmet.constant.SmsTemplateConstant; import com.epmet.dto.PaCustomerDTO; import com.epmet.dto.PaUserDTO; +import com.epmet.dto.PaUserWechatDTO; import com.epmet.dto.form.*; import com.epmet.dto.result.CustomerUserResultDTO; import com.epmet.dto.result.SaveUserResultDTO; @@ -77,7 +78,9 @@ public class PublicUserLoginServiceImpl implements PublicUserLoginService { //3.获取用户token String token = this.generateGovWxmpToken(resultDTO.getUserId()); //4.保存到redis - this.saveLatestGovTokenDto(resultDTO, wxMpUser, token); + String openid = wxMpUser.getOpenId(); + String unionId = (null == wxMpUser.getUnionId() ? "" : wxMpUser.getUnionId()); + this.saveLatestGovTokenDto("", resultDTO.getUserId(), openid, unionId, token); UserTokenResultDTO userTokenResultDTO = new UserTokenResultDTO(); userTokenResultDTO.setToken(token); return userTokenResultDTO; @@ -118,17 +121,17 @@ public class PublicUserLoginServiceImpl implements PublicUserLoginService { } //保存tokenDto到redis - private void saveLatestGovTokenDto(SaveUserResultDTO resultDTO, WxMpUser wxMpUser, String token) { + private void saveLatestGovTokenDto(String customerId, String userId, String openId, String unionId, String token) { TokenDto tokenDTO = new TokenDto(); int expire = jwtTokenProperties.getExpire(); tokenDTO.setApp(LoginConstant.APP_PUBLIC); tokenDTO.setClient(LoginConstant.CLIENT_MP); - tokenDTO.setOpenId(wxMpUser.getOpenId()); - tokenDTO.setUnionId(null == wxMpUser.getUnionId() ? "" : wxMpUser.getUnionId()); + tokenDTO.setOpenId(openId); + tokenDTO.setUnionId(unionId); tokenDTO.setToken(token); //首次初始化时还没有客户 - tokenDTO.setCustomerId(""); - tokenDTO.setUserId(resultDTO.getUserId()); + tokenDTO.setCustomerId(customerId); + tokenDTO.setUserId(userId); tokenDTO.setExpireTime(jwtTokenUtils.getExpiration(token).getTime()); tokenDTO.setUpdateTime(System.currentTimeMillis()); cpUserDetailRedis.set(tokenDTO, expire); @@ -206,19 +209,22 @@ public class PublicUserLoginServiceImpl implements PublicUserLoginService { logger.error(String.format("验证码错误code[%s],msg[%s]", EpmetErrorCode.MOBILE_CODE_ERROR.getCode(), EpmetErrorCode.MOBILE_CODE_ERROR.getMsg())); throw new RenException(EpmetErrorCode.MOBILE_CODE_ERROR.getCode()); } - //获取缓存中的token - TokenDto redisTokenDTO = cpUserDetailRedis.get(LoginConstant.APP_PUBLIC, LoginConstant.CLIENT_MP, userDTO.getId(), TokenDto.class); - if (redisTokenDTO == null) { - return null; - } - //4.判断是否存在客户信息,是否需要生成新的token + //生成的token是根据登陆手机号对应的user生成的token,访问记录表记录的是那个user根据自己或他人的手机号登陆的 + //4.直接生成一个新的token放入缓存中(不管缓存中是否存在旧的token,都重新生成) + //4-1.生成token + String token = this.generateGovWxmpToken(userDTO.getId()); + //4-2.判断是否存在信息,给customerId赋值 PaCustomerDTO customerDTO = resultDTO.getPaCustomerResult(); + String customerId = ""; if (null != customerDTO && !StringUtils.isBlank(customerDTO.getId())) { - redisTokenDTO.setCustomerId(customerDTO.getId()); - int expire = jwtTokenProperties.getExpire(); - cpUserDetailRedis.set(redisTokenDTO, expire); + customerId = customerDTO.getId(); } + //4-3.token存入redis + PaUserWechatDTO wechatDTO = resultDTO.getPaUserWechatResult(); + String openid = wechatDTO.getWxOpenId(); + String unionId = (null == wechatDTO.getUnionId() ? "" : wechatDTO.getUnionId()); + this.saveLatestGovTokenDto(customerId, userDTO.getId(), openid, unionId, token); //5.登陆成功,访问记录表新增访问记录(访问记录新增失败不应影响用户登陆) SaveUserVisitedFormDTO visited = new SaveUserVisitedFormDTO(); @@ -232,7 +238,7 @@ public class PublicUserLoginServiceImpl implements PublicUserLoginService { //6.返回token UserTokenResultDTO userTokenResultDTO = new UserTokenResultDTO(); - userTokenResultDTO.setToken(redisTokenDTO.getToken()); + userTokenResultDTO.setToken(token); return userTokenResultDTO; } 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 new file mode 100644 index 0000000000..4985f4d9e8 --- /dev/null +++ b/epmet-auth/src/main/java/com/epmet/service/impl/ThirdLoginServiceImpl.java @@ -0,0 +1,350 @@ +package com.epmet.service.impl; + +import com.epmet.common.token.constant.LoginConstant; +import com.epmet.commons.tools.exception.EpmetErrorCode; +import com.epmet.commons.tools.exception.ExceptionUtils; +import com.epmet.commons.tools.exception.RenException; +import com.epmet.commons.tools.security.dto.GovTokenDto; +import com.epmet.commons.tools.security.dto.TokenDto; +import com.epmet.commons.tools.utils.ConvertUtils; +import com.epmet.commons.tools.utils.CpUserDetailRedis; +import com.epmet.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.form.*; +import com.epmet.dto.result.DepartmentListResultDTO; +import com.epmet.dto.result.GridByStaffResultDTO; +import com.epmet.dto.result.StaffLatestAgencyResultDTO; +import com.epmet.dto.result.UserTokenResultDTO; +import com.epmet.feign.EpmetThirdFeignClient; +import com.epmet.feign.EpmetUserOpenFeignClient; +import com.epmet.feign.GovOrgOpenFeignClient; +import com.epmet.jwt.JwtTokenProperties; +import com.epmet.jwt.JwtTokenUtils; +import com.epmet.service.ThirdLoginService; +import lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.util.CollectionUtils; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.stream.Collectors; + +/** + * @author sun + * @Description 第三方-居民端、政府端登陆服务 + */ +@Slf4j +@Service +public class ThirdLoginServiceImpl implements ThirdLoginService { + + private static final Logger logger = LoggerFactory.getLogger(ThirdLoginServiceImpl.class); + @Autowired + private JwtTokenUtils jwtTokenUtils; + @Autowired + private JwtTokenProperties jwtTokenProperties; + @Autowired + private CpUserDetailRedis cpUserDetailRedis; + @Autowired + private EpmetThirdFeignClient epmetThirdFeignClient; + @Autowired + private EpmetUserOpenFeignClient epmetUserOpenFeignClient; + @Autowired + private GovOrgOpenFeignClient govOrgOpenFeignClient; + + /** + * @param formDTO + * @return + * @Author sun + * @Description 单客户-居民端微信小程序登录 + **/ + @Override + public UserTokenResultDTO resiLogin(LoginFormDTO formDTO) { + //1.调用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(); + + //2.调用epmet-user服务,新增用户信息(先判断用户是否存在,不存在则新增存在则更新) + WxUserFormDTO wxUserFormDTO = new WxUserFormDTO(); + wxUserFormDTO.setWechatDTO(userWechatDTO); + wxUserFormDTO.setApp(formDTO.getApp()); + Result userResult = epmetUserOpenFeignClient.saveWxUser(wxUserFormDTO); + if (!userResult.success()) { + throw new RenException(result.getCode()); + } + UserDTO userDTO = userResult.getData(); + + //3.生成业务token + String userId = userDTO.getId(); + String token = this.generateToken(formDTO, userId); + + //4.存放Redis + this.saveTokenDto(formDTO, userId, userWechatDTO, token); + + //5.接口返参 + UserTokenResultDTO userTokenResultDTO = new UserTokenResultDTO(); + userTokenResultDTO.setToken(token); + + return userTokenResultDTO; + } + + /** + * @Description 居民端登陆生成业务token的key + **/ + private String generateToken(LoginCommonFormDTO formDTO, String userId) { + Map map = new HashMap<>(); + map.put("app", formDTO.getApp()); + map.put("client", formDTO.getClient()); + map.put("userId", userId); + String token = jwtTokenUtils.createToken(map); + logger.info("app:" + formDTO.getApp() + ";client:" + formDTO.getClient() + ";userId:" + userId + ";生成token[" + token + "]"); + return token; + } + + /** + * @Description 将token存入redis + **/ + private String saveTokenDto(LoginCommonFormDTO formDTO, String userId, UserWechatDTO userWechatDTO, String token) { + int expire = jwtTokenProperties.getExpire(); + TokenDto tokenDto = new TokenDto(); + tokenDto.setApp(formDTO.getApp()); + tokenDto.setClient(formDTO.getClient()); + tokenDto.setUserId(userId); + tokenDto.setOpenId(userWechatDTO.getWxOpenId()); + tokenDto.setSessionKey(userWechatDTO.getSessionKey()); + tokenDto.setUnionId(userWechatDTO.getUnionId()); + tokenDto.setToken(token); + tokenDto.setUpdateTime(System.currentTimeMillis()); + tokenDto.setExpireTime(jwtTokenUtils.getExpiration(token).getTime()); + cpUserDetailRedis.set(tokenDto, expire); + logger.info("截止时间:" + DateUtils.format(jwtTokenUtils.getExpiration(token), "yyyy-MM-dd HH:mm:ss")); + return token; + } + + /** + * @param formDTO + * @return + * @Author sun + * @Description 单客户-政府端微信小程序登录 + **/ + @Override + public UserTokenResultDTO workLogin(LoginFormDTO formDTO) { + //1.调用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(); + + //2.根据openid查询用户是否存在历史登陆信息 + Result latestStaffWechat = epmetUserOpenFeignClient.getLatestStaffWechatLoginRecord(userWechatDTO.getWxOpenId()); + if (!latestStaffWechat.success() || null == latestStaffWechat.getData()) { + logger.error(String.format("没有获取到用户最近一次登录账户信息,code[%s],msg[%s]", EpmetErrorCode.PLEASE_LOGIN.getCode(), EpmetErrorCode.PLEASE_LOGIN.getMsg())); + throw new RenException(EpmetErrorCode.PLEASE_LOGIN.getCode()); + } + StaffLatestAgencyResultDTO staffLatestAgencyResultDTO = latestStaffWechat.getData(); + + //3.记录staff_wechat + this.savestaffwechat(staffLatestAgencyResultDTO.getStaffId(), userWechatDTO.getWxOpenId()); + + //4.记录登录日志 + this.saveStaffLoginRecord(staffLatestAgencyResultDTO); + + //5.获取用户token + String token = this.generateGovWxmpToken(staffLatestAgencyResultDTO.getStaffId()); + + //6.保存到redis + this.saveLatestGovTokenDto(staffLatestAgencyResultDTO, userWechatDTO, token); + UserTokenResultDTO userTokenResultDTO = new UserTokenResultDTO(); + userTokenResultDTO.setToken(token); + return userTokenResultDTO; + + } + + /** + * @param userId openid + * @return + * @Author sun + * @Description 保存微信和当前登录用户关系 + **/ + private Result savestaffwechat(String userId, String openid) { + StaffWechatFormDTO staffWechatFormDTO = new StaffWechatFormDTO(); + staffWechatFormDTO.setUserId(userId); + staffWechatFormDTO.setWxOpenId(openid); + return epmetUserOpenFeignClient.saveStaffWechat(staffWechatFormDTO); + } + + /** + * @param latestStaffWechatLoginDTO + * @return + * @Author sun + * @Description 保存登录日志 + **/ + private Result saveStaffLoginRecord(StaffLatestAgencyResultDTO latestStaffWechatLoginDTO) { + StaffLoginAgencyRecordFormDTO staffLoginAgencyRecordFormDTO = new StaffLoginAgencyRecordFormDTO(); + staffLoginAgencyRecordFormDTO.setCustomerId(latestStaffWechatLoginDTO.getCustomerId()); + staffLoginAgencyRecordFormDTO.setStaffId(latestStaffWechatLoginDTO.getStaffId()); + staffLoginAgencyRecordFormDTO.setWxOpenId(latestStaffWechatLoginDTO.getWxOpenId()); + staffLoginAgencyRecordFormDTO.setMobile(latestStaffWechatLoginDTO.getMobile()); + staffLoginAgencyRecordFormDTO.setAgencyId(latestStaffWechatLoginDTO.getAgencyId()); + Result staffLoginRecordResult = epmetUserOpenFeignClient.saveStaffLoginRecord(staffLoginAgencyRecordFormDTO); + return staffLoginRecordResult; + } + + /** + * @Description 生成政府端小程序业务token Key + * @Author sun + **/ + private String generateGovWxmpToken(String staffId) { + Map map = new HashMap<>(); + map.put("app", LoginConstant.APP_GOV); + map.put("client", LoginConstant.CLIENT_WXMP); + map.put("userId", staffId); + String token = jwtTokenUtils.createToken(map); + logger.info("app:" + LoginConstant.APP_GOV + ";client:" + LoginConstant.CLIENT_WXMP + ";userId:" + staffId + ";生成token[" + token + "]"); + return token; + } + + /** + * @Description 保存tokenDto到redis + * @Author sun + **/ + private void saveLatestGovTokenDto(StaffLatestAgencyResultDTO staffLatestAgency, UserWechatDTO userWechatDTO, String token) { + int expire = jwtTokenProperties.getExpire(); + GovTokenDto govTokenDto = new GovTokenDto(); + govTokenDto.setApp(LoginConstant.APP_GOV); + govTokenDto.setClient(LoginConstant.CLIENT_WXMP); + govTokenDto.setUserId(staffLatestAgency.getStaffId()); + govTokenDto.setOpenId(userWechatDTO.getWxOpenId()); + govTokenDto.setSessionKey(userWechatDTO.getSessionKey()); + govTokenDto.setUnionId(userWechatDTO.getUnionId()); + govTokenDto.setToken(token); + govTokenDto.setUpdateTime(System.currentTimeMillis()); + govTokenDto.setExpireTime(jwtTokenUtils.getExpiration(token).getTime()); + govTokenDto.setRootAgencyId(staffLatestAgency.getAgencyId()); + govTokenDto.setCustomerId(staffLatestAgency.getCustomerId()); + + //设置部门,网格,角色列表 + govTokenDto.setDeptIdList(getDeptartmentIdList(staffLatestAgency.getStaffId())); + govTokenDto.setGridIdList(getGridIdList(staffLatestAgency.getStaffId())); + CustomerAgencyDTO agency = getAgencyByStaffId(staffLatestAgency.getStaffId()); + if (agency != null) { + govTokenDto.setAgencyId(agency.getId()); + govTokenDto.setRoleList(queryGovStaffRoles(staffLatestAgency.getStaffId(), agency.getId())); + } + govTokenDto.setOrgIdPath(getOrgIdPath(staffLatestAgency.getStaffId())); + + cpUserDetailRedis.set(govTokenDto, expire); + logger.info("截止时间:" + DateUtils.format(jwtTokenUtils.getExpiration(token), "yyyy-MM-dd HH:mm:ss")); + } + + public Set getDeptartmentIdList(String staffId) { + try { + Result> deptListResult = govOrgOpenFeignClient.getDepartmentListByStaffId(staffId); + if (deptListResult.success()) { + if (!CollectionUtils.isEmpty(deptListResult.getData())) { + Set deptIdLists = deptListResult.getData().stream().map(dept -> dept.getDepartmentId()).collect(Collectors.toSet()); + return deptIdLists; + } + } else { + logger.error("登录:查询部门列表,远程调用返回错误:{}", deptListResult.getMsg()); + } + } catch (Exception e) { + String errorStackTrace = ExceptionUtils.getErrorStackTrace(e); + logger.error("登录:查询部门列表异常:{}", errorStackTrace); + } + return null; + } + + /** + * 根据工作人员ID查询网格ID列表 + * + * @param staffId + * @return + */ + public Set getGridIdList(String staffId) { + Result> result = govOrgOpenFeignClient.listGridsbystaffid(staffId); + if (!result.success()) { + logger.error("登录:查询网格列表,远程调用返回错误:{}", result.getMsg()); + return null; + } else { + List grids = result.getData(); + return grids.stream().map(grid -> grid.getGridId()).collect(Collectors.toSet()); + } + } + + /** + * 根据staffId查询所属的组织机构 + * + * @param staffId + */ + public CustomerAgencyDTO getAgencyByStaffId(String staffId) { + Result result = govOrgOpenFeignClient.getAgencyByStaff(staffId); + if (!result.success()) { + logger.error("登录:查询登录人所属的机关OrgIdPath失败:{}", result.getMsg()); + return null; + } + return result.getData(); + } + + /** + * 查询人员在某机关单位下的角色列表 + * + * @param staffId orgId + */ + public List queryGovStaffRoles(String staffId, String orgId) { + StaffRoleFormDTO formDTO = new StaffRoleFormDTO(); + formDTO.setStaffId(staffId); + formDTO.setOrgId(orgId); + Result> gridResult = epmetUserOpenFeignClient.getRolesOfStaff(formDTO); + if (!CollectionUtils.isEmpty(gridResult.getData())) { + //return gridResult.getData().stream().map(role -> role.getId()).collect(Collectors.toSet()); + return ConvertUtils.sourceToTarget(gridResult.getData(), GovTokenDto.Role.class); + } + return null; + } + + /** + * 查询工作人员的OrgIdPath + * + * @param staffId + * @return + */ + public String getOrgIdPath(String staffId) { + Result result = govOrgOpenFeignClient.getAgencyByStaff(staffId); + if (!result.success()) { + logger.error("登录:查询登录人所属的机关OrgIdPath失败:{}", result.getMsg()); + return null; + } + CustomerAgencyDTO agency = result.getData(); + if (agency != null) { + if ("0".equals(agency.getPid())) { + // 顶级 + return agency.getId(); + } else { + return agency.getPids().concat(":").concat(agency.getId()); + } + } + return null; + } + +} diff --git a/epmet-commons/epmet-commons-tools/pom.xml b/epmet-commons/epmet-commons-tools/pom.xml index 216ec1c8b1..01d92799d7 100644 --- a/epmet-commons/epmet-commons-tools/pom.xml +++ b/epmet-commons/epmet-commons-tools/pom.xml @@ -129,6 +129,10 @@ httpclient 4.5.2 + + org.apache.httpcomponents + httpmime + diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/config/ApplicationConfig.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/config/ApplicationConfig.java new file mode 100644 index 0000000000..a16de46621 --- /dev/null +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/config/ApplicationConfig.java @@ -0,0 +1,21 @@ +package com.epmet.commons.tools.config; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.support.PropertySourcesPlaceholderConfigurer; + +/** + * desc:应用配置 + * @author lyn + * @date 2020/7/22 14:08 + */ +@Configuration +public class ApplicationConfig { + // 设置@Value注解取值不到忽略(不报错) + @Bean + public static PropertySourcesPlaceholderConfigurer placeholderConfigurer() { + PropertySourcesPlaceholderConfigurer c = new PropertySourcesPlaceholderConfigurer(); + c.setIgnoreUnresolvablePlaceholders(true); + return c; + } +} diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/config/MqConfig.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/config/MqConfig.java new file mode 100644 index 0000000000..4d9acf91fa --- /dev/null +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/config/MqConfig.java @@ -0,0 +1,30 @@ +/** + * Copyright (c) 2018 人人开源 All rights reserved. + *

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

+ * 版权所有,侵权必究! + */ + +package com.epmet.commons.tools.config; + +import lombok.Data; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Configuration; + +/** + * 消息网关配置信息 + * + * @author Mark sunlightcs@gmail.com + * @since 1.0.0 + */ +@Data +@Configuration +public class MqConfig { + @Value("${elink.mq.appId}") + private String appId; + @Value("${elink.mq.token}") + private String token; + @Value("${elink.mq.host}") + private String host; +} diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/NumConstant.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/NumConstant.java index c6d5234ddd..1c0247c8b1 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/NumConstant.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/NumConstant.java @@ -50,5 +50,5 @@ public interface NumConstant { String FOUR_STR = "4"; String FIVE_STR = "5"; String POSITIVE_EIGHT_STR = "+8"; - + String EMPTY_STR = ""; } diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/dto/form/mq/MqBaseMsgDTO.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/dto/form/mq/MqBaseMsgDTO.java new file mode 100644 index 0000000000..812d2e5baa --- /dev/null +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/dto/form/mq/MqBaseMsgDTO.java @@ -0,0 +1,30 @@ +package com.epmet.commons.tools.dto.form.mq; + +import lombok.Data; +import org.springframework.stereotype.Component; + +/** + * 消息网关基础信息 + * + * @author jianjun liu + * @date 2020-07-21 14:33 + **/ +@Data +@Component +public class MqBaseMsgDTO extends MqConfigDTO { + private static final long serialVersionUID = 8176470786428432009L; + + /** + * mq的事件类型 + */ + private String eventClass; + /** + * 事件code + */ + private String eventTag; + /** + * 消息体 + */ + private String msg; + +} diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/dto/form/mq/MqConfigDTO.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/dto/form/mq/MqConfigDTO.java new file mode 100644 index 0000000000..24a388f8ae --- /dev/null +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/dto/form/mq/MqConfigDTO.java @@ -0,0 +1,18 @@ +package com.epmet.commons.tools.dto.form.mq; + +import lombok.Data; + +import java.io.Serializable; + +/** + * 消息网关基础信息 + * + * @author jianjun liu + * @date 2020-07-21 14:33 + **/ +@Data +public class MqConfigDTO implements Serializable { + private String appId; + private String token; + private String requestUrl; +} diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/dto/form/mq/MqReturnBaseResult.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/dto/form/mq/MqReturnBaseResult.java new file mode 100644 index 0000000000..f25e66bcfd --- /dev/null +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/dto/form/mq/MqReturnBaseResult.java @@ -0,0 +1,19 @@ +package com.epmet.commons.tools.dto.form.mq; + +import lombok.Data; + +import java.io.Serializable; + +/** + * desc:消息网关返回结果 + * + * @author lyn + * @date 2020/7/21 13:38 + */ +@Data +public class MqReturnBaseResult implements Serializable { + private static final long serialVersionUID = -7763308686382363929L; + Integer errCode; + String errMsg; + String data; +} diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/dto/form/mq/MqSubscribeFormDTO.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/dto/form/mq/MqSubscribeFormDTO.java new file mode 100644 index 0000000000..4eb3a21bc7 --- /dev/null +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/dto/form/mq/MqSubscribeFormDTO.java @@ -0,0 +1,36 @@ +package com.epmet.commons.tools.dto.form.mq; + +import lombok.Data; + +import java.io.Serializable; + +/** + * desc: 订阅服务参数 实体类 + * + * @date: 2020/6/29 9:06 + * @author: jianjun liu + * email:liujianjun@git.elinkit.com.cn + */ +@Data +public class MqSubscribeFormDTO implements Serializable { + + /** + * 消息接收者 + */ + private String belongAppId; + + /** + * 密钥 + */ + private String eventClass; + /** + * 发送内容 + */ + private String eventTag; + + /** + * 是否at所有人 + */ + private String callbackUrl; + +} diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/dto/form/mq/ReceiveMqMsg.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/dto/form/mq/ReceiveMqMsg.java new file mode 100644 index 0000000000..b78d568924 --- /dev/null +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/dto/form/mq/ReceiveMqMsg.java @@ -0,0 +1,21 @@ +package com.epmet.commons.tools.dto.form.mq; + +import lombok.Data; + +import java.io.Serializable; + +/** + * 亿联云消息网关消息回调外层DTO + * + * @author jianjun liu + * @date 2020-07-20 8:58 + **/ +@Data +public class ReceiveMqMsg implements Serializable { + + private static final long serialVersionUID = -2776439983884650701L; + /** + * 消息体 json串 + */ + private String msg; +} diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/enums/MqMethodPathEnum.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/enums/MqMethodPathEnum.java new file mode 100644 index 0000000000..014722de84 --- /dev/null +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/enums/MqMethodPathEnum.java @@ -0,0 +1,42 @@ +package com.epmet.commons.tools.enums; + +/** + * 消息网关方法枚举类 + * dev|test|prod + * + * @author jianjun liu + * @date 2020-07-03 11:14 + **/ +public enum MqMethodPathEnum { + SEND_MSG("producerService/producer/sendMsg", "发送消息"), + + ; + + private String code; + private String name; + + + + MqMethodPathEnum(String code, String name) { + this.code = code; + this.name = name; + } + + public static MqMethodPathEnum getEnum(String code) { + MqMethodPathEnum[] values = MqMethodPathEnum.values(); + for (MqMethodPathEnum value : values) { + if (code != null && value.getCode().equals(code)) { + return value; + } + } + return null; + } + + public String getCode() { + return code; + } + + public String getName() { + return name; + } +} diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java index 36f968e3b0..63cab186d4 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java @@ -49,6 +49,12 @@ public enum EpmetErrorCode { CANNOT_DELETE_PARTY_MEMBER(8111,"该用户已注册党员,不允许删除"), GROUP_LEADER_CAN_EDIT_GROUP_INFO(8112,"只有组长才可以修改小组信息"), INVITE_NEW_MEMBER(8113,"只有讨论中的小组才可以邀请新成员"), + ACT_TITLE_SCAN_FAILED(8114,"活动标题审核失败,请重新编辑"), + ACT_REQ_SCAN_FAILED(8115,"活动报名条件审核失败,请重新编辑"), + ACT_CONTENT_TEXT_SCAN_FAILED(8116,"活动详情内容审核失败,请重新编辑"), + ACT_CONTENT_IMG_SCAN_FAILED(8117,"活动详情图片失败,请重新编辑"), + ACT_COVER_PIC_SCAN_FAILED(8118,"活动封面图片审核失败,请重新编辑"), + CANNOT_AUDIT_WARM(8201, "请完善居民信息"), NOT_DEL_AGENCY(8202, "该机关存在下级机关,不允许删除"), NOT_DEL_AGENCY_PER(8205, "该机关存在工作人员,不允许删除"), @@ -85,7 +91,11 @@ public enum EpmetErrorCode { CUSTOMER_VALIDATE_ERROR(8999, "内部数据校验异常"), //公众号 865..开头的码 - PUBLIC_NOT_EXISTS(8651,"手机号未注册,请先完成信息注册"); + PUBLIC_NOT_EXISTS(8651,"手机号未注册,请先完成信息注册"), + SELECT_CUSTOMER_ERROR(8652,"未查询到注册客户信息"), + SELECT_AGENCY_ERROR(8653,"根据客户信息未查询到注册客户组织信息"), + SELECT_USER_ERROR(8654,"根据客户信息未查询到注册客户管理员信息"), + UPDATE_CUSTOMER_ERROR(8655,"更新注册客户信息为已完成初始化失败"); private int code; 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 dcf93d3a24..0dadd18200 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,4 +254,13 @@ public class RedisKeys { return rootPrefix.concat("tags:grid:relationTag:").concat(gridId).concat(StrConstant.COLON).concat(tagId); } + /** + * 获取生成的用户标识 缓存Key + * @param shortUserId + * @return + */ + public static String getShortUserIdKey(String shortUserId) { + return rootPrefix.concat("oper:user:shorId:").concat(shortUserId); + } + } diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisUtils.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisUtils.java index f7f985ed63..2f08f03683 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisUtils.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisUtils.java @@ -10,8 +10,6 @@ package com.epmet.commons.tools.redis; import com.epmet.commons.tools.constant.NumConstant; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.dao.DataAccessException; -import org.springframework.data.redis.connection.RedisConnection; import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory; import org.springframework.data.redis.core.*; import org.springframework.data.redis.support.atomic.RedisAtomicLong; @@ -316,4 +314,13 @@ public class RedisUtils { return redisTemplate.opsForZSet().incrementScore(key, value, delta); } + /** + * @Description 判断key是否存在 + * @param key + * @return + */ + public Boolean hasKey(String key) { + return redisTemplate.hasKey(key); + } + } 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 f79b22ccb5..e76c5a4c33 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 @@ -488,4 +488,18 @@ public class DateUtils { return format.format(timestamp); } + public static Date minStrToSecondDate(String minStr){ + if(StringUtils.isNotBlank(minStr)&&minStr.length()==16){ + String date=minStr.concat(":00"); + System.out.println(date); + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + try { + return format.parse(date); + } catch (ParseException e) { + e.printStackTrace(); + } + } + return null; + } + } 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 2b48025317..5061222074 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 @@ -4,12 +4,11 @@ import com.alibaba.fastjson.JSON; import com.epmet.commons.tools.dto.form.DingTalkTextMsg; import com.epmet.commons.tools.exception.EpmetErrorCode; import com.epmet.commons.tools.exception.RenException; -import com.epmet.commons.tools.scan.param.TextScanParamDTO; -import com.epmet.commons.tools.scan.param.TextTaskDTO; import lombok.extern.slf4j.Slf4j; import org.apache.commons.codec.binary.Base64; import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.StringUtils; +import org.apache.http.HttpEntity; import org.apache.http.HttpStatus; import org.apache.http.NameValuePair; import org.apache.http.client.config.RequestConfig; @@ -19,19 +18,34 @@ import org.apache.http.client.methods.HttpGet; import org.apache.http.client.methods.HttpPost; import org.apache.http.client.methods.HttpRequestBase; import org.apache.http.client.utils.URIBuilder; +import org.apache.http.config.Registry; +import org.apache.http.config.RegistryBuilder; +import org.apache.http.conn.socket.ConnectionSocketFactory; +import org.apache.http.conn.socket.PlainConnectionSocketFactory; +import org.apache.http.conn.ssl.SSLConnectionSocketFactory; import org.apache.http.entity.StringEntity; +import org.apache.http.entity.mime.MultipartEntityBuilder; +import org.apache.http.entity.mime.content.FileBody; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; +import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; import org.apache.http.message.BasicNameValuePair; import org.apache.http.util.EntityUtils; import org.springframework.util.CollectionUtils; import javax.crypto.Mac; import javax.crypto.spec.SecretKeySpec; +import javax.net.ssl.SSLContext; +import javax.net.ssl.TrustManager; +import javax.net.ssl.X509TrustManager; import java.io.ByteArrayOutputStream; +import java.io.File; import java.io.IOException; import java.io.InputStream; import java.net.URLEncoder; +import java.security.KeyManagementException; +import java.security.NoSuchAlgorithmException; +import java.security.cert.CertificateException; import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -51,6 +65,28 @@ public class HttpClientManager { * HttpClient对象 */ private static CloseableHttpClient httpclient = HttpClients.custom().disableAutomaticRetries().build(); + private static CloseableHttpClient httpsClient; + + static { + try { + // 采用绕过验证的方式处理https请求 + SSLContext sslcontext = createIgnoreVerifySSL(); + // 设置协议http和https对应的处理socket链接工厂的对象 + Registry socketFactoryRegistry = RegistryBuilder.create() + .register("http", PlainConnectionSocketFactory.INSTANCE) + .register("https", new SSLConnectionSocketFactory(sslcontext, + SSLConnectionSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER)) + .build(); + PoolingHttpClientConnectionManager connManager = new PoolingHttpClientConnectionManager( + socketFactoryRegistry); + HttpClients.custom().setConnectionManager(connManager); + + // 创建自定义的httpclient对象 + httpsClient = HttpClients.custom().setConnectionManager(connManager).build(); + } catch (Exception e) { + e.printStackTrace(); + } + } /*** 超时设置 ****/ private static RequestConfig requestConfig = RequestConfig.custom() @@ -74,7 +110,7 @@ public class HttpClientManager { * * @author: jianjun liu */ - public Result sendPost(String url, Map paramsMap) { + public Result sendPost(String url, Map paramsMap) { try { HttpPost httppost = new HttpPost(url); @@ -88,9 +124,8 @@ public class HttpClientManager { UrlEncodedFormEntity urlEncodedFormEntity = new UrlEncodedFormEntity(list, "utf-8"); httppost.setEntity(urlEncodedFormEntity); - return execute(httppost); + return execute(httppost, false); } catch (Exception e) { - e.printStackTrace(); log.error("send exception", e); return new Result().error(EpmetErrorCode.SERVER_ERROR.getCode(), EpmetErrorCode.SERVER_ERROR.getMsg()); } @@ -115,7 +150,7 @@ public class HttpClientManager { StringEntity se = new StringEntity(jsonStrParam, "utf-8"); httppost.setEntity(se); } - return execute(httppost); + return execute(httppost, false); } catch (Exception e) { log.error("send exception", e); throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode(), EpmetErrorCode.SERVER_ERROR.getMsg()); @@ -123,6 +158,55 @@ public class HttpClientManager { } + /** + * 上传临时素材 + * @author zhaoqifeng + * @date 2020/7/17 14:33 + * @param url + * @param file + * @return com.epmet.commons.tools.utils.Result + */ + public Result uploadWxMedia(String url, File file) { + try { + HttpPost httppost = new HttpPost(url); + httppost.setConfig(requestConfig); + httppost.addHeader("Content-Type", "application/json; charset=utf-8"); + FileBody fileBody = new FileBody(file); + HttpEntity reqEntity = MultipartEntityBuilder.create() + .addPart("media", fileBody).build(); + httppost.setEntity(reqEntity); + return execute(httppost,false); + } catch (Exception e) { + log.error("send exception", e); + throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode(), EpmetErrorCode.SERVER_ERROR.getMsg()); + } + } + + /** + * desc: https发送json post 请求 + * param: url,jsonStrParam + * return: Result + * date: 2019/2/21 9:12 + * + * @author: jianjun liu + */ + public Result sendPostByHttps(String url, String jsonStrParam) { + try { + HttpPost httppost = new HttpPost(url); + httppost.setConfig(requestConfig); + httppost.addHeader("Content-Type", "application/json"); + if (StringUtils.isNotEmpty(jsonStrParam)) { + StringEntity se = new StringEntity(jsonStrParam, "utf-8"); + httppost.setEntity(se); + } + return execute(httppost, true); + } catch (Exception e) { + log.error("sendPostByHttps exception", e); + throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode(), EpmetErrorCode.SERVER_ERROR.getMsg()); + } + + } + /** * desc: 发送钉钉群消息 简版 * param: url,jsonStrParam @@ -140,10 +224,10 @@ public class HttpClientManager { Mac mac = Mac.getInstance("HmacSHA256"); mac.init(new SecretKeySpec(secret.getBytes("UTF-8"), "HmacSHA256")); byte[] signData = mac.doFinal(stringToSign.getBytes("UTF-8")); - String sign = URLEncoder.encode(new String(Base64.encodeBase64(signData)),"UTF-8"); + String sign = URLEncoder.encode(new String(Base64.encodeBase64(signData)), "UTF-8"); DingTalkTextMsg msg = new DingTalkTextMsg(); msg.setContent(content); - url = url.concat("×tamp="+timestamp+"&sign="+sign); + url = url.concat("×tamp=" + timestamp + "&sign=" + sign); String jsonStrParam = msg.getMsgContent(); return sendPostByJSON(url, jsonStrParam); } catch (Exception e) { @@ -172,25 +256,28 @@ public class HttpClientManager { } HttpGet httpGet = new HttpGet(builder.build()); httpGet.setConfig(requestConfig); - return execute(httpGet); + return execute(httpGet, false); } catch (Exception e) { log.error("sendGet exception", e); return new Result().error(EpmetErrorCode.SERVER_ERROR.getCode(), EpmetErrorCode.SERVER_ERROR.getMsg()); } } - private Result execute(HttpRequestBase httpMethod) { + private Result execute(HttpRequestBase httpMethod, boolean isHttps) { CloseableHttpResponse response = null; try { - response = httpclient.execute(httpMethod); - log.debug("http send response:{}", JSON.toJSONString(response)); + if (isHttps) { + response = httpsClient.execute(httpMethod); + } else { + response = httpclient.execute(httpMethod); + } if (response != null && response.getStatusLine() != null) { if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) { String result = EntityUtils.toString(response.getEntity()); return new Result().ok(result); } else { log.warn("execute http method fail,httpStatus:{}", response.getStatusLine().getStatusCode()); - return new Result().error(EpmetErrorCode.SERVER_ERROR.getCode(),"请求失败httpStatus:"+response.getStatusLine().getStatusCode()); + return new Result().error(EpmetErrorCode.SERVER_ERROR.getCode(), "请求失败httpStatus:" + response.getStatusLine().getStatusCode()); } } } catch (Exception e) { @@ -269,17 +356,29 @@ public class HttpClientManager { return new Result().error(EpmetErrorCode.SERVER_ERROR.getCode(), EpmetErrorCode.SERVER_ERROR.getMsg()); } - public static void main(String[] args) { - String url = "http://localhost:8107/epmetscan/api/textSyncScan"; - TextTaskDTO p = new TextTaskDTO(); - p.setDataId("1"); - p.setContent("neirong1"); - List list = new ArrayList<>(); - list.add(p); - TextScanParamDTO param = new TextScanParamDTO(); - param.setTasks(list); - Result result = HttpClientManager.getInstance().sendPostByJSON(url, JSON.toJSONString(param)); - System.out.println(JSON.toJSONString(result)); + private static SSLContext createIgnoreVerifySSL() throws NoSuchAlgorithmException, KeyManagementException { + SSLContext sc = SSLContext.getInstance("SSLv3"); + + // 实现一个X509TrustManager接口,用于绕过验证,不用修改里面的方法 + X509TrustManager trustManager = new X509TrustManager() { + @Override + public void checkClientTrusted(java.security.cert.X509Certificate[] paramArrayOfX509Certificate, + String paramString) throws CertificateException { + } + + @Override + public void checkServerTrusted(java.security.cert.X509Certificate[] paramArrayOfX509Certificate, + String paramString) throws CertificateException { + } + + @Override + public java.security.cert.X509Certificate[] getAcceptedIssuers() { + return null; + } + }; + + sc.init(null, new TrustManager[]{trustManager}, null); + return sc; } } diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/Md5Util.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/Md5Util.java new file mode 100644 index 0000000000..1da80ff672 --- /dev/null +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/Md5Util.java @@ -0,0 +1,149 @@ +package com.epmet.commons.tools.utils; + +import lombok.extern.slf4j.Slf4j; + +import java.io.UnsupportedEncodingException; +import java.security.MessageDigest; + +@Slf4j +public class Md5Util { + /** + * 加密盐 值 + */ + public static final String SALT = "EPMET_UMD_SALT"; + + public static String md5(String string) { + if (string == null || string.trim().length() == 0) { + return null; + } + try { + return getMD5(string.getBytes("GBK")); + } catch (UnsupportedEncodingException e) { + log.error( "md5 is error,msg={0}", e); + return null; + } + } + + private static final char hexDigits[] = { // 用来将字节转换成 16 进制表示的字符 + '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'}; + + private static String getMD5(byte[] source) { + String s = null; + try { + MessageDigest md = MessageDigest.getInstance("MD5"); + md.update(source); + byte tmp[] = md.digest(); // MD5 的计算结果是一个 128 位的长整数, + // 用字节表示就是 16 个字节 + char str[] = new char[16 * 2]; // 每个字节用 16 进制表示的话,使用两个字符, + // 所以表示成 16 进制需要 32 个字符 + int k = 0; // 表示转换结果中对应的字符位置 + for (int i = 0; i < 16; i++) { // 从第一个字节开始,对 MD5 的每一个字节 + // 转换成 16 进制字符的转换 + byte byte0 = tmp[i]; // 取第 i 个字节 + str[k++] = hexDigits[byte0 >>> 4 & 0xf]; // 取字节中高 4 位的数字转换, + // >>> 为逻辑右移,将符号位一起右移 + str[k++] = hexDigits[byte0 & 0xf]; // 取字节中低 4 位的数字转换 + } + s = new String(str); // 换后的结果转换为字符串 + + } catch (Exception e) { + log.error("getMD5 is error,msg={0}", e); + } + return s; + } + + private static String byteArrayToHexString(byte b[]) { + StringBuffer resultSb = new StringBuffer(); + for (int i = 0; i < b.length; i++) + resultSb.append(byteToHexString(b[i])); + + return resultSb.toString(); + } + + private static String byteToHexString(byte b) { + int n = b; + if (n < 0) + n += 256; + int d1 = n / 16; + int d2 = n % 16; + return hexDigits[d1] + "" + hexDigits[d2]; + } + + public static String MD5Encode(String origin, String charsetname) { + String resultString = null; + try { + resultString = new String(origin); + MessageDigest md = MessageDigest.getInstance("MD5"); + if (charsetname == null || "".equals(charsetname)) + resultString = byteArrayToHexString(md.digest(resultString + .getBytes())); + else + resultString = byteArrayToHexString(md.digest(resultString + .getBytes(charsetname))); + } catch (Exception e) { + log.error("MD5Encode is error,msg={0}", e); + } + return resultString; + } + + + public static void main(String[] args) { + for (int i = 0; i < 5; i++) { + String uuid = "03a1dcd8cb1811eabac1c03fd56f7847"; + System.out.println(get12Char(uuid)); + } + } + + /** + * 获取短字符 + * + * @param str + * @return 大写 + */ + public static String get12Char(String str) { + String arr[] = ShortText(str); + String rst = (arr[0] + arr[1]).toUpperCase(); + return rst.substring(0, 4) + rst.substring(4, 8) + rst.substring(8, 12); + } + + private static String[] ShortText(String string) { + String[] chars = new String[]{ // 要使用生成URL的字符 + "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", + "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", + "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", + "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", + "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"}; + + String hex = ""; + + MessageDigest md = null; + try { + md = MessageDigest.getInstance("MD5"); + hex = byteArrayToHexString(md.digest(SALT.concat(string) + .getBytes("utf-8"))); + } catch (Exception e) { + e.printStackTrace(); + } + + int hexLen = hex.length(); + int subHexLen = hexLen / 8; + String[] ShortStr = new String[4]; + + for (int i = 0; i < subHexLen; i++) { + String outChars = ""; + int j = i + 1; + String subHex = hex.substring(i * 8, j * 8); + long idx = Long.valueOf("3FFFFFFF", 16) & Long.valueOf(subHex, 16); + + for (int k = 0; k < 6; k++) { + int index = (int) (Long.valueOf("0000003D", 16) & idx); + outChars += chars[index]; + idx = idx >> 5; + } + ShortStr[i] = outChars; + } + + return ShortStr; + } + +} diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/MultipartFileToFileUtils.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/MultipartFileToFileUtils.java new file mode 100644 index 0000000000..36f093405a --- /dev/null +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/MultipartFileToFileUtils.java @@ -0,0 +1,53 @@ +package com.epmet.commons.tools.utils; + +import org.springframework.web.multipart.MultipartFile; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.InputStream; +import java.io.OutputStream; + +/** + * @author zhaoqifeng + * @dscription + * @date 2020/7/17 14:01 + */ +public class MultipartFileToFileUtils { + /** + * MultipartFile 转 File + * + * @param file + * @throws Exception + */ + public static File multipartFileToFile(MultipartFile file) throws Exception { + File toFile = null; + if (("").equals(file) || file.getSize() <= 0) { + file = null; + } else { + InputStream ins = null; + ins = file.getInputStream(); + toFile = new File(file.getOriginalFilename()); + toFile = inputStreamToFile(ins, toFile); + ins.close(); + } + return toFile; + } + + + private static File inputStreamToFile(InputStream ins, File file) { + try { + OutputStream os = new FileOutputStream(file); + int bytesRead = 0; + byte[] buffer = new byte[8192]; + while ((bytesRead = ins.read(buffer, 0, 8192)) != -1) { + os.write(buffer, 0, bytesRead); + } + os.close(); + ins.close(); + return file; + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } +} diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/ScanContentUtils.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/ScanContentUtils.java index a39a45309e..ef7a3257a6 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/ScanContentUtils.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/ScanContentUtils.java @@ -18,7 +18,6 @@ import java.util.List; * 扫描内容工具类 * * @author jianjun liu - * @email liujianjun@yunzongnet.com * @date 2020-06-08 8:28 **/ @Slf4j diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/SendMqMsgUtils.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/SendMqMsgUtils.java new file mode 100644 index 0000000000..65fb179ca3 --- /dev/null +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/SendMqMsgUtils.java @@ -0,0 +1,69 @@ +package com.epmet.commons.tools.utils; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.epmet.commons.tools.config.MqConfig; +import com.epmet.commons.tools.constant.NumConstant; +import com.epmet.commons.tools.dto.form.mq.MqBaseMsgDTO; +import com.epmet.commons.tools.dto.form.mq.MqReturnBaseResult; +import com.epmet.commons.tools.enums.MqMethodPathEnum; +import com.epmet.commons.tools.exception.EpmetErrorCode; +import com.epmet.commons.tools.exception.ValidateException; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +/** + * 发送亿联云消息工具类 + * + * @author jianjun liu + * @date 2020-06-08 8:28 + **/ +@Slf4j +@Component +public class SendMqMsgUtils { + private static MqConfig mqStaticConfig; + + /** + * desc:发送mq消息 + * + * @return + */ + public static Result sendMsg(MqBaseMsgDTO msg) { + if (mqStaticConfig == null) { + mqStaticConfig = SpringContextUtils.getBean(MqConfig.class); + } + log.debug("sendMsg param:{}", JSON.toJSONString(msg)); + try { + // TODO + //ValidatorUtils.validateEntity(msg, null); + } catch (ValidateException e) { + return new Result().error(e.getMsg()); + } + msg.setAppId(mqStaticConfig.getAppId()); + msg.setRequestUrl(mqStaticConfig.getHost().concat(MqMethodPathEnum.SEND_MSG.getCode())); + msg.setToken(mqStaticConfig.getToken()); + try { + Result result = HttpClientManager.getInstance().sendPostByHttps(msg.getRequestUrl(), JSON.toJSONString(msg)); + log.debug("sendMsg result:{}", JSON.toJSONString(result)); + if (result.success()) { + MqReturnBaseResult resultResult = JSON.parseObject(result.getData(), MqReturnBaseResult.class); + if (resultResult.getErrCode().equals(NumConstant.ZERO)) { + JSONObject jsonObject = JSON.parseObject(resultResult.getData()); + return new Result().ok(jsonObject.getString("msgId")); + } else { + log.error("sendMsg fail,resultData:{}", JSON.toJSONString(resultResult)); + return new Result().error(EpmetErrorCode.SERVER_ERROR.getCode(), resultResult.getErrMsg()); + } + } + Result resultResult = new Result<>(); + resultResult.error(result.getCode(), result.getMsg()); + resultResult.setInternalMsg(result.getInternalMsg()); + return resultResult; + } catch (Exception e) { + log.debug("sendMsg exception", e); + return new Result().error(EpmetErrorCode.SERVER_ERROR.getCode(), EpmetErrorCode.SERVER_ERROR.getMsg()); + } + } + + +} diff --git a/epmet-gateway/deploy/docker-compose-dev.yml b/epmet-gateway/deploy/docker-compose-dev.yml index 451de14e3d..702ce1f34e 100644 --- a/epmet-gateway/deploy/docker-compose-dev.yml +++ b/epmet-gateway/deploy/docker-compose-dev.yml @@ -2,7 +2,7 @@ version: "3.7" services: epmet-gateway-server: container_name: epmet-gateway-server-dev - image: 192.168.1.130:10080/epmet-cloud-dev/epmet-gateway:0.3.26 + image: 192.168.1.130:10080/epmet-cloud-dev/epmet-gateway:0.3.27 ports: - "8080:8080" network_mode: host # 使用现有网络 diff --git a/epmet-gateway/deploy/docker-compose-test.yml b/epmet-gateway/deploy/docker-compose-test.yml index 3dfa75ed94..c4dd828dca 100644 --- a/epmet-gateway/deploy/docker-compose-test.yml +++ b/epmet-gateway/deploy/docker-compose-test.yml @@ -2,7 +2,7 @@ version: "3.7" services: epmet-gateway-server: container_name: epmet-gateway-server-test - image: registry-vpc.cn-qingdao.aliyuncs.com/epmet-cloud-release/epmet-gateway:0.3.25 + image: registry-vpc.cn-qingdao.aliyuncs.com/epmet-cloud-release/epmet-gateway:0.3.26 ports: - "8080:8080" network_mode: host # 使用现有网络 diff --git a/epmet-gateway/pom.xml b/epmet-gateway/pom.xml index 25a2c69fa1..057ba37342 100644 --- a/epmet-gateway/pom.xml +++ b/epmet-gateway/pom.xml @@ -2,7 +2,7 @@ 4.0.0 - 0.3.26 + 0.3.27 com.epmet epmet-cloud diff --git a/epmet-gateway/src/main/java/com/epmet/filter/CpAuthGatewayFilterFactory.java b/epmet-gateway/src/main/java/com/epmet/filter/CpAuthGatewayFilterFactory.java index 1b2c7b6d9b..7aec3a7f6f 100644 --- a/epmet-gateway/src/main/java/com/epmet/filter/CpAuthGatewayFilterFactory.java +++ b/epmet-gateway/src/main/java/com/epmet/filter/CpAuthGatewayFilterFactory.java @@ -134,8 +134,10 @@ public class CpAuthGatewayFilterFactory extends AbstractGatewayFilterFactory + * 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.resi; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.ArrayList; + +/** + * 用户活动打卡参数 + * + * @author zhangyong + * @since v1.0.0 2020-07-14 + */ +@Data +public class ActUserClockLogFormDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 用户ID + */ + private String userId; + /** + * 活动ID + */ + @NotBlank(message = "活动ID不能为空") + private String actId; + /** + * 打卡类型(0-打卡,1-更新打卡) + */ + @NotBlank(message = "打卡类型不能为空") + private String clockType; + /** + * 打卡位置经度 + */ + @NotBlank(message = "打卡位置经度不能为空") + private BigDecimal clockLongitude; + /** + * 打卡位置纬度 + */ + @NotBlank(message = "打卡位置纬度不能为空") + private BigDecimal clockLatitude; + /** + * 打卡地址 + */ + @NotBlank(message = "打卡地址不能为空") + private String clockAddress; + /** + * 打卡描述 + */ + @NotBlank(message = "打卡描述不能为空") + private String clockDesc; + /** + * 打卡是否有效(0-否,1-是) + */ + @NotBlank(message = "打卡是否有效不能为空") + private String effectiveFlag; + /** + * 打卡图片 + */ + private ArrayList images; +} diff --git a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/resi/ResiActBaseFormDTO.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/resi/ResiActBaseFormDTO.java new file mode 100644 index 0000000000..04a0b710aa --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/resi/ResiActBaseFormDTO.java @@ -0,0 +1,68 @@ +/** + * 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.resi; + +import lombok.Data; + +import javax.validation.constraints.Min; +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + +/** + * 活动列表(标准) 入参 + * + * @author zhangyong + * @since v1.0.0 2020-07-20 + */ +@Data +public class ResiActBaseFormDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + //>>>>>>>>>>>>>>>>>校验分组开始>>>>>>>>>>>>>>>>>>>>> + /** + * 添加用户操作的内部异常分组 + * 出现错误会提示给前端7000错误码,返回信息为:服务器开小差... + */ + public interface AddUserInternalGroup {} + + // <<<<<<<<<<<<<<<<<<<校验分组结束<<<<<<<<<<<<<<<<<<<<<<<< + + /** + * 客户Id + */ + @NotBlank(message = "客户Id不能为空", groups = { AddUserInternalGroup.class }) + private String customerId; + + /** + * 页码,从1开始 + */ + @Min(value = 1, message = "页码必须大于0", groups = { AddUserInternalGroup.class }) + private Integer pageNo; + + /** + * 页容量,默认20页 + */ + @Min(value = 1, message = "每页条数必须大于必须大于0", groups = { AddUserInternalGroup.class }) + private Integer pageSize; + + /** + * 用户id + */ + private String userId; +} diff --git a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/resi/ResiActCaculateDistanceFormDTO.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/resi/ResiActCaculateDistanceFormDTO.java new file mode 100644 index 0000000000..b48ff6bb08 --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/resi/ResiActCaculateDistanceFormDTO.java @@ -0,0 +1,45 @@ +package com.epmet.dto.form.resi; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + +/** + * 重新定位 入参 + * + * @author zhangyong + * @since v1.0.0 2020-07-20 + */ +@Data +public class ResiActCaculateDistanceFormDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + //>>>>>>>>>>>>>>>>>校验分组开始>>>>>>>>>>>>>>>>>>>>> + /** + * 添加用户操作的内部异常分组 + * 出现错误会提示给前端7000错误码,返回信息为:服务器开小差... + */ + public interface AddUserInternalGroup {} + + // <<<<<<<<<<<<<<<<<<<校验分组结束<<<<<<<<<<<<<<<<<<<<<<<< + + /** + * 经度 + */ + @NotBlank(message = "经度不能为空", groups = { ResiActBaseFormDTO.AddUserInternalGroup.class }) + private Double longitude; + + /** + * 纬度 + */ + @NotBlank(message = "纬度不能为空", groups = { ResiActBaseFormDTO.AddUserInternalGroup.class }) + private Double latitude; + + /** + * 用户id + */ + @NotBlank(message = "活动ID不能为空", groups = { ResiActBaseFormDTO.AddUserInternalGroup.class }) + private String actId; +} diff --git a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/resi/ResiActUserCancelSignUpFormDTO.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/resi/ResiActUserCancelSignUpFormDTO.java new file mode 100644 index 0000000000..cbe419a7b3 --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/resi/ResiActUserCancelSignUpFormDTO.java @@ -0,0 +1,71 @@ +/** + * 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.resi; + +import com.epmet.commons.tools.validator.group.CustomerClientShowGroup; +import lombok.Data; +import org.hibernate.validator.constraints.Length; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + +/** + * 取消报名参数 + * + * @author zhangyong + * @since v1.0.0 2020-07-20 + */ +@Data +public class ResiActUserCancelSignUpFormDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + //>>>>>>>>>>>>>>>>>校验分组开始>>>>>>>>>>>>>>>>>>>>> + /** + * 添加用户操作的内部异常分组 + * 出现错误会提示给前端7000错误码,返回信息为:服务器开小差... + */ + public interface AddUserInternalGroup {} + + /** + * 添加用户操作的用户可见异常分组 + * 该分组用于校验需要返回给前端错误信息提示的列,需要继承CustomerClientShowGroup + * 返回错误码为8999,提示信息为DTO中具体的列的校验注解message的内容 + */ + public interface AddUserShowGroup extends CustomerClientShowGroup {} + + // <<<<<<<<<<<<<<<<<<<校验分组结束<<<<<<<<<<<<<<<<<<<<<<<< + + /** + * 用户Id + */ + private String userId; + + /** + * 活动ID + */ + @NotBlank(message = "活动ID不能为空", groups = { AddUserInternalGroup.class }) + private String actId; + + /** + * 取消报名原因 + */ + @NotBlank(message = "请输入取消报名原因", groups = { AddUserInternalGroup.class, AddUserShowGroup.class }) + @Length(max = 150, message = "取消报名原因不能超过150字", groups = { AddUserInternalGroup.class, AddUserShowGroup.class }) + private String failureReason; +} diff --git a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/resi/ResiLatestActFormDTO.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/resi/ResiLatestActFormDTO.java new file mode 100644 index 0000000000..0f9af626e5 --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/resi/ResiLatestActFormDTO.java @@ -0,0 +1,57 @@ +/** + * 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.resi; + +import lombok.Data; + +import javax.validation.constraints.Min; +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + +/** + * 最新活动列表 入参 + * + * @author zhangyong + * @since v1.0.0 2020-07-21 + */ +@Data +public class ResiLatestActFormDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + //>>>>>>>>>>>>>>>>>校验分组开始>>>>>>>>>>>>>>>>>>>>> + /** + * 添加用户操作的内部异常分组 + * 出现错误会提示给前端7000错误码,返回信息为:服务器开小差... + */ + public interface AddUserInternalGroup {} + + // <<<<<<<<<<<<<<<<<<<校验分组结束<<<<<<<<<<<<<<<<<<<<<<<< + + /** + * 客户Id + */ + @NotBlank(message = "客户Id不能为空", groups = { AddUserInternalGroup.class }) + private String customerId; + + /** + * 页容量,默认20页 + */ + @Min(value = 1, message = "每页条数必须大于必须大于0", groups = { AddUserInternalGroup.class }) + private Integer num; +} diff --git a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/resi/ResiMyActFormDTO.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/resi/ResiMyActFormDTO.java new file mode 100644 index 0000000000..1cad8308bc --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/resi/ResiMyActFormDTO.java @@ -0,0 +1,62 @@ +/** + * 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.resi; + +import lombok.Data; + +import javax.validation.constraints.Min; +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + +/** + * 我的活动列表 入参 + * + * @author zhangyong + * @since v1.0.0 2020-07-20 + */ +@Data +public class ResiMyActFormDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + //>>>>>>>>>>>>>>>>>校验分组开始>>>>>>>>>>>>>>>>>>>>> + /** + * 添加用户操作的内部异常分组 + * 出现错误会提示给前端7000错误码,返回信息为:服务器开小差... + */ + public interface AddUserInternalGroup {} + + // <<<<<<<<<<<<<<<<<<<校验分组结束<<<<<<<<<<<<<<<<<<<<<<<< + + /** + * 页码,从1开始 + */ + @Min(value = 1, message = "页码必须大于0", groups = { AddUserInternalGroup.class }) + private Integer pageNo; + + /** + * 页容量,默认20页 + */ + @Min(value = 1, message = "每页条数必须大于必须大于0", groups = { AddUserInternalGroup.class }) + private Integer pageSize; + + /** + * 用户id + */ + private String userId; +} diff --git a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/work/ActPreviewFormDTO.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/work/ActPreviewFormDTO.java new file mode 100644 index 0000000000..57166c22f1 --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/work/ActPreviewFormDTO.java @@ -0,0 +1,26 @@ +package com.epmet.dto.form.work; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + +/** + * 活动预览-查看活动详情 + * + * @author yinzuomei@elink-cn.com + * @date 2020/7/21 17:19 + */ +@Data +public class ActPreviewFormDTO implements Serializable { + private static final long serialVersionUID = -1603801389350245626L; + + public interface UserInternalGroup { + } + + /** + * 活动草稿id + */ + @NotBlank(message = "活动草稿id不能为空", groups = {UserInternalGroup.class}) + private String actDraftId; +} diff --git a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/work/AuditingActUserFormDTO.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/work/AuditingActUserFormDTO.java new file mode 100644 index 0000000000..9fb58c8179 --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/work/AuditingActUserFormDTO.java @@ -0,0 +1,23 @@ +package com.epmet.dto.form.work; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + +/** + * 报名审核-待审核列表入参 + * + * @author yinzuomei@elink-cn.com + * @date 2020/7/21 22:12 + */ +@Data +public class AuditingActUserFormDTO implements Serializable { + private static final long serialVersionUID = 3811387419859675753L; + public interface AddUserInternalGroup {} + /** + * 活动id + */ + @NotBlank(message = "活动id不能为空", groups = { AddUserInternalGroup.class }) + private String actId; +} diff --git a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/work/DraftActContentFormDTO.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/work/DraftActContentFormDTO.java new file mode 100644 index 0000000000..91bbae914b --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/work/DraftActContentFormDTO.java @@ -0,0 +1,36 @@ +package com.epmet.dto.form.work; + +import com.epmet.commons.tools.validator.group.CustomerClientShowGroup; +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + +/** + * 活动内容 + * + * @author yinzuomei@elink-cn.com + * @date 2020/7/21 13:18 + */ +@Data +public class DraftActContentFormDTO implements Serializable { + private static final long serialVersionUID = 5236509944250440348L; + + public interface UserInternalGroup { + } + + public interface UserShowGroup extends CustomerClientShowGroup { + } + + /** + * 内容 + */ + @NotBlank(message = "内容不能为空", groups = {UserShowGroup.class}) + private String content; + + /** + * 内容类型 图片:img;文字:text + */ + @NotBlank(message = "内容类型不能为空,图片:img;文字:text", groups = {UserInternalGroup.class}) + private String contentType; +} diff --git a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/work/DraftActInfoFormDTO.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/work/DraftActInfoFormDTO.java new file mode 100644 index 0000000000..55cd75a090 --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/work/DraftActInfoFormDTO.java @@ -0,0 +1,168 @@ +package com.epmet.dto.form.work; + +import com.epmet.commons.tools.validator.group.CustomerClientShowGroup; +import lombok.Data; + +import javax.validation.Valid; +import javax.validation.constraints.NotBlank; +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.List; + +/** + * 预览-保存活动草稿入参DTO + * + * @author yinzuomei@elink-cn.com + * @date 2020/7/21 13:17 + */ +@Data +public class DraftActInfoFormDTO implements Serializable { + private static final long serialVersionUID = -4967079570884814526L; + + public interface AddUserInternalGroup { + } + + public interface AddDraftUserShowGroup extends CustomerClientShowGroup { + } + + @Valid + private List actContent; + + /** + * 活动草稿id,如果是编辑之前的活动草稿,此列是有值的 + */ + private String actDraftId; + + + /** + * 如果是重新发布活动,此列是有值的 + */ + private String actId; + + /** + * 客户id + */ + @NotBlank(message = "客户id不能为空", groups = {AddUserInternalGroup.class}) + private String customerId; + + /** + * 活动标题 + */ + private String title; + + /** + * 封面图 + */ + private String coverPic; + + /** + * 活动地点 + */ + private String actAddress; + + /** + * 活动地点-经度 + */ + private BigDecimal actLongitude; + + /** + * 活动地点-纬度 + */ + private BigDecimal actLatitude; + + /** + * 活动预计开始时间yyyy-MM-dd HH:mm + */ + private String actStartTime; + + /** + * 活动预计结束时间yyyy-MM-dd HH:mm + */ + private String actEndTime; + + /** + * 活动人数 + */ + private Integer actQuota; + + /** + * 活动积分 + */ + private Integer reward; + + /** + * 报名审核:true:只有志愿者才可以参加活动,false: 只要是居民就可以参加活动 + */ + private Boolean volunteerLimit; + + /** + * 报名审核: true: 需人工审核 false: 无需审核 + */ + private Boolean auditSwitch; + + /** + * 报名截止时间:yyyy-MM-dd HH:mm + */ + private String signUpEndTime; + + /** + * 报名条件 + */ + private String requirement; + + /** + * 签到开始时间:yyyy-MM-dd HH:mm + */ + private String signInStartTime; + + /** + * 签到结束时间: yyyy-MM-dd HH:mm + */ + private String signInEndTime; + + /** + * 签到地址 + */ + private String signInAddress; + + /** + * 签到地址-纬度 + */ + private BigDecimal signInLatitude; + + /** + * 签到地址-经度 + */ + private BigDecimal signInLongitude; + + /** + * 签到有效范围(米) + */ + private Integer signInRadius; + + /** + * 主办方id + */ + private String sponsorId; + + /** + * 主办方类型:以网格名义:grid , 以机关名义: agency + */ + private String sponsorType; + + /** + * 主办方名称 + */ + private String sponsorName; + + /** + * 联系人 + */ + private String sponsorContacts; + + /** + * 联系电话 + */ + private String sponsorTel; + +} diff --git a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/work/PublishActContentFormDTO.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/work/PublishActContentFormDTO.java new file mode 100644 index 0000000000..efe2592e7a --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/work/PublishActContentFormDTO.java @@ -0,0 +1,36 @@ +package com.epmet.dto.form.work; + +import com.epmet.commons.tools.validator.group.CustomerClientShowGroup; +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + +/** + * 发布活动入参 + * + * @author yinzuomei@elink-cn.com + * @date 2020/7/21 16:21 + */ +@Data +public class PublishActContentFormDTO implements Serializable { + private static final long serialVersionUID = 7541780156596764819L; + + public interface UserInternalGroup { + } + + public interface UserShowGroup extends CustomerClientShowGroup { + } + + /** + * 内容 + */ + @NotBlank(message = "内容不能为空", groups = {UserShowGroup.class}) + private String content; + + /** + * 内容类型 图片:img;文字:text + */ + @NotBlank(message = "内容类型不能为空,图片:img;文字:text", groups = {UserInternalGroup.class}) + private String contentType; +} diff --git a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/work/PublishActInfoFormDTO.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/work/PublishActInfoFormDTO.java new file mode 100644 index 0000000000..e1005aa31a --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/work/PublishActInfoFormDTO.java @@ -0,0 +1,193 @@ +package com.epmet.dto.form.work; + +import com.epmet.commons.tools.validator.group.CustomerClientShowGroup; +import lombok.Data; +import org.hibernate.validator.constraints.Length; + +import javax.validation.Valid; +import javax.validation.constraints.Min; +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Size; +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.List; + +/** + * 发布活动-入参 + * + * @author yinzuomei@elink-cn.com + * @date 2020/7/21 16:15 + */ +@Data +public class PublishActInfoFormDTO implements Serializable { + private static final long serialVersionUID = -2066903357493362692L; + + public interface AddUserInternalGroup { + } + + public interface AddUserShowGroup extends CustomerClientShowGroup { + } + + @Valid + @Size(min=1,message = "活动详情不能为空",groups = {AddUserShowGroup.class}) + private List actContent; + + /** + * 活动草稿id,如果是编辑之前的活动草稿,此列是有值的 + */ + private String actDraftId; + + /** + * 客户id + */ + @NotBlank(message = "客户id不能为空", groups = {AddUserInternalGroup.class}) + private String customerId; + + /** + * 活动标题 + */ + @NotBlank(message = "活动标题不能为空", groups = {AddUserShowGroup.class}) + @Length(min=1, max=50,message = "活动标题限50字以内", groups = {AddUserShowGroup.class}) + private String title; + + /** + * 封面图 + */ + @NotBlank(message = "封面图不能为空", groups = {AddUserShowGroup.class}) + private String coverPic; + + /** + * 活动地点 + */ + @NotBlank(message = "活动地点不能为空", groups = {AddUserShowGroup.class}) + private String actAddress; + + /** + * 活动地点-经度 + */ + @NotNull(message = "活动地点经度不能为空", groups = {AddUserInternalGroup.class}) + private BigDecimal actLongitude; + + /** + * 活动地点-纬度 + */ + @NotNull(message = "活动地点经度不能为空", groups = {AddUserInternalGroup.class}) + private BigDecimal actLatitude; + + /** + * 活动预计开始时间yyyy-MM-dd HH:mm + */ + @NotBlank(message = "活动预计开始时间不能为空", groups = {AddUserShowGroup.class}) + private String actStartTime; + + /** + * 活动预计结束时间yyyy-MM-dd HH:mm + */ + @NotBlank(message = "活动预计结束时间不能为空", groups = {AddUserShowGroup.class}) + private String actEndTime; + + /** + * 活动人数 + */ + @Min(0) + private Integer actQuota; + + /** + * 活动积分 + */ + @Min(0) + private Integer reward; + + /** + * 报名审核:true:只有志愿者才可以参加活动,false: 只要是居民就可以参加活动 + */ + @NotNull(message = "报名身份不能为空", groups = {AddUserInternalGroup.class}) + private Boolean volunteerLimit; + + /** + * 报名审核: true: 需人工审核 false: 无需审核 + */ + @NotNull(message = "报名审核方式不能为空", groups = {AddUserInternalGroup.class}) + private Boolean auditSwitch; + + /** + * 报名截止时间:yyyy-MM-dd HH:mm + */ + @NotBlank(message = "报名截止时间不能为空", groups = {AddUserShowGroup.class}) + private String signUpEndTime; + + /** + * 报名条件 + */ + @NotBlank(message = "报名条件不能为空", groups = {AddUserShowGroup.class}) + @Length(min=1, max=50,message = "报名条件限200字以内", groups = {AddUserShowGroup.class}) + private String requirement; + + /** + * 签到开始时间:yyyy-MM-dd HH:mm + */ + @NotBlank(message = "签到开始时间不能为空", groups = {AddUserShowGroup.class}) + private String signInStartTime; + + /** + * 签到结束时间: yyyy-MM-dd HH:mm + */ + @NotBlank(message = "签到结束时间不能为空", groups = {AddUserShowGroup.class}) + private String signInEndTime; + + /** + * 签到地址 + */ + @NotBlank(message = "签到地址不能为空", groups = {AddUserShowGroup.class}) + private String signInAddress; + + /** + * 签到地址-纬度 + */ + @NotNull(message = "签到地址-纬度不能为空", groups = {AddUserInternalGroup.class}) + private BigDecimal signInLatitude; + + /** + * 签到地址-经度 + */ + @NotNull(message = "签到地址-经度不能为空", groups = {AddUserInternalGroup.class}) + private BigDecimal signInLongitude; + + /** + * 签到有效范围(米) + */ + @Min(0) + @NotNull(message = "签到有效范围不能为空", groups = {AddUserShowGroup.class}) + private Integer signInRadius; + + /** + * 主办方id + */ + @NotBlank(message = "主办方id不能为空", groups = {AddUserInternalGroup.class}) + private String sponsorId; + + /** + * 主办方类型:以网格名义:grid , 以机关名义: agency + */ + @NotBlank(message = "主办方类型不能为空", groups = {AddUserInternalGroup.class}) + private String sponsorType; + + /** + * 主办方名称 + */ + @NotBlank(message = "主办方名称不能为空", groups = {AddUserShowGroup.class}) + private String sponsorName; + + /** + * 联系人 + */ + @NotBlank(message = "联系人不能为空", groups = {AddUserShowGroup.class}) + private String sponsorContacts; + + /** + * 联系电话 + */ + @NotBlank(message = "联系电话不能为空", groups = {AddUserShowGroup.class}) + private String sponsorTel; +} diff --git a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/resi/ActClockListResultDTO.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/resi/ActClockListResultDTO.java new file mode 100644 index 0000000000..cb3cc26361 --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/resi/ActClockListResultDTO.java @@ -0,0 +1,48 @@ +/** + * 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.result.resi; + +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + +/** + * 打卡列表 + * + * @author zhangyong + * @since v1.0.0 2020-07-14 + */ +@Data +public class ActClockListResultDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 活动打卡人次 + */ + private Integer clockNum; + + /** + * 打卡列表 + */ + private List clocks; + + + +} diff --git a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/resi/ResiActInfoResultDTO.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/resi/ResiActInfoResultDTO.java new file mode 100644 index 0000000000..c842cef5e4 --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/resi/ResiActInfoResultDTO.java @@ -0,0 +1,90 @@ +/** + * 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.result.resi; + +import lombok.Data; + +import java.io.Serializable; + +/** + * 活动列表(标准) 返回值 + * + * @author zhangyong + * @since v1.0.0 2020-07-20 + */ +@Data +public class ResiActInfoResultDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 活动ID + */ + private String actId; + + /** + * 标题 + */ + private String title; + + + /** + * 活动封面 + */ + private String coverPic; + + /** + * 活动开始时间 + */ + private String actStartTime; + + /** + * 活动结束时间 + */ + private String actEndTime; + + /** + * 活动地点 + */ + private String actAddress; + + /** + * 活动名额类型(true:固定名额(1) false: 不限制名额(0)) + */ + private Boolean actQuotaCategory; + + /** + * 活动名额 + */ + private Integer actQuota; + + /** + * 已报名人数 + */ + private Integer signupNum; + + /** + * 活动状态:(报名中:signing_up;已报满:enough;截止报名: end_sign_up; 已开始: in_progress; 已结束:finished;取消报名canceld;) + */ + private String actCurrentState; + + /** + *用户报名状态(no_signed_up: 未报名,signed_up: 已报名) + */ + private String signupFlag; +} diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/CustomerCodeOperationHistoryDao.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/resi/ResiInProgressActResultDTO.java similarity index 63% rename from epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/CustomerCodeOperationHistoryDao.java rename to epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/resi/ResiInProgressActResultDTO.java index 63ca70fb2b..b6905711fe 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/CustomerCodeOperationHistoryDao.java +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/resi/ResiInProgressActResultDTO.java @@ -15,19 +15,30 @@ * along with this program. If not, see . */ -package com.epmet.dao; +package com.epmet.dto.result.resi; -import com.epmet.commons.mybatis.dao.BaseDao; -import com.epmet.entity.CustomerCodeOperationHistoryEntity; -import org.apache.ibatis.annotations.Mapper; +import lombok.Data; + +import java.io.Serializable; /** - * 客户代码操作历史 + * 即将进行/正在进行中的活动 返回值 * - * @author generator generator@elink-cn.com - * @since v1.0.0 2020-07-09 + * @author zhangyong + * @since v1.0.0 2020-07-21 */ -@Mapper -public interface CustomerCodeOperationHistoryDao extends BaseDao { - -} \ No newline at end of file +@Data +public class ResiInProgressActResultDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 主键 + */ + private String actId; + + /** + * 标题 + */ + private String title; +} diff --git a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/resi/ResiLatestActResultDTO.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/resi/ResiLatestActResultDTO.java new file mode 100644 index 0000000000..1bf6b8124e --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/resi/ResiLatestActResultDTO.java @@ -0,0 +1,85 @@ +/** + * 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.result.resi; + +import lombok.Data; + +import java.io.Serializable; + +/** + * 最新活动列表 返回值 + * + * @author zhangyong + * @since v1.0.0 2020-07-20 + */ +@Data +public class ResiLatestActResultDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 主键 + */ + private String actId; + + /** + * 标题 + */ + private String title; + + + /** + * 活动封面 + */ + private String coverPic; + + /** + * 活动开始时间 + */ + private String actStartTime; + + /** + * 活动结束时间 + */ + private String actEndTime; + + /** + * 活动地点 + */ + private String actAddress; + + /** + * 活动名额类型(true:固定名额(1) false: 不限制名额(0)) + */ + private Boolean actQuotaCategory; + + /** + * 活动名额 + */ + private Integer actQuota; + + /** + * 已报名人数 + */ + private Integer signupNum; + + /** + * 活动状态:(报名中:signing_up;已报满:enough;截止报名: end_sign_up; 已开始: in_progress;) + */ + private String actCurrentState; +} diff --git a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/resi/ResiLookBackActResultDTO.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/resi/ResiLookBackActResultDTO.java new file mode 100644 index 0000000000..fc7d7d39e7 --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/resi/ResiLookBackActResultDTO.java @@ -0,0 +1,69 @@ +/** + * 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.result.resi; + +import lombok.Data; + +import java.io.Serializable; + +/** + * 活动回顾列表 返回值 + * + * @author zhangyong + * @since v1.0.0 2020-07-20 + */ +@Data +public class ResiLookBackActResultDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 主键 + */ + private String actId; + + /** + * 标题 + */ + private String title; + + /** + * 活动封面 + */ + private String coverPic; + + /** + * 活动开始时间 + */ + private String actStartTime; + + /** + * 活动结束时间 + */ + private String actEndTime; + + /** + * 活动地点 + */ + private String actAddress; + + /** + * 活动状态:(已结束:finished;) + */ + private String actCurrentState; +} diff --git a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/resi/ResiMyActResultDTO.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/resi/ResiMyActResultDTO.java new file mode 100644 index 0000000000..b477f6d513 --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/resi/ResiMyActResultDTO.java @@ -0,0 +1,85 @@ +/** + * 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.result.resi; + +import lombok.Data; + +import java.io.Serializable; + +/** + * 我的活动列表 返回值 + * + * @author zhangyong + * @since v1.0.0 2020-07-20 + */ +@Data +public class ResiMyActResultDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 主键 + */ + private String actId; + + /** + * 标题 + */ + private String title; + + + /** + * 活动封面 + */ + private String coverPic; + + /** + * 活动开始时间 + */ + private String actStartTime; + + /** + * 活动结束时间 + */ + private String actEndTime; + + /** + * 活动地点 + */ + private String actAddress; + + /** + * 活动名额类型(true:固定名额(1) false: 不限制名额(0)) + */ + private Boolean actQuotaCategory; + + /** + * 活动名额 + */ + private Integer actQuota; + + /** + * 已报名人数 + */ + private Integer signupNum; + + /** + * 活动当前状态(审核中auditing,审核通过passed,审核不通过refused,已结束canceld) + */ + private String actCurrentState; +} diff --git a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/work/ActPreviewContentResultDTO.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/work/ActPreviewContentResultDTO.java new file mode 100644 index 0000000000..73609e486f --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/work/ActPreviewContentResultDTO.java @@ -0,0 +1,25 @@ +package com.epmet.dto.result.work; + +import lombok.Data; + +import java.io.Serializable; + +/** + * 活动预览详情页-活动内容详情 + * + * @author yinzuomei@elink-cn.com + * @date 2020/7/21 17:39 + */ +@Data +public class ActPreviewContentResultDTO implements Serializable { + private static final long serialVersionUID = -3351984717336783565L; + /** + * 内容 + */ + private String content; + + /** + * 内容类型 图片:img;文字:text + */ + private String contentType; +} diff --git a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/work/ActPreviewResultDTO.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/work/ActPreviewResultDTO.java new file mode 100644 index 0000000000..f5869bdb87 --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/work/ActPreviewResultDTO.java @@ -0,0 +1,92 @@ +package com.epmet.dto.result.work; + +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; +import java.util.List; + +/** + * 活动预览-查看活动详情返参修改 + * + * @author yinzuomei@elink-cn.com + * @date 2020/7/21 17:23 + */ +@Data +public class ActPreviewResultDTO implements Serializable { + private static final long serialVersionUID = 8655407962470027973L; + + /** + * 活动草稿id + */ + private String actDraftId; + + /** + * 活动标题 + */ + private String title; + + /** + * 活动人数 + */ + private Integer actQuota; + + /** + * true:固定名额 false: 不限制名额 + */ + private Boolean actQuotaCategory; + + /** + * 活动积分 + */ + private Integer reward; + + /** + * 活动开始时间yyyy-MM-dd HH:mm + */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm", timezone = "GMT+8") + private Date actStartTime; + + /** + * 活动结束时间yyyy-MM-dd HH:mm + */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm", timezone = "GMT+8") + private Date actEndTime; + + /** + * 活动地点 + */ + private String actAddress; + + /** + * 报名截止时间:yyyy-MM-dd HH:mm + */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm", timezone = "GMT+8") + private Date signUpEndTime; + + /** + * 报名条件 + */ + private String requirement; + + /** + * 主办方名称 + */ + private String sponsorName; + + /** + * 联系人 + */ + private String sponsorContacts; + + /** + * 联系电话 + */ + private String sponsorTel; + + /** + * 活动详情 + */ + private List actContent; +} diff --git a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/work/AuditingActUserResultDTO.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/work/AuditingActUserResultDTO.java new file mode 100644 index 0000000000..c40e1310b2 --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/work/AuditingActUserResultDTO.java @@ -0,0 +1,55 @@ +package com.epmet.dto.result.work; + +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + +/** + * 报名审核-待审核列表返参 + * + * @author yinzuomei@elink-cn.com + * @date 2020/7/21 22:14 + */ +@Data +public class AuditingActUserResultDTO implements Serializable { + private static final long serialVersionUID = 5567556309702585031L; + + /** + * 活动id + */ + private String actId; + + /** + * 用户id + */ + private String userId; + + /** + * 姓名 + */ + private String realName; + + /** + * 微信昵称 + */ + private String nickName; + + /** + * 头像 + */ + private String headImgUrl; + + /** + * 报名时间yyyy-MM-dd HH:mm:ss + */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + private Date signUpTime; + + /** + * true: 是志愿者 false : 不是志愿者 + */ + private Boolean volunteerFlag; + +} diff --git a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/work/CustomerHeartConfigsResultDTO.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/work/CustomerHeartConfigsResultDTO.java new file mode 100644 index 0000000000..135a9d539e --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/work/CustomerHeartConfigsResultDTO.java @@ -0,0 +1,51 @@ +package com.epmet.dto.result.work; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.Data; + +import java.io.Serializable; + +/** + * 居民端根据客户id获取爱心互助自定义配置-返参DTO + * + * @author yinzuomei@elink-cn.com + * @date 2020/7/21 12:45 + */ +@Data +public class CustomerHeartConfigsResultDTO implements Serializable { + /** + * act_customized主键 + */ + @JsonIgnore + private String actCustomizedId; + + /** + * 标题:志愿者去哪儿 + */ + private String titleName; + + /** + * 咨询热线 + */ + private String hotLine; + + /** + * 活动列表 + */ + private String actListName; + + /** + * 爱心榜 + */ + private String heartRankName; + + /** + * 活动回顾 + */ + private String actReviewName; + + /** + * 我的活动 + */ + private String myActName; +} diff --git a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/work/LatestDraftActInfoResultDTO.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/work/LatestDraftActInfoResultDTO.java index 3f5a6dacaa..89d5c1e4ec 100644 --- a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/work/LatestDraftActInfoResultDTO.java +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/work/LatestDraftActInfoResultDTO.java @@ -17,6 +17,9 @@ import java.util.List; @Data public class LatestDraftActInfoResultDTO implements Serializable { private static final long serialVersionUID = 4104775168048712734L; + /** + * 活动草稿id + */ private String actDraftId; /** * 客户id @@ -36,13 +39,13 @@ public class LatestDraftActInfoResultDTO implements Serializable { /** * 报名开始时间 */ - @JsonFormat(pattern="yyyy-MM-dd HH:mm") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm", timezone = "GMT+8") private Date signUpStartTime; /** * 报名截止时间 */ - @JsonFormat(pattern="yyyy-MM-dd HH:mm") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm", timezone = "GMT+8") private Date signUpEndTime; /** @@ -53,13 +56,13 @@ public class LatestDraftActInfoResultDTO implements Serializable { /** * 活动预计开始时间 */ - @JsonFormat(pattern="yyyy-MM-dd HH:mm") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm", timezone = "GMT+8") private Date actStartTime; /** * 活动预计结束时间 */ - @JsonFormat(pattern="yyyy-MM-dd HH:mm") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm", timezone = "GMT+8") private Date actEndTime; /** @@ -80,13 +83,13 @@ public class LatestDraftActInfoResultDTO implements Serializable { /** * 签到开始时间 */ - @JsonFormat(pattern="yyyy-MM-dd HH:mm") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm", timezone = "GMT+8") private Date signInStartTime; /** * 签到截止时间 */ - @JsonFormat(pattern="yyyy-MM-dd HH:mm") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm", timezone = "GMT+8") private Date signInEndTime; /** diff --git a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/work/PublishActInitResultDTO.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/work/PublishActInitResultDTO.java similarity index 91% rename from epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/work/PublishActInitResultDTO.java rename to epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/work/PublishActInitResultDTO.java index 94b9e8b7af..08c3ff1d97 100644 --- a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/work/PublishActInitResultDTO.java +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/work/PublishActInitResultDTO.java @@ -1,4 +1,4 @@ -package com.epmet.dto.form.work; +package com.epmet.dto.result.work; import lombok.Data; diff --git a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/work/PublishActResultDTO.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/work/PublishActResultDTO.java new file mode 100644 index 0000000000..5fdc6a5c06 --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/work/PublishActResultDTO.java @@ -0,0 +1,17 @@ +package com.epmet.dto.result.work; + +import lombok.Data; + +import java.io.Serializable; + +/** + * 发布活动-返参 + * + * @author yinzuomei@elink-cn.com + * @date 2020/7/21 18:29 + */ +@Data +public class PublishActResultDTO implements Serializable { + private static final long serialVersionUID = 4699176252192192495L; + private String actId; +} diff --git a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/work/SaveActDraftResultDTO.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/work/SaveActDraftResultDTO.java new file mode 100644 index 0000000000..248519fc28 --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/work/SaveActDraftResultDTO.java @@ -0,0 +1,21 @@ +package com.epmet.dto.result.work; + +import lombok.Data; + +import java.io.Serializable; + +/** + * 预览-保存活动草稿返参DTO + * + * @author yinzuomei@elink-cn.com + * @date 2020/7/21 12:53 + */ +@Data +public class SaveActDraftResultDTO implements Serializable { + private static final long serialVersionUID = -111427814347693729L; + + /** + * 活动草稿id + */ + private String actDraftId; +} diff --git a/epmet-module/epmet-heart/epmet-heart-server/pom.xml b/epmet-module/epmet-heart/epmet-heart-server/pom.xml index 3c200a6622..e245a2cdc9 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/pom.xml +++ b/epmet-module/epmet-heart/epmet-heart-server/pom.xml @@ -64,6 +64,18 @@ 2.0.0 compile + + com.epmet + gov-org-client + 2.0.0 + compile + + + com.epmet + epmet-user-client + 2.0.0 + compile + @@ -120,6 +132,12 @@ false + https://epmet-dev.elinkservice.cn/api/epmetscan/api + + https://epmet-dev.elinkservice.cn/estos/ + producerService/producer/sendMsg + 202007161443499985fa2d397436d10356542134c8f008c48 + 52d9d9b0e7d0eb5b8b81c205b579e07c @@ -152,6 +170,12 @@ true + https://epmet-dev.elinkservice.cn/api/epmetscan/api + + https://epmet-dev.elinkservice.cn/estos/ + producerService/producer/sendMsg + 202007161443499985fa2d397436d10356542134c8f008c48 + 52d9d9b0e7d0eb5b8b81c205b579e07c @@ -184,6 +208,12 @@ true + https://epmet-open.elinkservice.cn/api/epmetscan/api + + https://epmet-dev.elinkservice.cn/estos/ + producerService/producer/sendMsg + 202007161443499985fa2d397436d10356542134c8f008c48 + 52d9d9b0e7d0eb5b8b81c205b579e07c diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/constant/ActConstant.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/constant/ActConstant.java new file mode 100644 index 0000000000..0ee7df0ae7 --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/constant/ActConstant.java @@ -0,0 +1,70 @@ +package com.epmet.constant; + +/** + * 描述一下 + * + * @author yinzuomei@elink-cn.com + * @date 2020/7/21 20:21 + */ +public interface ActConstant { + /** + * 文本 + */ + String ACT_CONTENT_TYPE_TEXT = "text"; + + /** + * 图片 + */ + String ACT_CONTENT_TYPE_IMG="img"; + + /** + * (1)活动状态 + * act_info表中的status,已发布/报名中, + * 发布成功后自动赋值 + */ + String ACT_STATUS_PUBLISHED="published"; + + /** + * (2)活动状态 + * 活动已取消, + * 成功取消活动后,写入act_info表中的status, + */ + String ACT_STATUS_CANCELED="canceled"; + + /** + * (3)活动状态 + * 活动已结束 + * 活动后,写入act_info表中的status, + */ + String ACT_STATUS_FINISHED="finished"; + + /** + * 发布活动时,选择的主办方名义,已组织名义发布 + */ + String SPONSOR_AGENCY="agency"; + + /** + * 发布活动时,选择的主办方名义,已网格名义发布 + */ + String SPONSOR_GRID="grid"; + + /** + * 活动操作日志:取消活动 + */ + String ACT_OPER_TYPE_CANCEL="cancel"; + + /** + * 活动操作日志:发布活动 + */ + String ACT_OPER_TYPE_PUBLISH="publish"; + + /** + * 活动操作日志:结束活动 + */ + String ACT_OPER_TYPE_FINISH="finish"; + + /** + * 活动操作日志:重新发布活动 + */ + String ACT_OPER_TYPE_UPDATE="update"; +} diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/ActCustomizedController.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/ActCustomizedController.java index c65621aae9..a2ce0f1972 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/ActCustomizedController.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/ActCustomizedController.java @@ -22,6 +22,7 @@ import com.epmet.commons.tools.validator.ValidatorUtils; import com.epmet.dto.form.work.ActCustomizedFormDTO; import com.epmet.dto.form.work.SaveActCustomizedFormDTO; import com.epmet.dto.result.work.ActCustomizedResultDTO; +import com.epmet.dto.result.work.CustomerHeartConfigsResultDTO; import com.epmet.service.ActCustomizedService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PostMapping; @@ -70,4 +71,18 @@ public class ActCustomizedController { actCustomizedService.saveConfigs(formDTO); return new Result(); } + + /** + * @param formDTO + * @return com.epmet.commons.tools.utils.Result + * @author yinzuomei + * @description 居民端根据客户id获取爱心互助自定义配置 + * @Date 2020/7/21 12:47 + **/ + @PostMapping("/resi/getconfigs") + public Result getCustomerHeartConfigs(@RequestBody ActCustomizedFormDTO formDTO) { + ValidatorUtils.validateEntity(formDTO, ActCustomizedFormDTO.AddUserInternalGroup.class); + CustomerHeartConfigsResultDTO resultDTO = actCustomizedService.getCustomerHeartConfigs(formDTO); + return new Result().ok(resultDTO); + } } \ No newline at end of file diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/ResiActListController.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/ResiActListController.java new file mode 100644 index 0000000000..235dbca23b --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/ResiActListController.java @@ -0,0 +1,168 @@ +package com.epmet.controller; + +import com.epmet.commons.tools.annotation.LoginUser; +import com.epmet.commons.tools.security.dto.TokenDto; +import com.epmet.commons.tools.validator.ValidatorUtils; +import com.epmet.dto.form.resi.*; +import com.epmet.dto.result.resi.*; +import com.epmet.service.ActInfoService; +import com.epmet.commons.tools.utils.Result; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * 居民端-活动列表相关api + * + * @author yinzuomei@elink-cn.com + * @date 2020/7/19 23:17 + */ +@RestController +@RequestMapping("/resi/act") +public class ResiActListController { + + @Autowired + private ActInfoService actInfoService; + + /** + * 活动列表(包含状态:报名中:signing_up;已报满:enough;截止报名: end_sign_up; 已开始: in_progress; 已结束:finished;) + * + * @param tokenDto + * @param formDto + * @return com.epmet.commons.tools.utils.Result> + * @Author zhangyong + * @Date 13:39 2020-07-21 + **/ + @PostMapping("list") + public Result> listAct(@LoginUser TokenDto tokenDto, @RequestBody ResiActBaseFormDTO formDto) { + return actInfoService.listAct(tokenDto, formDto); + } + + + /** + * 我的活动-审核中 + * + * @param tokenDto + * @param formDto + * @return java.util.List + * @Author zhangyong + * @Date 13:53 2020-07-21 + **/ + @PostMapping("list/auditing") + public Result> listAuditing(@LoginUser TokenDto tokenDto, @RequestBody ResiMyActFormDTO formDto) { + return actInfoService.myActListAuditing(tokenDto, formDto); + } + + /** + * 我的活动-未通过 + * + * @param tokenDto + * @param formDto + * @return java.util.List + * @Author zhangyong + * @Date 13:53 2020-07-21 + **/ + @PostMapping("list/refused") + public Result> listRefused(@LoginUser TokenDto tokenDto, @RequestBody ResiMyActFormDTO formDto) { + return actInfoService.myActListRefused(tokenDto, formDto); + } + + /** + * 我的活动-已通过 + * + * @param tokenDto + * @param formDto + * @return java.util.List + * @Author zhangyong + * @Date 13:53 2020-07-21 + **/ + @PostMapping("list/passed") + public Result> listPassed(@LoginUser TokenDto tokenDto, @RequestBody ResiMyActFormDTO formDto) { + return actInfoService.myActListPassed(tokenDto, formDto); + } + + /** + * 我的活动-已结束 + * + * @param tokenDto + * @param formDto + * @return java.util.List + * @Author zhangyong + * @Date 13:53 2020-07-21 + **/ + @PostMapping("list/canceld") + public Result> listcanceld(@LoginUser TokenDto tokenDto, @RequestBody ResiMyActFormDTO formDto) { + return actInfoService.myActListCanceld(tokenDto, formDto); + } + + /** + * 最新活动列表 + * + * @param formDto + * @return java.util.List + * @Author zhangyong + * @Date 13:53 2020-07-21 + **/ + @PostMapping("list/latestact") + public Result> latestAct(@RequestBody ResiLatestActFormDTO formDto) { + return actInfoService.latestAct(formDto); + } + + /* + * 正在进行中的活动 + * 进入活动的快捷入口, 前端只取第一条 + * + * @param tokenDto + * @return com.epmet.commons.tools.utils.Result> + * @Author zhangyong + * @Date 14:56 2020-07-21 + **/ + @PostMapping("inprogress") + public Result> inProgressAct(@LoginUser TokenDto tokenDto) { + return actInfoService.inProgressAct(tokenDto); + } + + /** + * 活动回顾列表(包含状态:已结束:finished;) + * @param formDto + * @return com.epmet.commons.tools.utils.Result> + * @Author zhangyong + * @Date 13:39 2020-07-21 + **/ + @PostMapping("actlookback") + public Result> actLookBack(@RequestBody ResiActBaseFormDTO formDto) { + return actInfoService.actLookBack(formDto); + } + + /** + * 取消活动报名 + * + * @param tokenDto + * @param formDTO + * @return com.epmet.commons.tools.utils.Result + * @Author zhangyong + * @Date 09:29 2020-07-20 + **/ + @PostMapping("cancelsignup") + public Result cancelSignUp(@LoginUser TokenDto tokenDto, @RequestBody ResiActUserCancelSignUpFormDTO formDTO) { + ValidatorUtils.validateEntity(formDTO); + return actInfoService.cancelSignUp(tokenDto, formDTO); + } + + /** + * 重新定位 + * 根据活动id、前端传的实时经纬度,与活动设置的经纬度相比较,判断用户是否已到达打卡地点 + * + * @param formDTO + * @return javax.xml.transform.Result + * @Author zhangyong + * @Date 16:48 2020-07-20 + **/ + @PostMapping("checksigninaddress") + public Result cancelSignUp(@RequestBody ResiActCaculateDistanceFormDTO formDTO) { + ValidatorUtils.validateEntity(formDTO); + return actInfoService.checkSignInAddress(formDTO); + } + +} diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/TestController.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/TestController.java index 773e645d2c..a7ddd79e3b 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/TestController.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/TestController.java @@ -1,15 +1,17 @@ package com.epmet.controller; +import com.alibaba.fastjson.JSON; import com.epmet.commons.tools.annotation.LoginUser; +import com.epmet.commons.tools.dto.form.mq.MqBaseMsgDTO; import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.security.user.LoginUserUtil; +import com.epmet.commons.tools.utils.HttpClientManager; import com.epmet.commons.tools.utils.Result; +import com.epmet.commons.tools.utils.SendMqMsgUtils; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; import java.util.HashMap; import java.util.Map; @@ -23,15 +25,38 @@ import java.util.Map; @RestController @RequestMapping("demo") public class TestController { - private Logger logger = LogManager.getLogger(TestController.class); - @Autowired - private LoginUserUtil loginUserUtil; - @GetMapping("test") - public Result test(@LoginUser TokenDto tokenDto){ - Map map=new HashMap<>(); - String userId=loginUserUtil.getLoginUserId(); - map.put("TokenDto", tokenDto); - map.put("userId",userId); - return new Result().ok(map); - } + private Logger logger = LogManager.getLogger(TestController.class); + @Autowired + private LoginUserUtil loginUserUtil; + + @GetMapping("test") + public Result test(@LoginUser TokenDto tokenDto) { + Map map = new HashMap<>(); + String userId = loginUserUtil.getLoginUserId(); + map.put("TokenDto", tokenDto); + map.put("userId", userId); + return new Result().ok(map); + } + + @PostMapping("sendPointMsg") + public Result sendPointEvent(@RequestBody MqBaseMsgDTO mqBaseMsgDTO) { + Result result = SendMqMsgUtils.sendMsg(mqBaseMsgDTO); + logger.info("param:{},reult:{}", mqBaseMsgDTO, result); + return result; + } + + public static void main(String[] args) { + String url = "https://epmet-dev.elinkservice.cn/estos/producerService/producer/sendMsg"; + Map msgInfo = new HashMap(6); + msgInfo.put("appId", "202007161443499985fa2d397436d10356542134c8f008c48"); + //msgInfo.put("appName", "党群e事通开发测试"); + msgInfo.put("eventClass", "epmet_heart"); + msgInfo.put("eventTag", "active_send_point"); + msgInfo.put("msg", "我是消息体"); + //msgInfo.put("msgId", "123456"); + msgInfo.put("token", "52d9d9b0e7d0eb5b8b81c205b579e07c"); + String jsonStrParam = JSON.toJSONString(msgInfo); + Result result = HttpClientManager.getInstance().sendPostByHttps(url, jsonStrParam); + System.out.println("result:" + result + "param:" + jsonStrParam); + } } diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/WorkActDraftController.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/WorkActDraftController.java index c224a270a9..f69b65b065 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/WorkActDraftController.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/WorkActDraftController.java @@ -1,11 +1,13 @@ package com.epmet.controller; import com.epmet.commons.tools.utils.Result; -import com.epmet.dto.form.work.PublishActInitResultDTO; -import com.epmet.dto.result.work.LatestDraftActInfoResultDTO; +import com.epmet.commons.tools.validator.ValidatorUtils; +import com.epmet.dto.form.work.*; +import com.epmet.dto.result.work.*; import com.epmet.service.WorkActDraftService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @@ -60,4 +62,65 @@ public class WorkActDraftController { LatestDraftActInfoResultDTO resultDTO=workActDraftService.getLatestDraft(); return new Result().ok(resultDTO); } + + /** + * @return com.epmet.commons.tools.utils.Result + * @param formDTO + * @author yinzuomei + * @description 预览按下-调用此接口保存活动信息、活动内容 + * @Date 2020/7/21 14:00 + **/ + @PostMapping("saveact") + public Result saveAct(@RequestBody DraftActInfoFormDTO formDTO){ + //起码活动标题不能为空 + ValidatorUtils.validateEntity(formDTO, DraftActInfoFormDTO.AddDraftUserShowGroup.class, + DraftActInfoFormDTO.AddUserInternalGroup.class); + //如果录入了活动内容,需要校验 content、contentType + if (null != formDTO.getActContent() && formDTO.getActContent().size() > 0) { + for(DraftActContentFormDTO actContentFormDTO:formDTO.getActContent()){ + ValidatorUtils.validateEntity(actContentFormDTO, + DraftActContentFormDTO.UserShowGroup.class, + DraftActContentFormDTO.UserInternalGroup.class + ); + } + } + SaveActDraftResultDTO resultDTO=workActDraftService.saveAct(formDTO); + return new Result().ok(resultDTO); + } + + /** + * @return com.epmet.commons.tools.utils.Result + * @param formDTO + * @author yinzuomei + * @description 预览-查看活动详情 + * @Date 2020/7/21 17:24 + **/ + @PostMapping("preview") + public Result previewActDetail(@RequestBody ActPreviewFormDTO formDTO){ + ValidatorUtils.validateEntity(formDTO,ActPreviewFormDTO.UserInternalGroup.class); + ActPreviewResultDTO resultDTO=workActDraftService.previewActDetail(formDTO); + return new Result().ok(resultDTO); + } + + /** + * @param formDTO + * @return com.epmet.commons.tools.utils.Result + * @author yinzuomei + * @description 发布活动 + * @Date 2020/7/21 18:32 + **/ + @PostMapping("publish") + public Result publishAct(@RequestBody PublishActInfoFormDTO formDTO) { + ValidatorUtils.validateEntity(formDTO, PublishActInfoFormDTO.AddUserShowGroup.class, PublishActInfoFormDTO.AddUserInternalGroup.class); + for (PublishActContentFormDTO actContentFormDTO : formDTO.getActContent()) { + ValidatorUtils.validateEntity(actContentFormDTO, + PublishActContentFormDTO.UserShowGroup.class, + PublishActContentFormDTO.UserInternalGroup.class + ); + } + PublishActResultDTO resultDTO = workActDraftService.publishAct(formDTO); + return new Result().ok(resultDTO); + } + + } diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/WorkActUserController.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/WorkActUserController.java index 165c110b9d..514a73f1e4 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/WorkActUserController.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/WorkActUserController.java @@ -1,8 +1,18 @@ package com.epmet.controller; +import com.epmet.commons.tools.utils.Result; +import com.epmet.commons.tools.validator.ValidatorUtils; +import com.epmet.dto.form.work.AuditingActUserFormDTO; +import com.epmet.dto.result.work.AuditingActUserResultDTO; +import com.epmet.service.WorkActUserService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import java.util.List; + /** * 工作端:活动人员相关api * @@ -12,4 +22,21 @@ import org.springframework.web.bind.annotation.RestController; @RestController @RequestMapping("/work/actuser") public class WorkActUserController { + + @Autowired + private WorkActUserService workActUserService; + + /** + * @return com.epmet.commons.tools.utils.Result> + * @param formDTO + * @author yinzuomei + * @description 报名审核-待审核列表 + * @Date 2020/7/21 22:24 + **/ + @PostMapping("auditinglist") + public Result> getAuditingList(@RequestBody AuditingActUserFormDTO formDTO){ + ValidatorUtils.validateEntity(formDTO, AuditingActUserFormDTO.AddUserInternalGroup.class); + List list=workActUserService.getAuditingList(formDTO); + return new Result>().ok(list); + } } diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/ActCustomizedDao.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/ActCustomizedDao.java index 80a94700f9..440c2cb81f 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/ActCustomizedDao.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/ActCustomizedDao.java @@ -19,6 +19,7 @@ package com.epmet.dao; import com.epmet.commons.mybatis.dao.BaseDao; import com.epmet.dto.result.work.ActCustomizedResultDTO; +import com.epmet.dto.result.work.CustomerHeartConfigsResultDTO; import com.epmet.entity.ActCustomizedEntity; import org.apache.ibatis.annotations.Mapper; @@ -39,4 +40,13 @@ public interface ActCustomizedDao extends BaseDao { * @Date 2020/7/20 17:04 **/ ActCustomizedResultDTO selectConfigsByCustomerId(String customerId); + + /** + * @return com.epmet.dto.result.work.CustomerHeartConfigsResultDTO + * @param customerId + * @author yinzuomei + * @description 居民端根据客户id获取爱心互助自定义配置 + * @Date 2020/7/21 12:48 + **/ + CustomerHeartConfigsResultDTO selectCustomerHeartConfigs(String customerId); } \ No newline at end of file diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/ActInfoDao.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/ActInfoDao.java index a5cdb23ff9..ddd1dc1088 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/ActInfoDao.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/ActInfoDao.java @@ -18,8 +18,16 @@ package com.epmet.dao; import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.dto.ActInfoDTO; +import com.epmet.dto.form.resi.ResiActBaseFormDTO; +import com.epmet.dto.form.resi.ResiLatestActFormDTO; +import com.epmet.dto.form.resi.ResiMyActFormDTO; +import com.epmet.dto.result.resi.*; import com.epmet.entity.ActInfoEntity; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; /** * 活动信息 @@ -29,5 +37,141 @@ import org.apache.ibatis.annotations.Mapper; */ @Mapper public interface ActInfoDao extends BaseDao { - -} \ No newline at end of file + + /** + * 活动列表 - 报名中(未报满) - signing_up + * 列表排序第一组 无分页 + * @param formDTO + * @return java.util.List + * @Author zhangyong + * @Date 11:00 2020-07-20 + **/ + List selectListActSigningUp(ResiActBaseFormDTO formDTO); + + /** + * 活动列表 - (报名中),已报满 - enough + * 列表排序第二组 无分页 + * @param formDTO + * @return java.util.List + * @Author zhangyong + * @Date 11:00 2020-07-20 + **/ + List selectListActQuotaIsEnough(ResiActBaseFormDTO formDTO); + + /** + * 活动列表 - 截止报名 - end_sign_up + * 列表排序第三组 无分页 + * @param formDTO + * @return java.util.List + * @Author zhangyong + * @Date 11:00 2020-07-20 + **/ + List selectListActEndSignUp(ResiActBaseFormDTO formDTO); + + /** + * 活动列表 - 已开始 - in_progress + * 列表排序第四组 无分页 + * @param formDTO + * @return java.util.List + * @Author zhangyong + * @Date 11:00 2020-07-20 + **/ + List selectListActInProgress(ResiActBaseFormDTO formDTO); + + /** + * 活动列表 - 已结束 - finished + * 列表排序第四无组 分页 + * @param formDTO + * @return java.util.List + * @Author zhangyong + * @Date 11:00 2020-07-20 + **/ + List selectListActFinished(ResiActBaseFormDTO formDTO); + // 活动列表End + + /** + * 我的活动-审核中 + * + * @param formDTO + * @return java.util.List + * @Author zhangyong + * @Date 13:53 2020-07-20 + **/ + List selectListMyActAuditing(ResiMyActFormDTO formDTO); + + /** + * 我的活动-审核不通过 + * + * @param formDTO + * @return java.util.List + * @Author zhangyong + * @Date 13:53 2020-07-20 + **/ + List selectListActRefused(ResiMyActFormDTO formDTO); + + /** + * 我的活动-已通过 + * + * @param formDTO + * @return java.util.List + * @Author zhangyong + * @Date 13:53 2020-07-20 + **/ + List selectListActMyHavePassed(ResiMyActFormDTO formDTO); + + /** + * 我的活动-已结束 + * + * @param formDTO + * @return java.util.List + * @Author zhangyong + * @Date 13:53 2020-07-20 + **/ + List selectListMyActCanceld(ResiMyActFormDTO formDTO); + // 我的活动End + + /** + * 最新活动列表(未结束的、未取消的活动) + * @param formDTO + * @return java.util.List + * @Author zhangyong + * @Date 11:00 2020-07-20 + **/ + List selectListLatestAct(ResiLatestActFormDTO formDTO); + + /** + * 即将进行/正在进行中的活动 + * 进入活动的快捷入口,滚动显示 当前用户正在(或将要)进行的一条活动 + * 活动开始前1小时,此处展示:您报名的“情暖夕阳,爱在锦水”的活动还有xx分钟开始。 + * 活动开始后显示:正在进行中的活动:“情暖夕阳。。。 + * + * @param userId + * @return java.util.List + * @Author zhangyong + * @Date 11:00 2020-07-20 + **/ + List selectListInProgress(@Param("userId") String userId); + + /** + * 活动回顾列表 + * 已结束的活动,并且有实况或有回顾 + * 按照时间顺序排序 + * + * @param formDTO + * @return java.util.List + * @Author zhangyong + * @Date 11:00 2020-07-20 + **/ + List selectListLookBackAct(ResiActBaseFormDTO formDTO); + + /** + * 根据活动id、用户id 查询用户报名的活动信息 + * + * @param actId + * @param userId + * @return com.epmet.dto.ActInfoDTO + * @Author zhangyong + * @Date 17:39 2020-07-20 + **/ + ActInfoDTO queryActAccordingToActIdAndUserId(@Param("actId") String actId, @Param("userId") String userId); +} diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/ActUserRelationDao.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/ActUserRelationDao.java index 83aeabfc61..4054f2dda7 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/ActUserRelationDao.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/ActUserRelationDao.java @@ -18,9 +18,12 @@ package com.epmet.dao; import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.dto.ActUserRelationDTO; import com.epmet.entity.ActUserRelationEntity; import org.apache.ibatis.annotations.Mapper; +import java.util.List; + /** * 用户活动关系表 * @@ -29,5 +32,22 @@ import org.apache.ibatis.annotations.Mapper; */ @Mapper public interface ActUserRelationDao extends BaseDao { - + + /** + * @return java.util.List + * @param actId 活动id + * @author yinzuomei + * @description 根据活动id,查询待审核人员关系记录 + * @Date 2020/7/21 22:41 + **/ + List selectAuditingUserList(String actId); + + /** + * @return java.util.List + * @param actId 活动id + * @author yinzuomei + * @description 根据活动id,查询待审核人员,返回用户id集合 + * @Date 2020/7/21 22:45 + **/ + List selectAuditingUserIds(String actId); } \ No newline at end of file diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/HeartUserInfoDao.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/HeartUserInfoDao.java index 595e9178c0..8ec5974ac9 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/HeartUserInfoDao.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/HeartUserInfoDao.java @@ -18,6 +18,7 @@ package com.epmet.dao; import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.dto.HeartUserInfoDTO; import com.epmet.entity.HeartUserInfoEntity; import org.apache.ibatis.annotations.Mapper; @@ -29,5 +30,13 @@ import org.apache.ibatis.annotations.Mapper; */ @Mapper public interface HeartUserInfoDao extends BaseDao { - + + /** + * @return com.epmet.dto.HeartUserInfoDTO + * @param userId + * @author yinzuomei + * @description 根据用户id查询爱心用户记录 + * @Date 2020/7/21 22:48 + **/ + HeartUserInfoDTO selectByUserId(String userId); } \ No newline at end of file diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/LatestActContentDao.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/LatestActContentDao.java index 12568cd4e6..a0cbb2b6e5 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/LatestActContentDao.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/LatestActContentDao.java @@ -19,6 +19,7 @@ package com.epmet.dao; import com.epmet.commons.mybatis.dao.BaseDao; import com.epmet.dto.result.work.ActDraftContentDTOResultDTO; +import com.epmet.dto.result.work.ActPreviewContentResultDTO; import com.epmet.entity.LatestActContentEntity; import org.apache.ibatis.annotations.Mapper; @@ -50,4 +51,13 @@ public interface LatestActContentDao extends BaseDao { * @Date 2020/7/20 23:01 **/ List selectActContentList(String actId); + + /** + * @return java.util.List + * @param actId + * @author yinzuomei + * @description 预览-查看活动详情 + * @Date 2020/7/21 18:07 + **/ + List previewActContent(String actId); } \ No newline at end of file diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/LatestActInfoDao.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/LatestActInfoDao.java index 0cd96b4a67..d1a00cb15d 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/LatestActInfoDao.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/LatestActInfoDao.java @@ -18,6 +18,7 @@ package com.epmet.dao; import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.dto.result.work.ActPreviewResultDTO; import com.epmet.dto.result.work.LatestDraftActInfoResultDTO; import com.epmet.entity.LatestActInfoEntity; import org.apache.ibatis.annotations.Mapper; @@ -48,4 +49,13 @@ public interface LatestActInfoDao extends BaseDao { * @Date 2020/7/20 23:05 **/ LatestDraftActInfoResultDTO selectLatestActDraft(String userId); + + /** + * @return com.epmet.dto.result.work.ActPreviewResultDTO + * @param actDraftId + * @author yinzuomei + * @description 预览-查看活动详情 + * @Date 2020/7/21 17:56 + **/ + ActPreviewResultDTO previewActInfo(String actDraftId); } \ No newline at end of file diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/entity/ActInfoEntity.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/entity/ActInfoEntity.java index c92f1733b2..7681415b68 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/entity/ActInfoEntity.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/entity/ActInfoEntity.java @@ -127,7 +127,7 @@ public class ActInfoEntity extends BaseEpmetEntity { /** * 活动名额类型(0-不限名额,1-固定名额) */ - private Integer actQuotaCategory; + private Boolean actQuotaCategory; /** * 活动名额 diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/entity/ActOperationRecEntity.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/entity/ActOperationRecEntity.java index fe794c6422..aef5e68fe0 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/entity/ActOperationRecEntity.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/entity/ActOperationRecEntity.java @@ -18,13 +18,10 @@ package com.epmet.entity; import com.baomidou.mybatisplus.annotation.TableName; - import com.epmet.commons.mybatis.entity.BaseEpmetEntity; import lombok.Data; import lombok.EqualsAndHashCode; -import java.util.Date; - /** * 活动操作日志表 * @@ -54,6 +51,6 @@ public class ActOperationRecEntity extends BaseEpmetEntity { /** * 1通知用户0不通知 */ - private Integer noticeUser; + private Boolean noticeUser; } diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/entity/HeartUserInfoEntity.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/entity/HeartUserInfoEntity.java index 97c1e1da4d..c7b90074b1 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/entity/HeartUserInfoEntity.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/entity/HeartUserInfoEntity.java @@ -18,13 +18,10 @@ package com.epmet.entity; import com.baomidou.mybatisplus.annotation.TableName; - import com.epmet.commons.mybatis.entity.BaseEpmetEntity; import lombok.Data; import lombok.EqualsAndHashCode; -import java.util.Date; - /** * 用户信息 * @@ -51,7 +48,7 @@ public class HeartUserInfoEntity extends BaseEpmetEntity { /** * 1是志愿者,0不是志愿者(志愿者注册成功后需要来更新值) */ - private Integer volunteerFlag; + private Boolean volunteerFlag; /** * 爱心时长(单位:分钟)(参与并签到了的活动,实际结束-实际开始)签到的。未签到但是有积分的 diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/ActCustomizedService.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/ActCustomizedService.java index 3d539c4076..7c56084f81 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/ActCustomizedService.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/ActCustomizedService.java @@ -23,6 +23,7 @@ import com.epmet.dto.ActCustomizedDTO; import com.epmet.dto.form.work.ActCustomizedFormDTO; import com.epmet.dto.form.work.SaveActCustomizedFormDTO; import com.epmet.dto.result.work.ActCustomizedResultDTO; +import com.epmet.dto.result.work.CustomerHeartConfigsResultDTO; import com.epmet.entity.ActCustomizedEntity; import java.util.List; @@ -113,4 +114,13 @@ public interface ActCustomizedService extends BaseService { * @Date 2020/7/20 17:26 **/ void saveConfigs(SaveActCustomizedFormDTO formDTO); + + /** + * @return com.epmet.dto.result.work.CustomerHeartConfigsResultDTO + * @param formDTO + * @author yinzuomei + * @description 居民端根据客户id获取爱心互助自定义配置 + * @Date 2020/7/21 12:47 + **/ + CustomerHeartConfigsResultDTO getCustomerHeartConfigs(ActCustomizedFormDTO formDTO); } \ No newline at end of file diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/ActInfoService.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/ActInfoService.java index 3f948abe52..32c0978916 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/ActInfoService.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/ActInfoService.java @@ -19,9 +19,13 @@ package com.epmet.service; import com.epmet.commons.mybatis.service.BaseService; import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.dto.ActInfoDTO; +import com.epmet.dto.form.resi.*; +import com.epmet.dto.result.resi.*; import com.epmet.entity.ActInfoEntity; +import com.epmet.commons.tools.utils.Result; import java.util.List; import java.util.Map; @@ -92,4 +96,109 @@ public interface ActInfoService extends BaseService { * @date 2020-07-19 */ void delete(String[] ids); -} \ No newline at end of file + + /** + * 根据活动id、前端传的实时经纬度,与活动设置的经纬度相比较,判断用户是否已到达打卡地点 + * @param fromDTO + * @return javax.xml.transform.Result + * @Author zhangyong + * @Date 16:48 2020-07-20 + **/ + Result checkSignInAddress(ResiActCaculateDistanceFormDTO fromDTO); + + /** + * 活动列表(包含状态:报名中:signing_up;已报满:enough;截止报名: end_sign_up; 已开始: in_progress; 已结束:finished;) + * + * @param tokenDto + * @param formDto + * @return com.epmet.commons.tools.utils.Result> + * @Author zhangyong + * @Date 13:39 2020-07-21 + **/ + Result> listAct(TokenDto tokenDto, ResiActBaseFormDTO formDto); + + /* + * 我的活动-审核中 + * + * @param tokenDto + * @param formDto + * @return com.epmet.commons.tools.utils.Result> + * @Author zhangyong + * @Date 14:15 2020-07-21 + **/ + Result> myActListAuditing(TokenDto tokenDto, ResiMyActFormDTO formDto); + + /* + * 我的活动-未通过 + * + * @param tokenDto + * @param formDto + * @return com.epmet.commons.tools.utils.Result> + * @Author zhangyong + * @Date 14:15 2020-07-21 + **/ + Result> myActListRefused(TokenDto tokenDto, ResiMyActFormDTO formDto); + + /* + * 我的活动-已通过 + * + * @param tokenDto + * @param formDto + * @return com.epmet.commons.tools.utils.Result> + * @Author zhangyong + * @Date 14:15 2020-07-21 + **/ + Result> myActListPassed(TokenDto tokenDto, ResiMyActFormDTO formDto); + + /* + * 我的活动-已结束 + * + * @param tokenDto + * @param formDto + * @return com.epmet.commons.tools.utils.Result> + * @Author zhangyong + * @Date 14:15 2020-07-21 + **/ + Result> myActListCanceld(TokenDto tokenDto, ResiMyActFormDTO formDto); + + /** + * 最新活动列表 + * + * @param formDto + * @return java.util.List + * @Author zhangyong + * @Date 13:53 2020-07-21 + **/ + Result> latestAct(ResiLatestActFormDTO formDto); + + /** + * 正在进行中的活动 + * 进入活动的快捷入口, 前端只取第一条 + * + * @param tokenDto + * @return com.epmet.commons.tools.utils.Result> + * @Author zhangyong + * @Date 15:00 2020-07-21 + **/ + Result> inProgressAct(TokenDto tokenDto); + + /** + * 活动回顾列表(包含状态:已结束:finished;) + * @param formDTO + * @return com.epmet.commons.tools.utils.Result> + * @Author zhangyong + * @Date 13:39 2020-07-21 + **/ + Result> actLookBack(ResiActBaseFormDTO formDTO); + + /** + * 取消活动报名 + * + * @param tokenDto + * @param formDTO + * @return com.epmet.commons.tools.utils.Result + * @Author zhangyong + * @Date 09:29 2020-07-20 + **/ + Result cancelSignUp(TokenDto tokenDto, ResiActUserCancelSignUpFormDTO formDTO); +} diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/ActUserRelationService.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/ActUserRelationService.java index 1def3fd939..f0d0fe7d5b 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/ActUserRelationService.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/ActUserRelationService.java @@ -92,4 +92,22 @@ public interface ActUserRelationService extends BaseService + * @param actId + * @author yinzuomei + * @description 根据活动id,查询待审核人员关系记录 + * @Date 2020/7/21 22:40 + **/ + List getAuditingUserList(String actId); + + /** + * @return java.util.List + * @param actId + * @author yinzuomei + * @description 根据活动id,查询待审核人员,返回用户id集合 + * @Date 2020/7/21 22:44 + **/ + List getAuditingUserIds(String actId); } \ No newline at end of file diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/HeartUserInfoService.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/HeartUserInfoService.java index 59427d9848..ba77b11ed9 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/HeartUserInfoService.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/HeartUserInfoService.java @@ -92,4 +92,13 @@ public interface HeartUserInfoService extends BaseService { * @date 2020-07-19 */ void delete(String[] ids); + + /** + * @return com.epmet.dto.HeartUserInfoDTO + * @param userId + * @author yinzuomei + * @description 根据用户id查询爱心用户记录 + * @Date 2020/7/21 22:48 + **/ + HeartUserInfoDTO getByUserId(String userId); } \ No newline at end of file diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/LatestActContentService.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/LatestActContentService.java index cc56738beb..39a067055f 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/LatestActContentService.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/LatestActContentService.java @@ -21,6 +21,7 @@ import com.epmet.commons.mybatis.service.BaseService; import com.epmet.commons.tools.page.PageData; import com.epmet.dto.LatestActContentDTO; import com.epmet.dto.result.work.ActDraftContentDTOResultDTO; +import com.epmet.dto.result.work.ActPreviewContentResultDTO; import com.epmet.entity.LatestActContentEntity; import java.util.List; @@ -74,6 +75,16 @@ public interface LatestActContentService extends BaseService dtoList); + /** * 默认更新 * @@ -111,4 +122,13 @@ public interface LatestActContentService extends BaseService selectActContentList(String actId); + + /** + * @return java.util.List + * @param actDraftId latest_act_info主键 + * @author yinzuomei + * @description 预览-查看活动详情 + * @Date 2020/7/21 17:47 + **/ + List previewActContent(String actDraftId); } \ No newline at end of file diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/LatestActInfoService.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/LatestActInfoService.java index 347fe62c5b..0102ea76ee 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/LatestActInfoService.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/LatestActInfoService.java @@ -20,6 +20,7 @@ package com.epmet.service; import com.epmet.commons.mybatis.service.BaseService; import com.epmet.commons.tools.page.PageData; import com.epmet.dto.LatestActInfoDTO; +import com.epmet.dto.result.work.ActPreviewResultDTO; import com.epmet.dto.result.work.LatestDraftActInfoResultDTO; import com.epmet.entity.LatestActInfoEntity; @@ -74,6 +75,16 @@ public interface LatestActInfoService extends BaseService { */ void save(LatestActInfoDTO dto); + /** + * 默认保存,返回主键 + * + * @param dto + * @return void + * @author generator + * @date 2020-07-19 + */ + String saveOrUpdateLatestActInfoDTO(LatestActInfoDTO dto); + /** * 默认更新 * @@ -120,4 +131,13 @@ public interface LatestActInfoService extends BaseService { * @Date 2020/7/20 22:59 **/ LatestDraftActInfoResultDTO getLatestActDraft(String userId); + + /** + * @return com.epmet.dto.result.work.ActPreviewResultDTO + * @param actDraftId latest_act_info主键 + * @author yinzuomei + * @description 预览-查看活动详情 + * @Date 2020/7/21 17:45 + **/ + ActPreviewResultDTO previewActInfo(String actDraftId); } \ No newline at end of file diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/WorkActDraftService.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/WorkActDraftService.java index 016a8e9564..e08b1671e4 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/WorkActDraftService.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/WorkActDraftService.java @@ -1,7 +1,9 @@ package com.epmet.service; -import com.epmet.dto.form.work.PublishActInitResultDTO; -import com.epmet.dto.result.work.LatestDraftActInfoResultDTO; +import com.epmet.dto.form.work.ActPreviewFormDTO; +import com.epmet.dto.form.work.DraftActInfoFormDTO; +import com.epmet.dto.form.work.PublishActInfoFormDTO; +import com.epmet.dto.result.work.*; /** * 工作端活动草稿 @@ -37,4 +39,31 @@ public interface WorkActDraftService { * @Date 2020/7/20 22:29 **/ LatestDraftActInfoResultDTO getLatestDraft(); + + /** + * @return com.epmet.dto.result.work.SaveActDraftResultDTO + * @param formDTO + * @author yinzuomei + * @description 预览按下-调用此接口保存活动信息、活动内容 + * @Date 2020/7/21 14:00 + **/ + SaveActDraftResultDTO saveAct(DraftActInfoFormDTO formDTO); + + /** + * @return com.epmet.dto.result.work.ActPreviewResultDTO + * @param formDTO + * @author yinzuomei + * @description 预览-查看活动详情 + * @Date 2020/7/21 17:24 + **/ + ActPreviewResultDTO previewActDetail(ActPreviewFormDTO formDTO); + + /** + * @return com.epmet.dto.result.work.PublishActResultDTO + * @param formDTO + * @author yinzuomei + * @description 发布活动 + * @Date 2020/7/21 18:33 + **/ + PublishActResultDTO publishAct(PublishActInfoFormDTO formDTO); } diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/WorkActUserService.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/WorkActUserService.java new file mode 100644 index 0000000000..a11d56794d --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/WorkActUserService.java @@ -0,0 +1,23 @@ +package com.epmet.service; + +import com.epmet.dto.form.work.AuditingActUserFormDTO; +import com.epmet.dto.result.work.AuditingActUserResultDTO; + +import java.util.List; + +/** + * 工作端:活动人员相关api + * + * @author yinzuomei@elink-cn.com + * @date 2020/7/21 22:23 + */ +public interface WorkActUserService { + /** + * @return java.util.List + * @param formDTO + * @author yinzuomei + * @description 报名审核-待审核列表 + * @Date 2020/7/21 22:25 + **/ + List getAuditingList(AuditingActUserFormDTO formDTO); +} diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/ActCustomizedServiceImpl.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/ActCustomizedServiceImpl.java index d3f5539d70..1ecc24fc9b 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/ActCustomizedServiceImpl.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/ActCustomizedServiceImpl.java @@ -29,6 +29,7 @@ import com.epmet.dto.ActCustomizedDTO; import com.epmet.dto.form.work.ActCustomizedFormDTO; import com.epmet.dto.form.work.SaveActCustomizedFormDTO; import com.epmet.dto.result.work.ActCustomizedResultDTO; +import com.epmet.dto.result.work.CustomerHeartConfigsResultDTO; import com.epmet.entity.ActCustomizedEntity; import com.epmet.redis.ActCustomizedRedis; import com.epmet.service.ActCustomizedService; @@ -130,6 +131,7 @@ public class ActCustomizedServiceImpl extends BaseServiceImpl page(Map params) { IPage page = baseDao.selectPage( @@ -101,4 +114,104 @@ public class ActInfoServiceImpl extends BaseServiceImpl> listAct(TokenDto tokenDto, ResiActBaseFormDTO formDto) { + List list = new ArrayList<>(); + formDto.setUserId(tokenDto.getUserId()); + // 查询活动状态是:报名中 signing_up + List signingUp = baseDao.selectListActSigningUp(formDto); + list.addAll(signingUp); + + // 查询活动状态是:已报满 enough + List enough = baseDao.selectListActQuotaIsEnough(formDto); + list.addAll(enough); + + // 查询活动状态是:截止报名 end_sign_up + List endSignUp = baseDao.selectListActEndSignUp(formDto); + list.addAll(endSignUp); + + // 查询活动状态是:已开始 in_progress + List inProgress = baseDao.selectListActInProgress(formDto); + list.addAll(inProgress); + + // 查询活动状态是:已结束 finished + int pageIndex = (formDto.getPageNo() - NumConstant.ONE) * formDto.getPageSize(); + formDto.setPageNo(pageIndex); + List finished = baseDao.selectListActFinished(formDto); + list.addAll(finished); + return new Result>().ok(list); + } + + @Override + public Result> myActListAuditing(TokenDto tokenDto, ResiMyActFormDTO formDto) { + formDto.setUserId(tokenDto.getUserId()); + List myAct = baseDao.selectListMyActAuditing(formDto); + return new Result>().ok(myAct); + } + + @Override + public Result> myActListRefused(TokenDto tokenDto, ResiMyActFormDTO formDto) { + formDto.setUserId(tokenDto.getUserId()); + List myAct = baseDao.selectListActRefused(formDto); + return new Result>().ok(myAct); + } + + @Override + public Result> myActListPassed(TokenDto tokenDto, ResiMyActFormDTO formDto) { + formDto.setUserId(tokenDto.getUserId()); + List myAct = baseDao.selectListActMyHavePassed(formDto); + return new Result>().ok(myAct); + } + + @Override + public Result> myActListCanceld(TokenDto tokenDto, ResiMyActFormDTO formDto) { + formDto.setUserId(tokenDto.getUserId()); + List myAct = baseDao.selectListMyActCanceld(formDto); + return new Result>().ok(myAct); + } + + @Override + public Result> latestAct(ResiLatestActFormDTO formDto) { + List latest = baseDao.selectListLatestAct(formDto); + return new Result>().ok(latest); + } + + @Override + public Result> inProgressAct(TokenDto tokenDto) { + List inProgress = baseDao.selectListInProgress(tokenDto.getUserId()); + return new Result>().ok(inProgress); + } + + @Override + public Result> actLookBack(ResiActBaseFormDTO formDTO) { + List lookBackAct = baseDao.selectListLookBackAct(formDTO); + return new Result>().ok(lookBackAct); + } + + @Override + public Result cancelSignUp(TokenDto tokenDto, ResiActUserCancelSignUpFormDTO formDTO) { + // 判断用户是否已报名该活动 + ActInfoDTO actInfoDTO = baseDao.queryActAccordingToActIdAndUserId(formDTO.getActId(),formDTO.getUserId()); +// if (null == actInfoDTO){ +// throw new RenException(EpmetErrorCode.NO_ACT_TO_CANCEL_SIGN_UP_WERE_FOUND.getCode()); +// } + //1、更新用户活动关系表 +// relationService.update(); + //2、插入用户活动关系日志表 + //3、更新act_info的已报名名额 + return null; + } + + @Override + public Result checkSignInAddress(ResiActCaculateDistanceFormDTO formDTO) { + // 根据活动id,查询活动基本信息 + ActInfoEntity entity = baseDao.selectById(formDTO.getActId()); + Double distance = CaculateDistance.getDistance(formDTO.getLongitude(),formDTO.getLatitude(),entity.getActLongitude().doubleValue(),entity.getActLatitude().doubleValue()); +// if (distance <= entity.getSigninRadius()){ +// return new Result(); +// } else { +// throw new RenException(EpmetErrorCode.NOT_IN_THE_SIGN_IN_RANGE.getCode()); +// } + return new Result(); + } +} diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/ActUserRelationServiceImpl.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/ActUserRelationServiceImpl.java index 214fd7b76c..0979dc568d 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/ActUserRelationServiceImpl.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/ActUserRelationServiceImpl.java @@ -101,4 +101,28 @@ public class ActUserRelationServiceImpl extends BaseServiceImpl + * @author yinzuomei + * @description 根据活动id,查询待审核人员关系记录 + * @Date 2020/7/21 22:40 + **/ + @Override + public List getAuditingUserList(String actId) { + return baseDao.selectAuditingUserList(actId); + } + + /** + * @param actId + * @return java.util.List + * @author yinzuomei + * @description 根据活动id,查询待审核人员,返回用户id集合 + * @Date 2020/7/21 22:44 + **/ + @Override + public List getAuditingUserIds(String actId) { + return baseDao.selectAuditingUserIds(actId); + } + } \ No newline at end of file diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/HeartUserInfoServiceImpl.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/HeartUserInfoServiceImpl.java index 61506b7e6f..3b7aa9f2c9 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/HeartUserInfoServiceImpl.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/HeartUserInfoServiceImpl.java @@ -101,4 +101,16 @@ public class HeartUserInfoServiceImpl extends BaseServiceImpl dtoList) { + //先删除之前的 + this.deleteByActId(dtoList.get(0).getActId()); + //再插入新的 + for(LatestActContentDTO dto:dtoList){ + LatestActContentEntity entity = ConvertUtils.sourceToTarget(dto, LatestActContentEntity.class); + insert(entity); + } + } + @Override @Transactional(rollbackFor = Exception.class) public void update(LatestActContentDTO dto) { @@ -112,6 +125,7 @@ public class LatestActContentServiceImpl extends BaseServiceImpl + * @author yinzuomei + * @description 预览-查看活动详情 + * @Date 2020/7/21 17:47 + **/ + @Override + public List previewActContent(String actId) { + return baseDao.previewActContent(actId); + } + } \ No newline at end of file diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/LatestActInfoServiceImpl.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/LatestActInfoServiceImpl.java index ee6022f70b..fb1a572fde 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/LatestActInfoServiceImpl.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/LatestActInfoServiceImpl.java @@ -26,6 +26,7 @@ import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.dao.LatestActInfoDao; import com.epmet.dto.LatestActInfoDTO; +import com.epmet.dto.result.work.ActPreviewResultDTO; import com.epmet.dto.result.work.LatestDraftActInfoResultDTO; import com.epmet.entity.LatestActInfoEntity; import com.epmet.redis.LatestActInfoRedis; @@ -92,6 +93,19 @@ public class LatestActInfoServiceImpl extends BaseServiceImpl actContentList=latestActContentService.selectActContentList(latestAct.getActDraftId()); latestAct.setActContentList(actContentList); } + return latestAct; }else{ logger.warn("loginUserUtil.getLoginUserId()获取当前用户id为空"); } return null; } + + /** + * @param formDTO + * @return com.epmet.dto.result.work.SaveActDraftResultDTO + * @author yinzuomei + * @description 预览按下-调用此接口保存活动信息、活动内容 + * @Date 2020/7/21 14:00 + **/ + @Override + public SaveActDraftResultDTO saveAct(DraftActInfoFormDTO formDTO) { + //保存活动属性 + LatestActInfoDTO latestActInfoDTO=this.constructLatestActInfoDTO(formDTO); + //如果存在草稿id,则更新 + String actDraftId=latestActInfoService.saveOrUpdateLatestActInfoDTO(latestActInfoDTO); + if(null!=formDTO.getActContent()&&formDTO.getActContent().size()>0){ + //保存活动内容 + List actContentList=this.constructLatestActContent(formDTO.getActContent(),actDraftId); + //删除之前的内容 + latestActContentService.saveLatestActContentDTOList(actContentList); + } + SaveActDraftResultDTO resultDTO=new SaveActDraftResultDTO(); + resultDTO.setActDraftId(actDraftId); + return resultDTO; + } + + /** + * @param formDTO + * @return com.epmet.dto.result.work.ActPreviewResultDTO + * @author yinzuomei + * @description 预览-查看活动详情 + * @Date 2020/7/21 17:24 + **/ + @Override + public ActPreviewResultDTO previewActDetail(ActPreviewFormDTO formDTO) { + ActPreviewResultDTO actPreviewResultDTO = latestActInfoService.previewActInfo(formDTO.getActDraftId()); + if (null != actPreviewResultDTO) { + List actContent = latestActContentService.previewActContent(formDTO.getActDraftId()); + if (null != actContent && actContent.size() > 0) { + actPreviewResultDTO.setActContent(actContent); + } + } + return actPreviewResultDTO; + } + + /** + * @param formDTO + * @return com.epmet.dto.result.work.PublishActResultDTO + * @author yinzuomei + * @description 发布活动 + * @Date 2020/7/21 18:33 + **/ + @Override + @Transactional(rollbackFor = Exception.class) + public PublishActResultDTO publishAct(PublishActInfoFormDTO formDTO) { + PublishActResultDTO publishActResultDTO=new PublishActResultDTO(); + //内容审核(活动标题、招募要求、活动内容图文) + this.auditAct(formDTO); + logger.info("发布活动,审核成功"); + + //构造属性保存活动属性,活动内容 + ActInfoEntity actInfoEntity=this.constructActInfo(formDTO); + actInfoDao.insert(actInfoEntity); + + List actContentEntityList=this.constructActContent(formDTO.getActContent(),actInfoEntity.getId()); + for(ActContentEntity actContentEntity:actContentEntityList){ + actContentDao.insert(actContentEntity); + } + //插入一条操作日志 + ActOperationRecEntity actOperationRecEntity=new ActOperationRecEntity(); + actOperationRecEntity.setActId(actInfoEntity.getId()); + actOperationRecEntity.setType(ActConstant.ACT_OPER_TYPE_PUBLISH); + actOperationRecEntity.setNoticeUser(false); + actOperationRecDao.insert(actOperationRecEntity); + + //删除所有的草稿 + this.deleteDraft(); + publishActResultDTO.setActId(actInfoEntity.getId()); + + return publishActResultDTO; + } + + /** + * @return com.epmet.entity.ActInfoEntity + * @param formDTO + * @author yinzuomei + * @description 发布活动-构造act_info + * @Date 2020/7/21 20:00 + **/ + private ActInfoEntity constructActInfo(PublishActInfoFormDTO formDTO) { + ActInfoEntity actInfoEntity = ConvertUtils.sourceToTarget(formDTO, ActInfoEntity.class); + //活动名额类型(0-不限名额,1-固定名额) + if(actInfoEntity.getActQuota()==0){ + actInfoEntity.setActQuotaCategory(false); + }else{ + actInfoEntity.setActQuotaCategory(true); + } + actInfoEntity.setSignUpStartTime(new Date()); + actInfoEntity.setActStatus(ActConstant.ACT_STATUS_PUBLISHED); + + //1已经总结0未总结 + actInfoEntity.setSummaryFlag(false); + if(ActConstant.SPONSOR_AGENCY.equals(actInfoEntity.getSponsorType())){ + //调用gov_org服务获取当前组织的上一级机关id TODO + Result result=govOrgOpenFeignClient.getAgencyById(formDTO.getSponsorId()); + if(result.success()&&null!=result.getData()){ + actInfoEntity.setPid(result.getData().getPid()); + }else{ + logger.warn("根据agencyId查询组织信息失败,agencyId=",formDTO.getSponsorId()); + } + }else{ + actInfoEntity.setPid(""); + } + return actInfoEntity; + } + + /** + * @return java.util.List + * @param actContent + * @param actId + * @author yinzuomei + * @description 发布活动-构造活动详情act_content + * @Date 2020/7/21 19:59 + **/ + private List constructActContent(List actContent, String actId) { + List list=new ArrayList<>(); + int orderNum=1; + for(PublishActContentFormDTO actContentFormDTO:actContent){ + ActContentEntity actContentEntity=new ActContentEntity(); + actContentEntity.setActId(actId); + actContentEntity.setContent(actContentFormDTO.getContent()); + actContentEntity.setContentType(actContentFormDTO.getContentType()); + actContentEntity.setOrderNum(orderNum); + list.add(actContentEntity); + orderNum++; + } + return list; + } + + /** + * @return void + * @param formDTO + * @author yinzuomei + * @description 活动相关内容审核(活动标题、招募要求、活动内容图文) + * @Date 2020/7/21 19:20 + **/ + private void auditAct(PublishActInfoFormDTO formDTO) { + //1、活动标题 + if (StringUtils.isNotBlank(formDTO.getTitle())) { + this.auditActTitle(formDTO.getTitle()); + } + //2、活动封面 + if(StringUtils.isNotBlank(formDTO.getCoverPic())){ + this.auditActCoverPic(formDTO.getCoverPic()); + } + + //3、招募要求 + if (StringUtils.isNotBlank(formDTO.getRequirement())) { + this.auditActRequirement(formDTO.getRequirement()); + } + //4、活动内容 + if(null==formDTO.getActContent()||formDTO.getActContent().size()<1){ + return; + } + List textList=new ArrayList<>(); + List imgList=new ArrayList<>(); + for(PublishActContentFormDTO actContent:formDTO.getActContent()){ + if(ActConstant.ACT_CONTENT_TYPE_TEXT.equals(actContent.getContentType())){ + textList.add(actContent.getContent()); + }else if(ActConstant.ACT_CONTENT_TYPE_IMG.equals(actContent.getContentType())){ + imgList.add(actContent.getContent()); + } + } + this.auditActContent(textList,imgList); + } + + /** + * @return void + * @param textList + * @param imgList + * @author yinzuomei + * @description 活动详情审核 + * @Date 2020/7/21 19:21 + **/ + private void auditActContent(List textList, List imgList) { + //审核活动详情中的内容 + if(null!=textList&&textList.size()>0){ + TextScanParamDTO textScanParamDTO = new TextScanParamDTO(); + textList.forEach(content -> { + TextTaskDTO taskDTO = new TextTaskDTO(); + taskDTO.setContent(content); + taskDTO.setDataId(UUID.randomUUID().toString().replace("-", "")); + textScanParamDTO.getTasks().add(taskDTO); + }); + Result contentSyncScanRes = ScanContentUtils.textSyncScan(scanApiUrl.concat(textSyncScanMethod), textScanParamDTO); + if (!contentSyncScanRes.success()) { + logger.error("活动详情内容审核接口失败,返参:", JSON.toJSONString(contentSyncScanRes)); + throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode()); + } else { + if (!contentSyncScanRes.getData().isAllPass()) { + throw new RenException(EpmetErrorCode.ACT_REQ_SCAN_FAILED.getCode()); + } + } + logger.info("活动详情内容审核成功"); + } + if(null!=imgList&&imgList.size()>0){ + //审核活动详情中的图片 + ImgScanParamDTO imgScanParamDTO = new ImgScanParamDTO(); + imgList.forEach(url -> { + ImgTaskDTO task = new ImgTaskDTO(); + task.setDataId(UUID.randomUUID().toString().replace("-", "")); + task.setUrl(url); + imgScanParamDTO.getTasks().add(task); + }); + Result imgScanResult = ScanContentUtils.imgSyncScan(scanApiUrl.concat(imgSyncScanMethod), imgScanParamDTO); + if (!imgScanResult.success()){ + logger.error("活动详情图片审核接口失败,返参:", JSON.toJSONString(imgScanResult)); + throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode()); + } else { + if (!imgScanResult.getData().isAllPass()) { + throw new RenException(EpmetErrorCode.ACT_CONTENT_IMG_SCAN_FAILED.getCode()); + } + } + logger.info("活动详情图片审核成功"); + } + } + + /** + * @return void + * @param requirement + * @author yinzuomei + * @description 活动招募条件审核 + * @Date 2020/7/21 19:21 + **/ + private void auditActRequirement(String requirement) { + TextScanParamDTO textScanParamDTO = new TextScanParamDTO(); + TextTaskDTO taskDTO = new TextTaskDTO(); + taskDTO.setContent(requirement); + taskDTO.setDataId(UUID.randomUUID().toString().replace("-", "")); + textScanParamDTO.getTasks().add(taskDTO); + Result textSyncScanResult = ScanContentUtils.textSyncScan(scanApiUrl.concat(textSyncScanMethod), textScanParamDTO); + if (!textSyncScanResult.success()) { + logger.error("活动报名条件审核接口返回失败,返参:", JSON.toJSONString(textSyncScanResult)); + throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode()); + } else { + if (!textSyncScanResult.getData().isAllPass()) { + logger.error("活动报名条件审核失败,报名条件:",requirement); + throw new RenException(EpmetErrorCode.ACT_REQ_SCAN_FAILED.getCode()); + } + } + logger.info("活动报名条件审核成功"); + } + + /** + * @return void + * @param coverPic + * @author yinzuomei + * @description 活动封面图片审核 + * @Date 2020/7/21 19:21 + **/ + private void auditActCoverPic(String coverPic) { + ImgScanParamDTO coverPicScanParamDTO = new ImgScanParamDTO(); + ImgTaskDTO coverImgtask = new ImgTaskDTO(); + coverImgtask.setDataId(UUID.randomUUID().toString().replace("-", "")); + coverImgtask.setUrl(coverPic); + coverPicScanParamDTO.getTasks().add(coverImgtask); + Result coverPicScanRes = ScanContentUtils.imgSyncScan(scanApiUrl.concat(imgSyncScanMethod), coverPicScanParamDTO); + if (!coverPicScanRes.success()){ + logger.error("活动封面审核失败接口返回失败,返参:",JSON.toJSONString(coverPicScanRes)); + throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode()); + } else { + if (!coverPicScanRes.getData().isAllPass()) { + logger.error("活动封面审核失败,封面图片地址:",coverPic); + throw new RenException(EpmetErrorCode.ACT_COVER_PIC_SCAN_FAILED.getCode()); + } + } + logger.info("活动封面审核成功"); + } + + /** + * @return void + * @param title + * @author yinzuomei + * @description 活动标题审核 + * @Date 2020/7/21 19:21 + **/ + private void auditActTitle(String title) { + TextScanParamDTO textScanParamDTO = new TextScanParamDTO(); + TextTaskDTO taskDTO = new TextTaskDTO(); + taskDTO.setContent(title); + taskDTO.setDataId(UUID.randomUUID().toString().replace("-", "")); + textScanParamDTO.getTasks().add(taskDTO); + Result textSyncScanResult = ScanContentUtils.textSyncScan(scanApiUrl.concat(textSyncScanMethod), textScanParamDTO); + if (!textSyncScanResult.success()) { + logger.error("活动标题审核接口返回失败,返参:", JSON.toJSONString(textSyncScanResult)); + throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode()); + } else { + if (!textSyncScanResult.getData().isAllPass()) { + logger.error("活动标题审核失败,标题内容:",title); + throw new RenException(EpmetErrorCode.ACT_TITLE_SCAN_FAILED.getCode()); + } + } + logger.info("活动标题审核通过"); + } + + /** + * @return java.util.List + * @param actContent + * @param actDraftId + * @author yinzuomei + * @description 保存草稿- 构造latest_act_content + * @Date 2020/7/21 19:22 + **/ + private List constructLatestActContent(List actContent,String actDraftId) { + List list=new ArrayList<>(); + int orderNum=1; + for(DraftActContentFormDTO actContentFormDTO:actContent){ + LatestActContentDTO latestAct=new LatestActContentDTO(); + latestAct.setActId(actDraftId); + latestAct.setContent(actContentFormDTO.getContent()); + latestAct.setContentType(actContentFormDTO.getContentType()); + latestAct.setOrderNum(orderNum); + list.add(latestAct); + orderNum++; + } + return list; + } + + /** + * @return com.epmet.dto.LatestActInfoDTO + * @param formDTO + * @author yinzuomei + * @description 保存草稿- 构造latest_act_info + * @Date 2020/7/21 19:22 + **/ + private LatestActInfoDTO constructLatestActInfoDTO(DraftActInfoFormDTO formDTO) { + LatestActInfoDTO latestActInfoDTO=new LatestActInfoDTO(); + if(StringUtils.isNotBlank(formDTO.getActDraftId())){ + logger.info("修改活动草稿actDraftId",formDTO.getActDraftId()); + latestActInfoDTO.setId(formDTO.getActDraftId()); + } + latestActInfoDTO.setCustomerId(formDTO.getCustomerId()); + //活动标题 + latestActInfoDTO.setTitle(formDTO.getTitle()); + //活动封面 + latestActInfoDTO.setCoverPic(formDTO.getCoverPic()); + //报名开始时间latestActInfoDTO.setSignUpStartTime(new Date()); + //报名截止时间 + if(StringUtils.isNotBlank(formDTO.getSignUpEndTime())){ + Date signUpEndTime= DateUtils.minStrToSecondDate(formDTO.getSignUpEndTime()); + latestActInfoDTO.setSignUpEndTime(signUpEndTime); + } + //招募要求 + latestActInfoDTO.setRequirement(formDTO.getRequirement()); + //活动预计开始时间 + if(StringUtils.isNotBlank(formDTO.getActStartTime())){ + Date actStartTime= DateUtils.minStrToSecondDate(formDTO.getActStartTime()); + latestActInfoDTO.setActStartTime(actStartTime); + } + //活动预计结束时间 + if(StringUtils.isNotBlank(formDTO.getActEndTime())){ + Date actEndTime=DateUtils.minStrToSecondDate(formDTO.getActEndTime()); + latestActInfoDTO.setActEndTime(actEndTime); + } + //活动地点 + latestActInfoDTO.setActAddress(formDTO.getActAddress()); + //活动地点-经度 + if(null!=formDTO.getActLongitude()){ + latestActInfoDTO.setActLongitude(formDTO.getActLongitude()); + } + //活动地点-纬度 + if(null!=formDTO.getActLatitude()){ + latestActInfoDTO.setActLatitude(formDTO.getActLatitude()); + } + //打开开始时间 + if(StringUtils.isNotBlank(formDTO.getSignInStartTime())){ + Date signInStartTime=DateUtils.minStrToSecondDate(formDTO.getSignInStartTime()); + latestActInfoDTO.setSignInStartTime(signInStartTime); + } + //打开截止时间 + if(StringUtils.isNotBlank(formDTO.getSignInEndTime())){ + Date signInEndTime=DateUtils.minStrToSecondDate(formDTO.getSignInEndTime()); + latestActInfoDTO.setSignInEndTime(signInEndTime); + } + //活动签到打卡地点 + latestActInfoDTO.setSignInAddress(formDTO.getSignInAddress()); + //活动签到打卡位置经度 + if(null!=formDTO.getSignInLongitude()){ + latestActInfoDTO.setSignInLongitude(formDTO.getSignInLongitude()); + } + //活动签到打卡位置纬度 + if(null!=formDTO.getSignInLatitude()){ + latestActInfoDTO.setSignInLatitude(formDTO.getSignInLatitude()); + } + //活动签到打卡半径(单位:米) + if(null!=formDTO.getSignInRadius()){ + latestActInfoDTO.setSignInRadius(formDTO.getSignInRadius()); + } + //活动名额类型(0-不限名额,1-固定名额) + if(null!=formDTO.getActQuota()&&formDTO.getActQuota()==0){ + latestActInfoDTO.setActQuotaCategory(false); + }else{ + latestActInfoDTO.setActQuotaCategory(true); + } + //活动名额 + latestActInfoDTO.setActQuota(formDTO.getActQuota()); + //联系人 + latestActInfoDTO.setSponsorContacts(formDTO.getSponsorContacts()); + //联系电话 + latestActInfoDTO.setSponsorTel(formDTO.getSponsorTel()); + //主办方类型:网格主办:grid;组织主办:agency + latestActInfoDTO.setSponsorType(formDTO.getSponsorType()); + //主办方id(机关或网格的id) + latestActInfoDTO.setSponsorId(formDTO.getSponsorId()); + //活动主办方名称(机关或网格的名称) + latestActInfoDTO.setSponsorName(formDTO.getSponsorName()); + //如果以网格名义发布,存储空字符串"" + latestActInfoDTO.setSponsorType(formDTO.getSponsorType()); + //活动奖励积分 + latestActInfoDTO.setReward(formDTO.getReward()); + //身份限制:1只有志愿者才可以参加活动0不限制志愿者身份 + latestActInfoDTO.setVolunteerLimit(formDTO.getVolunteerLimit()); + //审核开关:1报名人员需要人工审核0不需要 + latestActInfoDTO.setAuditSwitch(formDTO.getAuditSwitch()); + return latestActInfoDTO; + } + + } diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/WorkActUserServiceImpl.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/WorkActUserServiceImpl.java new file mode 100644 index 0000000000..9e7cac148d --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/WorkActUserServiceImpl.java @@ -0,0 +1,110 @@ +package com.epmet.service.impl; + +import com.epmet.commons.tools.constant.NumConstant; +import com.epmet.commons.tools.utils.Result; +import com.epmet.dto.ActUserRelationDTO; +import com.epmet.dto.HeartUserInfoDTO; +import com.epmet.dto.form.work.AuditingActUserFormDTO; +import com.epmet.dto.result.UserBaseInfoResultDTO; +import com.epmet.dto.result.work.AuditingActUserResultDTO; +import com.epmet.feign.EpmetUserOpenFeignClient; +import com.epmet.service.ActUserRelationService; +import com.epmet.service.HeartUserInfoService; +import com.epmet.service.WorkActUserService; +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 java.util.ArrayList; +import java.util.List; + +/** + * 工作端:活动人员相关api + * + * @author yinzuomei@elink-cn.com + * @date 2020/7/21 22:23 + */ +@Service +public class WorkActUserServiceImpl implements WorkActUserService { + private Logger logger = LogManager.getLogger(WorkActUserServiceImpl.class); + @Autowired + private ActUserRelationService actUserRelationService; + @Autowired + private HeartUserInfoService heartUserInfoService; + @Autowired + private EpmetUserOpenFeignClient epmetUserOpenFeignClient; + + /** + * @param formDTO + * @return java.util.List + * @author yinzuomei + * @description 报名审核-待审核列表 + * @Date 2020/7/21 22:25 + **/ + @Override + public List getAuditingList(AuditingActUserFormDTO formDTO) { + List list=new ArrayList<>(); + //查询出待审核的人员列表 + List actUserRelationDTOList=actUserRelationService.getAuditingUserList(formDTO.getActId()); + if(null==actUserRelationDTOList||actUserRelationDTOList.size()==0){ + logger.info(String.format("当前活动%s没有待审核的报名人员",formDTO.getActId())); + return list; + } + //查询出待审核的人员id集合 + List userIdList=actUserRelationService.getAuditingUserIds(formDTO.getActId()); + //根据待审核的人员结合,查询出用户基本信息 + List userInfoList=this.queryUserBaseInfo(userIdList); + //调用epemet_user服务获取用户的基本信息 + for(ActUserRelationDTO actUserRelationDTO:actUserRelationDTOList){ + AuditingActUserResultDTO resultDTO=new AuditingActUserResultDTO(); + resultDTO.setActId(formDTO.getActId()); + resultDTO.setUserId(actUserRelationDTO.getUserId()); + resultDTO.setSignUpTime(actUserRelationDTO.getCreatedTime()); + //微信基本信息先默认为空字符串 + resultDTO.setRealName(NumConstant.EMPTY_STR); + resultDTO.setNickName(NumConstant.EMPTY_STR); + resultDTO.setHeadImgUrl(NumConstant.EMPTY_STR); + + HeartUserInfoDTO heartUserInfoDTO=heartUserInfoService.getByUserId(actUserRelationDTO.getUserId()); + //true: 是志愿者 false : 不是志愿者 + if(null!=heartUserInfoDTO){ + resultDTO.setVolunteerFlag(heartUserInfoDTO.getVolunteerFlag()); + }else{ + resultDTO.setVolunteerFlag(false); + } + //赋值基本信息 + for(UserBaseInfoResultDTO userBaseInfoResultDTO:userInfoList){ + if(actUserRelationDTO.getUserId().equals(userBaseInfoResultDTO.getUserId())){ + resultDTO.setRealName(userBaseInfoResultDTO.getRealName()); + resultDTO.setNickName(userBaseInfoResultDTO.getNickname()); + resultDTO.setHeadImgUrl(userBaseInfoResultDTO.getHeadImgUrl()); + break; + } + } + list.add(resultDTO); + } + return list; + } + + /** + * @return java.util.List + * @param userIdList + * @author yinzuomei + * @description 传入用户id集合,返回用户的基本信息(包含微信基本信息) + * @Date 2020/7/22 10:38 + **/ + private List queryUserBaseInfo(List userIdList) { + List userInfoList=new ArrayList<>(); + if(null==userIdList||userIdList.size()==0){ + return userInfoList; + } + Result> resultUserList =epmetUserOpenFeignClient.queryUserBaseInfo(userIdList); + if(resultUserList.success()&&resultUserList.getData().size()>0){ + return resultUserList.getData(); + }else{ + logger.warn("查询用户基本信息接口返回失败"); + } + return userInfoList; + } +} diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/utils/CaculateDistance.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/utils/CaculateDistance.java new file mode 100644 index 0000000000..5a772706da --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/utils/CaculateDistance.java @@ -0,0 +1,40 @@ +package com.epmet.utils; + + +/** + * 计算两个经纬度之间相差的距离(米) + * + * @Auther: zhangyong + * @Date: 2020-07-17 14:54 + */ +public class CaculateDistance { + + private static final double EARTH_RADIUS = 6378137; + private static double rad(double d) { + return d * Math.PI / 180.0; + } + + /** + * 根据两点间经纬度坐标(double值),计算两点间距离,单位为米 + * + * @param lng1 经度1 + * @param lat1 纬度1 + * @param lng2 经度2 + * @param lat2 纬度2 + * @return double + * @Author zhangyong + * @Date 14:56 2020-07-17 + **/ + public static double getDistance(double lng1, double lat1, double lng2, double lat2) { + double radLat1 = rad(lat1); + double radLat2 = rad(lat2); + double a = radLat1 - radLat2; + double b = rad(lng1) - rad(lng2); + double s = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(a/2),2) + + Math.cos(radLat1)*Math.cos(radLat2)*Math.pow(Math.sin(b/2),2))); + s = s * EARTH_RADIUS; + s = Math.round(s * 10000) / 10000; + return s; + } + +} diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/bootstrap.yml b/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/bootstrap.yml index f1b4e09318..8571a47da1 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/bootstrap.yml +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/bootstrap.yml @@ -116,4 +116,19 @@ ribbon: #pageHelper分页插件 pagehelper: helper-dialect: mysql - reasonable: false #分页合理化配置,例如输入页码为-1,则自动转化为最小页码1 \ No newline at end of file + reasonable: false #分页合理化配置,例如输入页码为-1,则自动转化为最小页码1 + +#亿联云消息网关 +elink: + mq: + appId: @elink.mq.appId@ #项目接入亿联云的应用Id + token: @elink.mq.token@ #项目接入亿联云的应用token 相当于secret + host: @elink.mq.host@ #亿联云消息网关服务地址 + sendMsgPath: @elink.mq.sendMsgPath@ #发送消息路径 +openapi: + scan: + server: + url: @openapi.scan.server.url@ + method: + imgSyncScan: /imgSyncScan + textSyncScan: /textSyncScan \ No newline at end of file diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/ActCustomizedDao.xml b/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/ActCustomizedDao.xml index 522d9dfdce..7661ed10dd 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/ActCustomizedDao.xml +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/ActCustomizedDao.xml @@ -36,4 +36,22 @@ ac.DEL_FLAG = '0' AND ac.CUSTOMER_ID = #{customerId} + + + + \ No newline at end of file diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/ActInfoDao.xml b/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/ActInfoDao.xml index 5f95eb5ee2..bf0d043bf6 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/ActInfoDao.xml +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/ActInfoDao.xml @@ -49,4 +49,317 @@ - \ No newline at end of file + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/ActUserRelationDao.xml b/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/ActUserRelationDao.xml index 9c4689d6e2..7dcd874931 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/ActUserRelationDao.xml +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/ActUserRelationDao.xml @@ -25,5 +25,29 @@ + + + + \ No newline at end of file diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/HeartUserInfoDao.xml b/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/HeartUserInfoDao.xml index 5da94b031e..341370c3f7 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/HeartUserInfoDao.xml +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/HeartUserInfoDao.xml @@ -19,5 +19,14 @@ - + + \ No newline at end of file diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/LatestActContentDao.xml b/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/LatestActContentDao.xml index 61e18e4f89..68f536b24d 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/LatestActContentDao.xml +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/LatestActContentDao.xml @@ -21,8 +21,8 @@ UPDATE latest_act_content SET DEL_FLAG = '1' - WHERE - ACT_ID = #{actId} + WHERE DEL_FLAG = '0' + AND ACT_ID = #{actId} @@ -37,4 +37,17 @@ ORDER BY lac.ORDER_NUM ASC + + + \ No newline at end of file diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/LatestActInfoDao.xml b/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/LatestActInfoDao.xml index 9c860a03b2..28b43cd8cf 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/LatestActInfoDao.xml +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/LatestActInfoDao.xml @@ -8,20 +8,20 @@ - - + + - - - - - - + + + + + + @@ -57,20 +57,20 @@ - - + + - - - - - - + + + + + + @@ -95,4 +95,27 @@ lai.CREATED_TIME DESC LIMIT 1 + + + \ No newline at end of file diff --git a/epmet-module/epmet-job/epmet-job-server/deploy/docker-compose-dev.yml b/epmet-module/epmet-job/epmet-job-server/deploy/docker-compose-dev.yml index bb00768ada..497d893625 100644 --- a/epmet-module/epmet-job/epmet-job-server/deploy/docker-compose-dev.yml +++ b/epmet-module/epmet-job/epmet-job-server/deploy/docker-compose-dev.yml @@ -2,7 +2,7 @@ version: "3.7" services: epmet-job-server: container_name: epmet-job-server-dev - image: 192.168.1.130:10080/epmet-cloud-dev/epmet-job-server:0.3.22 + image: 192.168.1.130:10080/epmet-cloud-dev/epmet-job-server:0.3.23 ports: - "8084:8084" network_mode: host # 使用现有网络 diff --git a/epmet-module/epmet-job/epmet-job-server/pom.xml b/epmet-module/epmet-job/epmet-job-server/pom.xml index 16bcd6516e..7ee8d4b25d 100644 --- a/epmet-module/epmet-job/epmet-job-server/pom.xml +++ b/epmet-module/epmet-job/epmet-job-server/pom.xml @@ -2,7 +2,7 @@ 4.0.0 - 0.3.22 + 0.3.23 com.epmet epmet-job @@ -33,6 +33,11 @@ data-statistical-client 2.0.0 + + com.epmet + epmet-third-client + 2.0.0 + org.springframework.boot spring-boot-starter-web diff --git a/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/service/ComponentAccessTokenService.java b/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/service/ComponentAccessTokenService.java new file mode 100644 index 0000000000..197bb6d59d --- /dev/null +++ b/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/service/ComponentAccessTokenService.java @@ -0,0 +1,13 @@ +package com.epmet.service; + +import com.epmet.commons.tools.utils.Result; + +/** + * @Author zxc + * @CreateTime 2020/7/20 10:21 + */ +public interface ComponentAccessTokenService { + + Result componentAccessTokenJob(); + +} diff --git a/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/service/RefreshAuthAccessTokenService.java b/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/service/RefreshAuthAccessTokenService.java new file mode 100644 index 0000000000..9a460f0ceb --- /dev/null +++ b/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/service/RefreshAuthAccessTokenService.java @@ -0,0 +1,13 @@ +package com.epmet.service; + +import com.epmet.commons.tools.utils.Result; + +/** + * @Author zxc + * @CreateTime 2020/7/20 10:44 + */ +public interface RefreshAuthAccessTokenService { + + Result refreshAuthorizerAccessTokenJob(); + +} diff --git a/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/service/impl/ComponentAccessTokenServiceImpl.java b/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/service/impl/ComponentAccessTokenServiceImpl.java new file mode 100644 index 0000000000..dbf0375a29 --- /dev/null +++ b/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/service/impl/ComponentAccessTokenServiceImpl.java @@ -0,0 +1,25 @@ +package com.epmet.service.impl; + +import com.epmet.commons.tools.utils.Result; +import com.epmet.feign.EpmetThirdFeignClient; +import com.epmet.service.ComponentAccessTokenService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +/** + * @Author zxc + * @CreateTime 2020/7/20 10:22 + */ +@Slf4j +@Service +public class ComponentAccessTokenServiceImpl implements ComponentAccessTokenService { + + @Autowired + private EpmetThirdFeignClient epmetThirdFeignClient; + + @Override + public Result componentAccessTokenJob() { + return epmetThirdFeignClient.getComponentAccessTokenJob(); + } +} diff --git a/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/service/impl/RefreshAuthAccessTokenServiceImpl.java b/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/service/impl/RefreshAuthAccessTokenServiceImpl.java new file mode 100644 index 0000000000..5edb9725a2 --- /dev/null +++ b/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/service/impl/RefreshAuthAccessTokenServiceImpl.java @@ -0,0 +1,23 @@ +package com.epmet.service.impl; + +import com.epmet.commons.tools.utils.Result; +import com.epmet.feign.EpmetThirdFeignClient; +import com.epmet.service.RefreshAuthAccessTokenService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +/** + * @Author zxc + * @CreateTime 2020/7/20 10:44 + */ +@Service +public class RefreshAuthAccessTokenServiceImpl implements RefreshAuthAccessTokenService { + + @Autowired + private EpmetThirdFeignClient epmetThirdFeignClient; + + @Override + public Result refreshAuthorizerAccessTokenJob() { + return epmetThirdFeignClient.refreshAuthorizerAccessTokenJob(); + } +} diff --git a/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/task/ComponentAccessTokenTask.java b/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/task/ComponentAccessTokenTask.java new file mode 100644 index 0000000000..1ae759af83 --- /dev/null +++ b/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/task/ComponentAccessTokenTask.java @@ -0,0 +1,34 @@ +package com.epmet.task; + +import com.epmet.commons.tools.utils.Result; +import com.epmet.service.ComponentAccessTokenService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + + +/** + * @Author zxc + * @CreateTime 2020/7/20 10:28 + */ +@Component("componentAccessToken") +public class ComponentAccessTokenTask implements ITask{ + + @Autowired + private ComponentAccessTokenService componentAccessTokenService; + + private Logger logger = LoggerFactory.getLogger(getClass()); + + + @Override + public void run(String params) { + logger.info("ComponentAccessTokenTask正在执行定时任务,参数为{}",params); + Result result = componentAccessTokenService.componentAccessTokenJob(); + if (result.success()){ + logger.info("ComponentAccessTokenTask定时任务执行成功"); + }else { + logger.error("ComponentAccessTokenTask定时任务执行失败:" + result.getMsg()); + } + } +} diff --git a/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/task/RefreshAuthAccessTokenTask.java b/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/task/RefreshAuthAccessTokenTask.java new file mode 100644 index 0000000000..40033447b2 --- /dev/null +++ b/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/task/RefreshAuthAccessTokenTask.java @@ -0,0 +1,32 @@ +package com.epmet.task; + +import com.epmet.commons.tools.utils.Result; +import com.epmet.service.RefreshAuthAccessTokenService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +/** + * @Author zxc + * @CreateTime 2020/7/20 10:46 + */ +@Component("refreshAuthAccessTokenTask") +public class RefreshAuthAccessTokenTask implements ITask { + + private Logger logger = LoggerFactory.getLogger(getClass()); + + @Autowired + private RefreshAuthAccessTokenService refreshAuthAccessTokenService; + + @Override + public void run(String params) { + logger.info("RefreshAuthAccessTokenTask正在执行定时任务,参数为{}",params); + Result result = refreshAuthAccessTokenService.refreshAuthorizerAccessTokenJob(); + if (result.success()){ + logger.info("RefreshAuthAccessTokenTask定时任务执行成功"); + }else { + logger.error("RefreshAuthAccessTokenTask定时任务执行失败:" + result.getMsg()); + } + } +} diff --git a/epmet-module/epmet-point/epmet-point-client/src/main/java/dto/form/SendPointFormDTO.java b/epmet-module/epmet-point/epmet-point-client/src/main/java/dto/form/SendPointFormDTO.java new file mode 100644 index 0000000000..ae4c7aeeba --- /dev/null +++ b/epmet-module/epmet-point/epmet-point-client/src/main/java/dto/form/SendPointFormDTO.java @@ -0,0 +1,18 @@ +package dto.form;/** + * @author jianjun liu + * @email liujianjun@yunzongnet.com + * @date 2020-07-17 17:16 + **/ + +import lombok.Data; + +/** + * desc:发送积分dto + * @author lyn + * @date 2020/7/17 17:16 + */ +@Data +public class SendPointFormDTO { + private String pointDesc; + private Integer point; +} diff --git a/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/config/MqSubcribeConfig.java b/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/config/MqSubcribeConfig.java new file mode 100644 index 0000000000..e7e1a33c7f --- /dev/null +++ b/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/config/MqSubcribeConfig.java @@ -0,0 +1,45 @@ +package com.epmet.config; + +import com.alibaba.fastjson.JSON; +import com.epmet.commons.tools.dto.form.mq.MqSubscribeFormDTO; +import com.epmet.commons.tools.utils.HttpClientManager; +import com.epmet.commons.tools.utils.Result; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.springframework.stereotype.Component; + +import javax.annotation.PostConstruct; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * desc:订阅积分事件 + */ +@Component +public class MqSubcribeConfig { + private Logger logger = LogManager.getLogger(MqSubcribeConfig.class); + + private String mqServer = "https://epmet-dev.elinkservice.cn/estos/mq-subscriber/subscribe"; + private String token = "1cfcbb5ade1e3202855ee5819983d773"; + + @PostConstruct + private void subscribe() { + MqSubscribeFormDTO event = new MqSubscribeFormDTO(); + event.setBelongAppId("202007161443499985fa2d397436d10356542134c8f008c48"); + event.setEventClass("epmet_heart"); + event.setEventTag("active_send_point"); + String callbackUrl = "http://192.168.51.49/point/callback/sendPoint"; + callbackUrl = ""; + event.setCallbackUrl(callbackUrl); + List subscribeFormDTOList = new ArrayList<>(); + subscribeFormDTOList.add(event); + Map param = new HashMap<>(); + param.put("token", token); + param.put("mqSubscribeList", subscribeFormDTOList); + String jsonStrParam = JSON.toJSONString(param); + Result result = HttpClientManager.getInstance().sendPostByHttps(mqServer, JSON.toJSONString(param)); + logger.error("subscriber==jsonStrParam:{}=====result:{}" ,jsonStrParam, JSON.toJSONString(result)); + } +} diff --git a/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/controller/MqPointCallbackController.java b/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/controller/MqPointCallbackController.java new file mode 100644 index 0000000000..aeaca6e25d --- /dev/null +++ b/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/controller/MqPointCallbackController.java @@ -0,0 +1,45 @@ +package com.epmet.controller; + +import com.alibaba.fastjson.JSON; +import com.epmet.commons.tools.dto.form.mq.ReceiveMqMsg; +import com.epmet.commons.tools.utils.ConvertUtils; +import dto.form.SendPointFormDTO; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * desc: 积分相关消息回调controller + * + * @date: 2020/7/21 9:04 + * @author: jianjun liu + * email:liujianjun@git.elinkit.com.cn + */ +@Slf4j +@RestController +@RequestMapping("mqCallback") +public class MqPointCallbackController { + private Logger logger = LogManager.getLogger(MqPointCallbackController.class); + + /** + * desc:爱心活动积分发放 + * + * @param mqMsg + * @return + */ + @RequestMapping("activeSendPoint") + public String activeSendPoint(ReceiveMqMsg mqMsg) { + log.debug("activeSendPoint receive mqMsg:{}", JSON.toJSONString(mqMsg)); + if (mqMsg == null || StringUtils.isBlank(mqMsg.getMsg())) { + log.warn("activeSendPoint mqMsg is empty"); + return "success"; + } + SendPointFormDTO formDTO = ConvertUtils.sourceToTarget(mqMsg.getMsg(), SendPointFormDTO.class); + log.info("activeSendPoint consumer success,formDTO:{}", JSON.toJSONString(formDTO)); + return "success"; + } +} + diff --git a/epmet-module/epmet-point/epmet-point-server/src/main/resources/db/migration/epmet_point.sql b/epmet-module/epmet-point/epmet-point-server/src/main/resources/db/migration/epmet_point.sql index af08a35db6..91e47c87ad 100644 --- a/epmet-module/epmet-point/epmet-point-server/src/main/resources/db/migration/epmet_point.sql +++ b/epmet-module/epmet-point/epmet-point-server/src/main/resources/db/migration/epmet_point.sql @@ -1,15 +1,15 @@ CREATE TABLE point_rule( ID VARCHAR(64) NOT NULL COMMENT '主键' , CUSTOMER_ID VARCHAR(64) COMMENT '客户ID' , + RULE_NAME VARCHAR(32) COMMENT '规则名称 与事件名称保持一致即可' , + RULE_DESC VARCHAR(32) COMMENT '规则说明 事件说明' , EVENT_CODE VARCHAR(32) COMMENT '事件CODE 来自事件表' , EVENT_NAME VARCHAR(32) COMMENT '事件名称 来自事件表' , - RULE_DESC VARCHAR(32) COMMENT '积分说明 事件说明' , OPERATE_TYPE VARCHAR(32) COMMENT '操作类型 加积分:add;减积分:subtract' , UP_LIMIT INT COMMENT '积分上限' , - untitled VARCHAR(32) COMMENT '积分上限描述' , + UP_LIMIT_DESC VARCHAR(64) COMMENT '积分上限描述' , POINT_NUM INT DEFAULT 0 COMMENT '获得积分值' , POINT_UNIT VARCHAR(32) COMMENT '获得积分单位 次:time;分钟:minute;小时:hour' , - REMARK VARCHAR(128) COMMENT '备注 备注说明' , ENABLED_FLAG VARCHAR(1) COMMENT '是否启用 0-否,1-是' , DEL_FLAG VARCHAR(1) COMMENT '删除标识 0-否,1-是' , REVISION INT COMMENT '乐观锁' , @@ -18,7 +18,7 @@ CREATE TABLE point_rule( UPDATED_BY VARCHAR(32) COMMENT '更新人' , UPDATED_TIME DATETIME COMMENT '更新时间' , PRIMARY KEY (ID) -) COMMENT = '积分规则表';; +) COMMENT = '积分规则表'; CREATE TABLE sys_operate_log( ID VARCHAR(64) NOT NULL COMMENT '主键' , diff --git a/epmet-module/epmet-third/epmet-third-client/pom.xml b/epmet-module/epmet-third/epmet-third-client/pom.xml index 3a2173aa25..3899202cf7 100644 --- a/epmet-module/epmet-third/epmet-third-client/pom.xml +++ b/epmet-module/epmet-third/epmet-third-client/pom.xml @@ -26,6 +26,12 @@ 3.6.0 compile + + com.epmet + epmet-user-client + 2.0.0 + compile + diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/CodeExtDTO.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/CodeExtDTO.java new file mode 100644 index 0000000000..0e4abe7130 --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/CodeExtDTO.java @@ -0,0 +1,91 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

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

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

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.dto; + +import java.io.Serializable; +import java.util.Date; +import lombok.Data; + + +/** + * 代码第三方配置 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-07-17 + */ +@Data +public class CodeExtDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 主键 + */ + private String id; + + /** + * 客户ID + */ + private String customerId; + + /** + * 所属端 居民的:resi,工作端:work + */ + private String clientType; + + /** + * APPID + */ + private String appId; + + /** + * 自定义配置 + */ + private String extJson; + + /** + * 乐观锁 + */ + private Integer revision; + + /** + * 是否删除 + */ + private String delFlag; + + /** + * 创建人 + */ + private String createdBy; + + /** + * 创建时间 + */ + private Date createdTime; + + /** + * 更新人 + */ + private String updatedBy; + + /** + * 更新时间 + */ + private Date updatedTime; + +} \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/CustomerCodeOperationHistoryDTO.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/CodeOperationHistoryDTO.java similarity index 96% rename from epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/CustomerCodeOperationHistoryDTO.java rename to epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/CodeOperationHistoryDTO.java index 9d400efb40..c668daeaea 100644 --- a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/CustomerCodeOperationHistoryDTO.java +++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/CodeOperationHistoryDTO.java @@ -29,7 +29,7 @@ import lombok.Data; * @since v1.0.0 2020-07-09 */ @Data -public class CustomerCodeOperationHistoryDTO implements Serializable { +public class CodeOperationHistoryDTO implements Serializable { private static final long serialVersionUID = 1L; diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/PaCustomerAgencyDTO.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/PaCustomerAgencyDTO.java index e659efc669..3ea9efa543 100644 --- a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/PaCustomerAgencyDTO.java +++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/PaCustomerAgencyDTO.java @@ -19,6 +19,8 @@ package com.epmet.dto; import java.io.Serializable; import java.util.Date; + +import com.fasterxml.jackson.annotation.JsonIgnore; import lombok.Data; @@ -52,6 +54,11 @@ public class PaCustomerAgencyDTO implements Serializable { * 级别 */ private String level; + /** + * 级别(0.省级,1市级,2.区县级,3.乡镇街道级 4.社区级 5无) + */ + @JsonIgnore + private String levelNum; /** * 地区编码 diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/AuthCodeAndTimeFromDTO.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/AuthCodeAndTimeFromDTO.java new file mode 100644 index 0000000000..b42181fa63 --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/AuthCodeAndTimeFromDTO.java @@ -0,0 +1,30 @@ +package com.epmet.dto.form; + +import lombok.Data; + +import java.io.Serializable; + +/** + * @Author zxc + * @CreateTime 2020/7/21 14:36 + */ +@Data +public class AuthCodeAndTimeFromDTO implements Serializable { + + private static final long serialVersionUID = 7149257227563083044L; + + /** + * 授权码 【auth_code】 + */ + private String authCode; + + /** + * 过期时间 + */ + private String expiresIn; + + /** + * 客户端类型: resi:居民端,work:工作端 + */ + private String clientType; +} diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/CodeAuditRecordFormDTO.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/CodeAuditRecordFormDTO.java index c0530f1bb7..1081ab0891 100644 --- a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/CodeAuditRecordFormDTO.java +++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/CodeAuditRecordFormDTO.java @@ -42,12 +42,12 @@ public class CodeAuditRecordFormDTO implements Serializable { /** * 小程序的原始 ID */ - private String toUserName; + private String ToUserName; /** * 发送方帐号(一个 OpenID,此时发送方是系统帐号) */ - private String fromUserName; + private String FromUserName; /** * 消息创建时间 (整型),时间戳 @@ -57,7 +57,7 @@ public class CodeAuditRecordFormDTO implements Serializable { /** * 消息类型 event */ - private String msgType; + private String MsgType; /** * 事件类型 @@ -65,32 +65,32 @@ public class CodeAuditRecordFormDTO implements Serializable { weapp_audit_fail:审核不通过, weapp_audit_delay:审核延后 */ - private String event; + private String Event; /** * 审核成功时的时间戳 */ - private Date succTime; + private Date SuccTime; /** * 审核不通过的时间戳 */ - private Date failTime; + private Date FailTime; /** * 审核延后时的时间戳 */ - private Date delayTime; + private Date DelayTime; /** * 审核不通过的原因 */ - private String reason; + private String Reason; /** * 审核不通过的截图示例。用 | 分隔的 media_id 的列表,可通过获取永久素材接口拉取截图内容 */ - private String screenShot; + private String ScreenShot; /** * 删除状态 diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/CodeCommonFormDTO.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/CodeCommonFormDTO.java index 083f145ba6..e854b15992 100644 --- a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/CodeCommonFormDTO.java +++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/CodeCommonFormDTO.java @@ -20,4 +20,6 @@ public class CodeCommonFormDTO implements Serializable { * 代码ID */ private String codeId; + private Integer page; + private Integer limit; } diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/MediaUploadFormDTO.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/MediaUploadFormDTO.java new file mode 100644 index 0000000000..d01ba9d62c --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/MediaUploadFormDTO.java @@ -0,0 +1,19 @@ +package com.epmet.dto.form; + +import lombok.Data; +import org.springframework.web.multipart.MultipartFile; + +import java.io.Serializable; + +/** + * @author zhaoqifeng + * @dscription + * @date 2020/7/17 11:15 + */ +@Data +public class MediaUploadFormDTO implements Serializable { + private static final long serialVersionUID = -7342624180676221309L; + private String codeId; + private String type; + private MultipartFile media; +} diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/MiniInfoFormDTO.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/MiniInfoFormDTO.java index 072877f958..bed074d166 100644 --- a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/MiniInfoFormDTO.java +++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/MiniInfoFormDTO.java @@ -28,32 +28,32 @@ public class MiniInfoFormDTO implements Serializable { /** * 昵称 */ - private String nickName; + private String nick_name; /** * 头像 */ - private String headImg; + private String head_img; /** * 小程序类型 默认为 0 */ - private String serviceTypeInfo; + private String service_type_info; /** * 小程序认证类型 小程序认证类型 */ - private String verifyTypeInfo; + private String verify_type_info; /** * 原始 ID */ - private String userName; + private String user_name; /** * 主体名称 */ - private String principalName; + private String principal_name; /** * 账号介绍 @@ -63,7 +63,7 @@ public class MiniInfoFormDTO implements Serializable { /** * 二维码图片的 URL */ - private String qrcodeUrl; + private String qrcode_url; private Integer delFlag = 0; diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/MyInfoFormDTO.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/MyInfoFormDTO.java deleted file mode 100644 index 052133e0df..0000000000 --- a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/MyInfoFormDTO.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.epmet.dto.form; - -import lombok.Data; - -import javax.validation.constraints.NotBlank; -import java.io.Serializable; - -/** - * @Author sun - * @Description 公众号-查询我的信息-接口入参 - */ -@Data -public class MyInfoFormDTO implements Serializable { - - private static final long serialVersionUID = -6547893374373422628L; - - public interface AddUserInternalGroup { - } - - /** - * 客户Id - */ - //@NotBlank(message = "客户Id不能为空", groups = {MyInfoFormDTO.AddUserInternalGroup.class}) - private String customerId; - -} diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/PaInfoFormDTO.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/PaInfoFormDTO.java index d91c84cfa3..cfd60e3d9a 100644 --- a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/PaInfoFormDTO.java +++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/PaInfoFormDTO.java @@ -28,19 +28,19 @@ public class PaInfoFormDTO implements Serializable { /** * 昵称 */ - private String nickName; + private String nick_name; /** * 头像 */ - private String headImg; + private String head_img; /** * 公众号类型 0:订阅号 1:由历史老帐号升级后的订阅号 2:服务号 */ - private String serviceTypeInfo; + private String service_type_info; /** * 公众号认证类型 -1:未认证 @@ -51,17 +51,17 @@ public class PaInfoFormDTO implements Serializable { 4:已资质认证通过、还未通过名称认证,但通过了新浪微博认证 5:已资质认证通过、还未通过名称认证,但通过了腾讯微博认证 */ - private String verifyTypeInfo; + private String verify_type_info; /** * 原始ID */ - private String userName; + private String user_name; /** * 主体名称 */ - private String principalName; + private String principal_name; /** * 公众号所设置的微信号,可能为空 公众号所设置的微信号,可能为空 @@ -71,7 +71,7 @@ public class PaInfoFormDTO implements Serializable { /** * 二维码图片的 URL */ - private String qrcodeUrl; + private String qrcode_url; /** * 删除状态 0:正常,1:删除 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 new file mode 100644 index 0000000000..2d067fd589 --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/RegisterByAuthFormDTO.java @@ -0,0 +1,44 @@ +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 运营端-根据授权状态和初始化状态获取客户列表(不分页)-接口入参 + */ +@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/WxLoginFormDTO.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/WxLoginFormDTO.java new file mode 100644 index 0000000000..bd358f8614 --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/WxLoginFormDTO.java @@ -0,0 +1,27 @@ +package com.epmet.dto.form; + +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + +/** + * @Author sun + * @Description 小程序居民端登陆-接口入参 + */ +@Data +public class WxLoginFormDTO implements Serializable { + + private static final long serialVersionUID = -6163303184086480522L; + + /** + * 小程序AppId + */ + private String appId; + + /** + * 用户微信code + */ + private String wxCode; + +} diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/AuthorizationInfoResultDTO.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/AuthorizationInfoResultDTO.java index 1d20dc3aac..ce31106941 100644 --- a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/AuthorizationInfoResultDTO.java +++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/AuthorizationInfoResultDTO.java @@ -29,7 +29,7 @@ public class AuthorizationInfoResultDTO implements Serializable { /** * authorizer_access_token 的有效期(在授权的公众号/小程序具备API权限时,才有此返回值),单位:秒 */ - private String expires_in; + private Integer expires_in; /** * 刷新令牌(在授权的公众号具备API权限时,才有此返回值),刷新令牌主要用于第三方平台获取和刷新已授权用户的 authorizer_access_token。 diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/CodeHistoryResultDTO.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/CodeHistoryResultDTO.java new file mode 100644 index 0000000000..1aa68a49c2 --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/CodeHistoryResultDTO.java @@ -0,0 +1,34 @@ +package com.epmet.dto.result; + +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; +import java.util.List; + +/** + * @author zhaoqifeng + * @dscription + * @date 2020/7/16 9:53 + */ +@NoArgsConstructor +@Data +public class CodeHistoryResultDTO implements Serializable { + private static final long serialVersionUID = 6030280825893585115L; + /** + * 操作时间 + */ + private String operationTime; + /** + * 版本 + */ + private String version; + /** + * 操作 上传upload,审核audit,撤回undo,发布release + */ + private String operation; + /** + * 描述 + */ + private String describe; +} diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/CreateAgencyResultDTO.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/CreateAgencyResultDTO.java index 285b662e40..f344e5c062 100644 --- a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/CreateAgencyResultDTO.java +++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/CreateAgencyResultDTO.java @@ -19,9 +19,5 @@ public class CreateAgencyResultDTO implements Serializable { * 新增客户Id */ private String customerId; - /** - * 包含customerId的token - */ - private String token; } diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/CustomerUserResultDTO.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/CustomerUserResultDTO.java index 3b8d20f9e9..d0090c3fa7 100644 --- a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/CustomerUserResultDTO.java +++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/CustomerUserResultDTO.java @@ -2,6 +2,7 @@ package com.epmet.dto.result; import com.epmet.dto.PaCustomerDTO; import com.epmet.dto.PaUserDTO; +import com.epmet.dto.PaUserWechatDTO; import lombok.Data; import java.io.Serializable; @@ -22,4 +23,8 @@ public class CustomerUserResultDTO implements Serializable { * 用户对应的客户信息 */ private PaCustomerDTO paCustomerResult; + /** + * 用户对应的微信基本信息 + */ + private PaUserWechatDTO paUserWechatResult; } diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/InitCustomerResultDTO.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/InitCustomerResultDTO.java new file mode 100644 index 0000000000..3d46c4cebc --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/InitCustomerResultDTO.java @@ -0,0 +1,32 @@ +package com.epmet.dto.result; + +import com.epmet.dto.PaCustomerAgencyDTO; +import com.epmet.dto.PaCustomerDTO; +import com.epmet.dto.PaUserDTO; +import lombok.Data; + +import java.io.Serializable; + +/** + * @Author sun + * @Description 运营端初始化客户信息-查询客户各项注册信息-接口返参 + */ +@Data +public class InitCustomerResultDTO implements Serializable { + + private static final long serialVersionUID = 3253989119352850315L; + + /** + * 注册客户信息 + */ + private PaCustomerDTO paCustomer; + /** + * 注册客户组织信息 + */ + private PaCustomerAgencyDTO paAgency; + /** + * 注册客户管理员信息 + */ + private PaUserDTO paUser; + +} diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/MediaUploadResultDTO.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/MediaUploadResultDTO.java new file mode 100644 index 0000000000..501e9aeb9b --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/MediaUploadResultDTO.java @@ -0,0 +1,17 @@ +package com.epmet.dto.result; + +import lombok.Data; + +import java.io.Serializable; + +/** + * @author zhaoqifeng + * @dscription + * @date 2020/7/17 11:17 + */ +@Data +public class MediaUploadResultDTO implements Serializable { + private static final long serialVersionUID = -8462768939270515547L; + private String id; + private String name; +} diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/PublicCustomerResultDTO.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/PublicCustomerResultDTO.java new file mode 100644 index 0000000000..36a820f939 --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/PublicCustomerResultDTO.java @@ -0,0 +1,22 @@ +package com.epmet.dto.result; + +import com.epmet.dto.PaCustomerDTO; +import lombok.Data; + +import java.io.Serializable; + +/** + * 根据appid查询公众号注册的客户信息 + * @Author sun + */ +@Data +public class PublicCustomerResultDTO implements Serializable { + + private static final long serialVersionUID = 4642988014737245076L; + + /** + * 客户信息 + */ + private PaCustomerDTO customer; + +} diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/QrCodeResultDTO.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/QrCodeResultDTO.java new file mode 100644 index 0000000000..c33b27f8dc --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/QrCodeResultDTO.java @@ -0,0 +1,22 @@ +package com.epmet.dto.result; + +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +/** + * @author zhaoqifeng + * @dscription + * @date 2020/7/16 9:46 + */ +@NoArgsConstructor +@Data +public class QrCodeResultDTO implements Serializable { + + private static final long serialVersionUID = -1145375851106140589L; + /** + * 二维码 + */ + private Object qrcode; +} diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/ReasonResultDTO.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/ReasonResultDTO.java new file mode 100644 index 0000000000..82223d583a --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/ReasonResultDTO.java @@ -0,0 +1,26 @@ +package com.epmet.dto.result; + +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; +import java.util.List; + +/** + * @author zhaoqifeng + * @dscription + * @date 2020/7/16 9:28 + */ +@NoArgsConstructor +@Data +public class ReasonResultDTO implements Serializable { + private static final long serialVersionUID = -1905907350492787127L; + /** + * 失败原因 + */ + private String reason; + /** + * 失败的小程序截图url + */ + private List screenshotUrl; +} diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/RegisterByAuthResultDTO.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/RegisterByAuthResultDTO.java new file mode 100644 index 0000000000..3c4c3c1eb8 --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/RegisterByAuthResultDTO.java @@ -0,0 +1,26 @@ +package com.epmet.dto.result; + +import lombok.Data; + +import java.io.Serializable; + +/** + * @Author sun + * @Description 运营端-根据授权状态和初始化状态获取客户列表(不分页)-接口返参 + */ +@Data +public class RegisterByAuthResultDTO implements Serializable { + + private static final long serialVersionUID = 4642988014737245076L; + + /** + * 客户Id + */ + private String customerId; + + /** + * 客户名称 + */ + private String customerName; + +} diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/TemplateListResultDTO.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/TemplateListResultDTO.java index 083ca650d9..0496f09232 100644 --- a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/TemplateListResultDTO.java +++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/TemplateListResultDTO.java @@ -18,7 +18,7 @@ public class TemplateListResultDTO implements Serializable { /** * 模板 id */ - private String templateId; + private String id; /** * 模板描述 */ diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/feign/EpmetThirdFeignClient.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/feign/EpmetThirdFeignClient.java index 4b038324ac..5a91825392 100644 --- a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/feign/EpmetThirdFeignClient.java +++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/feign/EpmetThirdFeignClient.java @@ -2,8 +2,12 @@ package com.epmet.feign; import com.epmet.commons.tools.constant.ServiceConstant; import com.epmet.commons.tools.utils.Result; +import com.epmet.dto.UserWechatDTO; import com.epmet.dto.form.SaveUserVisitedFormDTO; +import com.epmet.dto.form.WxLoginFormDTO; import com.epmet.dto.result.CustomerUserResultDTO; +import com.epmet.dto.result.InitCustomerResultDTO; +import com.epmet.dto.result.PublicCustomerResultDTO; import com.epmet.dto.result.SaveUserResultDTO; import com.epmet.feign.fallback.EpmetThirdFeignClientFallback; import me.chanjar.weixin.mp.bean.result.WxMpUser; @@ -18,6 +22,7 @@ import org.springframework.web.bind.annotation.RequestBody; * * @Author zxc * @CreateTime 2020/7/5 14:45 + * ,url="localhost:8110" */ @FeignClient(name = ServiceConstant.EPMET_THIRD_SERVER, fallback = EpmetThirdFeignClientFallback.class) @@ -49,4 +54,56 @@ public interface EpmetThirdFeignClient { **/ @PostMapping(value = "third/pauservisited/saveuservisited") Result saveUserVisited(@RequestBody SaveUserVisitedFormDTO visited); + + /** + * @param customerId + * @return + * @Author sun + * @Description 根据客户Id查询各项注册信息 + **/ + @PostMapping(value = "third/pacustomer/getcustomeragencyuser/{customerId}") + Result getCustomerAgencyUser(@PathVariable("customerId") String customerId); + + /** + * @param customerId + * @return + * @Author sun + * @Description 修改客户数据状态为已完成初始化 + **/ + @PostMapping(value = "third/pacustomer/updatecustomer/{customerId}") + Result updateCustomer(@PathVariable("customerId") String customerId); + + /** + * @Description 获取【component_access_token】的定时任务 10min/次 + * @param + * @author zxc + */ + @PostMapping(value = "third/wechatthird/componentaccesstoken") + Result getComponentAccessTokenJob(); + + /** + * @Description 获取/刷新接口调用令牌 10min/次 + * @param + * @author zxc + */ + @PostMapping(value = "third/wechatthird/refreshtoken") + Result refreshAuthorizerAccessTokenJob(); + + /** + * @param formDTO + * @return + * @Author sun + * @Description 校验appId是否有效以及是否授权,校验通过的调用微信API获取用户基本信息 + **/ + @PostMapping(value = "third/customermp/resiandworklogin") + Result resiAndWorkLogin(@RequestBody WxLoginFormDTO formDTO); + + /** + * @param appId + * @return + * @Author sun + * @Description 根据appId查询公众号注册的客户信息 + **/ + @PostMapping(value = "third/customermp/getcustomermsg/{appId}") + Result getCustomerMsg(@PathVariable("appId") String appId); } diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/feign/fallback/EpmetThirdFeignClientFallback.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/feign/fallback/EpmetThirdFeignClientFallback.java index b1965cad5a..fda713210f 100644 --- a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/feign/fallback/EpmetThirdFeignClientFallback.java +++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/feign/fallback/EpmetThirdFeignClientFallback.java @@ -3,8 +3,12 @@ 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.UserWechatDTO; import com.epmet.dto.form.SaveUserVisitedFormDTO; +import com.epmet.dto.form.WxLoginFormDTO; import com.epmet.dto.result.CustomerUserResultDTO; +import com.epmet.dto.result.InitCustomerResultDTO; +import com.epmet.dto.result.PublicCustomerResultDTO; import com.epmet.dto.result.SaveUserResultDTO; import com.epmet.feign.EpmetThirdFeignClient; import me.chanjar.weixin.mp.bean.result.WxMpUser; @@ -31,4 +35,34 @@ public class EpmetThirdFeignClientFallback implements EpmetThirdFeignClient { public Result saveUserVisited(SaveUserVisitedFormDTO visited) { return ModuleUtils.feignConError(ServiceConstant.EPMET_THIRD_SERVER, "saveUserVisited", visited); } + + @Override + public Result getCustomerAgencyUser(String customerId) { + return ModuleUtils.feignConError(ServiceConstant.EPMET_THIRD_SERVER, "getCustomerAgencyUser", customerId); + } + + @Override + public Result updateCustomer(String customerId) { + return ModuleUtils.feignConError(ServiceConstant.EPMET_THIRD_SERVER, "updateCustomer", customerId); + } + + @Override + public Result getComponentAccessTokenJob() { + return ModuleUtils.feignConError(ServiceConstant.EPMET_THIRD_SERVER, "getComponentAccessTokenJob"); + } + + @Override + public Result refreshAuthorizerAccessTokenJob() { + return ModuleUtils.feignConError(ServiceConstant.EPMET_THIRD_SERVER, "refreshAuthorizerAccessTokenJob"); + } + + @Override + public Result resiAndWorkLogin(WxLoginFormDTO formDTO) { + return ModuleUtils.feignConError(ServiceConstant.EPMET_THIRD_SERVER, "resiAndWorkLogin", formDTO); + } + + @Override + public Result getCustomerMsg(String appId) { + return ModuleUtils.feignConError(ServiceConstant.EPMET_THIRD_SERVER, "getCustomerMsg", appId); + } } 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 58e0013a0e..494df190a6 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.13 + image: 192.168.1.130:10080/epmet-cloud-dev/epmet-third-server:0.0.39 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 1b21690631..60cf655960 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.13 + image: registry-vpc.cn-qingdao.aliyuncs.com/epmet-cloud-release/epmet-third-server:0.0.14 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 3312989042..6c831bfb2f 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.14 + 0.0.39 com.epmet diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/constant/CodeConstant.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/constant/CodeConstant.java index 6089c8b936..e3735ec240 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/constant/CodeConstant.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/constant/CodeConstant.java @@ -46,4 +46,9 @@ public interface CodeConstant { * 发布失败 */ String RELEASE_FAILED = "release_failed"; + + String OPER_UPLOAD = "上传代码"; + String OPER_SUBMIT = "提交审核"; + String OPER_UNDO = "审核撤回"; + String OPER_RELEASE = "发布"; } diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/constant/ModuleConstant.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/constant/ModuleConstant.java index dce046fc84..5e72094a57 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/constant/ModuleConstant.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/constant/ModuleConstant.java @@ -11,8 +11,10 @@ public interface ModuleConstant { //获得授权事件的票据 如下 String UTF8 = "UTF-8"; String MSG_SIGNATURE = "msg_signature"; + String SIGNATURE = "signature"; String TIMESTAMP = "timestamp"; String NONCE = "nonce"; + String ENCRYPT_TYPE = "encrypt_type"; String INFO_TYPE = "InfoType"; String TICKET_UNDERLINE_KEY = "component_verify_ticket"; String TICKET_KEY = "ComponentVerifyTicket"; @@ -29,6 +31,9 @@ public interface ModuleConstant { String COMPONENT_APPSECRET = "component_appsecret"; String COMPONENT_ACCESS_TOKEN = "component_access_token"; String EXPIRES_IN = "expires_in"; + String ACCOUNT_TOKEN_FLAG_ONE = "FIRST"; + String ACCOUNT_TOKEN_FLAG_TWO = "JOB"; + //获取预授权码 如下 String PRE_AUTH_CODE = "pre_auth_code"; @@ -36,6 +41,7 @@ public interface ModuleConstant { //使用授权码获取授权信息 如下 String AUTHORIZATION_CODE = "authorization_code"; String AUTHORIZATION_INFO = "authorization_info"; + String ID = "id"; //获取/刷新接口调用令牌 如下 String AUTHORIZER_APPID = "authorizer_appid"; @@ -72,6 +78,8 @@ public interface ModuleConstant { String DELAY = "delay"; String AUDIT_SUCCESS = "audit_success"; String AUDIT_FAILED = "audit_failed"; + String XML = "xml"; + String CREATE_TIME = "CreateTime"; int FORTY_THOUSAND_AND_THIRTEEN = 40013; int EIGHTY_NINE_THOUSAND = 89000; 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 9f43dface4..cbed19f1c2 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 @@ -29,7 +29,9 @@ public interface PaConstant { String PROVINCE_KEY = "province"; String PROVINCE_NAME = "省级"; String CITY_KEY = "city"; - String CITY_NAME = "区县级"; + String CITY_NAME = "市级"; + String DISTRICT_KEY = "district"; + String DISTRICT_NAME = "区县级"; String STREET_KEY = "street"; String STREET_NAME = "乡(镇、街道)级"; String COMMUNITY_KEY = "community"; @@ -60,4 +62,8 @@ public interface PaConstant { * 获取缓存中token信息失败 */ String TOKEN_EXCEPTION = "token已过期"; + /** + * 获取客户信息失败 + */ + String SELECT_CUSTOMER_EXCEPTION = "获取客户信息失败"; } diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/constant/ThirdApiConstant.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/constant/ThirdApiConstant.java deleted file mode 100644 index 5b05154cbc..0000000000 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/constant/ThirdApiConstant.java +++ /dev/null @@ -1,59 +0,0 @@ -package com.epmet.constant; - -/** - * @Author zxc - * @CreateTime 2020/7/8 17:59 - */ -public interface ThirdApiConstant { - - /** - * 获取预授权码 - */ - String API_CREATE_PREAUTHCODE_URL = "https://api.weixin.qq.com/cgi-bin/component/api_create_preauthcode"; - - /** - * 使用授权码获取授权信息请求地址 - */ - String API_QUERY_AUTH_URL = "https://api.weixin.qq.com/cgi-bin/component/api_query_auth"; - - /** - * 获取令牌请求地址 - */ - String API_COMPONENT_TOKEN_URL = "https://api.weixin.qq.com/cgi-bin/component/api_component_token"; - - String API_AUTHORIZER_TOKEN_URL = "https://api.weixin.qq.com/cgi-bin/component/api_authorizer_token"; - - /** - * 授权回调url - */ - String API_REDIRECT_URL = "https://epmet-dev.elinkservice.cn/api/third/redirectauthcode"; - - /** - * 反参授权回调url - */ - String API_RETURN_REDIRECT_URL = "https://epmet-dev.elinkservice.cn/api/third/redirectauthcode?client=%s&customerId=%s"; - - /** - * 授权注册页面扫码授权 - * component_appid:第三方AppId - * pre_auth_code:预授权码 - * redirect_uri:回调url(获取授权码) - */ - String API_AUTH_REGISTER_URL = "https://mp.weixin.qq.com/cgi-bin/componentloginpage?component_appid=%s&pre_auth_code=%s&redirect_uri=%s"; - - /** - * 创建开放平台帐号并绑定公众号/小程序 - */ - String API_CREATE_OPEN = "https://api.weixin.qq.com/cgi-bin/open/create"; - - /** - * 公众号/小程序绑定到开放平台帐号下 - */ - String API_BIND_OPEN = "https://api.weixin.qq.com/cgi-bin/open/bind?"; - - /** - * 获取授权方的帐号基本信息 - */ - String API_GET_AUTHORIZER_INFO = "https://api.weixin.qq.com/cgi-bin/component/api_get_authorizer_info"; - -} diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/constant/ThirdRedisKeyConstant.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/constant/ThirdRedisKeyConstant.java index 43e1e19f52..13fa20c226 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/constant/ThirdRedisKeyConstant.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/constant/ThirdRedisKeyConstant.java @@ -34,7 +34,7 @@ public interface ThirdRedisKeyConstant { /** * 第三方 和 授权方交互使用的 */ - String AUTHORIZER_REFRESH_TOKEN_REDIS_KEY = "epmet:wechartthird:authorizerrefreshtoken"; + String AUTHORIZER_REFRESH_TOKEN_REDIS_KEY = "epmet:wechartthird:authorizerrefreshtoken:"; /** * auth_code 授权码 diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/constant/ThirdRunTimeInfoConstant.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/constant/ThirdRunTimeInfoConstant.java index 2e0448a712..2e4e5e7083 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/constant/ThirdRunTimeInfoConstant.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/constant/ThirdRunTimeInfoConstant.java @@ -80,4 +80,6 @@ public interface ThirdRunTimeInfoConstant { */ String TO_LIMIT = "该开放平台帐号所绑定的公众号/小程序已达上限(100 个)"; + String VERIFY_TICKET = "msgSignature = %s, timeStamp = %s, nonce = %s, encryptType = %s, signature = %s"; + } diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/AuthRedirectController.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/AuthRedirectController.java index b1b89e380d..72e1330724 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/AuthRedirectController.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/AuthRedirectController.java @@ -1,14 +1,16 @@ package com.epmet.controller; +import com.epmet.commons.tools.annotation.LoginUser; +import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.utils.Result; +import com.epmet.dto.form.AuthCodeAndTimeFromDTO; import com.epmet.service.ComponentVerifyTicketService; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import java.io.IOException; /** * @Author zxc @@ -26,9 +28,9 @@ public class AuthRedirectController { * @param * @author zxc */ - @GetMapping("redirect") - public Result redirectUri(HttpServletRequest request, HttpServletResponse response){ - componentVerifyTicketService.redirectUri(request,response); + @PostMapping("redirect") + public Result redirectUri(@LoginUser TokenDto tokenDto, @RequestBody AuthCodeAndTimeFromDTO fromDTO){ + componentVerifyTicketService.redirectUri(tokenDto,fromDTO); return new Result(); } diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/CodeController.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/CodeController.java index 59eef94f35..c24e502e47 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/CodeController.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/CodeController.java @@ -1,13 +1,13 @@ package com.epmet.controller; +import com.baomidou.mybatisplus.extension.api.R; +import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.utils.Result; -import com.epmet.dto.form.CodeCommonFormDTO; -import com.epmet.dto.form.CodeUploadFormDTO; -import com.epmet.dto.form.SubmitAuditFormDTO; -import com.epmet.dto.form.UploadListFormDTO; -import com.epmet.dto.result.TemplateListResultDTO; -import com.epmet.dto.result.UploadListResultDTO; +import com.epmet.dto.form.*; +import com.epmet.dto.result.*; +import com.epmet.service.CodeService; import oracle.jdbc.proxy.annotation.Post; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; @@ -24,62 +24,159 @@ import java.util.List; @RequestMapping("code") public class CodeController { + @Autowired + private CodeService codeService; + /** * 获取代码模板列表 + * + * @return com.epmet.commons.tools.utils.Result * @author zhaoqifeng * @date 2020/7/14 15:10 - * @return com.epmet.commons.tools.utils.Result */ @PostMapping("templatelist") public Result> templateList() { - return null; + List list = codeService.templateList(); + return new Result>().ok(list); + } + + /** + * 获取客户第三方配置 + * + * @param formDTO + * @return com.epmet.commons.tools.utils.Result + * @author zhaoqifeng + * @date 2020/7/17 16:22 + */ + @PostMapping("getextjson") + public Result getExtJson(CodeUploadFormDTO formDTO) { + String extJson = codeService.getExtJson(formDTO); + return new Result().ok(extJson); } /** * 代码上传 + * + * @param formDTO 参数 + * @return com.epmet.commons.tools.utils.Result * @author zhaoqifeng * @date 2020/7/9 14:23 - * @param formDTO - * @return com.epmet.commons.tools.utils.Result */ @PostMapping("upload") public Result upload(@RequestBody CodeUploadFormDTO formDTO) { + codeService.upload(formDTO); return new Result<>(); } /** * 已上传代码列表 + * + * @param formDTO 参数 + * @return com.epmet.commons.tools.utils.Result> * @author zhaoqifeng * @date 2020/7/14 16:30 - * @param formDTO - * @return com.epmet.commons.tools.utils.Result> */ @PostMapping("uploadlist") - public Result> uploadList(@RequestBody UploadListFormDTO formDTO) { - return new Result<>(); + public Result uploadList(@RequestBody UploadListFormDTO formDTO) { + PageData pageData = codeService.uploadList(formDTO); + return new Result().ok(pageData); } /** * 提交审核 + * + * @param formDTO 参数 + * @return com.epmet.commons.tools.utils.Result * @author zhaoqifeng * @date 2020/7/14 16:40 - * @param formDTO - * @return com.epmet.commons.tools.utils.Result */ @PostMapping("audit") public Result submitAudit(@RequestBody SubmitAuditFormDTO formDTO) { + codeService.submitAudit(formDTO); return new Result<>(); } /** * 审核撤回 + * + * @param formDTO 参数 + * @return com.epmet.commons.tools.utils.Result * @author zhaoqifeng * @date 2020/7/14 17:52 - * @param formDTO - * @return com.epmet.commons.tools.utils.Result */ @PostMapping("undo") public Result undo(@RequestBody CodeCommonFormDTO formDTO) { + codeService.undo(formDTO); return new Result<>(); } + + /** + * 发布 + * + * @param formDTO 参数 + * @return com.epmet.commons.tools.utils.Result + * @author zhaoqifeng + * @date 2020/7/14 17:52 + */ + @PostMapping("release") + public Result release(@RequestBody CodeCommonFormDTO formDTO) { + codeService.release(formDTO); + return new Result<>(); + } + + /** + * 审核失败原因 + * + * @param formDTO 参数 + * @return com.epmet.commons.tools.utils.Result + * @author zhaoqifeng + * @date 2020/7/14 17:52 + */ + @PostMapping("reason") + public Result reason(@RequestBody CodeCommonFormDTO formDTO) { + ReasonResultDTO resultDTO = codeService.reason(formDTO); + return new Result().ok(resultDTO); + } + + /** + * 获取体验版二维码 + * + * @param formDTO 参数 + * @return com.epmet.commons.tools.utils.Result + * @author zhaoqifeng + * @date 2020/7/14 17:52 + */ + @PostMapping("qrcode") + public Result qrCode(@RequestBody CodeCommonFormDTO formDTO) { + QrCodeResultDTO resultDTO = codeService.qrCode(formDTO); + return new Result().ok(resultDTO); + } + + /** + * 操作历史 + * + * @param formDTO 参数 + * @return com.epmet.commons.tools.utils.Result + * @author zhaoqifeng + * @date 2020/7/16 10:16 + */ + @PostMapping("history") + public Result history(@RequestBody CodeCommonFormDTO formDTO) { + PageData result = codeService.history(formDTO); + return new Result().ok(result); + } + + /** + * 上传临时素材 + * + * @param formDTO + * @return com.epmet.commons.tools.utils.Result> + * @author zhaoqifeng + * @date 2020/7/17 11:20 + */ + @PostMapping("mediaupload") + public Result mediaUpload(@RequestBody MediaUploadFormDTO formDTO) { + String result = codeService.mediaUpload(formDTO); + return new Result().ok(result); + } } diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/CodeExtController.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/CodeExtController.java new file mode 100644 index 0000000000..c4b9a467e9 --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/CodeExtController.java @@ -0,0 +1,84 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

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

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

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.controller; + +import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.utils.Result; +import com.epmet.commons.tools.validator.AssertUtils; +import com.epmet.commons.tools.validator.ValidatorUtils; +import com.epmet.commons.tools.validator.group.AddGroup; +import com.epmet.commons.tools.validator.group.DefaultGroup; +import com.epmet.commons.tools.validator.group.UpdateGroup; +import com.epmet.dto.CodeExtDTO; +import com.epmet.service.CodeExtService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.Map; + + +/** + * 代码第三方配置 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-07-17 + */ +@RestController +@RequestMapping("codeext") +public class CodeExtController { + + @Autowired + private CodeExtService codeExtService; + + @GetMapping("page") + public Result> page(@RequestParam Map params){ + PageData page = codeExtService.page(params); + return new Result>().ok(page); + } + + @GetMapping("{id}") + public Result get(@PathVariable("id") String id){ + CodeExtDTO data = codeExtService.get(id); + return new Result().ok(data); + } + + @PostMapping + public Result save(@RequestBody CodeExtDTO dto){ + //效验数据 + ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); + codeExtService.save(dto); + return new Result(); + } + + @PutMapping + public Result update(@RequestBody CodeExtDTO dto){ + //效验数据 + ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); + codeExtService.update(dto); + return new Result(); + } + + @DeleteMapping + public Result delete(@RequestBody String[] ids){ + //效验数据 + AssertUtils.isArrayEmpty(ids, "id"); + codeExtService.delete(ids); + return new Result(); + } + +} \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/CustomerCodeOperationHistoryController.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/CodeOperationHistoryController.java similarity index 62% rename from epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/CustomerCodeOperationHistoryController.java rename to epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/CodeOperationHistoryController.java index a764889ed6..4a7fb08c98 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/CustomerCodeOperationHistoryController.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/CodeOperationHistoryController.java @@ -24,8 +24,8 @@ import com.epmet.commons.tools.validator.ValidatorUtils; import com.epmet.commons.tools.validator.group.AddGroup; import com.epmet.commons.tools.validator.group.UpdateGroup; import com.epmet.commons.tools.validator.group.DefaultGroup; -import com.epmet.dto.CustomerCodeOperationHistoryDTO; -import com.epmet.service.CustomerCodeOperationHistoryService; +import com.epmet.dto.CodeOperationHistoryDTO; +import com.epmet.service.CodeOperationHistoryService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; @@ -39,37 +39,37 @@ import java.util.Map; * @since v1.0.0 2020-07-09 */ @RestController -@RequestMapping("customercodeoperationhistory") -public class CustomerCodeOperationHistoryController { +@RequestMapping("codeoperationhistory") +public class CodeOperationHistoryController { @Autowired - private CustomerCodeOperationHistoryService customerCodeOperationHistoryService; + private CodeOperationHistoryService codeOperationHistoryService; @GetMapping("page") - public Result> page(@RequestParam Map params){ - PageData page = customerCodeOperationHistoryService.page(params); - return new Result>().ok(page); + public Result> page(@RequestParam Map params){ + PageData page = codeOperationHistoryService.page(params); + return new Result>().ok(page); } @GetMapping("{id}") - public Result get(@PathVariable("id") String id){ - CustomerCodeOperationHistoryDTO data = customerCodeOperationHistoryService.get(id); - return new Result().ok(data); + public Result get(@PathVariable("id") String id){ + CodeOperationHistoryDTO data = codeOperationHistoryService.get(id); + return new Result().ok(data); } @PostMapping - public Result save(@RequestBody CustomerCodeOperationHistoryDTO dto){ + public Result save(@RequestBody CodeOperationHistoryDTO dto){ //效验数据 ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); - customerCodeOperationHistoryService.save(dto); + codeOperationHistoryService.save(dto); return new Result(); } @PutMapping - public Result update(@RequestBody CustomerCodeOperationHistoryDTO dto){ + public Result update(@RequestBody CodeOperationHistoryDTO dto){ //效验数据 ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); - customerCodeOperationHistoryService.update(dto); + codeOperationHistoryService.update(dto); return new Result(); } @@ -77,7 +77,7 @@ public class CustomerCodeOperationHistoryController { public Result delete(@RequestBody String[] ids){ //效验数据 AssertUtils.isArrayEmpty(ids, "id"); - customerCodeOperationHistoryService.delete(ids); + codeOperationHistoryService.delete(ids); return new Result(); } diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/ComponentVerifyTicketController.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/ComponentVerifyTicketController.java index 4a2a6791f5..59df638da9 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/ComponentVerifyTicketController.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/ComponentVerifyTicketController.java @@ -22,7 +22,7 @@ public class ComponentVerifyTicketController { private ComponentVerifyTicketService componentVerifyTicketService; /** - * @Description 获取验证票据3 + * @Description 获取验证票据 * @author zxc */ @PostMapping(value = "/callback") diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/CustomerMpController.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/CustomerMpController.java index fc1cfafafb..d338789f03 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/CustomerMpController.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/CustomerMpController.java @@ -23,9 +23,12 @@ import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.validator.AssertUtils; import com.epmet.commons.tools.validator.ValidatorUtils; import com.epmet.commons.tools.validator.group.AddGroup; -import com.epmet.commons.tools.validator.group.UpdateGroup; import com.epmet.commons.tools.validator.group.DefaultGroup; +import com.epmet.commons.tools.validator.group.UpdateGroup; import com.epmet.dto.CustomerMpDTO; +import com.epmet.dto.UserWechatDTO; +import com.epmet.dto.form.WxLoginFormDTO; +import com.epmet.dto.result.PublicCustomerResultDTO; import com.epmet.excel.CustomerMpExcel; import com.epmet.service.CustomerMpService; import org.springframework.beans.factory.annotation.Autowired; @@ -91,4 +94,26 @@ public class CustomerMpController { ExcelUtils.exportExcelToTarget(response, null, list, CustomerMpExcel.class); } + /** + * @param formDTO + * @return + * @Author sun + * @Description 校验appId是否有效以及是否授权,校验通过的调用微信API获取用户基本信息 + **/ + @PostMapping("resiandworklogin") + public Result resiAndWorkLogin(@RequestBody WxLoginFormDTO formDTO) { + return new Result().ok(customerMpService.resiAndWorkLogin(formDTO)); + } + + /** + * @param appId + * @return + * @Author sun + * @Description 根据appId查询公众号注册的客户信息 + **/ + @PostMapping("getcustomermsg/{appId}") + public Result getCustomerMsg(@PathVariable("appId") String appId) { + return new Result().ok(customerMpService.getCustomerMsg(appId)); + } + } \ No newline at end of file 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 60962bd6a0..519a1a4cc4 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/PaCustomerController.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/PaCustomerController.java @@ -7,18 +7,13 @@ import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.validator.ValidatorUtils; import com.epmet.commons.tools.validator.group.DefaultGroup; import com.epmet.dto.form.CreateAgencyFormDTO; -import com.epmet.dto.form.MyInfoFormDTO; +import com.epmet.dto.form.RegisterByAuthFormDTO; import com.epmet.dto.form.RegisterFormDTO; import com.epmet.dto.form.RegisterInfoFormDTO; -import com.epmet.dto.result.AgencyLevelListResultDTO; -import com.epmet.dto.result.CreateAgencyResultDTO; -import com.epmet.dto.result.MyInfoResultDTO; +import com.epmet.dto.result.*; import com.epmet.service.*; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; import java.util.List; @@ -80,16 +75,14 @@ public class PaCustomerController { } /** - * @param formDTO + * @param tokenDTO * @return * @Author sun * @Description 公众号-查询我的信息 **/ @PostMapping("myinfo") - public Result myInfo(@LoginUser TokenDto tokenDTO, @RequestBody MyInfoFormDTO formDTO) { - //ValidatorUtils.validateEntity(formDTO, MyInfoFormDTO.AddUserInternalGroup.class); - ValidatorUtils.validateEntity(formDTO); - return new Result().ok(paCustomerService.myInfo(tokenDTO, formDTO)); + public Result myInfo(@LoginUser TokenDto tokenDTO) { + return new Result().ok(paCustomerService.myInfo(tokenDTO)); } /** @@ -104,5 +97,39 @@ public class PaCustomerController { return new Result().ok(paCustomerService.registerInfo(formDTO)); } + /** + * @param customerId + * @return + * @Author sun + * @Description 根据客户Id查询各项注册信息 + **/ + @PostMapping(value = "getcustomeragencyuser/{customerId}") + public Result getCustomerAgencyUser(@PathVariable("customerId") String customerId) { + return new Result().ok(paCustomerService.getCustomerAgencyUser(customerId)); + } + + /** + * @param customerId + * @return + * @Author sun + * @Description 修改客户数据状态为已完成初始化 + **/ + @PostMapping(value = "updatecustomer/{customerId}") + public Result updateCustomer(@PathVariable("customerId") String customerId) { + paCustomerService.updateCustomer(customerId); + return new Result(); + } + + /** + * @param formDTO + * @return + * @Author sun + * @Description 根据授权状态和初始化状态获取客户列表(不分页) + **/ + @PostMapping(value = "registerbyauth") + public Result> registerByAuth(@LoginUser TokenDto tokenDTO, @RequestBody RegisterByAuthFormDTO formDTO) { + ValidatorUtils.validateEntity(formDTO, RegisterByAuthFormDTO.AddUserInternalGroup.class); + return new Result>().ok( paCustomerService.registerByAuth(formDTO)); + } } diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/WarrantController.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/WarrantController.java index 1acb7a60ab..1cb35bb666 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/WarrantController.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/WarrantController.java @@ -1,6 +1,6 @@ package com.epmet.controller; -import com.epmet.exception.AesException; +import com.epmet.mpaes.AesException; import com.epmet.service.WarrantService; import lombok.extern.slf4j.Slf4j; import org.dom4j.DocumentException; diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/WeChatNotifyController.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/WeChatNotifyController.java index 27e1051b58..36e2ee3d5e 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/WeChatNotifyController.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/WeChatNotifyController.java @@ -1,6 +1,7 @@ package com.epmet.controller; import com.epmet.commons.tools.utils.Result; +import com.epmet.constant.ModuleConstant; import com.epmet.service.ComponentVerifyTicketService; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; @@ -27,7 +28,8 @@ public class WeChatNotifyController { @PostMapping("componentaccesstoken") public Result getComponentAccessToken() { log.info("开始获取【component_access_token】......"); - componentVerifyTicketService.getComponentAccessToken(); + String accessTokenCountFlag = ModuleConstant.ACCOUNT_TOKEN_FLAG_TWO; + componentVerifyTicketService.getComponentAccessToken(accessTokenCountFlag); log.info("已成功获取到【component_access_token】......"); return new Result(); } diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/AuthCodeDao.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/AuthCodeDao.java index 53bf395ea1..f4e9eaf698 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/AuthCodeDao.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/AuthCodeDao.java @@ -55,5 +55,12 @@ public interface AuthCodeDao extends BaseDao { * @author zxc */ void updateAppId(@Param("customerId")String customerId,@Param("clientType")String clientType,@Param("authAppId")String authAppId); - + + /** + * @Description 逻辑删除客户下的授权码,保持一个授权码有用 + * @param customerId + * @param clientType + * @author zxc + */ + void deleteCustomerAuthCode(@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/CodeCustomerDao.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/CodeCustomerDao.java index 7b3e60abe3..60e77b7bcf 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/CodeCustomerDao.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/CodeCustomerDao.java @@ -18,6 +18,7 @@ package com.epmet.dao; import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.dto.CodeCustomerDTO; import com.epmet.dto.form.UploadListFormDTO; import com.epmet.dto.result.UploadListResultDTO; import com.epmet.dto.form.CodeAuditRecordFormDTO; @@ -61,4 +62,23 @@ public interface CodeCustomerDao extends BaseDao { */ String selectCodeCustomerId(CodeAuditRecordFormDTO codeAuditRecord); + /** + * 删除旧的上传记录 + * @author zhaoqifeng + * @date 2020/7/15 18:06 + * @param customerId + * @param clientType + * @return void + */ + void deleteCode(@Param("customerId") String customerId, @Param("clientType") String clientType); + + /** + * 获取审核中代码列表 + * @author zhaoqifeng + * @date 2020/7/15 18:17 + * @param + * @return java.util.List + */ + List selectAuditingCodeList(); + } \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/CodeExtDao.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/CodeExtDao.java new file mode 100644 index 0000000000..8964c7bc3d --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/CodeExtDao.java @@ -0,0 +1,54 @@ +/** + * 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.dto.CodeExtDTO; +import com.epmet.entity.CodeExtEntity; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +/** + * 代码第三方配置 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-07-17 + */ +@Mapper +public interface CodeExtDao extends BaseDao { + + /** + * 获取第三方配置模板 + * @author zhaoqifeng + * @date 2020/7/17 15:25 + * @param + * @return java.lang.String + */ + String selectExtTemplate(@Param("clientType") String clientType); + + /** + * 获取客户的第三方配置 + * @author zhaoqifeng + * @date 2020/7/17 15:26 + * @param customerId + * @param clientType + * @return java.lang.String + */ + CodeExtDTO selectExtByCustomerId(@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/CodeOperationHistoryDao.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/CodeOperationHistoryDao.java new file mode 100644 index 0000000000..f624c2212e --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/CodeOperationHistoryDao.java @@ -0,0 +1,48 @@ +/** + * 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.dto.result.CodeHistoryResultDTO; +import com.epmet.entity.CodeOperationHistoryEntity; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * 客户代码操作历史 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-07-09 + */ +@Mapper +public interface CodeOperationHistoryDao extends BaseDao { + + List selectHistoryList(@Param("customerId") String customerId, @Param("clientType") String clientType); + + /** + * 更新描述 + * @author zhaoqifeng + * @date 2020/7/16 16:11 + * @param codeId + * @param describe + * @return void + */ + void updateDescribeByCodeId(@Param("codeId") String codeId, @Param("describe") String describe); +} \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/CustomerMpDao.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/CustomerMpDao.java index c8609064e9..593194e2c7 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/CustomerMpDao.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/CustomerMpDao.java @@ -19,6 +19,7 @@ package com.epmet.dao; import com.epmet.commons.mybatis.dao.BaseDao; import com.epmet.dto.CustomerMpDTO; +import com.epmet.dto.PaCustomerDTO; import com.epmet.dto.form.AuthCodeFormDTO; import com.epmet.entity.CustomerMpEntity; import org.apache.ibatis.annotations.Mapper; @@ -81,4 +82,29 @@ public interface CustomerMpDao extends BaseDao { */ String selectClientTypeByCustomerIdAndAuthId(@Param("customerId")String customerId,@Param("authAppId")String authAppId); + /** + * 获取授权状态 + * @param customerId + * @param clientType + * @return java.lang.Boolean + * @author zhaoqifeng + * @date 2020/7/16 15:28 + */ + Boolean selectAuthFlag(@Param("customerId")String customerId, @Param("clientType")String clientType); + + /** + * @param appId + * @return + * @Author sun + * @Description 根据appId查询小程序信息 + **/ + CustomerMpDTO selectByAppId(@Param("appId") String appId); + + /** + * @param appId + * @return + * @Author sun + * @Description 根据appId查询客户信息 + **/ + PaCustomerDTO selectCustomerByAppId(@Param("appId") String appId); } \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/FuncInfoDao.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/FuncInfoDao.java index 722a1b889d..28fb939847 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/FuncInfoDao.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/FuncInfoDao.java @@ -46,6 +46,6 @@ public interface FuncInfoDao extends BaseDao { * @param customerId * @author zxc */ - void updateOldFuncInfo(@Param("customerId")String customerId); + void updateOldFuncInfo(@Param("customerId")String customerId,@Param("authAppId")String authAppId); } \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/PaCustomerAgencyDao.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/PaCustomerAgencyDao.java index 219d88fd83..a3031b9b15 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/PaCustomerAgencyDao.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/PaCustomerAgencyDao.java @@ -46,4 +46,12 @@ public interface PaCustomerAgencyDao extends BaseDao { * @Description 公众号-查询客户组织信息 **/ PaCustomerAgencyDTO selectCustomerAgency(@Param("customerId") String customerId); + + /** + * @param customerId + * @return + * @Author sun + * @Description 公众号-查询客户组织信息 + **/ + PaCustomerAgencyDTO selectAgency(@Param("customerId") String customerId); } \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/PaCustomerDao.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/PaCustomerDao.java index de4111e6c6..a632d9b3eb 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/PaCustomerDao.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/PaCustomerDao.java @@ -19,7 +19,9 @@ package com.epmet.dao; import com.epmet.commons.mybatis.dao.BaseDao; import com.epmet.dto.PaCustomerDTO; +import com.epmet.dto.form.RegisterByAuthFormDTO; import com.epmet.dto.result.CustomerAgencyResultDTO; +import com.epmet.dto.result.RegisterByAuthResultDTO; import com.epmet.entity.PaCustomerEntity; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; @@ -50,4 +52,21 @@ public interface PaCustomerDao extends BaseDao { * @Description 查询公众号注册的客户信息列表 **/ List registerInfo(); + + /** + * @param dto + * @return + * @Author sun + * @Description 修改客户数据状态为已完成初始化 + **/ + int updateCustomerById(PaCustomerDTO dto); + + /** + * @param formDTO + * @return + * @Author sun + * @Description 根据所属端授权状态、初始化状态查询客户列表数据 + **/ + List selectCustomerList(RegisterByAuthFormDTO formDTO); + } \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/PaUserDao.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/PaUserDao.java index 2ced9f5760..2cdd7a9bb4 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/PaUserDao.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/PaUserDao.java @@ -41,4 +41,12 @@ public interface PaUserDao extends BaseDao { * @Description 根据手机号查询公众号用户基本信息,校验用户是否存在 **/ List selectUserByPhone(@Param("phone") String phone); + + /** + * @param customerId + * @return + * @Author sun + * @Description 根据客户Id级联查询客户管理员注册信息 + **/ + PaUserDTO selectPaUser(@Param("customerId") String customerId); } \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/entity/CodeExtEntity.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/entity/CodeExtEntity.java new file mode 100644 index 0000000000..8be3f7bb34 --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/entity/CodeExtEntity.java @@ -0,0 +1,61 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

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

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

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.entity; + +import com.baomidou.mybatisplus.annotation.TableName; + +import com.epmet.commons.mybatis.entity.BaseEpmetEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.Date; + +/** + * 代码第三方配置 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-07-17 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("code_ext") +public class CodeExtEntity extends BaseEpmetEntity { + + private static final long serialVersionUID = 1L; + + /** + * 客户ID + */ + private String customerId; + + /** + * 所属端 居民的:resi,工作端:work + */ + private String clientType; + + /** + * APPID + */ + private String appId; + + /** + * 自定义配置 + */ + private String extJson; + +} diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/entity/CustomerCodeOperationHistoryEntity.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/entity/CodeOperationHistoryEntity.java similarity index 92% rename from epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/entity/CustomerCodeOperationHistoryEntity.java rename to epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/entity/CodeOperationHistoryEntity.java index e747bb57d4..fe56ddd312 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/entity/CustomerCodeOperationHistoryEntity.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/entity/CodeOperationHistoryEntity.java @@ -33,8 +33,8 @@ import java.util.Date; */ @Data @EqualsAndHashCode(callSuper=false) -@TableName("customer_code_operation_history") -public class CustomerCodeOperationHistoryEntity extends BaseEpmetEntity { +@TableName("code_operation_history") +public class CodeOperationHistoryEntity extends BaseEpmetEntity { private static final long serialVersionUID = 1L; diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/exception/AesException.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/exception/AesException.java deleted file mode 100644 index 6b03534378..0000000000 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/exception/AesException.java +++ /dev/null @@ -1,65 +0,0 @@ -package com.epmet.exception; - -/** - * @Author zxc - * @CreateTime 2020/7/6 10:03 - */ -@SuppressWarnings("serial") -public class AesException extends Exception { - - public final static int OK = 0; - public final static int ValidateSignatureError = -40001; - public final static int ParseXmlError = -40002; - public final static int ComputeSignatureError = -40003; - public final static int IllegalAesKey = -40004; - public final static int ValidateCorpidError = -40005; - public final static int EncryptAESError = -40006; - public final static int DecryptAESError = -40007; - public final static int IllegalBuffer = -40008; - public final static int EncodeBase64Error = -40009; - public final static int DecodeBase64Error = -40010; - public final static int GenReturnXmlError = -40011; - - private int code; - - private static String getMessage(int code) { - switch (code) { - case ValidateSignatureError: - return "签名验证错误"; - case ParseXmlError: - return "xml解析失败"; - case ComputeSignatureError: - return "sha加密生成签名失败"; - case IllegalAesKey: - return "SymmetricKey非法"; - case ValidateCorpidError: - return "corpid校验失败"; - case EncryptAESError: - return "aes加密失败"; - case DecryptAESError: - return "aes解密失败"; - case IllegalBuffer: - return "解密后得到的buffer非法"; - case EncodeBase64Error: - return "base64加密错误"; - case DecodeBase64Error: - return "base64解密错误"; - case GenReturnXmlError: - return "xml生成失败"; - default: - return null; // cannot be - } - } - - public int getCode() { - return code; - } - - public AesException(int code) { - super(getMessage(code)); - this.code = code; - } - -} - - diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/mpaes/AesDecryptUtil.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/mpaes/AesDecryptUtil.java new file mode 100644 index 0000000000..453e2add84 --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/mpaes/AesDecryptUtil.java @@ -0,0 +1,96 @@ +/* + * Copyright (C) 2018 Baidu, Inc. All Rights Reserved. + */ +package com.epmet.mpaes; + +import org.apache.commons.codec.binary.Base64; + +import javax.crypto.Cipher; +import javax.crypto.spec.IvParameterSpec; +import javax.crypto.spec.SecretKeySpec; +import java.nio.charset.Charset; +import java.util.Arrays; + +/** + * JAVA AES 消息加解密 + */ +public class AesDecryptUtil { + + private static Charset CHARSET = Charset.forName("utf-8"); + private Cipher decCipher; + + /** + * 构造函数 + * + * @param encodingAesKey encodingAESKey + * + * @throws Exception 异常错误信息 + */ + public AesDecryptUtil(String encodingAesKey) throws Exception { + int encodingAesKeyLength = 43; + if (encodingAesKey.length() != encodingAesKeyLength) { + throw new Exception("ILLEGAL_AES_KEY_ERROR"); + } + byte[] aesKey = Base64.decodeBase64(encodingAesKey + "="); + + SecretKeySpec keySpec = new SecretKeySpec(aesKey, "AES"); + IvParameterSpec iv = new IvParameterSpec(aesKey, 0, 16); + Cipher encCipher = Cipher.getInstance("AES/CBC/NoPadding"); + encCipher.init(Cipher.ENCRYPT_MODE, keySpec, iv); + + decCipher = Cipher.getInstance("AES/CBC/NoPadding"); + decCipher.init(Cipher.DECRYPT_MODE, keySpec, iv); + } + + /** + * 还原4个字节的网络字节序 + * + * @param orderBytes 字节码 + * + * @return sourceNumber + */ + private int recoverNetworkBytesOrder(byte[] orderBytes) { + int sourceNumber = 0; + int length = 4; + int number = 8; + for (int i = 0; i < length; i++) { + sourceNumber <<= number; + sourceNumber |= orderBytes[i] & 0xff; + } + return sourceNumber; + } + + /** + * 对密文进行解密 + * + * @param text 需要解密的密文 + * + * @return 解密得到的明文 + * + * @throws Exception 异常错误信息 + */ + public String decrypt(String text) + throws Exception { + byte[] original; + try { + + byte[] encrypted = Base64.decodeBase64(text); + original = decCipher.doFinal(encrypted); + } catch (Exception e) { + throw new Exception("DECRYPT_AES_ERROR"); + } + String xmlContent; + try { + // 去除补位字符 + byte[] bytes = PKCS7Encoder.decode(original); + // 分离16位随机字符串,网络字节序和ClientId + byte[] networkOrder = Arrays.copyOfRange(bytes, 16, 20); + int xmlLength = recoverNetworkBytesOrder(networkOrder); + xmlContent = new String(Arrays.copyOfRange(bytes, 20, 20 + xmlLength), CHARSET); + } catch (Exception e) { + throw new Exception("ILLEGAL_BUFFER_ERROR"); + } + return xmlContent; + } + +} \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/mpaes/AesException.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/mpaes/AesException.java new file mode 100644 index 0000000000..4df48adb54 --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/mpaes/AesException.java @@ -0,0 +1,59 @@ +package com.epmet.mpaes; + +@SuppressWarnings("serial") +public class AesException extends Exception { + + /*public final static int OK = 0; + public final static int ValidateSignatureError = -40001; + public final static int ParseXmlError = -40002; + public final static int ComputeSignatureError = -40003; + public final static int IllegalAesKey = -40004; + public final static int ValidateAppidError = -40005; + public final static int EncryptAESError = -40006; + public final static int DecryptAESError = -40007; + public final static int IllegalBuffer = -40008; + //public final static int EncodeBase64Error = -40009; + //public final static int DecodeBase64Error = -40010; + //public final static int GenReturnXmlError = -40011; + + private int code; + + private static String getMessage(int code) { + switch (code) { + case ValidateSignatureError: + return "签名验证错误"; + case ParseXmlError: + return "xml解析失败"; + case ComputeSignatureError: + return "sha加密生成签名失败"; + case IllegalAesKey: + return "SymmetricKey非法"; + case ValidateAppidError: + return "appid校验失败"; + case EncryptAESError: + return "aes加密失败"; + case DecryptAESError: + return "aes解密失败"; + case IllegalBuffer: + return "解密后得到的buffer非法"; +// case EncodeBase64Error: +// return "base64加密错误"; +// case DecodeBase64Error: +// return "base64解密错误"; +// case GenReturnXmlError: +// return "xml生成失败"; + default: + return null; // cannot be + } + } + + public int getCode() { + return code; + } + + AesException(int code) { + super(getMessage(code)); + this.code = code; + }*/ + +} diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/mpaes/ByteGroup.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/mpaes/ByteGroup.java new file mode 100644 index 0000000000..a4090d265f --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/mpaes/ByteGroup.java @@ -0,0 +1,26 @@ +package com.epmet.mpaes; + +import java.util.ArrayList; + +class ByteGroup { + ArrayList byteContainer = new ArrayList(); + + public byte[] toBytes() { + byte[] bytes = new byte[byteContainer.size()]; + for (int i = 0; i < byteContainer.size(); i++) { + bytes[i] = byteContainer.get(i); + } + return bytes; + } + + public ByteGroup addBytes(byte[] bytes) { + for (byte b : bytes) { + byteContainer.add(b); + } + return this; + } + + public int size() { + return byteContainer.size(); + } +} diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/mpaes/PKCS7Encoder.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/mpaes/PKCS7Encoder.java new file mode 100644 index 0000000000..4c7e024f25 --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/mpaes/PKCS7Encoder.java @@ -0,0 +1,67 @@ +/** + * 对公众平台发送给公众账号的消息加解密示例代码. + * + * @copyright Copyright (c) 1998-2014 Tencent Inc. + */ + +// ------------------------------------------------------------------------ + +package com.epmet.mpaes; + +import java.nio.charset.Charset; +import java.util.Arrays; + +/** + * 提供基于PKCS7算法的加解密接口. + */ +class PKCS7Encoder { + static Charset CHARSET = Charset.forName("utf-8"); + static int BLOCK_SIZE = 32; + + /** + * 获得对明文进行补位填充的字节. + * + * @param count 需要进行填充补位操作的明文字节个数 + * @return 补齐用的字节数组 + */ + static byte[] encode(int count) { + // 计算需要填充的位数 + int amountToPad = BLOCK_SIZE - (count % BLOCK_SIZE); + if (amountToPad == 0) { + amountToPad = BLOCK_SIZE; + } + // 获得补位所用的字符 + char padChr = chr(amountToPad); + String tmp = new String(); + for (int index = 0; index < amountToPad; index++) { + tmp += padChr; + } + return tmp.getBytes(CHARSET); + } + + /** + * 删除解密后明文的补位字符 + * + * @param decrypted 解密后的明文 + * @return 删除补位字符后的明文 + */ + static byte[] decode(byte[] decrypted) { + int pad = (int) decrypted[decrypted.length - 1]; + if (pad < 1 || pad > 32) { + pad = 0; + } + return Arrays.copyOfRange(decrypted, 0, decrypted.length - pad); + } + + /** + * 将数字转化成ASCII码对应的字符,用于对明文进行补码 + * + * @param a 需要转化的数字 + * @return 转化得到的字符 + */ + static char chr(int a) { + byte target = (byte) (a & 0xFF); + return (char) target; + } + +} diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/mpaes/SHA1.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/mpaes/SHA1.java new file mode 100644 index 0000000000..9e419b6805 --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/mpaes/SHA1.java @@ -0,0 +1,65 @@ +/** + * 对公众平台发送给公众账号的消息加解密示例代码. + * + * @copyright Copyright (c) 1998-2014 Tencent Inc. + */ + +// ------------------------------------------------------------------------ + +package com.epmet.mpaes; + +import com.epmet.commons.tools.exception.RenException; +import com.epmet.wxapi.enums.WxMaErrorMsgEnum; +import org.springframework.stereotype.Component; + +import java.security.MessageDigest; +import java.util.Arrays; + +/** + * SHA1 class + * + * 计算公众平台的消息签名接口. + */ +@Component +public class SHA1 { + + /** + * 用SHA1算法生成安全签名 + * @param token 票据 + * @param timestamp 时间戳 + * @param nonce 随机字符串 + * @param encrypt 密文 + * @return 安全签名 + * @throws AesException + */ + public static String getSHA1(String token, String timestamp, String nonce, String encrypt) throws AesException { + try { + String[] array = new String[]{token, timestamp, nonce, encrypt}; + StringBuffer sb = new StringBuffer(); + // 字符串排序 + Arrays.sort(array); + for (int i = 0; i < 4; i++) { + sb.append(array[i]); + } + String str = sb.toString(); + // SHA1签名生成 + MessageDigest md = MessageDigest.getInstance("SHA-1"); + md.update(str.getBytes()); + byte[] digest = md.digest(); + + StringBuffer hexstr = new StringBuffer(); + String shaHex = ""; + for (int i = 0; i < digest.length; i++) { + shaHex = Integer.toHexString(digest[i] & 0xFF); + if (shaHex.length() < 2) { + hexstr.append(0); + } + hexstr.append(shaHex); + } + return hexstr.toString(); + } catch (Exception e) { + e.printStackTrace(); + throw new RenException(WxMaErrorMsgEnum.CODE_MINUS_40003.getMsg()); + } + } +} diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/mpaes/WXBizMsgCrypt.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/mpaes/WXBizMsgCrypt.java new file mode 100644 index 0000000000..73b61f930b --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/mpaes/WXBizMsgCrypt.java @@ -0,0 +1,283 @@ +/** + * 对公众平台发送给公众账号的消息加解密示例代码. + * + * @copyright Copyright (c) 1998-2014 Tencent Inc. + */ + +// ------------------------------------------------------------------------ + +/** + * 针对org.apache.commons.codec.binary.Base64, + * 需要导入架包commons-codec-1.9(或commons-codec-1.8等其他版本) + * 官方下载地址:http://commons.apache.org/proper/commons-codec/download_codec.cgi + */ +package com.epmet.mpaes; + +import com.epmet.commons.tools.exception.RenException; +import com.epmet.wxapi.enums.WxMaErrorMsgEnum; +import org.apache.commons.codec.binary.Base64; + +import javax.crypto.Cipher; +import javax.crypto.spec.IvParameterSpec; +import javax.crypto.spec.SecretKeySpec; +import java.nio.charset.Charset; +import java.util.Arrays; +import java.util.Random; + +/** + * 提供接收和推送给公众平台消息的加解密接口(UTF8编码的字符串). + *

    + *
  1. 第三方回复加密消息给公众平台
  2. + *
  3. 第三方收到公众平台发送的消息,验证消息的安全性,并对消息进行解密。
  4. + *
+ * 说明:异常java.security.InvalidKeyException:illegal Key Size的解决方案 + *
    + *
  1. 在官方网站下载JCE无限制权限策略文件(JDK7的下载地址: + * http://www.oracle.com/technetwork/java/javase/downloads/jce-7-download-432124.html
  2. + *
  3. 下载后解压,可以看到local_policy.jar和US_export_policy.jar以及readme.txt
  4. + *
  5. 如果安装了JRE,将两个jar文件放到%JRE_HOME%\lib\security目录下覆盖原来的文件
  6. + *
  7. 如果安装了JDK,将两个jar文件放到%JDK_HOME%\jre\lib\security目录下覆盖原来文件
  8. + *
+ */ +public class WXBizMsgCrypt { + static Charset CHARSET = Charset.forName("utf-8"); + Base64 base64 = new Base64(); + byte[] aesKey; + String token; + String appId; + + /** + * 构造函数 + * @param token 公众平台上,开发者设置的token + * @param encodingAesKey 公众平台上,开发者设置的EncodingAESKey + * @param appId 公众平台appid + * + * @throws AesException 执行失败,请查看该异常的错误码和具体的错误信息 + */ + public WXBizMsgCrypt(String token, String encodingAesKey, String appId) throws AesException { + if (encodingAesKey.length() != 43) { + throw new RenException(WxMaErrorMsgEnum.CODE_MINUS_40004.getMsg()); + } + + this.token = token; + this.appId = appId; + aesKey = Base64.decodeBase64(encodingAesKey + "="); + } + + // 生成4个字节的网络字节序 + byte[] getNetworkBytesOrder(int sourceNumber) { + byte[] orderBytes = new byte[4]; + orderBytes[3] = (byte) (sourceNumber & 0xFF); + orderBytes[2] = (byte) (sourceNumber >> 8 & 0xFF); + orderBytes[1] = (byte) (sourceNumber >> 16 & 0xFF); + orderBytes[0] = (byte) (sourceNumber >> 24 & 0xFF); + return orderBytes; + } + + // 还原4个字节的网络字节序 + int recoverNetworkBytesOrder(byte[] orderBytes) { + int sourceNumber = 0; + for (int i = 0; i < 4; i++) { + sourceNumber <<= 8; + sourceNumber |= orderBytes[i] & 0xff; + } + return sourceNumber; + } + + // 随机生成16位字符串 + String getRandomStr() { + String base = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; + Random random = new Random(); + StringBuffer sb = new StringBuffer(); + for (int i = 0; i < 16; i++) { + int number = random.nextInt(base.length()); + sb.append(base.charAt(number)); + } + return sb.toString(); + } + + /** + * 对明文进行加密. + * + * @param text 需要加密的明文 + * @return 加密后base64编码的字符串 + * @throws AesException aes加密失败 + */ + String encrypt(String randomStr, String text) throws AesException { + ByteGroup byteCollector = new ByteGroup(); + byte[] randomStrBytes = randomStr.getBytes(CHARSET); + byte[] textBytes = text.getBytes(CHARSET); + byte[] networkBytesOrder = getNetworkBytesOrder(textBytes.length); + byte[] appidBytes = appId.getBytes(CHARSET); + + // randomStr + networkBytesOrder + text + appid + byteCollector.addBytes(randomStrBytes); + byteCollector.addBytes(networkBytesOrder); + byteCollector.addBytes(textBytes); + byteCollector.addBytes(appidBytes); + + // ... + pad: 使用自定义的填充方式对明文进行补位填充 + byte[] padBytes = PKCS7Encoder.encode(byteCollector.size()); + byteCollector.addBytes(padBytes); + + // 获得最终的字节流, 未加密 + byte[] unencrypted = byteCollector.toBytes(); + + try { + // 设置加密模式为AES的CBC模式 + Cipher cipher = Cipher.getInstance("AES/CBC/NoPadding"); + SecretKeySpec keySpec = new SecretKeySpec(aesKey, "AES"); + IvParameterSpec iv = new IvParameterSpec(aesKey, 0, 16); + cipher.init(Cipher.ENCRYPT_MODE, keySpec, iv); + + // 加密 + byte[] encrypted = cipher.doFinal(unencrypted); + + // 使用BASE64对加密后的字符串进行编码 + String base64Encrypted = base64.encodeToString(encrypted); + + return base64Encrypted; + } catch (Exception e) { + e.printStackTrace(); + throw new RenException(WxMaErrorMsgEnum.CODE_MINUS_40006.getMsg()); + } + } + + /** + * 对密文进行解密. + * + * @param text 需要解密的密文 + * @return 解密得到的明文 + * @throws AesException aes解密失败 + */ + String decrypt(String text) throws AesException { + byte[] original; + try { + // 设置解密模式为AES的CBC模式 + Cipher cipher = Cipher.getInstance("AES/CBC/NoPadding"); + SecretKeySpec key_spec = new SecretKeySpec(aesKey, "AES"); + IvParameterSpec iv = new IvParameterSpec(Arrays.copyOfRange(aesKey, 0, 16)); + cipher.init(Cipher.DECRYPT_MODE, key_spec, iv); + + // 使用BASE64对密文进行解码 + byte[] encrypted = Base64.decodeBase64(text); + + // 解密 + original = cipher.doFinal(encrypted); + } catch (Exception e) { + e.printStackTrace(); + throw new RenException(WxMaErrorMsgEnum.CODE_MINUS_40007.getMsg()); + } + + String xmlContent, from_appid; + try { + // 去除补位字符 + byte[] bytes = PKCS7Encoder.decode(original); + + // 分离16位随机字符串,网络字节序和AppId + byte[] networkOrder = Arrays.copyOfRange(bytes, 16, 20); + + int xmlLength = recoverNetworkBytesOrder(networkOrder); + + xmlContent = new String(Arrays.copyOfRange(bytes, 20, 20 + xmlLength), CHARSET); + from_appid = new String(Arrays.copyOfRange(bytes, 20 + xmlLength, bytes.length), + CHARSET); + } catch (Exception e) { + e.printStackTrace(); + throw new RenException(WxMaErrorMsgEnum.CODE_MINUS_40008.getMsg()); + } + + // appid不相同的情况 + if (!from_appid.equals(appId)) { + throw new RenException(WxMaErrorMsgEnum.CODE_MINUS_40005.getMsg()); + } + return xmlContent; + + } + + /** + * 将公众平台回复用户的消息加密打包. + *
    + *
  1. 对要发送的消息进行AES-CBC加密
  2. + *
  3. 生成安全签名
  4. + *
  5. 将消息密文和安全签名打包成xml格式
  6. + *
+ * + * @param replyMsg 公众平台待回复用户的消息,xml格式的字符串 + * @param timeStamp 时间戳,可以自己生成,也可以用URL参数的timestamp + * @param nonce 随机串,可以自己生成,也可以用URL参数的nonce + * + * @return 加密后的可以直接回复用户的密文,包括msg_signature, timestamp, nonce, encrypt的xml格式的字符串 + * @throws AesException 执行失败,请查看该异常的错误码和具体的错误信息 + */ + public String encryptMsg(String replyMsg, String timeStamp, String nonce) throws AesException { + // 加密 + String encrypt = encrypt(getRandomStr(), replyMsg); + + // 生成安全签名 + if (timeStamp == "") { + timeStamp = Long.toString(System.currentTimeMillis()); + } + + String signature = SHA1.getSHA1(token, timeStamp, nonce, encrypt); + + // System.out.println("发送给平台的签名是: " + signature[1].toString()); + // 生成发送的xml + String result = XMLParse.generate(encrypt, signature, timeStamp, nonce); + return result; + } + + /** + * 检验消息的真实性,并且获取解密后的明文. + *
    + *
  1. 利用收到的密文生成安全签名,进行签名验证
  2. + *
  3. 若验证通过,则提取xml中的加密消息
  4. + *
  5. 对消息进行解密
  6. + *
+ * + * @param msgSignature 签名串,对应URL参数的msg_signature + * @param timeStamp 时间戳,对应URL参数的timestamp + * @param nonce 随机串,对应URL参数的nonce + * @param postData 密文,对应POST请求的数据 + * + * @return 解密后的原文 + * @throws AesException 执行失败,请查看该异常的错误码和具体的错误信息 + */ + public String decryptMsg(String msgSignature, String timeStamp, String nonce, String postData) + throws AesException { + // 提取密文 + String encrypt = XMLParse.extract(postData); + + // 验证安全签名 + String signature = SHA1.getSHA1(token, timeStamp, nonce, encrypt); + if (!signature.equals(msgSignature)) { + throw new RenException(WxMaErrorMsgEnum.CODE_MINUS_40001.getMsg()); + } + // 解密 + String result = decrypt(encrypt); + return result; + } + + /** + * 验证URL + * @param msgSignature 签名串,对应URL参数的msg_signature + * @param timeStamp 时间戳,对应URL参数的timestamp + * @param nonce 随机串,对应URL参数的nonce + * @param echoStr 随机串,对应URL参数的echostr + * + * @return 解密之后的echostr + * @throws AesException 执行失败,请查看该异常的错误码和具体的错误信息 + */ + public String verifyUrl(String msgSignature, String timeStamp, String nonce, String echoStr) + throws AesException { + String signature = SHA1.getSHA1(token, timeStamp, nonce, echoStr); + + if (!signature.equals(msgSignature)) { + throw new RenException(WxMaErrorMsgEnum.CODE_MINUS_40001.getMsg()); + } + + String result = decrypt(echoStr); + return result; + } + +} \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/util/WXXmlToMapUtil.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/mpaes/WXXmlToMapUtil.java similarity index 87% rename from epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/util/WXXmlToMapUtil.java rename to epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/mpaes/WXXmlToMapUtil.java index e7b119ed20..d405bea43f 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/util/WXXmlToMapUtil.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/mpaes/WXXmlToMapUtil.java @@ -1,5 +1,8 @@ -package com.epmet.util; +package com.epmet.mpaes; +import com.thoughtworks.xstream.XStream; +import com.thoughtworks.xstream.io.naming.NoNameCoder; +import com.thoughtworks.xstream.io.xml.DomDriver; import org.dom4j.Document; import org.dom4j.DocumentException; import org.dom4j.DocumentHelper; @@ -16,6 +19,7 @@ import java.io.ByteArrayInputStream; import java.io.InputStream; import java.io.StringReader; import java.io.StringWriter; +import java.nio.charset.StandardCharsets; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -226,5 +230,40 @@ public class WXXmlToMapUtil { return null; } } + + /** + * 以格式化的方式输出XML + * + * @param obj + * @return + */ + public static String toXml(Object obj) { + XStream xstream = getXStream(); + // 识别obj类中的注解 + xstream.processAnnotations(obj.getClass()); + // 设置JavaBean的类别名 + xstream.aliasType("xml", obj.getClass()); + return xstream.toXML(obj); + } + + /** + * 转换不带CDDATA的XML + * + * @return + * @ + */ + private static XStream getXStream() { + // 实例化XStream基本对象 + XStream xstream = new XStream(new DomDriver(StandardCharsets.UTF_8.name(), new NoNameCoder() { + // 不对特殊字符进行转换,避免出现重命名字段时的“双下划线” + @Override + public String encodeNode(String name) { + return name; + } + })); + // 忽视XML与JAVABEAN转换时,XML中的字段在JAVABEAN中不存在的部分 + xstream.ignoreUnknownElements(); + return xstream; + } } diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/mpaes/XMLParse.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/mpaes/XMLParse.java new file mode 100644 index 0000000000..da53d3b005 --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/mpaes/XMLParse.java @@ -0,0 +1,73 @@ +/** + * 对公众平台发送给公众账号的消息加解密示例代码. + * + * @copyright Copyright (c) 1998-2014 Tencent Inc. + */ + +// ------------------------------------------------------------------------ + +package com.epmet.mpaes; + +import com.epmet.commons.tools.exception.RenException; +import com.epmet.wxapi.enums.WxMaErrorMsgEnum; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.NodeList; +import org.xml.sax.InputSource; + +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import java.io.StringReader; + +/** + * XMLParse class + * + * 提供提取消息格式中的密文及生成回复消息格式的接口. + */ +public class XMLParse { + + /** + * 提取出xml数据包中的加密消息 + * @param xmltext 待提取的xml字符串 + * @return 提取出的加密消息字符串 + * @throws AesException + */ + public static String extract(String xmltext) throws AesException { +// Object[] result = new Object[3]; + try { + DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); + DocumentBuilder db = dbf.newDocumentBuilder(); + StringReader sr = new StringReader(xmltext); + InputSource is = new InputSource(sr); + Document document = db.parse(is); + + Element root = document.getDocumentElement(); + NodeList nodelist1 = root.getElementsByTagName("Encrypt"); + NodeList nodelist2 = root.getElementsByTagName("ToUserName"); +// result[0] = 0; + String result = nodelist1.item(0).getTextContent(); +// result[2] = nodelist2.item(0).getTextContent(); + return result; + } catch (Exception e) { + e.printStackTrace(); + throw new RenException(WxMaErrorMsgEnum.CODE_MINUS_40002.getMsg()); + } + } + + /** + * 生成xml消息 + * @param encrypt 加密后的消息密文 + * @param signature 安全签名 + * @param timestamp 时间戳 + * @param nonce 随机字符串 + * @return 生成的xml字符串 + */ + public static String generate(String encrypt, String signature, String timestamp, String nonce) { + + String format = "\n" + "\n" + + "\n" + + "%3$s\n" + "\n" + ""; + return String.format(format, encrypt, signature, timestamp, nonce); + + } +} diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/redis/CodeExtRedis.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/redis/CodeExtRedis.java new file mode 100644 index 0000000000..ee0290166f --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/redis/CodeExtRedis.java @@ -0,0 +1,47 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

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

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

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.redis; + +import com.epmet.commons.tools.redis.RedisUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +/** + * 代码第三方配置 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-07-17 + */ +@Component +public class CodeExtRedis { + @Autowired + private RedisUtils redisUtils; + + public void delete(Object[] ids) { + + } + + public void set(){ + + } + + public String get(String id){ + return null; + } + +} \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/redis/CustomerCodeOperationHistoryRedis.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/redis/CodeOperationHistoryRedis.java similarity index 96% rename from epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/redis/CustomerCodeOperationHistoryRedis.java rename to epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/redis/CodeOperationHistoryRedis.java index 247e724de9..cb698781b0 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/redis/CustomerCodeOperationHistoryRedis.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/redis/CodeOperationHistoryRedis.java @@ -28,7 +28,7 @@ import org.springframework.stereotype.Component; * @since v1.0.0 2020-07-09 */ @Component -public class CustomerCodeOperationHistoryRedis { +public class CodeOperationHistoryRedis { @Autowired private RedisUtils redisUtils; diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/redis/RedisThird.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/redis/RedisThird.java index de326be7d7..9317ce418e 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/redis/RedisThird.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/redis/RedisThird.java @@ -1,18 +1,19 @@ package com.epmet.redis; +import cn.hutool.core.bean.BeanUtil; import com.epmet.commons.tools.redis.RedisUtils; -import com.epmet.constant.ModuleConstant; import com.epmet.constant.ThirdRedisKeyConstant; import com.epmet.dto.form.AuthCodeFormDTO; import com.epmet.dto.form.AuthorizationInfoFormDTO; -import com.epmet.dto.form.AuthorizerAccessTokenFormDTO; import com.epmet.dto.result.AuthorizationInfoResultDTO; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Component; -import java.util.concurrent.TimeUnit; +import java.util.Map; + +import static com.epmet.commons.tools.redis.RedisUtils.NOT_EXPIRE; /** * @Author zxc @@ -73,28 +74,29 @@ public class RedisThird { /** * @Description 缓存 刷新令牌 【授权信息(不包括 授权给开发者的权限集列表)】 - * (在授权的公众号具备API权限时,才有此返回值),刷新令牌主要用于第三方平台获取和刷新已授权用户的 authorizer_access_token。 - * 一旦丢失,只能让用户重新授权,才能再次拿到新的刷新令牌。用户重新授权后,之前的刷新令牌会失效 * @param authInfoDTO + * key = 前缀+客户ID+客户端类型 * @author zxc */ public void setAuthorizerRefreshToken(AuthorizationInfoFormDTO authInfoDTO){ - String key = ThirdRedisKeyConstant.AUTHORIZER_REFRESH_TOKEN_REDIS_KEY + ThirdRedisKeyConstant.COLON + authInfoDTO.getCustomerId()+ThirdRedisKeyConstant.COLON+authInfoDTO.getClientType(); - redisUtils.set(key,authInfoDTO,-1); + Map map = BeanUtil.beanToMap(authInfoDTO, false, true); + String key = ThirdRedisKeyConstant.AUTHORIZER_REFRESH_TOKEN_REDIS_KEY + authInfoDTO.getCustomerId()+ThirdRedisKeyConstant.COLON+authInfoDTO.getClientType(); + redisUtils.hMSet(key, map,NOT_EXPIRE); } /** * @Description 获取刷新 - * @param key = epmet:wechartthird:authorizerrefreshtoken:customerId:clientType + * @param key = epmet:wechartthird:authorizerrefreshtoken:custome rId:clientType 前缀+客户ID+客户端类型 * @author zxc */ - public String getAuthorizerRefreshToken(String key){ - return redisTemplate.opsForValue().get(ThirdRedisKeyConstant.AUTHORIZER_REFRESH_TOKEN_REDIS_KEY+key).toString(); + public Map getAuthorizerRefreshToken(String key){ + Map result = redisUtils.hGetAll(ThirdRedisKeyConstant.AUTHORIZER_REFRESH_TOKEN_REDIS_KEY + key); + return result; } /** * @Description 缓存授权码 auth_Code - * @param + * key = ""前缀+客户ID+客户端类型 * @author zxc */ public void setAuthCode(AuthCodeFormDTO formDTO){ @@ -105,7 +107,7 @@ public class RedisThird { /** * @Description 获取授权码 * 授权码, 会在授权成功时(回调url)返回给第三方平台【code、expiresIn】 - * @param key + * @param key = "epmet:wechartthird:authcode:customerId:clientType"前缀+客户ID+客户端类型 * @author zxc */ public String getAuthCode(String key){ @@ -115,21 +117,12 @@ public class RedisThird { /** * @Description 缓存授权信息【完整的,包括 授权给开发者的权限集列表 】 * @param authInfo + * key = "epmet:wechartthird:authinfo:customerId:clientType"前缀+客户ID+客户端类型 * @author zxc */ - public void setAuthInfo(AuthorizationInfoResultDTO authInfo){ - redisUtils.set(ThirdRedisKeyConstant.AUTH_INFO_REDIS_KEY,authInfo,-1); + public void setAuthInfo(AuthorizationInfoResultDTO authInfo,String customerId,String clientType){ + String key = ThirdRedisKeyConstant.AUTH_INFO_REDIS_KEY+ThirdRedisKeyConstant.COLON+customerId+ThirdRedisKeyConstant.COLON+clientType; + redisUtils.set(key,authInfo,-1); } - /** - * @Description 缓存 刷新后的 授权方令牌 【authorizer_access_token】 和 刷新令牌 【authorizer_refresh_token】 - * @param refreshAccessToken - * @param clientType - * @author zxc - */ - /*public void setAuthorizerRefreshToken(AuthorizerAccessTokenFormDTO refreshAccessToken,String clientType){ - String key = ThirdRedisKeyConstant.AUTHORIZER_REFRESH_TOKEN_REDIS_KEY + ThirdRedisKeyConstant.COLON + refreshAccessToken.getCustomerId()+ThirdRedisKeyConstant.COLON+clientType; - redisUtils.set(key,refreshAccessToken,-1); - }*/ - } diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/CodeCustomerService.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/CodeCustomerService.java index bfa85cc383..fc2190a39d 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/CodeCustomerService.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/CodeCustomerService.java @@ -102,4 +102,23 @@ public interface CodeCustomerService extends BaseService { * @return com.epmet.commons.tools.page.PageData */ PageData getCodeList(UploadListFormDTO formDTO); + + /** + * 获取审核中代码列表 + * @author zhaoqifeng + * @date 2020/7/15 18:16 + * @param + * @return java.util.List + */ + List getAuditingCodeList(); + + /** + * 删除旧代码记录 + * @author zhaoqifeng + * @date 2020/7/15 18:10 + * @param customerId + * @param clientType + * @return void + */ + void deleteCode(String customerId, String clientType); } \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/CodeExtService.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/CodeExtService.java new file mode 100644 index 0000000000..888ba2c0a3 --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/CodeExtService.java @@ -0,0 +1,116 @@ +/** + * 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.CodeExtDTO; +import com.epmet.entity.CodeExtEntity; + +import java.util.List; +import java.util.Map; + +/** + * 代码第三方配置 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-07-17 + */ +public interface CodeExtService extends BaseService { + + /** + * 默认分页 + * + * @param params + * @return PageData + * @author generator + * @date 2020-07-17 + */ + PageData page(Map params); + + /** + * 默认查询 + * + * @param params + * @return java.util.List + * @author generator + * @date 2020-07-17 + */ + List list(Map params); + + /** + * 单条查询 + * + * @param id + * @return CodeExtDTO + * @author generator + * @date 2020-07-17 + */ + CodeExtDTO get(String id); + + /** + * 默认保存 + * + * @param dto + * @return void + * @author generator + * @date 2020-07-17 + */ + void save(CodeExtDTO dto); + + /** + * 默认更新 + * + * @param dto + * @return void + * @author generator + * @date 2020-07-17 + */ + void update(CodeExtDTO dto); + + /** + * 批量删除 + * + * @param ids + * @return void + * @author generator + * @date 2020-07-17 + */ + void delete(String[] ids); + + /** + * 获取配置模板 + * + * @param clientType + * @return java.lang.String + * @author zhaoqifeng + * @date 2020/7/17 15:29 + */ + String getExtTemplate(String clientType); + + /** + * 获取客户第三方配置 + * + * @param customerId + * @param clientType + * @return java.lang.String + * @author zhaoqifeng + * @date 2020/7/17 15:29 + */ + CodeExtDTO getExtByCustomer(String customerId, String clientType); +} \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/CustomerCodeOperationHistoryService.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/CodeOperationHistoryService.java similarity index 65% rename from epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/CustomerCodeOperationHistoryService.java rename to epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/CodeOperationHistoryService.java index 986fce9c09..7f0ba1752c 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/CustomerCodeOperationHistoryService.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/CodeOperationHistoryService.java @@ -19,8 +19,9 @@ package com.epmet.service; import com.epmet.commons.mybatis.service.BaseService; import com.epmet.commons.tools.page.PageData; -import com.epmet.dto.CustomerCodeOperationHistoryDTO; -import com.epmet.entity.CustomerCodeOperationHistoryEntity; +import com.epmet.dto.CodeOperationHistoryDTO; +import com.epmet.dto.result.CodeHistoryResultDTO; +import com.epmet.entity.CodeOperationHistoryEntity; import java.util.List; import java.util.Map; @@ -31,7 +32,7 @@ import java.util.Map; * @author generator generator@elink-cn.com * @since v1.0.0 2020-07-09 */ -public interface CustomerCodeOperationHistoryService extends BaseService { +public interface CodeOperationHistoryService extends BaseService { /** * 默认分页 @@ -41,7 +42,7 @@ public interface CustomerCodeOperationHistoryService extends BaseService page(Map params); + PageData page(Map params); /** * 默认查询 @@ -51,7 +52,7 @@ public interface CustomerCodeOperationHistoryService extends BaseService list(Map params); + List list(Map params); /** * 单条查询 @@ -61,7 +62,7 @@ public interface CustomerCodeOperationHistoryService extends BaseService getHistoryList(String customerId, String clientType); + + /** + * 更新描述 + * @author zhaoqifeng + * @date 2020/7/16 16:10 + * @param codeId + * @param describe + * @return void + */ + void updateDescribe(String codeId, String describe); } \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/CodeService.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/CodeService.java index 2ba332f663..9bc9bb9bd1 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/CodeService.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/CodeService.java @@ -1,12 +1,9 @@ package com.epmet.service; import com.epmet.commons.tools.page.PageData; -import com.epmet.dto.form.CodeCommonFormDTO; -import com.epmet.dto.form.CodeUploadFormDTO; -import com.epmet.dto.form.SubmitAuditFormDTO; -import com.epmet.dto.form.UploadListFormDTO; -import com.epmet.dto.result.TemplateListResultDTO; -import com.epmet.dto.result.UploadListResultDTO; +import com.epmet.commons.tools.utils.Result; +import com.epmet.dto.form.*; +import com.epmet.dto.result.*; import java.util.List; @@ -26,10 +23,20 @@ public interface CodeService { */ List templateList(); + /** + * 获取第三方配置 + * + * @param formDTO 参数 + * @return java.lang.String + * @author zhaoqifeng + * @date 2020/7/17 16:04 + */ + String getExtJson(CodeUploadFormDTO formDTO); + /** * 代码上传 * - * @param formDTO + * @param formDTO 参数 * @author zhaoqifeng * @date 2020/7/14 18:15 */ @@ -38,7 +45,7 @@ public interface CodeService { /** * 已上传代码列表 * - * @param formDTO + * @param formDTO 参数 * @return java.util.List < com.epmet.dto.result.UploadListResultDTO> * @author zhaoqifeng * @date 2020/7/14 18:15 @@ -48,7 +55,7 @@ public interface CodeService { /** * 提交审核 * - * @param formDTO + * @param formDTO 参数 * @author zhaoqifeng * @date 2020/7/14 18:15 */ @@ -57,9 +64,58 @@ public interface CodeService { /** * 审核撤回 * - * @param formDTO + * @param formDTO 参数 * @author zhaoqifeng * @date 2020/7/14 18:15 */ void undo(CodeCommonFormDTO formDTO); + + /** + * 发布 + * + * @param formDTO 参数 + * @author zhaoqifeng + * @date 2020/7/14 18:15 + */ + void release(CodeCommonFormDTO formDTO); + + /** + * 审核失败原因 + * + * @param formDTO 参数 + * @return com.epmet.dto.result.ReasonResultDTO + * @author zhaoqifeng + * @date 2020/7/16 9:38 + */ + ReasonResultDTO reason(CodeCommonFormDTO formDTO); + + /** + * 获取体验版二维码 + * + * @param formDTO 参数 + * @return com.epmet.dto.result.QrCodeResultDTO + * @author zhaoqifeng + * @date 2020/7/16 9:49 + */ + QrCodeResultDTO qrCode(CodeCommonFormDTO formDTO); + + /** + * 操作历史 + * + * @param formDTO 参数 + * @return com.epmet.dto.result.CodeHistoryResultDTO + * @author zhaoqifeng + * @date 2020/7/16 10:16 + */ + PageData history(CodeCommonFormDTO formDTO); + + /** + * 上传临时素材 + * + * @param formDTO 参数 + * @return java.util.List + * @author zhaoqifeng + * @date 2020/7/17 11:20 + */ + String mediaUpload(MediaUploadFormDTO formDTO); } diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/ComponentVerifyTicketService.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/ComponentVerifyTicketService.java index 2fb00e3322..28cfae2fde 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/ComponentVerifyTicketService.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/ComponentVerifyTicketService.java @@ -1,7 +1,12 @@ package com.epmet.service; +import com.epmet.commons.tools.security.dto.TokenDto; +import com.epmet.dto.form.AuthCodeAndTimeFromDTO; +import org.springframework.web.bind.annotation.RequestBody; + import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import java.io.IOException; /** * @Author zxc @@ -21,7 +26,7 @@ public interface ComponentVerifyTicketService { * 令牌(component_access_token)是第三方平台接口的调用凭据。令牌的获取是有限制的,每个令牌的有效期为 2 小时 * @author zxc */ - void getComponentAccessToken(); + void getComponentAccessToken(String accessTokenCountFlag); /** * @Description 每个预授权码有效期为 10 分钟。需要先获取令牌才能调用 获取预授权码 @@ -41,6 +46,6 @@ public interface ComponentVerifyTicketService { * @param * @author zxc */ - void redirectUri(HttpServletRequest request, HttpServletResponse response); + void redirectUri(TokenDto tokenDto, @RequestBody AuthCodeAndTimeFromDTO fromDTO); } diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/CustomerMpService.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/CustomerMpService.java index ba98b8b295..35b4245325 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/CustomerMpService.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/CustomerMpService.java @@ -20,6 +20,9 @@ package com.epmet.service; import com.epmet.commons.mybatis.service.BaseService; import com.epmet.commons.tools.page.PageData; import com.epmet.dto.CustomerMpDTO; +import com.epmet.dto.UserWechatDTO; +import com.epmet.dto.form.WxLoginFormDTO; +import com.epmet.dto.result.PublicCustomerResultDTO; import com.epmet.entity.CustomerMpEntity; import java.util.List; @@ -92,4 +95,30 @@ public interface CustomerMpService extends BaseService { * @date 2020-07-09 */ void delete(String[] ids); + + /** + * 获取授权状态 + * @author zhaoqifeng + * @date 2020/7/16 15:34 + * @param customerId + * @param clientType + * @return java.lang.Boolean + */ + Boolean getAuthFlag(String customerId, String clientType); + + /** + * @param formDTO + * @return + * @Author sun + * @Description 校验appId是否有效以及是否授权,校验通过的调用微信API获取用户基本信息 + **/ + UserWechatDTO resiAndWorkLogin(WxLoginFormDTO formDTO); + + /** + * @param appId + * @return + * @Author sun + * @Description 根据appId查询公众号注册的客户信息 + **/ + PublicCustomerResultDTO getCustomerMsg(String appId); } \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/PaCustomerService.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/PaCustomerService.java index e0d5da1a3e..87bd164d01 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/PaCustomerService.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/PaCustomerService.java @@ -22,12 +22,10 @@ import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.dto.PaCustomerDTO; import com.epmet.dto.form.CreateAgencyFormDTO; -import com.epmet.dto.form.MyInfoFormDTO; +import com.epmet.dto.form.RegisterByAuthFormDTO; import com.epmet.dto.form.RegisterFormDTO; import com.epmet.dto.form.RegisterInfoFormDTO; -import com.epmet.dto.result.AgencyLevelListResultDTO; -import com.epmet.dto.result.CreateAgencyResultDTO; -import com.epmet.dto.result.MyInfoResultDTO; +import com.epmet.dto.result.*; import com.epmet.entity.PaCustomerEntity; import java.util.List; @@ -125,12 +123,12 @@ public interface PaCustomerService extends BaseService { CreateAgencyResultDTO createAgency(TokenDto tokenDTO, CreateAgencyFormDTO formDTO); /** - * @param formDTO + * @param tokenDTO * @return * @Author sun * @Description 公众号-查询我的信息 **/ - MyInfoResultDTO myInfo(TokenDto tokenDTO, MyInfoFormDTO formDTO); + MyInfoResultDTO myInfo(TokenDto tokenDTO); /** * @param formDTO @@ -139,4 +137,28 @@ public interface PaCustomerService extends BaseService { * @Description 查询公众号注册的客户信息列表 **/ PageData registerInfo(RegisterInfoFormDTO formDTO); + + /** + * @param customerId + * @return + * @Author sun + * @Description 根据客户Id查询各项注册信息 + **/ + InitCustomerResultDTO getCustomerAgencyUser(String customerId); + + /** + * @param customerId + * @return + * @Author sun + * @Description 修改客户数据状态为已完成初始化 + **/ + void updateCustomer(String customerId); + + /** + * @param formDTO + * @return + * @Author sun + * @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/WarrantService.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/WarrantService.java index 8475322c5b..4ae4cfd5e1 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/WarrantService.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/WarrantService.java @@ -1,8 +1,7 @@ package com.epmet.service; -import com.epmet.exception.AesException; +import com.epmet.mpaes.AesException; import org.dom4j.DocumentException; -import org.springframework.web.bind.annotation.PathVariable; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; 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 49d182479a..a80fe2b76a 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 @@ -1,26 +1,17 @@ package com.epmet.service.impl; -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONObject; import com.epmet.commons.tools.security.dto.TokenDto; -import com.epmet.commons.tools.utils.HttpClientManager; -import com.epmet.constant.ModuleConstant; -import com.epmet.constant.ThirdApiConstant; -import com.epmet.dao.ComponentAccessTokenDao; import com.epmet.dao.PaCustomerAgencyDao; import com.epmet.dto.form.GoToAuthFormDTO; import com.epmet.dto.result.GoToAuthResultDTO; -import com.epmet.redis.RedisThird; import com.epmet.service.AppLetAuthorizationService; import com.epmet.service.ComponentVerifyTicketService; -import com.google.gson.JsonObject; +import com.epmet.wxapi.constant.WxMaCodeConstant; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; -import java.util.Map; - /** * @Author zxc * @CreateTime 2020/7/10 15:52 @@ -33,10 +24,6 @@ public class AppLetAuthorizationServiceImpl implements AppLetAuthorizationServic private PaCustomerAgencyDao paCustomerAgencyDao; @Autowired private ComponentVerifyTicketService componentVerifyTicketService; - @Autowired - private ComponentAccessTokenDao componentAccessTokenDao; - @Autowired - private RedisThird redisThird; @Value("${third.platform.appId}") private String componentAppId; @@ -52,8 +39,8 @@ public class AppLetAuthorizationServiceImpl implements AppLetAuthorizationServic String customerId = paCustomerAgencyDao.getCustomerIdByUserId(userId); //获取预授权码 String preAuthCode = componentVerifyTicketService.preAuthCode(); - String redirectUrl = String.format(ThirdApiConstant.API_RETURN_REDIRECT_URL, formDTO.getClientType(), customerId); - String authUrl = String.format(ThirdApiConstant.API_AUTH_REGISTER_URL, componentAppId, preAuthCode, redirectUrl); + String redirectUrl = WxMaCodeConstant.WEB_URL + formDTO.getClientType(); + String authUrl = String.format(WxMaCodeConstant.API_AUTH_REGISTER_URL, componentAppId, preAuthCode, redirectUrl); result.setUrl(authUrl); return result; } diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/CodeCustomerServiceImpl.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/CodeCustomerServiceImpl.java index 3181daebdc..f2e9d5fd4c 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/CodeCustomerServiceImpl.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/CodeCustomerServiceImpl.java @@ -113,4 +113,14 @@ public class CodeCustomerServiceImpl extends BaseServiceImpl(list, pageInfo.getTotal()); } + @Override + public List getAuditingCodeList() { + return baseDao.selectAuditingCodeList(); + } + + @Override + public void deleteCode(String customerId, String clientType) { + baseDao.deleteCode(customerId, clientType); + } + } \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/CustomerCodeOperationHistoryServiceImpl.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/CodeExtServiceImpl.java similarity index 53% rename from epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/CustomerCodeOperationHistoryServiceImpl.java rename to epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/CodeExtServiceImpl.java index fc424619cc..f3fceb0436 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/CustomerCodeOperationHistoryServiceImpl.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/CodeExtServiceImpl.java @@ -23,11 +23,11 @@ import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.constant.FieldConstant; -import com.epmet.dao.CustomerCodeOperationHistoryDao; -import com.epmet.dto.CustomerCodeOperationHistoryDTO; -import com.epmet.entity.CustomerCodeOperationHistoryEntity; -import com.epmet.redis.CustomerCodeOperationHistoryRedis; -import com.epmet.service.CustomerCodeOperationHistoryService; +import com.epmet.dao.CodeExtDao; +import com.epmet.dto.CodeExtDTO; +import com.epmet.entity.CodeExtEntity; +import com.epmet.redis.CodeExtRedis; +import com.epmet.service.CodeExtService; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -38,59 +38,59 @@ import java.util.List; import java.util.Map; /** - * 客户代码操作历史 + * 代码第三方配置 * * @author generator generator@elink-cn.com - * @since v1.0.0 2020-07-09 + * @since v1.0.0 2020-07-17 */ @Service -public class CustomerCodeOperationHistoryServiceImpl extends BaseServiceImpl implements CustomerCodeOperationHistoryService { +public class CodeExtServiceImpl extends BaseServiceImpl implements CodeExtService { @Autowired - private CustomerCodeOperationHistoryRedis customerCodeOperationHistoryRedis; + private CodeExtRedis codeExtRedis; @Override - public PageData page(Map params) { - IPage page = baseDao.selectPage( + public PageData page(Map params) { + IPage page = baseDao.selectPage( getPage(params, FieldConstant.CREATED_TIME, false), getWrapper(params) ); - return getPageData(page, CustomerCodeOperationHistoryDTO.class); + return getPageData(page, CodeExtDTO.class); } @Override - public List list(Map params) { - List entityList = baseDao.selectList(getWrapper(params)); + public List list(Map params) { + List entityList = baseDao.selectList(getWrapper(params)); - return ConvertUtils.sourceToTarget(entityList, CustomerCodeOperationHistoryDTO.class); + return ConvertUtils.sourceToTarget(entityList, CodeExtDTO.class); } - private QueryWrapper getWrapper(Map params){ + private QueryWrapper getWrapper(Map params){ String id = (String)params.get(FieldConstant.ID_HUMP); - QueryWrapper wrapper = new QueryWrapper<>(); + QueryWrapper wrapper = new QueryWrapper<>(); wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); return wrapper; } @Override - public CustomerCodeOperationHistoryDTO get(String id) { - CustomerCodeOperationHistoryEntity entity = baseDao.selectById(id); - return ConvertUtils.sourceToTarget(entity, CustomerCodeOperationHistoryDTO.class); + public CodeExtDTO get(String id) { + CodeExtEntity entity = baseDao.selectById(id); + return ConvertUtils.sourceToTarget(entity, CodeExtDTO.class); } @Override @Transactional(rollbackFor = Exception.class) - public void save(CustomerCodeOperationHistoryDTO dto) { - CustomerCodeOperationHistoryEntity entity = ConvertUtils.sourceToTarget(dto, CustomerCodeOperationHistoryEntity.class); + public void save(CodeExtDTO dto) { + CodeExtEntity entity = ConvertUtils.sourceToTarget(dto, CodeExtEntity.class); insert(entity); } @Override @Transactional(rollbackFor = Exception.class) - public void update(CustomerCodeOperationHistoryDTO dto) { - CustomerCodeOperationHistoryEntity entity = ConvertUtils.sourceToTarget(dto, CustomerCodeOperationHistoryEntity.class); + public void update(CodeExtDTO dto) { + CodeExtEntity entity = ConvertUtils.sourceToTarget(dto, CodeExtEntity.class); updateById(entity); } @@ -101,4 +101,14 @@ public class CustomerCodeOperationHistoryServiceImpl extends BaseServiceImpl + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

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

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; +import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.utils.ConvertUtils; +import com.epmet.commons.tools.constant.FieldConstant; +import com.epmet.dao.CodeOperationHistoryDao; +import com.epmet.dto.CodeOperationHistoryDTO; +import com.epmet.dto.result.CodeHistoryResultDTO; +import com.epmet.entity.CodeOperationHistoryEntity; +import com.epmet.redis.CodeOperationHistoryRedis; +import com.epmet.service.CodeOperationHistoryService; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +/** + * 客户代码操作历史 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-07-09 + */ +@Service +public class CodeOperationHistoryServiceImpl extends BaseServiceImpl implements CodeOperationHistoryService { + + @Autowired + private CodeOperationHistoryRedis customerCodeOperationHistoryRedis; + + @Override + public PageData page(Map params) { + IPage page = baseDao.selectPage( + getPage(params, FieldConstant.CREATED_TIME, false), + getWrapper(params) + ); + return getPageData(page, CodeOperationHistoryDTO.class); + } + + @Override + public List list(Map params) { + List entityList = baseDao.selectList(getWrapper(params)); + + return ConvertUtils.sourceToTarget(entityList, CodeOperationHistoryDTO.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 CodeOperationHistoryDTO get(String id) { + CodeOperationHistoryEntity entity = baseDao.selectById(id); + return ConvertUtils.sourceToTarget(entity, CodeOperationHistoryDTO.class); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void save(CodeOperationHistoryDTO dto) { + CodeOperationHistoryEntity entity = ConvertUtils.sourceToTarget(dto, CodeOperationHistoryEntity.class); + insert(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void update(CodeOperationHistoryDTO dto) { + CodeOperationHistoryEntity entity = ConvertUtils.sourceToTarget(dto, CodeOperationHistoryEntity.class); + updateById(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void delete(String[] ids) { + // 逻辑删除(@TableLogic 注解) + baseDao.deleteBatchIds(Arrays.asList(ids)); + } + + @Override + public List getHistoryList(String customerId, String clientType) { + return baseDao.selectHistoryList(customerId, clientType); + } + + @Override + public void updateDescribe(String codeId, String describe) { + baseDao.updateDescribeByCodeId(codeId, describe); + } + +} \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/CodeServiceImpl.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/CodeServiceImpl.java index 8cf9b54571..4b9bfe1757 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 @@ -1,38 +1,38 @@ package com.epmet.service.impl; +import com.alibaba.fastjson.JSONObject; 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.utils.DateUtils; +import com.epmet.commons.tools.utils.MultipartFileToFileUtils; import com.epmet.commons.tools.utils.Result; import com.epmet.constant.CodeConstant; import com.epmet.dao.AuthorizationInfoDao; import com.epmet.dao.ComponentAccessTokenDao; -import com.epmet.dto.AuthorizationInfoDTO; -import com.epmet.dto.CodeAuditResultDTO; -import com.epmet.dto.CodeCustomerDTO; -import com.epmet.dto.CustomerDTO; -import com.epmet.dto.form.CodeCommonFormDTO; -import com.epmet.dto.form.CodeUploadFormDTO; -import com.epmet.dto.form.SubmitAuditFormDTO; -import com.epmet.dto.form.UploadListFormDTO; -import com.epmet.dto.result.TemplateListResultDTO; +import com.epmet.dto.*; +import com.epmet.dto.form.*; +import com.epmet.dto.result.*; import com.epmet.feign.OperCrmOpenFeignClient; -import com.epmet.service.CodeAuditResultService; -import com.epmet.service.CodeCustomerService; -import com.epmet.service.CodeService; +import com.epmet.service.*; import com.epmet.wxapi.param.WxMaCodeAuditStatusReq; import com.epmet.wxapi.param.WxMaCodeCommitReq; import com.epmet.wxapi.param.WxMaCodeSubmitAuditRequest; -import com.epmet.wxapi.result.WxMaAuditStatusResult; -import com.epmet.wxapi.result.WxMaTemplateResult; -import com.epmet.wxapi.result.WxResult; +import com.epmet.wxapi.param.WxMaNewsReq; +import com.epmet.wxapi.result.*; import com.epmet.wxapi.service.WxMaCodeService; +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; +import com.google.gson.JsonElement; +import com.google.gson.JsonParser; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import java.io.File; import java.util.ArrayList; +import java.util.Collections; import java.util.List; /** @@ -55,6 +55,14 @@ public class CodeServiceImpl implements CodeService { private OperCrmOpenFeignClient operCrmOpenFeignClient; @Autowired private CodeAuditResultService codeAuditResultService; + @Autowired + private CustomerMpService customerMpService; + @Autowired + private CodeOperationHistoryService codeOperationHistoryService; + @Autowired + private CodeMediaService codeMediaService; + @Autowired + private CodeExtService codeExtService; @Override public List templateList() { @@ -71,7 +79,7 @@ public class CodeServiceImpl implements CodeService { } wxResult.getData().forEach(temp -> { TemplateListResultDTO dto = new TemplateListResultDTO(); - dto.setTemplateId(temp.getTemplateId()); + dto.setId(temp.getTemplateId()); dto.setUserVersion(temp.getUserVersion()); dto.setUserDesc(temp.getUserDesc()); dto.setCreateTime(DateUtils.formatTimestamp(temp.getCreateTime(), DateUtils.DATE_PATTERN)); @@ -81,21 +89,49 @@ public class CodeServiceImpl implements CodeService { } @Override + public String getExtJson(CodeUploadFormDTO formDTO) { + CodeExtDTO codeExtDTO = codeExtService.getExtByCustomer(formDTO.getCustomerId(), formDTO.getClientType()); + if (null == codeExtDTO) { + return codeExtService.getExtTemplate(formDTO.getClientType()); + } + return codeExtDTO.getExtJson(); + } + + @Override + @Transactional(rollbackFor = Exception.class) public void upload(CodeUploadFormDTO formDTO) { + //是否授权 + if (customerMpService.getAuthFlag(formDTO.getCustomerId(), formDTO.getClientType())) { + throw new RenException("未授权"); + } //获取小程序调用令牌 AuthorizationInfoDTO authInfo = authorizationInfoDao.getAuthInfoByCustomer(formDTO.getCustomerId(), formDTO.getClientType()); if (null == authInfo) { throw new RenException("未授权"); } - //TODO 获取第三方自定义配置 - String extJson = "{}"; + if (!isJson(formDTO.getExtJson())) { + throw new RenException("第三方配置不是有效的Json"); + } + + CodeExtDTO codeExtDTO = codeExtService.getExtByCustomer(formDTO.getCustomerId(), formDTO.getClientType()); + if (null == codeExtDTO) { + codeExtDTO = new CodeExtDTO(); + codeExtDTO.setCustomerId(formDTO.getCustomerId()); + codeExtDTO.setClientType(formDTO.getClientType()); + codeExtDTO.setAppId(authInfo.getAuthorizerAppid()); + codeExtDTO.setExtJson(formDTO.getExtJson()); + codeExtService.save(codeExtDTO); + } + codeExtDTO.setExtJson(formDTO.getExtJson()); + codeExtService.update(codeExtDTO); WxMaCodeCommitReq request = ConvertUtils.sourceToTarget(formDTO, WxMaCodeCommitReq.class); - request.setExtJson(extJson); + request.setExtJson(formDTO.getExtJson()); //调用微信API上传代码 WxResult wxResult = wxMaCodeService.commit(authInfo.getAuthorizerAccessToken(), request); //上传失败,抛出异常 if (!wxResult.success()) { + saveOperation(formDTO.getCustomerId(), null, formDTO.getUserVersion(), CodeConstant.OPER_UPLOAD, wxResult.getErrorMsg()); throw new RenException(wxResult.getErrorCode(), wxResult.getErrorMsg()); } //获取客户信息 @@ -105,19 +141,54 @@ public class CodeServiceImpl implements CodeService { if (!customerInfo.success()) { throw new RenException(customerInfo.getCode(), customerInfo.getMsg()); } - //TODO 将之前上传信息删除 + //将之前上传信息删除 + codeCustomerService.deleteCode(formDTO.getCustomerId(), formDTO.getClientType()); //将上传信息存入表中 CodeCustomerDTO codeCustomerDTO = ConvertUtils.sourceToTarget(formDTO, CodeCustomerDTO.class); codeCustomerDTO.setCustomerName(customerInfo.getData().getCustomerName()); - codeCustomerDTO.setExtJson(extJson); + codeCustomerDTO.setExtJson(formDTO.getExtJson()); codeCustomerDTO.setStatus(CodeConstant.UNAUDITED); codeCustomerService.save(codeCustomerDTO); + + saveOperation(formDTO.getCustomerId(), codeCustomerDTO.getId(), formDTO.getUserVersion(), CodeConstant.OPER_UPLOAD, "上传成功"); } @Override public PageData uploadList(UploadListFormDTO formDTO) { - //TODO 更新审核状态 + //获取小程序调用令牌 + AuthorizationInfoDTO authInfo = authorizationInfoDao.getAuthInfoByCustomer(formDTO.getCustomerId(), formDTO.getClientType()); + if (null == authInfo) { + throw new RenException("未授权"); + } + List auditingList = codeCustomerService.getAuditingCodeList(); + auditingList.forEach(code -> { + //获取审核结果信息 + CodeAuditResultDTO auditResult = codeAuditResultService.getAuditResultByCodeId(code.getId()); + //调用微信API获取最新审核状态 + WxMaCodeAuditStatusReq request = new WxMaCodeAuditStatusReq(); + request.setAuditId(auditResult.getAuditId()); + WxResult wxAuditResult = wxMaCodeService.getAuditStatus(authInfo.getAuthorizerAccessToken(), request); + if (wxAuditResult.success()) { + WxMaAuditStatusResult result = wxAuditResult.getData(); + if (result.getStatus() == NumConstant.ZERO) { + code.setStatus(CodeConstant.AUDIT_SUCCESS); + auditResult.setResult(CodeConstant.AUDIT_SUCCESS); + codeOperationHistoryService.updateDescribe(code.getId(), "审核成功"); + } else if (result.getStatus() == NumConstant.ONE) { + code.setStatus(CodeConstant.AUDIT_FAILED); + auditResult.setResult(CodeConstant.AUDIT_FAILED); + auditResult.setReason(result.getReason()); + codeOperationHistoryService.updateDescribe(code.getId(), result.getReason()); + } else if (result.getStatus() == NumConstant.FOUR) { + code.setStatus(CodeConstant.DELAY); + auditResult.setResult(CodeConstant.DELAY); + codeOperationHistoryService.updateDescribe(code.getId(), "审核延后"); + } + codeCustomerService.update(code); + codeAuditResultService.update(auditResult); + } + }); return codeCustomerService.getCodeList(formDTO); } @@ -125,12 +196,21 @@ public class CodeServiceImpl implements CodeService { public void submitAudit(SubmitAuditFormDTO formDTO) { //获取上传代码信息 CodeCustomerDTO codeCustomerDTO = codeCustomerService.get(formDTO.getCodeId()); + //是否授权 + if (customerMpService.getAuthFlag(codeCustomerDTO.getCustomerId(), codeCustomerDTO.getClientType())) { + throw new RenException("未授权"); + } //获取小程序调用令牌 AuthorizationInfoDTO authInfo = authorizationInfoDao.getAuthInfoByCustomer(codeCustomerDTO.getCustomerId(), codeCustomerDTO.getClientType()); + if (null == authInfo) { + throw new RenException("未授权"); + } //调用微信API上提交审核 WxMaCodeSubmitAuditRequest request = ConvertUtils.sourceToTarget(formDTO, WxMaCodeSubmitAuditRequest.class); WxResult wxResult = wxMaCodeService.submitAudit(authInfo.getAuthorizerAccessToken(), request); if (!wxResult.success()) { + saveOperation(codeCustomerDTO.getCustomerId(), codeCustomerDTO.getId(), codeCustomerDTO.getUserVersion(), CodeConstant.OPER_SUBMIT, + wxResult.getErrorMsg()); throw new RenException(wxResult.getErrorCode(), wxResult.getErrorMsg()); } //将数据存入代码审核表 @@ -143,21 +223,30 @@ public class CodeServiceImpl implements CodeService { //更新代码表状态 codeCustomerDTO.setStatus(CodeConstant.AUDITING); codeCustomerService.update(codeCustomerDTO); + saveOperation(codeCustomerDTO.getCustomerId(), codeCustomerDTO.getId(), codeCustomerDTO.getUserVersion(), CodeConstant.OPER_SUBMIT, + "审核中"); } @Override public void undo(CodeCommonFormDTO formDTO) { //获取上传代码信息 CodeCustomerDTO codeCustomerDTO = codeCustomerService.get(formDTO.getCodeId()); + //是否授权 + if (customerMpService.getAuthFlag(codeCustomerDTO.getCustomerId(), codeCustomerDTO.getClientType())) { + throw new RenException("未授权"); + } //获取审核结果信息 CodeAuditResultDTO codeAuditResultDTO = codeAuditResultService.getAuditResultByCodeId(formDTO.getCodeId()); //获取小程序调用令牌 AuthorizationInfoDTO authInfo = authorizationInfoDao.getAuthInfoByCustomer(codeCustomerDTO.getCustomerId(), codeCustomerDTO.getClientType()); + if (null == authInfo) { + throw new RenException("未授权"); + } //调用微信API获取最新审核状态 WxMaCodeAuditStatusReq request = new WxMaCodeAuditStatusReq(); request.setAuditId(codeAuditResultDTO.getAuditId()); WxResult wxAuditResult = wxMaCodeService.getAuditStatus(authInfo.getAuthorizerAccessToken(), request); - if (!wxAuditResult.success() ) { + if (!wxAuditResult.success()) { throw new RenException(wxAuditResult.getErrorCode(), wxAuditResult.getErrorMsg()); } if (wxAuditResult.getData().getStatus() != NumConstant.TWO) { @@ -166,6 +255,8 @@ public class CodeServiceImpl implements CodeService { //调用微信API撤销审核 WxResult wxResult = wxMaCodeService.undoCodeAudit(authInfo.getAuthorizerAccessToken()); if (!wxResult.success()) { + saveOperation(codeCustomerDTO.getCustomerId(), codeCustomerDTO.getId(), codeCustomerDTO.getUserVersion(), CodeConstant.OPER_UNDO, + wxResult.getErrorMsg()); throw new RenException(wxResult.getErrorCode(), wxResult.getErrorMsg()); } //更新审核结果 @@ -174,6 +265,160 @@ public class CodeServiceImpl implements CodeService { //更新代码表状态 codeCustomerDTO.setStatus(CodeConstant.WITHDRAWN); codeCustomerService.update(codeCustomerDTO); + //更新审核操作记录描述 + codeOperationHistoryService.updateDescribe(codeCustomerDTO.getId(), "已撤回"); + + saveOperation(codeCustomerDTO.getCustomerId(), codeCustomerDTO.getId(), codeCustomerDTO.getUserVersion(), CodeConstant.OPER_UNDO, + "成功"); + } + + @Override + public void release(CodeCommonFormDTO formDTO) { + //获取上传代码信息 + CodeCustomerDTO codeCustomerDTO = codeCustomerService.get(formDTO.getCodeId()); + //是否授权 + if (customerMpService.getAuthFlag(codeCustomerDTO.getCustomerId(), codeCustomerDTO.getClientType())) { + throw new RenException("未授权"); + } + //获取小程序调用令牌 + AuthorizationInfoDTO authInfo = authorizationInfoDao.getAuthInfoByCustomer(codeCustomerDTO.getCustomerId(), codeCustomerDTO.getClientType()); + if (null == authInfo) { + throw new RenException("未授权"); + } + //调用微信API发布代码 + WxResult wxResult = wxMaCodeService.release(authInfo.getAuthorizerAccessToken()); + if (!wxResult.success()) { + //更新代码表状态 + codeCustomerDTO.setStatus(CodeConstant.RELEASE_FAILED); + codeCustomerService.update(codeCustomerDTO); + saveOperation(codeCustomerDTO.getCustomerId(), codeCustomerDTO.getId(), codeCustomerDTO.getUserVersion(), CodeConstant.OPER_RELEASE, + wxResult.getErrorMsg()); + throw new RenException(wxResult.getErrorCode(), wxResult.getErrorMsg()); + } + //更新代码表状态 + codeCustomerDTO.setStatus(CodeConstant.RELEASE_SUCCESS); + codeCustomerService.update(codeCustomerDTO); + saveOperation(codeCustomerDTO.getCustomerId(), codeCustomerDTO.getId(), codeCustomerDTO.getUserVersion(), CodeConstant.OPER_RELEASE, + "发布成功"); } + @Override + public ReasonResultDTO reason(CodeCommonFormDTO formDTO) { + ReasonResultDTO result = new ReasonResultDTO(); + //获取上传代码信息 + CodeCustomerDTO codeCustomerDTO = codeCustomerService.get(formDTO.getCodeId()); + //是否授权 + if (customerMpService.getAuthFlag(codeCustomerDTO.getCustomerId(), codeCustomerDTO.getClientType())) { + throw new RenException("未授权"); + } + AuthorizationInfoDTO authInfo = authorizationInfoDao.getAuthInfoByCustomer(codeCustomerDTO.getCustomerId(), codeCustomerDTO.getClientType()); + if (null == authInfo) { + throw new RenException("未授权"); + } + //获取审核结果信息 + CodeAuditResultDTO codeAuditResultDTO = codeAuditResultService.getAuditResultByCodeId(formDTO.getCodeId()); + result.setReason(codeAuditResultDTO.getReason()); + String[] mediaIds = codeAuditResultDTO.getScreenShot().split("[|]"); + List mediaIdList = new ArrayList<>(mediaIds.length); + Collections.addAll(mediaIdList, mediaIds); + List urlList = new ArrayList<>(); + mediaIdList.forEach(mediaId -> { + //调用微信API获取素材 + WxMaCodeAuditStatusReq request = new WxMaCodeAuditStatusReq(); + request.setAuditId(codeAuditResultDTO.getAuditId()); + WxMaNewsReq wxMaNewsReq = new WxMaNewsReq(); + wxMaNewsReq.setMediaId(mediaId); + WxResult wxAuditResult = wxMaCodeService.getMaterial(authInfo.getAuthorizerAccessToken(), wxMaNewsReq); + wxAuditResult.getData().getNewsItem().forEach(news -> { + urlList.add(news.getUrl()); + }); + }); + result.setScreenshotUrl(urlList); + return result; + } + + @Override + public QrCodeResultDTO qrCode(CodeCommonFormDTO formDTO) { + QrCodeResultDTO result = new QrCodeResultDTO(); + //获取上传代码信息 + CodeCustomerDTO codeCustomerDTO = codeCustomerService.get(formDTO.getCodeId()); + //是否授权 + if (customerMpService.getAuthFlag(codeCustomerDTO.getCustomerId(), codeCustomerDTO.getClientType())) { + throw new RenException("未授权"); + } + //获取小程序调用令牌 + AuthorizationInfoDTO authInfo = authorizationInfoDao.getAuthInfoByCustomer(codeCustomerDTO.getCustomerId(), codeCustomerDTO.getClientType()); + //调用微信API获取获取体验版二维码 + WxResult wxResult = wxMaCodeService.getQrCode(authInfo.getAuthorizerAccessToken(), null); + if (!wxResult.success()) { + throw new RenException(wxResult.getErrorCode(), wxResult.getErrorMsg()); + } + result.setQrcode(wxResult.getData()); + return result; + } + + @Override + public PageData history(CodeCommonFormDTO formDTO) { + PageHelper.startPage(formDTO.getPage(), formDTO.getLimit()); + //获取上传代码信息 + CodeCustomerDTO codeCustomerDTO = codeCustomerService.get(formDTO.getCodeId()); + List list = codeOperationHistoryService.getHistoryList(codeCustomerDTO.getCustomerId(), codeCustomerDTO.getClientType()); + PageInfo pageInfo = new PageInfo<>(list); + return new PageData<>(list, pageInfo.getTotal()); + } + + @Override + public String mediaUpload(MediaUploadFormDTO formDTO) { + try { + File file = MultipartFileToFileUtils.multipartFileToFile(formDTO.getMedia()); + //获取上传代码信息 + CodeCustomerDTO codeCustomerDTO = codeCustomerService.get(formDTO.getCodeId()); + //获取小程序调用令牌 + AuthorizationInfoDTO authInfo = authorizationInfoDao.getAuthInfoByCustomer(codeCustomerDTO.getCustomerId(), codeCustomerDTO.getClientType()); + WxResult wxResult = wxMaCodeService.uploadMedia(authInfo.getAuthorizerAccessToken(), formDTO.getType(), file); + if (!wxResult.success()) { + throw new RenException(wxResult.getErrorCode(), wxResult.getErrorMsg()); + } + //将素材信息存入数据库表中 + CodeMediaDTO codeMediaDTO = new CodeMediaDTO(); + codeMediaDTO.setCodeId(formDTO.getCodeId()); + codeMediaDTO.setMediaId(wxResult.getData().getMediaId()); + codeMediaDTO.setMediaName(formDTO.getMedia().getName()); + codeMediaDTO.setMediaType(wxResult.getData().getType()); + codeMediaService.save(codeMediaDTO); + return wxResult.getData().getMediaId(); + + } catch (Exception e) { + throw new RenException("上传失败"); + } + } + + private void saveOperation(String customerId, String codeId, String version, String operation, String describe) { + CodeOperationHistoryDTO operationDTO = new CodeOperationHistoryDTO(); + operationDTO.setCustomerId(customerId); + operationDTO.setCodeId(codeId); + operationDTO.setVersion(version); + operationDTO.setOperation(operation); + operationDTO.setDescribe(describe); + codeOperationHistoryService.save(operationDTO); + } + + /** + * 校验是否是Json + * + * @param content + * @return boolean + * @author zhaoqifeng + * @date 2020/7/17 15:43 + */ + private boolean isJson(String content) { + try { + JSONObject jsonStr = JSONObject.parseObject(content); + return true; + } catch (Exception e) { + return false; + } + } + + } 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 6e2916dac6..30517d5cb7 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 @@ -5,9 +5,10 @@ import com.alibaba.fastjson.JSONObject; import com.alibaba.nacos.client.config.utils.IOUtils; import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.exception.RenException; +import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.utils.HttpClientManager; import com.epmet.constant.ModuleConstant; -import com.epmet.constant.ThirdApiConstant; +import com.epmet.constant.ThirdRedisKeyConstant; import com.epmet.constant.ThirdRunTimeInfoConstant; import com.epmet.dao.*; import com.epmet.dto.form.*; @@ -15,12 +16,11 @@ import com.epmet.dto.result.AuthCodeResultDTO; import com.epmet.dto.result.AuthorizationInfoResultDTO; import com.epmet.dto.result.CreateOpenResultDTO; import com.epmet.dto.result.WillOverDueResultDTO; +import com.epmet.mpaes.WXBizMsgCrypt; +import com.epmet.mpaes.WXXmlToMapUtil; import com.epmet.redis.RedisThird; import com.epmet.service.ComponentVerifyTicketService; -import com.epmet.util.WXBizMsgCrypt; -import com.epmet.util.WXXmlToMapUtil; -import com.epmet.util.XmlUtil; -import com.github.pagehelper.util.StringUtil; +import com.epmet.wxapi.constant.WxMaCodeConstant; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.BeanUtils; @@ -28,17 +28,17 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import org.springframework.web.bind.annotation.RequestBody; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import java.io.IOException; import java.io.InputStream; import java.io.UnsupportedEncodingException; import java.lang.reflect.Field; -import java.time.Instant; -import java.time.LocalDateTime; -import java.time.ZoneOffset; import java.util.*; +import static com.epmet.constant.ModuleConstant.COMPONENT_ACCESS_TOKEN; import static com.epmet.constant.ThirdRunTimeInfoConstant.*; /** @@ -107,27 +107,17 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe String timeStamp = request.getParameter(ModuleConstant.TIMESTAMP); // 随机数 String nonce = request.getParameter(ModuleConstant.NONCE); + String encryptType = request.getParameter(ModuleConstant.ENCRYPT_TYPE); + String signature = request.getParameter(ModuleConstant.SIGNATURE); + log.info(String.format(ThirdRunTimeInfoConstant.VERIFY_TICKET,msgSignature,timeStamp,nonce,encryptType,signature)); // 从请求中读取整个post数据 InputStream inputStream; String postData = null; inputStream = request.getInputStream(); postData= IOUtils.toString(inputStream,ModuleConstant.UTF8); - //从XML中获取标签内的密文文本 - String encrypt = XmlUtil.toXml(postData); - log.info(String.format(ThirdRunTimeInfoConstant.ENCRYPT,encrypt)); - //格式化密文文本,否则没有标签,会解密失败,参考官方的加解密代码JAVA版本 - String format = ""; - String fromXML = String.format(format, encrypt); - - String msg = ""; //解密后的明文 - WXBizMsgCrypt wxcpt; - if(StringUtil.isEmpty(encrypt)) { - msg = fromXML; - } else { - wxcpt = new WXBizMsgCrypt(token,aesKey, componentAppId); - // 解密消息 - msg = wxcpt.decryptMsg(msgSignature, timeStamp, nonce, fromXML); - } + log.info("postData = "+postData); + WXBizMsgCrypt wxBizMsgCrypt = new WXBizMsgCrypt(token,aesKey,componentAppId); + String msg = wxBizMsgCrypt.decryptMsg(msgSignature, timeStamp, nonce, postData); log.info(String.format(ThirdRunTimeInfoConstant.MSG,msg)); // 将xml转为map Map result = WXXmlToMapUtil.xmlToMap(msg); @@ -149,13 +139,16 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe break; case ModuleConstant.AUTHORIZED: //授权成功 // 更改customer_mp 授权信息,appId,并绑定 - String authAppId = result.get(ModuleConstant.APP_ID); +// String authAppId = result.get(ModuleConstant.APP_ID); String authCode = result.get(ModuleConstant.AUTHORIZATION_CODE_HUMP); + log.info("=============================="+authCode); AuthCodeResultDTO authCodeResultDTO = authCodeDao.selectCustomerIdByAuthCode(authCode); String clientType = authCodeResultDTO.getClientType(); String customerId = authCodeResultDTO.getCustomerId(); + Map authorizerRefreshToken = redisThird.getAuthorizerRefreshToken(customerId + ThirdRedisKeyConstant.COLON + clientType); + String authAppId = authorizerRefreshToken.get("authorizerAppid").toString(); this.updateCustomerMpAppIdAndCreateOpenPlatform(customerId,authAppId,clientType); - this.authInfoByAuthCode(authCode, customerId,clientType); +// this.authInfoByAuthCode(authCode, customerId,clientType); authCodeDao.updateAppId(customerId,clientType,authAppId); this.saveAuthAccountInfo(customerId,authAppId,clientType); // customerMpDao.updateAuthorizationFlag(authAppId); @@ -171,7 +164,8 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe log.info(ThirdRunTimeInfoConstant.END_TICKET); Integer tokenCount = componentAccessTokenDao.selectAccessTokenCount(); if (tokenCount == NumConstant.ZERO){ - this.getComponentAccessToken(); + String accessTokenCountFlag = ModuleConstant.ACCOUNT_TOKEN_FLAG_ONE; + this.getComponentAccessToken(accessTokenCountFlag); } return ModuleConstant.SUCCESS; } @@ -179,44 +173,40 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe /** * @Description 定时获取 (令牌,component_access_token) 第三方与微信交互使用的component_access_token * 每十分钟执行一次,判断是否有马上超时的(15分钟以内算马上超时) - * @param + * @param accessTokenCountFlag 表里的 component_access_token的数量 * @author zxc */ @Transactional(rollbackFor = Exception.class) @Override - public void getComponentAccessToken() { + public void getComponentAccessToken(String accessTokenCountFlag) { log.info(ThirdRunTimeInfoConstant.START_GET_COMPONENT_ACCESS_TOKEN); Map reMap; //距离超时时间小于15分钟的数量 Integer tokenCount = componentAccessTokenDao.selectWillOverTokenCount(); - if (tokenCount > NumConstant.ZERO) { - try { - String componentVerifyTicket = redisThird.getComponentVerifyTicket(); - JSONObject jsonObject = new JSONObject(); - jsonObject.put(ModuleConstant.COMPONENT_APPID, componentAppId); - jsonObject.put(ModuleConstant.COMPONENT_APPSECRET, appSecret); - jsonObject.put(ModuleConstant.TICKET_UNDERLINE_KEY, componentVerifyTicket); - String post = HttpClientManager.getInstance().sendPostByJSON(ThirdApiConstant.API_COMPONENT_TOKEN_URL, JSON.toJSONString(jsonObject)).getData(); - HashMap hashMap = JSON.parseObject(post, HashMap.class); - String componentAccessToken = hashMap.get(ModuleConstant.COMPONENT_ACCESS_TOKEN); - String expiresIn = hashMap.get(ModuleConstant.EXPIRES_IN); - Date expiresInTime = this.countExpirationTime(expiresIn); - if (StringUtils.isNotEmpty(componentAccessToken)) { - //令牌信息存DB - ComponentAccessTokenFormDTO formDTO = new ComponentAccessTokenFormDTO(); - formDTO.setComponentAccessToken(componentAccessToken); - formDTO.setExpiresInTime(expiresInTime); - //先逻辑删,在插入 - log.info(ThirdRunTimeInfoConstant.START_DELETE_COMPONENT_ACCESS_TOKEN); - componentAccessTokenDao.updateOldComponentAccessToken(); - componentAccessTokenDao.insertComponentAccessToken(formDTO); - //存缓存 - redisThird.setComponentAccessToken(componentAccessToken); - } else { - throw new RenException(ThirdRunTimeInfoConstant.FAILURE_ACCESS_TOKEN); - } - } catch (Exception e) { - e.printStackTrace(); + if ((tokenCount > NumConstant.ZERO && accessTokenCountFlag.equals(ModuleConstant.ACCOUNT_TOKEN_FLAG_TWO)) || accessTokenCountFlag.equals(ModuleConstant.ACCOUNT_TOKEN_FLAG_ONE)) { + String componentVerifyTicket = redisThird.getComponentVerifyTicket(); + JSONObject jsonObject = new JSONObject(); + jsonObject.put(ModuleConstant.COMPONENT_APPID, componentAppId); + jsonObject.put(ModuleConstant.COMPONENT_APPSECRET, appSecret); + jsonObject.put(ModuleConstant.TICKET_UNDERLINE_KEY, componentVerifyTicket); + String post = HttpClientManager.getInstance().sendPostByJSON(WxMaCodeConstant.API_COMPONENT_TOKEN_URL, JSON.toJSONString(jsonObject)).getData(); + Map hashMap = JSON.parseObject(post, Map.class); + String componentAccessToken = hashMap.get(COMPONENT_ACCESS_TOKEN).toString(); + Integer expiresIn = (Integer) hashMap.get(ModuleConstant.EXPIRES_IN); + Date expiresInTime = this.countExpirationTime(expiresIn.toString()); + if (StringUtils.isNotEmpty(componentAccessToken)) { + //令牌信息存DB + ComponentAccessTokenFormDTO formDTO = new ComponentAccessTokenFormDTO(); + formDTO.setComponentAccessToken(componentAccessToken); + formDTO.setExpiresInTime(expiresInTime); + //先逻辑删,在插入 + log.info(ThirdRunTimeInfoConstant.START_DELETE_COMPONENT_ACCESS_TOKEN); + componentAccessTokenDao.updateOldComponentAccessToken(); + componentAccessTokenDao.insertComponentAccessToken(formDTO); + //存缓存 + redisThird.setComponentAccessToken(componentAccessToken); + } else { + throw new RenException(ThirdRunTimeInfoConstant.FAILURE_ACCESS_TOKEN); } log.info(ThirdRunTimeInfoConstant.SUCCESS_ACCESS_TOKEN); } @@ -236,12 +226,12 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe String accessToken = redisThird.getComponentAccessToken(); JSONObject jsonObject = new JSONObject(); jsonObject.put(ModuleConstant.COMPONENT_APPID, componentAppId); - String post = HttpClientManager.getInstance().sendPostByJSON(ThirdApiConstant.API_CREATE_PREAUTHCODE_URL + accessToken, JSON.toJSONString(jsonObject)).getData(); + String post = HttpClientManager.getInstance().sendPostByJSON(WxMaCodeConstant.API_CREATE_PREAUTHCODE_URL + accessToken, JSON.toJSONString(jsonObject)).getData(); log.info(String.format(POST_RESULT,post)); - HashMap hashMap = JSON.parseObject(post, HashMap.class); - preAuthCode = hashMap.get(ModuleConstant.PRE_AUTH_CODE); - String expiresIn = hashMap.get(ModuleConstant.EXPIRES_IN); - Date expiresInTime = this.countExpirationTime(expiresIn); + Map hashMap = JSON.parseObject(post, Map.class); + preAuthCode = hashMap.get(ModuleConstant.PRE_AUTH_CODE).toString(); + Integer expiresIn = (Integer) hashMap.get(ModuleConstant.EXPIRES_IN); + Date expiresInTime = this.countExpirationTime(expiresIn.toString()); if (StringUtils.isNotEmpty(preAuthCode)) { //预授权码 存DB PreAuthTokenFormDTO formDTO = new PreAuthTokenFormDTO(); @@ -276,16 +266,18 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe JSONObject jsonObject = new JSONObject(); jsonObject.put(ModuleConstant.COMPONENT_APPID, componentAppId); jsonObject.put(ModuleConstant.AUTHORIZATION_CODE, authCode); - String authInfo = HttpClientManager.getInstance().sendPostByJSON(ThirdApiConstant.API_QUERY_AUTH_URL + accessToken, JSON.toJSONString(jsonObject)).getData(); + String authInfo = HttpClientManager.getInstance().sendPostByJSON(WxMaCodeConstant.API_QUERY_AUTH_URL + accessToken, JSON.toJSONString(jsonObject)).getData(); HashMap hashMap = JSON.parseObject(authInfo, HashMap.class); Map map = hashMap.get(ModuleConstant.AUTHORIZATION_INFO); authorizationInfoResultDTO = mapToEntity(map, AuthorizationInfoResultDTO.class); - String expiresIn = authorizationInfoResultDTO.getExpires_in(); + String authAppId = authorizationInfoResultDTO.getAuthorizer_appid(); + log.info("授权信息:"+map); + String expiresIn = authorizationInfoResultDTO.getExpires_in().toString(); Date expiresInTime = this.countExpirationTime(expiresIn); //授权信息分为两张表,基础信息authorization_info,授权列表func_info // 1. 基础信息 AuthorizationInfoFormDTO authInfoDTO = new AuthorizationInfoFormDTO(); - authInfoDTO.setAuthorizerAppid(authorizationInfoResultDTO.getAuthorizer_appid()); + authInfoDTO.setAuthorizerAppid(authAppId); authInfoDTO.setAuthorizerAccessToken(authorizationInfoResultDTO.getAuthorizer_access_token()); authInfoDTO.setAuthorizerRefreshToken(authorizationInfoResultDTO.getAuthorizer_refresh_token()); authInfoDTO.setExpiresInTime(expiresInTime); @@ -298,23 +290,23 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe log.info(START_INSERT_FUNC_INFO); List funcInfos = new ArrayList<>(); List func_info = authorizationInfoResultDTO.getFunc_info(); - for (Map map1 : func_info) { - List key = (List)map1.keySet(); - FuncInfoFormDTO fu = new FuncInfoFormDTO(); - String funcscopeCategory = key.get(NumConstant.ZERO).toString(); - fu.setFuncscopeCategory(funcscopeCategory); - Map funcscope = (Map) map1.get(funcscopeCategory); - String funcscopeId = funcscope.get("id").toString(); - fu.setFuncscopeId(funcscopeId); - fu.setAuthorizationInfoAppid(authorizationInfoResultDTO.getAuthorizer_appid()); - fu.setCustomerId(customerId); - funcInfos.add(fu); - } - //先逻辑删除,在插入 - funcInfoDao.updateOldFuncInfo(customerId); - funcInfoDao.insertFuncInfo(funcInfos); + log.info("权限列表信息:"+func_info); + /*func_info.forEach(func -> { + func.forEach((key,value) -> { + FuncInfoFormDTO fu = new FuncInfoFormDTO(); + fu.setFuncscopeCategory((String) key); + Map funcScope = (Map) value; + fu.setFuncscopeId(funcScope.get(ModuleConstant.ID).toString()); + fu.setAuthorizationInfoAppid(authAppId); + fu.setCustomerId(customerId); + funcInfos.add(fu); + }); + });*/ + // todo 先逻辑删除,在插入 + /*funcInfoDao.updateOldFuncInfo(customerId,authAppId); + funcInfoDao.insertFuncInfo(funcInfos);*/ // 授权信息放入缓存 - redisThird.setAuthInfo(authorizationInfoResultDTO); + redisThird.setAuthInfo(authorizationInfoResultDTO,customerId,clientType); //authorizer_refresh_token 放入缓存 redisThird.setAuthorizerRefreshToken(authInfoDTO); log.info(END_GET_AUTH_INFO); @@ -332,6 +324,7 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe //查询 即将过期的 authorizer_access_token List willOverDueResultDTOS = authorizationInfoDao.checkWillOverDue(); if (willOverDueResultDTOS.size() != NumConstant.ZERO && null != willOverDueResultDTOS){ + log.info("查询到即将过期的authorizer_access_token"); willOverDueResultDTOS.forEach(willOverDueDTO -> { String authAppId = willOverDueDTO.getAuthAppId(); String customerId = willOverDueDTO.getCustomerId(); @@ -342,7 +335,8 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe //第三方平台AppId jsonObject.put(ModuleConstant.COMPONENT_APPID,componentAppId); jsonObject.put(ModuleConstant.AUTHORIZER_REFRESH_TOKEN,willOverDueDTO.getAuthorizerRefreshToken()); - String data = HttpClientManager.getInstance().sendPostByJSON(ThirdApiConstant.API_AUTHORIZER_TOKEN_URL, JSON.toJSONString(jsonObject)).getData(); + String componentAccessToken = redisThird.getComponentAccessToken(); + String data = HttpClientManager.getInstance().sendPostByJSON(WxMaCodeConstant.API_AUTHORIZER_TOKEN_URL + componentAccessToken, JSON.toJSONString(jsonObject)).getData(); Map map = JSON.parseObject(data, HashMap.class); //authorizer_access_token String authorizerAccessToken = map.get(ModuleConstant.AUTHORIZER_ACCESS_TOKEN).toString(); @@ -366,6 +360,7 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe //缓存 refreshAuthorizerAccessToken redisThird.setAuthorizerRefreshToken(authorizationInfo); }); + log.info("更新authorizer_access_token成功"); } } @@ -377,32 +372,31 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe */ @Transactional(rollbackFor = Exception.class) @Override - public void redirectUri(HttpServletRequest request, HttpServletResponse response) { - try { - request.setCharacterEncoding(ModuleConstant.UTF8); - response.setCharacterEncoding(ModuleConstant.UTF8); - } catch (UnsupportedEncodingException e) { - e.printStackTrace(); - } - String customerId = request.getParameter(ModuleConstant.CUSTOMER_ID); - String client = request.getParameter(ModuleConstant.CLIENT); - String authCode = request.getParameter(ModuleConstant.AUTH_CODE); - String expiresIn = request.getParameter(ModuleConstant.EXPIRES_IN); + public void redirectUri(TokenDto tokenDto, @RequestBody AuthCodeAndTimeFromDTO authCodeAndTime){ + log.info("开始执行回调URL"); + String authCode = authCodeAndTime.getAuthCode(); + String client = authCodeAndTime.getClientType(); + String expiresIn = authCodeAndTime.getExpiresIn(); + String customerId = tokenDto.getCustomerId(); + customerId = "f530774b31e0609a3c7f0f83794cda0c"; Date expiresInTime = this.countExpirationTime(expiresIn); -// AuthorizationInfoResultDTO authorizationInfo = this.authInfoByAuthCode(authCode, customerId,client); + if (StringUtils.isBlank(customerId)||StringUtils.isBlank(client)||StringUtils.isBlank(authCode)||StringUtils.isBlank(expiresIn)){ + log.info("客户ID = "+customerId+", 客户端类型为 = "+client+", 授权码为 = "+authCode+", 有效期 = "+expiresIn); + } //authCode存数据库 AuthCodeFormDTO formDTO = new AuthCodeFormDTO(); formDTO.setAuthCode(authCode); formDTO.setExpiresInTime(expiresInTime); formDTO.setClientType(client); //授权方AppId -// formDTO.setAuthAppId(authorizationInfo.getAuthorizer_appid()); formDTO.setCustomerId(customerId); -// this.updateCustomerMpAppIdAndCreateOpenPlatform(customerId,authorizationInfo.getAuthorizer_appid(),client); + log.info(formDTO.toString()); + authCodeDao.deleteCustomerAuthCode(customerId,client); authCodeDao.insertRedirectAuthCode(formDTO); //authCode存缓存 redisThird.setAuthCode(formDTO); - + this.authInfoByAuthCode(authCode, customerId,client); + log.info("回调结束"); } /** @@ -413,15 +407,19 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe */ @Transactional(rollbackFor = Exception.class) public void saveAuthAccountInfo(String customerId, String authAppId,String clientType) { + log.info("开始执行保存授权账户基本信息"); JSONObject jsonObject = new JSONObject(); jsonObject.put(ModuleConstant.COMPONENT_APP_ID,componentAppId); jsonObject.put(ModuleConstant.AUTHORIZER_APP_ID,authAppId); - String data = HttpClientManager.getInstance().sendPostByJSON(ThirdApiConstant.API_GET_AUTHORIZER_INFO, JSON.toJSONString(jsonObject)).getData(); + String componentAccessToken = redisThird.getComponentAccessToken(); + String data = HttpClientManager.getInstance().sendPostByJSON(WxMaCodeConstant.API_GET_AUTHORIZER_INFO + componentAccessToken , JSON.toJSONString(jsonObject)).getData(); Map map = JSON.parseObject(data, Map.class); Map authorizerInfo = map.get(ModuleConstant.AUTHORIZER_INFO); + log.info("授权信息:"+authorizerInfo); // 存在 “miniprograminfo” 字段为小程序,不存在为公众号 boolean keyExist = authorizerInfo.containsKey(ModuleConstant.MINI_PROGRAM_INFO); if (keyExist == true){ + log.info("授权方为小程序 并 开始插入信息"); MiniInfoFormDTO miniInfoFormDTO = this.mapToEntity(authorizerInfo, MiniInfoFormDTO.class); miniInfoFormDTO.setCustomerId(customerId); miniInfoFormDTO.setClientType(clientType); @@ -471,6 +469,7 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe }); miniCategoryInfoDao.insertCategoryInfo(categoryInfoList); }else { + log.info("授权方为公众号 并 开始插入信息"); PaInfoFormDTO paInfoFormDTO = this.mapToEntity(authorizerInfo, PaInfoFormDTO.class); //公众号基本信息插入 paInfoDao.insertPaInfo(paInfoFormDTO); @@ -489,7 +488,7 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe }); businessInfoDao.insertBusinessInfo(businessInfoList); } - + log.info("保存授权方基本信息结束"); } @@ -500,13 +499,18 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe */ @Transactional(rollbackFor = Exception.class) public void updateCustomerMpAppIdAndCreateOpenPlatform(String customerId,String authAppId,String clientType){ + log.info("开始创建开放平台账号并绑定"); Integer authCount = customerMpDao.selectAuthCount(customerId); String openPlatformId = null; + Map authorizerRefreshToken = redisThird.getAuthorizerRefreshToken(customerId + ThirdRedisKeyConstant.COLON + clientType); + String authorizerAccessToken = authorizerRefreshToken.get("authorizerAccessToken").toString(); if (authCount==NumConstant.ZERO){ + log.info("未查询到该客户授权信息,先创建开放平台账号,再绑定"); //没有任何一个小程序/公众号授权,【先创建,再绑定】 JSONObject jsonObject = new JSONObject(); - jsonObject.put(ModuleConstant.APP_ID,authAppId); - String data = HttpClientManager.getInstance().sendPostByJSON(ThirdApiConstant.API_CREATE_OPEN, JSON.toJSONString(jsonObject)).getData(); + jsonObject.put(ModuleConstant.LOW_APP_ID,authAppId); + // 此处的 access_token 为 【authorizer_access_token】 + String data = HttpClientManager.getInstance().sendPostByJSON(WxMaCodeConstant.API_CREATE_OPEN + authorizerAccessToken, JSON.toJSONString(jsonObject)).getData(); Map map = JSON.parseObject(data, Map.class); CreateOpenResultDTO createOpen = new CreateOpenResultDTO(); createOpen.setErrCode(Integer.valueOf(map.get(ModuleConstant.ERR_CODE))); @@ -530,11 +534,12 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe openPlatformAccountDao.insertOpenPlatFormAccount(coForm); openPlatformId = coForm.getId(); }else if (authCount>NumConstant.ZERO){ + log.info("该客户已创建过开放平台账号,直接绑定"); String openAppId = openPlatformAccountDao.selectOpenAppIdByCustomerId(customerId); JSONObject jsonObject = new JSONObject(); jsonObject.put(ModuleConstant.LOW_APP_ID,componentAppId); jsonObject.put(ModuleConstant.OPEN_APP_ID,openAppId); - String data = HttpClientManager.getInstance().sendPostByJSON(ThirdApiConstant.API_BIND_OPEN, JSON.toJSONString(jsonObject)).getData(); + String data = HttpClientManager.getInstance().sendPostByJSON(WxMaCodeConstant.API_BIND_OPEN + authorizerRefreshToken, JSON.toJSONString(jsonObject)).getData(); Map map = JSON.parseObject(data, Map.class); CreateOpenResultDTO createOpen = new CreateOpenResultDTO(); createOpen.setErrCode(Integer.valueOf(map.get(ModuleConstant.ERR_CODE))); @@ -570,6 +575,7 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe bindingAccount.setClientType(clientType); bindingAccount.setCustomerId(customerId); bindingAccountDao.insertBindingAccount(bindingAccount); + log.info("创建绑定账号结束"); } /** @@ -608,10 +614,10 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe * @author zxc */ public Date countExpirationTime(String expiresIn){ - long now = LocalDateTime.now().toEpochSecond(ZoneOffset.of(NumConstant.POSITIVE_EIGHT_STR)); - long expiresInTime = now + Long.valueOf(expiresIn); - LocalDateTime localDateTime = Instant.ofEpochMilli(expiresInTime).atZone(ZoneOffset.ofHours(NumConstant.EIGHT)).toLocalDateTime(); - Date date = Date.from(localDateTime.atZone(ZoneOffset.ofHours(NumConstant.EIGHT)).toInstant()); + expiresIn = expiresIn + "000"; + Date date = new Date(); + long l = date.getTime() + Long.valueOf(expiresIn); + date.setTime(l); return date; } } diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/CustomerMpServiceImpl.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/CustomerMpServiceImpl.java index 5bb85272a0..b716dff1b9 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/CustomerMpServiceImpl.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/CustomerMpServiceImpl.java @@ -20,15 +20,26 @@ 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.EpmetErrorCode; +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.CustomerMpDao; import com.epmet.dto.CustomerMpDTO; +import com.epmet.dto.PaCustomerDTO; +import com.epmet.dto.UserWechatDTO; +import com.epmet.dto.form.WxLoginFormDTO; +import com.epmet.dto.result.PublicCustomerResultDTO; import com.epmet.entity.CustomerMpEntity; import com.epmet.redis.CustomerMpRedis; import com.epmet.service.CustomerMpService; +import com.epmet.wxapi.service.WxLoginService; import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -46,8 +57,11 @@ import java.util.Map; @Service public class CustomerMpServiceImpl extends BaseServiceImpl implements CustomerMpService { + private static final Logger logger = LoggerFactory.getLogger(CustomerMpServiceImpl.class); @Autowired private CustomerMpRedis customerMpRedis; + @Autowired + private WxLoginService wxLoginService; @Override public PageData page(Map params) { @@ -101,4 +115,54 @@ public class CustomerMpServiceImpl extends BaseServiceImpl根据appId未查询到对应的小程序信息,appId:" + formDTO.getAppId()); + throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode()); + } + if (NumConstant.ONE != mpDTO.getAuthorizationFlag()) { + logger.error("当前appId对应的小程序未完成第三方平台授权不允许使用,appId:" + formDTO.getAppId()); + throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode()); + } + + //2.调用微信API获取用户信息 + UserWechatDTO resultMap = wxLoginService.resiAndWorkLogin(formDTO.getAppId(), formDTO.getWxCode(), mpDTO.getCustomerId(), mpDTO.getClient()); + + return resultMap; + } + + /** + * @param appId + * @return + * @Author sun + * @Description 根据appId查询公众号注册的客户信息 + **/ + @Override + public PublicCustomerResultDTO getCustomerMsg(String appId) { + PublicCustomerResultDTO resultDTO = new PublicCustomerResultDTO(); + //1.根据appid查询客户信息 + PaCustomerDTO paCustomerDTO = baseDao.selectCustomerByAppId(appId); + if (null == paCustomerDTO) { + logger.error("根据小程序appId未查询到已授权并且已完成客户初始化的客户信息,appId->" + appId); + throw new RenException(PaConstant.SELECT_CUSTOMER_EXCEPTION); + } + resultDTO.setCustomer(paCustomerDTO); + + return resultDTO; + } + } \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/PaCustomerServiceImpl.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/PaCustomerServiceImpl.java index 1c744dc9ee..63290cfb9f 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 @@ -35,13 +35,10 @@ import com.epmet.constant.PaConstant; import com.epmet.dao.*; import com.epmet.dto.*; import com.epmet.dto.form.CreateAgencyFormDTO; -import com.epmet.dto.form.MyInfoFormDTO; +import com.epmet.dto.form.RegisterByAuthFormDTO; import com.epmet.dto.form.RegisterFormDTO; import com.epmet.dto.form.RegisterInfoFormDTO; -import com.epmet.dto.result.AgencyLevelListResultDTO; -import com.epmet.dto.result.CreateAgencyResultDTO; -import com.epmet.dto.result.CustomerAgencyResultDTO; -import com.epmet.dto.result.MyInfoResultDTO; +import com.epmet.dto.result.*; import com.epmet.entity.*; import com.epmet.redis.PaCustomerRedis; import com.epmet.service.CustomerMpService; @@ -207,22 +204,31 @@ public class PaCustomerServiceImpl extends BaseServiceImpl agencyLevelList() { List list = new ArrayList<>(); + //省级 AgencyLevelListResultDTO dto1 = new AgencyLevelListResultDTO(); dto1.setLevelKey(PaConstant.PROVINCE_KEY); dto1.setLevelName(PaConstant.PROVINCE_NAME); list.add(dto1); + //市级 AgencyLevelListResultDTO dto2 = new AgencyLevelListResultDTO(); dto2.setLevelKey(PaConstant.CITY_KEY); dto2.setLevelName(PaConstant.CITY_NAME); list.add(dto2); + //区县级 AgencyLevelListResultDTO dto3 = new AgencyLevelListResultDTO(); - dto3.setLevelKey(PaConstant.STREET_KEY); - dto3.setLevelName(PaConstant.STREET_NAME); + dto3.setLevelKey(PaConstant.DISTRICT_KEY); + dto3.setLevelName(PaConstant.DISTRICT_NAME); list.add(dto3); + //乡镇级 AgencyLevelListResultDTO dto4 = new AgencyLevelListResultDTO(); - dto4.setLevelKey(PaConstant.COMMUNITY_KEY); - dto4.setLevelName(PaConstant.COMMUNITY_NAME); + dto4.setLevelKey(PaConstant.STREET_KEY); + dto4.setLevelName(PaConstant.STREET_NAME); list.add(dto4); + //社区级 + AgencyLevelListResultDTO dto5 = new AgencyLevelListResultDTO(); + dto5.setLevelKey(PaConstant.COMMUNITY_KEY); + dto5.setLevelName(PaConstant.COMMUNITY_NAME); + list.add(dto5); return list; } @@ -284,27 +290,27 @@ public class PaCustomerServiceImpl extends BaseServiceImpl pageInfo = new PageInfo<>(); + PageInfo pageInfo = new PageInfo<>(list); return new PageData<>(list, pageInfo.getTotal()); } + /** + * @param customerId + * @return + * @Author sun + * @Description 根据客户Id查询各项注册信息 + **/ + @Override + public InitCustomerResultDTO getCustomerAgencyUser(String customerId) { + InitCustomerResultDTO result = new InitCustomerResultDTO(); + //1.查询注册客户信息,并判断是否已完成初始化 + PaCustomerEntity entity = baseDao.selectById(customerId); + //未查询到注册客户信息 + if (null == entity) { + throw new RenException(EpmetErrorCode.SELECT_CUSTOMER_ERROR.getCode()); + } + //客户已完成初始化 + if (NumConstant.ONE == entity.getIsInitialize()) { + throw new RenException(EpmetErrorCode.OPER_CUSTOMER_EXISTS.getCode()); + } + PaCustomerDTO paCustomer = ConvertUtils.sourceToTarget(entity, PaCustomerDTO.class); + result.setPaCustomer(paCustomer); + + //2.查询注册客户对应的组织信息 + PaCustomerAgencyDTO paAgency = paCustomerAgencyDao.selectAgency(customerId); + if (null == paAgency) { + throw new RenException(EpmetErrorCode.SELECT_AGENCY_ERROR.getCode()); + } + result.setPaAgency(paAgency); + + //3.查询组织客户对应的管理员信息 + PaUserDTO paUser = paUserDao.selectPaUser(customerId); + if (null == paUser) { + throw new RenException(EpmetErrorCode.SELECT_USER_ERROR.getCode()); + } + result.setPaUser(paUser); + + return result; + } + + /** + * @param customerId + * @return + * @Author sun + * @Description 修改客户数据状态为已完成初始化 + **/ + @Override + @Transactional(rollbackFor = Exception.class) + public void updateCustomer(String customerId) { + //更新pa_customer表数据状态 + PaCustomerDTO dto = new PaCustomerDTO(); + dto.setId(customerId); + dto.setIsInitialize(NumConstant.ONE); + if (baseDao.updateCustomerById(dto) < NumConstant.ONE) { + logger.error(EpmetErrorCode.UPDATE_CUSTOMER_ERROR.getMsg()); + throw new RenException(EpmetErrorCode.UPDATE_CUSTOMER_ERROR.getCode()); + } + } + + /** + * @param formDTO + * @return + * @Author sun + * @Description 根据授权状态和初始化状态获取客户列表(不分页) + **/ + @Override + public List 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; + } } \ 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 2184893584..dfdb56af5f 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 @@ -26,6 +26,7 @@ import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.constant.FieldConstant; import com.epmet.dao.PaCustomerDao; import com.epmet.dao.PaUserDao; +import com.epmet.dao.PaUserWechatDao; import com.epmet.dto.PaCustomerDTO; import com.epmet.dto.PaUserDTO; import com.epmet.dto.PaUserWechatDTO; @@ -61,6 +62,8 @@ public class PaUserServiceImpl extends BaseServiceImpl private PaUserWechatService paUserWechatService; @Autowired private PaCustomerDao paCustomerDao; + @Autowired + private PaUserWechatDao paUserWechatDao; @Override public PageData page(Map params) { @@ -175,17 +178,25 @@ public class PaUserServiceImpl extends BaseServiceImpl @Override public CustomerUserResultDTO checkPaUser(String phone) { CustomerUserResultDTO resultDTO = new CustomerUserResultDTO(); + //1.根据手机号查询用户信息 List userList = baseDao.selectUserByPhone(phone); if (null == userList || userList.size() < NumConstant.ONE) { resultDTO.setPaUserResult(null); resultDTO.setPaCustomerResult(null); + resultDTO.setPaUserWechatResult(null); return resultDTO; } PaUserDTO dto = userList.get(NumConstant.ZERO); + //2.根据用户Id查询对应的客户信息 List customerList = paCustomerDao.selectCustomerByUserId(dto.getId()); + //3.根据用户Id查询对应的微信基本信息 + PaUserWechatDTO wechatDTO = new PaUserWechatDTO(); + wechatDTO.setUserId(dto.getId()); + PaUserWechatEntity wechatEntity = paUserWechatDao.selectWechatByUserId(wechatDTO); resultDTO.setPaUserResult(dto); resultDTO.setPaCustomerResult(customerList.size() > NumConstant.ZERO ? customerList.get(NumConstant.ZERO) : null); + resultDTO.setPaUserWechatResult(ConvertUtils.sourceToTarget(wechatEntity, PaUserWechatDTO.class)); return resultDTO; } diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/WarrantServiceImpl.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/WarrantServiceImpl.java index 1db2652bfa..b49c04788e 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/WarrantServiceImpl.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/WarrantServiceImpl.java @@ -10,12 +10,10 @@ import com.epmet.dao.MiniInfoDao; import com.epmet.dto.form.CodeAuditRecordFormDTO; import com.epmet.dto.result.CustomerIdAndClientResultDTO; import com.epmet.dto.result.TemplateAndAppIdResultDTO; -import com.epmet.exception.AesException; +import com.epmet.mpaes.AesException; +import com.epmet.mpaes.WXBizMsgCrypt; +import com.epmet.mpaes.WXXmlToMapUtil; import com.epmet.service.WarrantService; -import com.epmet.util.WXBizMsgCrypt; -import com.epmet.util.WXXmlToMapUtil; -import com.epmet.util.XmlUtil; -import com.github.pagehelper.util.StringUtil; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; import org.dom4j.DocumentException; @@ -26,9 +24,9 @@ import org.springframework.transaction.annotation.Transactional; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; +import java.util.Date; import java.util.Map; /** @@ -61,13 +59,14 @@ public class WarrantServiceImpl implements WarrantService { /** * @Description 1.保存代码审核结果 2.更新代码上传结果 * @param request - * @param appid + * @param appId * @param response * @author zxc */ @Transactional(rollbackFor = Exception.class) @Override - public void acceptMessageAndEvent(HttpServletRequest request, String appid, HttpServletResponse response)throws IOException, DocumentException, AesException { + public void acceptMessageAndEvent(HttpServletRequest request, String appId, HttpServletResponse response)throws IOException, DocumentException, AesException { + log.info("appId:"+ appId); request.setCharacterEncoding(ModuleConstant.UTF8); String msgSignature = request.getParameter(ModuleConstant.MSG_SIGNATURE); String timeStamp = request.getParameter(ModuleConstant.TIMESTAMP); @@ -79,26 +78,21 @@ public class WarrantServiceImpl implements WarrantService { String postData = null; inputStream = request.getInputStream(); postData= IOUtils.toString(inputStream,ModuleConstant.UTF8); - //从XML中获取标签内的密文文本 - String encrypt = XmlUtil.toXml(postData); - log.info(String.format(ThirdRunTimeInfoConstant.ENCRYPT,encrypt)); - //格式化密文文本,否则没有标签,会解密失败,参考官方的加解密代码JAVA版本 - String format = ""; - String fromXML = String.format(format, encrypt); - - String msg = ""; //解密后的明文 - WXBizMsgCrypt wxcpt; - if(StringUtil.isEmpty(encrypt)) { - msg = fromXML; - } else { - wxcpt = new WXBizMsgCrypt(token,aesKey, componentAppId); - // 解密消息 - msg = wxcpt.decryptMsg(msgSignature, timeStamp, nonce, fromXML); + WXBizMsgCrypt wxBizMsgCrypt = null; + String msg = null; + try { + wxBizMsgCrypt = new WXBizMsgCrypt(token,aesKey,componentAppId); + msg = wxBizMsgCrypt.decryptMsg(msgSignature, timeStamp, nonce, postData); + } catch (AesException e) { + e.printStackTrace(); } log.info(String.format(ThirdRunTimeInfoConstant.MSG,msg)); // 将xml转为map Map result = WXXmlToMapUtil.multilayerXmlToMap(msg); - CodeAuditRecordFormDTO codeAuditRecord = componentVerifyTicketService.mapToEntity(result, CodeAuditRecordFormDTO.class); + Map xml = (Map) result.get(ModuleConstant.XML); + Long createTime = Long.valueOf(xml.get(ModuleConstant.CREATE_TIME).toString()); + CodeAuditRecordFormDTO codeAuditRecord = componentVerifyTicketService.mapToEntity(xml, CodeAuditRecordFormDTO.class); + codeAuditRecord.setWechatCreateTime(new Date(createTime)); String toUserName = codeAuditRecord.getToUserName();//小程序原始ID CustomerIdAndClientResultDTO customerIdAndClientResultDTO = miniInfoDao.selectCustomerIdAndClientByToUserName(toUserName); String clientType = customerIdAndClientResultDTO.getClientType(); diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/util/OkHttpHelper.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/util/OkHttpHelper.java deleted file mode 100644 index 0c11244db8..0000000000 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/util/OkHttpHelper.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.epmet.util; - -import okhttp3.*; -import org.springframework.stereotype.Component; - -import java.io.IOException; - -/** - * @Author zxc - * @CreateTime 2020/7/7 17:39 - */ -@Component -public class OkHttpHelper { - - public static final MediaType JSON = MediaType.get("application/json; charset=utf-8"); - - OkHttpClient client = new OkHttpClient(); - - public String post(String url, String json) throws IOException { - RequestBody body = RequestBody.create(JSON, json); - Request request = new Request.Builder() - .url(url) - .post(body) - .build(); - try (Response response = client.newCall(request).execute()) { - return response.body().string(); - } - } - -} diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/util/PKCS7EncoderUtil.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/util/PKCS7EncoderUtil.java deleted file mode 100644 index 1cfac333af..0000000000 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/util/PKCS7EncoderUtil.java +++ /dev/null @@ -1,63 +0,0 @@ -package com.epmet.util; - -import com.epmet.commons.tools.constant.NumConstant; - -import java.nio.charset.Charset; -import java.util.Arrays; - -/** - * @Author zxc - * @CreateTime 2020/7/6 10:45 - */ -public class PKCS7EncoderUtil { - - static Charset CHARSET = Charset.forName("utf-8"); - static int BLOCK_SIZE = 32; - - /** - * 获得对明文进行补位填充的字节. - * - * @param count 需要进行填充补位操作的明文字节个数 - * @return 补齐用的字节数组 - */ - static byte[] encode(int count) { - // 计算需要填充的位数 - int amountToPad = BLOCK_SIZE - (count % BLOCK_SIZE); - if (amountToPad == NumConstant.ZERO) { - amountToPad = BLOCK_SIZE; - } - // 获得补位所用的字符 - char padChr = chr(amountToPad); - String tmp = new String(); - for (int index = NumConstant.ZERO; index < amountToPad; index++) { - tmp += padChr; - } - return tmp.getBytes(CHARSET); - } - - /** - * 删除解密后明文的补位字符 - * - * @param decrypted 解密后的明文 - * @return 删除补位字符后的明文 - */ - static byte[] decode(byte[] decrypted) { - int pad = (int) decrypted[decrypted.length - 1]; - if (pad < NumConstant.ONE || pad > 32) { - pad = NumConstant.ZERO; - } - return Arrays.copyOfRange(decrypted, 0, decrypted.length - pad); - } - - /** - * 将数字转化成ASCII码对应的字符,用于对明文进行补码 - * - * @param a 需要转化的数字 - * @return 转化得到的字符 - */ - static char chr(int a) { - byte target = (byte) (a & 0xFF); - return (char) target; - } - -} diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/util/WXBizMsgCrypt.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/util/WXBizMsgCrypt.java deleted file mode 100644 index 332e363eaa..0000000000 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/util/WXBizMsgCrypt.java +++ /dev/null @@ -1,246 +0,0 @@ -package com.epmet.util; - -import com.epmet.exception.AesException; -import me.chanjar.weixin.common.util.crypto.PKCS7Encoder; -import org.apache.commons.codec.binary.Base64; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.NodeList; -import org.xml.sax.InputSource; - -import java.io.StringReader; -import java.nio.charset.Charset; -import java.security.MessageDigest; -import java.util.Arrays; - -import javax.crypto.Cipher; -import javax.crypto.spec.IvParameterSpec; -import javax.crypto.spec.SecretKeySpec; -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; - -/** - * 提供接收和推送给公众平台消息的加解密接口(UTF8编码的字符串). - *

    *
  1. 第三方回复加密消息给公众平台
  2. *
  3. 第三方收到公众平台发送的消息,验证消息的安全性,并对消息进行解密。
  4. - *
- * 说明:异常java.security.InvalidKeyException:illegal Key Size的解决方案 - *
    - *
  1. 在官方网站下载JCE无限制权限策略文件(JDK7的下载地址: * - * http://www.oracle.com/technetwork/java/javase/downloads/jce-7-download-432124.html
  2. - *
  3. 下载后解压,可以看到local_policy.jar和US_export_policy.jar以及readme.txt
  4. - *
  5. 如果安装了JRE,将两个jar文件放到%JRE_HOME%\lib\security目录下覆盖原来的文件
  6. - *
  7. 如果安装了JDK,将两个jar文件放到%JDK_HOME%\jre\lib\security目录下覆盖原来文件
  8. - * - *
- */ - -/** - * @Author zxc - * @CreateTime 2020/7/6 9:51 - */ -public class WXBizMsgCrypt { - static Charset CHARSET = Charset.forName("utf-8"); - Base64 base64 = new Base64(); - byte[] aesKey; - String token; - String appId; - - /** - * 构造函数 - * @param token 公众平台上,开发者设置的token - * @param encodingAesKey 公众平台上,开发者设置的EncodingAESKey - * @param appId 公众平台appid - * - * @throws AesException 执行失败,请查看该异常的错误码和具体的错误信息 - */ - public WXBizMsgCrypt(String token, String encodingAesKey, String appId) throws AesException { - if (encodingAesKey.length() != 43) { - throw new AesException(AesException.IllegalAesKey); - } - - this.token = token; - this.appId = appId; - aesKey = Base64.decodeBase64(encodingAesKey + "="); - } - - // 还原4个字节的网络字节序 - int recoverNetworkBytesOrder(byte[] orderBytes) { - int sourceNumber = 0; - for (int i = 0; i < 4; i++) { - sourceNumber <<= 8; - sourceNumber |= orderBytes[i] & 0xff; - } - return sourceNumber; - } - - /** - * 对密文进行解密. - * @param text 需要解密的密文 - * @return 解密得到的明文 - * @throws AesException aes解密失败 - */ - String decrypt(String text) throws AesException { - byte[] original; - try { - // 设置解密模式为AES的CBC模式 - Cipher cipher = Cipher.getInstance("AES/CBC/NoPadding"); - SecretKeySpec key_spec = new SecretKeySpec(aesKey, "AES"); - IvParameterSpec iv = new IvParameterSpec(Arrays.copyOfRange(aesKey, 0, 16)); - cipher.init(Cipher.DECRYPT_MODE, key_spec, iv); - - // 使用BASE64对密文进行解码 - byte[] encrypted = Base64.decodeBase64(text); - - // 解密 - original = cipher.doFinal(encrypted); - } catch (Exception e) { - e.printStackTrace(); - throw new AesException(AesException.DecryptAESError); - } - - String xmlContent, from_appid; - try { - // 去除补位字符 - byte[] bytes = PKCS7Encoder.decode(original); - - // 分离16位随机字符串,网络字节序和AppId - byte[] networkOrder = Arrays.copyOfRange(bytes, 16, 20); - - int xmlLength = recoverNetworkBytesOrder(networkOrder); - - xmlContent = new String(Arrays.copyOfRange(bytes, 20, 20 + xmlLength), CHARSET); - from_appid = - new String(Arrays.copyOfRange(bytes, 20 + xmlLength, bytes.length), CHARSET); - } catch (Exception e) { - e.printStackTrace(); - throw new AesException(AesException.IllegalBuffer); - } - - // appid不相同的情况 - if (!from_appid.equals(appId)) { - throw new AesException(AesException.ValidateSignatureError); - } - return xmlContent; - - } - - /** - * * 检验消息的真实性,并且获取解密后的明文. - *
    - *
  1. 利用收到的密文生成安全签名,进行签名验证
  2. - *
  3. 若验证通过,则提取xml中的加密消息
  4. - *
  5. 对消息进行解密
  6. - *
- * - * @param msgSignature 签名串,对应URL参数的msg_signature - * @param timeStamp 时间戳,对应URL参数的timestamp - * @param nonce 随机串,对应URL参数的nonce - * @param postData 密文,对应POST请求的数据 - * @return 解密后的原文 - * @throws AesException 执行失败,请查看该异常的错误码和具体的错误信息 - */ - public String decryptMsg(String msgSignature, String timeStamp, String nonce, String postData) - throws AesException { - - // 密钥,公众账号的app secret - // 提取密文 - Object[] encrypt = extract(postData); - - // 验证安全签名 - String signature = getSHA1(token, timeStamp, nonce, encrypt[1].toString()); - - // 和URL中的签名比较是否相等 - // System.out.println("第三方收到URL中的签名:" + msg_sign); - // System.out.println("第三方校验签名:" + signature); - if (!signature.equals(msgSignature)) { - throw new AesException(AesException.ValidateSignatureError); - } - - // 解密 - String result = decrypt(encrypt[1].toString()); - return result; - } - - /** - * 提取出xml数据包中的加密消息 - * @param xmltext 待提取的xml字符串 - * @return 提取出的加密消息字符串 - * @throws AesException - */ - public static Object[] extract(String xmltext) throws AesException { - Object[] result = new Object[3]; - try { - DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); - dbf.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true); - dbf.setFeature("http://xml.org/sax/features/external-general-entities", false); - dbf.setFeature("http://xml.org/sax/features/external-parameter-entities", false); - dbf.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false); - dbf.setXIncludeAware(false); - dbf.setExpandEntityReferences(false); - DocumentBuilder db = dbf.newDocumentBuilder(); - StringReader sr = new StringReader(xmltext); - InputSource is = new InputSource(sr); - Document document = db.parse(is); - - Element root = document.getDocumentElement(); - NodeList nodelist1 = root.getElementsByTagName("Encrypt"); - NodeList nodelist2 = root.getElementsByTagName("ToUserName"); - result[0] = 0; - result[1] = nodelist1.item(0).getTextContent(); - - //注意这里,获取ticket中的xml里面没有ToUserName这个元素,官网原示例代码在这里会报空 - //空指针,所以需要处理一下 - if (nodelist2 != null) { - if (nodelist2.item(0) != null) { - result[2] = nodelist2.item(0).getTextContent(); - } - } - return result; - } catch (Exception e) { - e.printStackTrace(); - throw new AesException(AesException.ParseXmlError); - } - } - - /** - * 用SHA1算法生成安全签名 - * @param token 票据 - * @param timestamp 时间戳 - * @param nonce 随机字符串 - * @param encrypt 密文 - * @return 安全签名 - * @throws - * AesException - */ - public static String getSHA1(String token, String timestamp, String nonce, String encrypt) - throws AesException { - try { - String[] array = new String[]{token, timestamp, nonce, encrypt}; - StringBuffer sb = new StringBuffer(); - // 字符串排序 - Arrays.sort(array); - for (int i = 0; i < 4; i++) { - sb.append(array[i]); - } - String str = sb.toString(); - // SHA1签名生成 - MessageDigest md = MessageDigest.getInstance("SHA-1"); - md.update(str.getBytes()); - byte[] digest = md.digest(); - - StringBuffer hexstr = new StringBuffer(); - String shaHex = ""; - for (int i = 0; i < digest.length; i++) { - shaHex = Integer.toHexString(digest[i] & 0xFF); - if (shaHex.length() < 2) { - hexstr.append(0); - } - hexstr.append(shaHex); - } - return hexstr.toString(); - } catch (Exception e) { - e.printStackTrace(); - throw new AesException(AesException.ComputeSignatureError); - } - } -} diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/util/XmlUtil.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/util/XmlUtil.java deleted file mode 100644 index 1fdc3d0307..0000000000 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/util/XmlUtil.java +++ /dev/null @@ -1,172 +0,0 @@ -package com.epmet.util; -import com.google.common.collect.Lists; -import com.thoughtworks.xstream.XStream; -import com.thoughtworks.xstream.core.util.QuickWriter; -import com.thoughtworks.xstream.io.HierarchicalStreamWriter; -import com.thoughtworks.xstream.io.naming.NoNameCoder; -import com.thoughtworks.xstream.io.xml.CompactWriter; -import com.thoughtworks.xstream.io.xml.DomDriver; -import com.thoughtworks.xstream.io.xml.PrettyPrintWriter; -import com.thoughtworks.xstream.io.xml.XppDriver; - -import java.io.StringWriter; -import java.io.Writer; -import java.nio.charset.StandardCharsets; -import java.util.List; - -public class XmlUtil { - - /** - * 转换不带CDDATA的XML - * - * @return - * @ - */ - private static XStream getXStream() { - // 实例化XStream基本对象 - XStream xstream = new XStream(new DomDriver(StandardCharsets.UTF_8.name(), new NoNameCoder() { - // 不对特殊字符进行转换,避免出现重命名字段时的“双下划线” - @Override - public String encodeNode(String name) { - return name; - } - })); - // 忽视XML与JAVABEAN转换时,XML中的字段在JAVABEAN中不存在的部分 - xstream.ignoreUnknownElements(); - return xstream; - } - - - - /** - * 转换带CDDATA的XML - * - * @return - * @ - */ - private static XStream getXStreamWithCData(List ignoreCDATA) { - // 实例化XStream扩展对象 - XStream xstream = new XStream(new XppDriver() { - // 扩展xstream,使其支持CDATA块 - @Override - public HierarchicalStreamWriter createWriter(Writer out) { - return new PrettyPrintWriter(out) { - boolean cdata = true; - // 不对特殊字符进行转换,避免出现重命名字段时的“双下划线” - @Override - public String encodeNode(String name) { - if(!ignoreCDATA.isEmpty()){ - for(String str:ignoreCDATA){ - if(str.equals(name)){ - cdata=false; - return name; - } - } - } - cdata=true; - return name; - } - // 对xml节点的转换都增加CDATA标记 - @Override - protected void writeText(QuickWriter writer, String text) { - if (cdata) { - writer.write(""); - } else { - writer.write(text); - } - } - - - }; - } - }); - // 忽视XML与JAVABEAN转换时,XML中的字段在JAVABEAN中不存在的部分 - xstream.ignoreUnknownElements(); - return xstream; - } - - /** - * 以压缩的方式输出XML - * - * @param obj - * @return - */ - public static String toCompressXml(Object obj) { - XStream xstream = getXStream(); - StringWriter sw = new StringWriter(); - // 识别obj类中的注解 - xstream.processAnnotations(obj.getClass()); - // 设置JavaBean的类别名 - xstream.aliasType("xml", obj.getClass()); - xstream.marshal(obj, new CompactWriter(sw)); - return sw.toString(); - } - - /** - * 以格式化的方式输出XML - * - * @param obj - * @return - */ - public static String toXml(Object obj) { - XStream xstream = getXStream(); - // 识别obj类中的注解 - xstream.processAnnotations(obj.getClass()); - // 设置JavaBean的类别名 - xstream.aliasType("xml", obj.getClass()); - return xstream.toXML(obj); - } - - /** - * 转换成JavaBean - * - * @param xmlStr - * @param cls - * @return - */ - @SuppressWarnings("unchecked") - public static T toBean(String xmlStr, Class cls) { - XStream xstream = getXStream(); - // 识别cls类中的注解 - xstream.processAnnotations(cls); - // 设置JavaBean的类别名 - xstream.aliasType("xml", cls); - T t = (T) xstream.fromXML(xmlStr); - return t; - } - - /** - * 以格式化的方式输出XML - * - * @param obj - * @return - */ - public static String toXmlWithCData(Object obj,List ignoreCDAA) { - XStream xstream = getXStreamWithCData(ignoreCDAA); - // 识别obj类中的注解 - xstream.processAnnotations(obj.getClass()); - // 设置JavaBean的类别名 - xstream.aliasType("xml", obj.getClass()); - return xstream.toXML(obj); - } - - /** - * 转换成JavaBean - * - * @param xmlStr - * @param cls - * @return - */ - @SuppressWarnings("unchecked") - public static T toBeanWithCData(String xmlStr, Class cls) { - XStream xstream = getXStreamWithCData(null); - // 识别cls类中的注解 - xstream.processAnnotations(cls); - // 设置JavaBean的类别名 - xstream.alias("xml", cls); - T t = (T) xstream.fromXML(xmlStr); - return t; - } -} diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/constant/WxLoginConstant.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/constant/WxLoginConstant.java new file mode 100644 index 0000000000..214eec875a --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/constant/WxLoginConstant.java @@ -0,0 +1,20 @@ +package com.epmet.wxapi.constant; + +/** + * 微信登陆-获取用户信息-API + * @author sun + */ +public interface WxLoginConstant { + + /** + * 第三方平台代小程序实现-小程序登陆-根据wxcode获取openid + */ + String WXCODE_BY_OPENID = "https://api.weixin.qq.com/sns/component/jscode2session"; + + /** + * 获取用户基本信息(UnionID机制) + * 根据小程序token和openid获取用户基本信息 + */ + String OPENID_TO_INFORMATION = "https://api.weixin.qq.com/cgi-bin/user/info"; + +} diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/constant/WxMaCodeConstant.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/constant/WxMaCodeConstant.java index 3fe8d49f7e..e98f7a4701 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/constant/WxMaCodeConstant.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/constant/WxMaCodeConstant.java @@ -7,6 +7,58 @@ package com.epmet.wxapi.constant; * @date 2020/7/10 12:57 */ public interface WxMaCodeConstant { + + /** + * 获取预授权码 + */ + String API_CREATE_PREAUTHCODE_URL = "https://api.weixin.qq.com/cgi-bin/component/api_create_preauthcode?component_access_token="; + + /** + * 使用授权码获取授权信息请求地址 + */ + String API_QUERY_AUTH_URL = "https://api.weixin.qq.com/cgi-bin/component/api_query_auth?component_access_token="; + + /** + * 获取令牌请求地址 + */ + String API_COMPONENT_TOKEN_URL = "https://api.weixin.qq.com/cgi-bin/component/api_component_token"; + + String API_AUTHORIZER_TOKEN_URL = "https://api.weixin.qq.com/cgi-bin/component/api_authorizer_token?component_access_token="; + + /** + * 反参授权回调url + */ + String API_RETURN_REDIRECT_URL = "https://epmet-cloud.elinkservice.cn/api/third/redirectauthcode/%s/%s"; + + /** + * 前端地址 【授权之后的跳转的地址】 + */ + String WEB_URL = "https://epmet-cloud.elinkservice.cn/third/mpweb/page/#/info?clientType="; + + /** + * 授权注册页面扫码授权 + * component_appid:第三方AppId + * pre_auth_code:预授权码 + * redirect_uri:回调url(获取授权码) + */ +// String API_AUTH_REGISTER_URL = "https://mp.weixin.qq.com/cgi-bin/componentloginpage?component_appid=%s&pre_auth_code=%s&redirect_uri=%s"; + String API_AUTH_REGISTER_URL = "https://mp.weixin.qq.com/safe/bindcomponent?action=bindcomponent&auth_type=3&no_scan=1&component_appid=%s&pre_auth_code=%s&redirect_uri=%s#wechat_redirect"; + + /** + * 创建开放平台帐号并绑定公众号/小程序 + */ + String API_CREATE_OPEN = "https://api.weixin.qq.com/cgi-bin/open/create?access_token="; + + /** + * 公众号/小程序绑定到开放平台帐号下 + */ + String API_BIND_OPEN = "https://api.weixin.qq.com/cgi-bin/open/bind?access_token="; + + /** + * 获取授权方的帐号基本信息 + */ + String API_GET_AUTHORIZER_INFO = "https://api.weixin.qq.com/cgi-bin/component/api_get_authorizer_info?component_access_token="; + /** * 为授权的小程序帐号上传小程序代码. */ @@ -71,4 +123,24 @@ public interface WxMaCodeConstant { * 小程序审核撤回 */ String UNDO_CODE_AUDIT_URL = "https://api.weixin.qq.com/wxa/undocodeaudit"; + + /** + * 获取永久素材 + */ + String GET_MATERIAL_URL = "https://api.weixin.qq.com/cgi-bin/material/get_material"; + + /** + * 设置服务器域名 + */ + String MODIFY_DOMAIN_URL = "https://api.weixin.qq.com/wxa/modify_domain"; + + /** + * 设置业务域名 + */ + String SET_WEBVIEW_DOMAIN_URL = "https://api.weixin.qq.com/wxa/setwebviewdomain"; + + /** + * 新增临时素材 + */ + String MEDIA_UPLOAD_URL = "https://api.weixin.qq.com/wxa/setwebviewdomain"; } diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/enums/WxMaErrorMsgEnum.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/enums/WxMaErrorMsgEnum.java index 7e21cdf51c..52750f230c 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/enums/WxMaErrorMsgEnum.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/enums/WxMaErrorMsgEnum.java @@ -14,6 +14,61 @@ public enum WxMaErrorMsgEnum { */ CODE_0(0, "请求成功"), + /** + * 签名验证错误 + */ + CODE_MINUS_40001(-40001,"签名验证错误"), + + /** + * xml解析失败 + */ + CODE_MINUS_40002(-40002,"xml解析失败"), + + /** + * sha加密生成签名失败 + */ + CODE_MINUS_40003(-40003,"sha加密生成签名失败"), + + /** + * SymmetricKey非法 + */ + CODE_MINUS_40004(-40004,"SymmetricKey非法"), + + /** + * corpid校验失败 + */ + CODE_MINUS_40005(-40005,"corpid校验失败"), + + /** + * aes加密失败 + */ + CODE_MINUS_40006(-40006,"aes加密失败"), + + /** + * aes解密失败 + */ + CODE_MINUS_40007(-40007,"aes解密失败"), + + /** + * 解密后得到的buffer非法 + */ + CODE_MINUS_40008(-40008,"解密后得到的buffer非法"), + + /** + * base64加密错误 + */ + CODE_MINUS_40009(-40009,"base64加密错误"), + + /** + * base64解密错误 + */ + CODE_MINUS_40010(-40010,"base64解密错误"), + + /** + * xml生成失败 + */ + CODE_MINUS_40011(-40011,"xml生成失败"), + /** *
      * 获取 access_token 时 AppSecret 错误,
diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/param/WxMaModifyDomainReq.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/param/WxMaModifyDomainReq.java
new file mode 100644
index 0000000000..634d66e39d
--- /dev/null
+++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/param/WxMaModifyDomainReq.java
@@ -0,0 +1,44 @@
+package com.epmet.wxapi.param;
+
+import com.google.gson.annotations.SerializedName;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * @author zhaoqifeng
+ * @dscription
+ * @date 2020/7/16 17:28
+ */
+@NoArgsConstructor
+@Data
+public class WxMaModifyDomainReq implements Serializable {
+
+	private static final long serialVersionUID = 2768949609300541671L;
+	/**
+	 * 操作类型
+	 */
+	private String action;
+	/**
+	 * request 合法域名
+	 */
+	@SerializedName("requestdomain")
+	private List requestDomain;
+	/**
+	 * socket 合法域名
+	 */
+	@SerializedName("wsrequestdomain")
+	private List wsRequestDomain;
+	/**
+	 * uploadFile 合法域名
+	 */
+	@SerializedName("uploaddomain")
+	private List uploadDomain;
+	/**
+	 * downloadFile 合法域名
+	 */
+	@SerializedName("downloaddomain")
+	private List downloadDomain;
+}
diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/param/WxMaNewsReq.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/param/WxMaNewsReq.java
new file mode 100644
index 0000000000..b0cc794400
--- /dev/null
+++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/param/WxMaNewsReq.java
@@ -0,0 +1,20 @@
+package com.epmet.wxapi.param;
+
+import com.google.gson.annotations.SerializedName;
+import lombok.Builder;
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * @author zhaoqifeng
+ * @dscription
+ * @date 2020/7/16 14:42
+ */
+@Data
+public class WxMaNewsReq implements Serializable {
+	private static final long serialVersionUID = -2575933909006637636L;
+
+	@SerializedName("media_id")
+	private String mediaId;
+}
diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/param/WxMaSetWebviewDomainReq.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/param/WxMaSetWebviewDomainReq.java
new file mode 100644
index 0000000000..78c1e2540e
--- /dev/null
+++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/param/WxMaSetWebviewDomainReq.java
@@ -0,0 +1,29 @@
+package com.epmet.wxapi.param;
+
+import com.google.gson.annotations.SerializedName;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * @author zhaoqifeng
+ * @dscription
+ * @date 2020/7/16 17:31
+ */
+@NoArgsConstructor
+@Data
+public class WxMaSetWebviewDomainReq implements Serializable {
+
+	private static final long serialVersionUID = 4560145267553484959L;
+	/**
+	 * 操作类型
+	 */
+	private String action;
+	/**
+	 * 小程序业务域名
+	 */
+	@SerializedName("webviewdomain")
+	private List webViewDomain;
+}
diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/result/WxMaGetCategoryResult.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/result/WxMaGetCategoryResult.java
index b120ad55df..c729095e64 100644
--- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/result/WxMaGetCategoryResult.java
+++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/result/WxMaGetCategoryResult.java
@@ -1,5 +1,6 @@
 package com.epmet.wxapi.result;
 
+import com.google.gson.annotations.SerializedName;
 import lombok.Data;
 
 import java.io.Serializable;
@@ -24,5 +25,6 @@ public class WxMaGetCategoryResult implements Serializable {
 	/**
 	 * 可填选的类目信息列表
 	 */
+	@SerializedName("category_list")
 	private List categoryList;
 }
diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/result/WxMaNewsResult.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/result/WxMaNewsResult.java
new file mode 100644
index 0000000000..7bce05e30a
--- /dev/null
+++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/result/WxMaNewsResult.java
@@ -0,0 +1,60 @@
+package com.epmet.wxapi.result;
+
+import com.google.gson.annotations.SerializedName;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * @author zhaoqifeng
+ * @dscription
+ * @date 2020/7/16 14:43
+ */
+@Data
+public class WxMaNewsResult implements Serializable {
+	private static final long serialVersionUID = -5844290246590127322L;
+
+	@SerializedName("news_item")
+	private List newsItem;
+
+	@Data
+	public static class NewsItemBean {
+		/**
+		 * 图文消息的标题
+		 */
+		private String title;
+		/**
+		 * 图文消息的封面图片素材id
+		 */
+		@SerializedName("thumb_media_id")
+		private String thumbMediaId;
+		/**
+		 * 是否显示封面,0为false,即不显示,1为true,即显示
+		 */
+		@SerializedName("show_cover_pic")
+		private Integer showCoverPic;
+		/**
+		 * 作者
+		 */
+		private String author;
+		/**
+		 * 图文消息的摘要,仅有单图文消息才有摘要,多图文此处为空
+		 */
+		private String digest;
+		/**
+		 * 图文消息的具体内容,支持HTML标签,必须少于2万字符,小于1M,且此处会去除JS
+		 */
+		private String content;
+		/**
+		 * 图文页的URL
+		 */
+		private String url;
+		/**
+		 * 图文消息的原文地址,即点击“阅读原文”后的URL
+		 */
+		@SerializedName("content_source_url")
+		private String contentSourceUrl;
+	}
+}
diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/result/WxMaUploadMediaResult.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/result/WxMaUploadMediaResult.java
new file mode 100644
index 0000000000..3ab26aff9a
--- /dev/null
+++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/result/WxMaUploadMediaResult.java
@@ -0,0 +1,25 @@
+package com.epmet.wxapi.result;
+
+import com.google.gson.annotations.SerializedName;
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * @author zhaoqifeng
+ * @dscription
+ * @date 2020/7/17 14:10
+ */
+@Data
+public class WxMaUploadMediaResult implements Serializable {
+	private static final long serialVersionUID = 7258823761146570668L;
+	@SerializedName("errcode")
+	private Integer errCode = 0;
+	@SerializedName("errmsg")
+	private String errMsg;
+	private String type;
+	@SerializedName("media_id")
+	private String mediaId;
+	@SerializedName("created_at")
+	private String createdAt;
+}
diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/service/WxLoginService.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/service/WxLoginService.java
new file mode 100644
index 0000000000..457f53af08
--- /dev/null
+++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/service/WxLoginService.java
@@ -0,0 +1,21 @@
+package com.epmet.wxapi.service;
+
+import com.epmet.dto.UserWechatDTO;
+
+import java.util.HashMap;
+
+/**
+ * 小程序代码管理相关 API(微信登陆)
+ * 文档:https://open.weixin.qq.com/cgi-bin/showdocument?action=dir_list&t=resource/res_list&verify=1&id=open1489140610_Uavc4&token=&lang=zh_CN
+ * @author sun
+ */
+public interface WxLoginService {
+
+	/**
+	 * @param appId wxCode customerId clientType
+	 * @return
+	 * @Author sun
+	 * @Description 微信登陆获取用户信息
+	 **/
+	UserWechatDTO resiAndWorkLogin(String appId, String wxCode, String customerId, String clientType);
+}
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 60d243f62d..111dff5f06 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
@@ -3,10 +3,10 @@ package com.epmet.wxapi.service;
 import com.epmet.wxapi.param.WxMaCodeAuditStatusReq;
 import com.epmet.wxapi.param.WxMaCodeCommitReq;
 import com.epmet.wxapi.param.WxMaCodeSubmitAuditRequest;
-import com.epmet.wxapi.result.WxMaAuditStatusResult;
-import com.epmet.wxapi.result.WxMaTemplateResult;
-import com.epmet.wxapi.result.WxResult;
+import com.epmet.wxapi.param.WxMaNewsReq;
+import com.epmet.wxapi.result.*;
 
+import java.io.File;
 import java.util.List;
 
 /**
@@ -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);
 
 	/**
 	 * 获取授权小程序帐号的可选类目.
@@ -101,7 +101,43 @@ public interface WxMaCodeService {
 	 */
 	WxResult undoCodeAudit(String accessToken);
 
-	//TODO 设置服务器域名
+	/**
+	 * 获取永久图文素材
+	 *
+	 * @param accessToken 提交审核参数
+	 * @param request     参数
+	 * @return com.epmet.wxapi.result.WxResult
+	 * @author zhaoqifeng
+	 * @date 2020/7/16 14:52
+	 */
+	WxResult getMaterial(String accessToken, WxMaNewsReq request);
+
+	/**
+	 * 设置服务器郁闷
+	 * @author zhaoqifeng
+	 * @date 2020/7/16 17:21
+	 * @param accessToken
+	 * @return com.epmet.wxapi.result.WxResult
+	 */
+	WxResult modifyDomain(String accessToken);
 
-	//TODO 设置业务域名
+	/**
+	 * 设置业务域名
+	 * @author zhaoqifeng
+	 * @date 2020/7/16 17:22
+	 * @param accessToken
+	 * @return com.epmet.wxapi.result.WxResult
+	 */
+	WxResult setWebviewDomain(String accessToken);
+
+	/**
+	 * 上传临时素材
+	 * @author zhaoqifeng
+	 * @date 2020/7/17 10:27
+	 * @param accessToken
+	 * @param type
+	 * @param file
+	 * @return com.epmet.wxapi.result.WxResult
+	 */
+	WxResult uploadMedia(String accessToken, String type, File file);
 }
diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/service/impl/WxLoginServiceImpl.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/service/impl/WxLoginServiceImpl.java
new file mode 100644
index 0000000000..8ae28634de
--- /dev/null
+++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/service/impl/WxLoginServiceImpl.java
@@ -0,0 +1,89 @@
+package com.epmet.wxapi.service.impl;
+
+import com.alibaba.fastjson.JSON;
+import com.epmet.commons.tools.exception.RenException;
+import com.epmet.commons.tools.redis.RedisUtils;
+import com.epmet.commons.tools.utils.HttpClientManager;
+import com.epmet.dto.UserWechatDTO;
+import com.epmet.wxapi.constant.WxLoginConstant;
+import com.epmet.wxapi.service.WxLoginService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Service;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * 小程序代码管理相关 API(微信登陆)
+ * 文档:https://open.weixin.qq.com/cgi-bin/showdocument?action=dir_list&t=resource/res_list&verify=1&id=open1489140610_Uavc4&token=&lang=zh_CN
+ * @author sun
+ */
+@Service
+public class WxLoginServiceImpl implements WxLoginService {
+	private static final Logger logger = LoggerFactory.getLogger(WxLoginServiceImpl.class);
+
+	@Value("${third.platform.appId}")
+	private String componentAppId;
+	@Autowired
+	private RedisUtils redisUtils;
+
+
+	/**
+	 * @param appId wxCode customerId clientType
+	 * @return
+	 * @Author sun
+	 * @Description 微信登陆获取用户信息
+	 **/
+	@Override
+	public UserWechatDTO resiAndWorkLogin(String appId, String wxCode, String customerId, String clientType) {
+		//1.获取用户openid和session_key
+		Map map = new HashMap<>();
+		map.put("appid", appId);
+		map.put("js_code", wxCode);
+		map.put("grant_type", "authorization_code");
+		map.put("component_appid", componentAppId);
+		String componentAccessToken = (String) redisUtils.get("epmet:wechartthird:componentaccesstoken");
+		map.put("component_access_token", componentAccessToken);
+		String resultStr = HttpClientManager.getInstance().sendGet(WxLoginConstant.WXCODE_BY_OPENID, map).getData();
+		HashMap hashMap = JSON.parseObject(resultStr, HashMap.class);
+		if (null != hashMap.get("errorCode")) {
+			logger.error("wxcode换取openid接口调用失败");
+			throw new RenException(hashMap.get("errorMsg"));
+		}
+		String openid = hashMap.get("openid");
+		String sessionKey = hashMap.get("session_key");
+
+		//2.换取用户基本信息
+		//小程序access_token
+		String access_token = (String) redisUtils.get("epmet:wechartthird:authinfo" + ":" + customerId + ":" + clientType);
+		Map hash = new HashMap<>();
+		hash.put("access_token", access_token);
+		hash.put("openid", openid);
+		hash.put("lang", "zh_CN");
+		String getStr = HttpClientManager.getInstance().sendGet(WxLoginConstant.OPENID_TO_INFORMATION, map).getData();
+		HashMap resultMap = JSON.parseObject(getStr, HashMap.class);
+		if (null != resultMap.get("errorCode")) {
+			logger.error("openid和access_token换取微信用户基本信息接口调用失败");
+			throw new RenException(resultMap.get("errorMsg"));
+		}
+
+		//3.返回结果
+		UserWechatDTO dto = new UserWechatDTO();
+		dto.setSessionKey(sessionKey);
+		dto.setWxOpenId(resultMap.get("openid"));
+		dto.setUnionId(resultMap.get("unionid"));
+		dto.setNickname(resultMap.get("nickname"));
+		dto.setSex(Integer.parseInt(resultMap.get("sex")));
+		dto.setHeadImgUrl(resultMap.get("headimgurl"));
+		dto.setCountry(resultMap.get("country"));
+		dto.setProvince(resultMap.get("province"));
+		dto.setCity(resultMap.get("city"));
+		dto.setLanguage(resultMap.get("language"));
+
+		return dto;
+	}
+
+}
\ No newline at end of file
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 41c1e17f7e..dfc9bb5cc9 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
@@ -4,16 +4,17 @@ import com.alibaba.fastjson.JSONObject;
 import com.epmet.commons.tools.utils.HttpClientManager;
 import com.epmet.commons.tools.utils.Result;
 import com.epmet.wxapi.constant.WxMaCodeConstant;
-import com.epmet.wxapi.param.WxMaCodeAuditStatusReq;
-import com.epmet.wxapi.param.WxMaCodeCommitReq;
-import com.epmet.wxapi.param.WxMaCodeSubmitAuditRequest;
+import com.epmet.wxapi.enums.WxMaErrorMsgEnum;
+import com.epmet.wxapi.param.*;
 import com.epmet.wxapi.result.*;
 import com.epmet.wxapi.service.WxMaCodeService;
 import com.google.gson.Gson;
 import com.google.gson.GsonBuilder;
 import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 
+import java.io.File;
 import java.io.UnsupportedEncodingException;
 import java.net.URLEncoder;
 import java.nio.charset.StandardCharsets;
@@ -29,6 +30,16 @@ import java.util.List;
 public class WxMaCodeServiceImpl implements WxMaCodeService {
 	private static final String ERR_CODE = "errcode";
 	private static final String ERR_MSG = "errmsg";
+	@Value("${third.domain.requestdomain}")
+	private List requestDomain;
+	@Value("${third.domain.wsrequestdomain}")
+	private List wsRequestDomain;
+	@Value("${third.domain.uploaddomain}")
+	private List uploadDomain;
+	@Value("${third.domain.downloaddomain}")
+	private List downloadDomain;
+	@Value("${third.domain.webviewdomain}")
+	private List webviewDomain;
 
 	@Override
 	public WxResult> getTemplateList(String accessToken) {
@@ -41,7 +52,7 @@ public class WxMaCodeServiceImpl implements WxMaCodeService {
 			return result;
 		}
 		Gson gson = new Gson();
-		WxMaTemplateListResult templateList = new Gson().fromJson(templateListResult.getData(), WxMaTemplateListResult.class);
+		WxMaTemplateListResult templateList = gson.fromJson(templateListResult.getData(), WxMaTemplateListResult.class);
 		result.setErrorCode(templateList.getErrCode());
 		result.setErrorMsg(templateList.getErrMsg());
 		result.setData(templateList.getTemplateList());
@@ -60,12 +71,12 @@ public class WxMaCodeServiceImpl implements WxMaCodeService {
 		}
 		JSONObject jsonObject = JSONObject.parseObject(commitResult.getData());
 		result.setErrorCode(jsonObject.getInteger(ERR_CODE));
-		result.setErrorMsg(jsonObject.getString(ERR_MSG));
+		result.setErrorMsg(WxMaErrorMsgEnum.findMsgByCode(jsonObject.getInteger(ERR_CODE)));
 		return result;
 	}
 
 	@Override
-	public WxResult getQrCode(String accessToken, String path) {
+	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)) {
@@ -78,7 +89,7 @@ public class WxMaCodeServiceImpl implements WxMaCodeService {
 		Result qrCodeResult = HttpClientManager.getInstance().sendGetFile(url.toString(), null);
 		if (!qrCodeResult.success()) {
 			result.setErrorCode(qrCodeResult.getCode());
-			result.setErrorMsg(qrCodeResult.getMsg());
+			result.setErrorMsg(WxMaErrorMsgEnum.findMsgByCode(qrCodeResult.getCode()));
 			return result;
 		}
 
@@ -97,9 +108,10 @@ public class WxMaCodeServiceImpl implements WxMaCodeService {
 			result.setErrorMsg(getCategoryResult.getMsg());
 			return result;
 		}
-		WxMaGetCategoryResult categoryResult = JSONObject.parseObject(getCategoryResult.getData(), WxMaGetCategoryResult.class);
+		Gson gson = new Gson();
+		WxMaGetCategoryResult categoryResult = gson.fromJson(getCategoryResult.getData(), WxMaGetCategoryResult.class);
 		result.setErrorCode(categoryResult.getErrcode());
-		result.setErrorMsg(categoryResult.getErrmsg());
+		result.setErrorMsg(WxMaErrorMsgEnum.findMsgByCode(categoryResult.getErrcode()));
 		result.setData(categoryResult.getCategoryList());
 		return result;
 	}
@@ -116,7 +128,7 @@ public class WxMaCodeServiceImpl implements WxMaCodeService {
 		}
 		WxMaGetPageResult pageResult = JSONObject.parseObject(getPageResult.getData(), WxMaGetPageResult.class);
 		result.setErrorCode(pageResult.getErrcode());
-		result.setErrorMsg(pageResult.getErrmsg());
+		result.setErrorMsg(WxMaErrorMsgEnum.findMsgByCode(pageResult.getErrcode()));
 		result.setData(pageResult.getPageList());
 		return result;
 	}
@@ -133,7 +145,7 @@ public class WxMaCodeServiceImpl implements WxMaCodeService {
 		}
 		JSONObject jsonObject = JSONObject.parseObject(submitResult.getData());
 		result.setErrorCode(jsonObject.getInteger(ERR_CODE));
-		result.setErrorMsg(jsonObject.getString(ERR_MSG));
+		result.setErrorMsg(WxMaErrorMsgEnum.findMsgByCode(jsonObject.getInteger(ERR_CODE)));
 		result.setData(jsonObject.getString("auditid"));
 		return result;
 	}
@@ -151,7 +163,7 @@ public class WxMaCodeServiceImpl implements WxMaCodeService {
 		WxMaAuditStatusResult auditStatusResult = JSONObject.parseObject(statusResult.getData(), WxMaAuditStatusResult.class);
 		if (!auditStatusResult.success()){
 			result.setErrorCode(auditStatusResult.getErrcode());
-			result.setErrorMsg(auditStatusResult.getErrmsg());
+			result.setErrorMsg(WxMaErrorMsgEnum.findMsgByCode(auditStatusResult.getErrcode()));
 			return result;
 		}
 		result.ok(auditStatusResult);
@@ -170,7 +182,7 @@ public class WxMaCodeServiceImpl implements WxMaCodeService {
 		}
 		JSONObject jsonObject = JSONObject.parseObject(releaseResult.getData());
 		result.setErrorCode(jsonObject.getInteger(ERR_CODE));
-		result.setErrorMsg(jsonObject.getString(ERR_MSG));
+		result.setErrorMsg(WxMaErrorMsgEnum.findMsgByCode(jsonObject.getInteger(ERR_CODE)));
 		return result;
 	}
 
@@ -186,21 +198,82 @@ public class WxMaCodeServiceImpl implements WxMaCodeService {
 		}
 		JSONObject jsonObject = JSONObject.parseObject(undoResult.getData());
 		result.setErrorCode(jsonObject.getInteger(ERR_CODE));
-		result.setErrorMsg(jsonObject.getString(ERR_MSG));
+		result.setErrorMsg(WxMaErrorMsgEnum.findMsgByCode(jsonObject.getInteger(ERR_CODE)));
 		return result;
 	}
 
-	public static void main(String[] args) {
-		String url = "{\"errcode\":0,\"errmsg\":\"ok\",\"category_list\":[{\"first_class\":\"工具\",\"second_class\":\"备忘录\",\"first_id\":1,\"second_id\":2,}\n" +
-				"{\"first_class\":\"教育\",\"second_class\":\"学历教育\",\"third_class\":\"高等\",\"first_id\":3,\"second_id\":4,\"third_id\":5,}]}";
-		WxMaGetCategoryResult video = JSONObject.parseObject(url, WxMaGetCategoryResult.class);
-		WxResult> result = new WxResult<>();
-		result.setErrorCode(video.getErrcode());
-		result.setErrorMsg(video.getErrmsg());
-		result.setData(video.getCategoryList());
-		System.out.println(result);
-		WxMaCodeSubmitAuditRequest request = new WxMaCodeSubmitAuditRequest();
-		request.setVersionDesc("aasdf");
+	@Override
+	public WxResult getMaterial(String accessToken, WxMaNewsReq request) {
+		WxResult result = new WxResult<>();
+		String url = WxMaCodeConstant.GET_MATERIAL_URL + "?" + "access_token=" + accessToken;
+		Result statusResult = HttpClientManager.getInstance().sendPostByJSON(url, toJson(request));
+		if (!statusResult.success()) {
+			result.setErrorCode(statusResult.getCode());
+			result.setErrorMsg(statusResult.getMsg());
+			return result;
+		}
+		Gson gson = new Gson();
+		WxMaNewsResult newsResult = gson.fromJson(statusResult.getData(), WxMaNewsResult.class);
+		result.ok(newsResult);
+		return result;
+	}
+
+	@Override
+	public WxResult modifyDomain(String accessToken) {
+		WxResult result = new WxResult();
+		String url = WxMaCodeConstant.MODIFY_DOMAIN_URL + "?" + "access_token=" + accessToken;
+		WxMaModifyDomainReq request = new WxMaModifyDomainReq();
+		request.setAction("set");
+		request.setRequestDomain(requestDomain);
+		request.setUploadDomain(uploadDomain);
+		request.setWsRequestDomain(wsRequestDomain);
+		request.setDownloadDomain(downloadDomain);
+		Result modifyResult = HttpClientManager.getInstance().sendPostByJSON(url, toJson(request));
+		if (!modifyResult.success()) {
+			result.setErrorCode(modifyResult.getCode());
+			result.setErrorMsg(modifyResult.getMsg());
+			return result;
+		}
+		JSONObject jsonObject = JSONObject.parseObject(modifyResult.getData());
+		result.setErrorCode(jsonObject.getInteger(ERR_CODE));
+		result.setErrorMsg(WxMaErrorMsgEnum.findMsgByCode(jsonObject.getInteger(ERR_CODE)));
+		return result;
+	}
+
+	@Override
+	public WxResult setWebviewDomain(String accessToken) {
+		WxResult result = new WxResult();
+		String url = WxMaCodeConstant.SET_WEBVIEW_DOMAIN_URL + "?" + "access_token=" + accessToken;
+		WxMaSetWebviewDomainReq request = new WxMaSetWebviewDomainReq();
+		request.setAction("set");
+		request.setWebViewDomain(webviewDomain);
+		Result modifyResult = HttpClientManager.getInstance().sendPostByJSON(url, toJson(request));
+		if (!modifyResult.success()) {
+			result.setErrorCode(modifyResult.getCode());
+			result.setErrorMsg(modifyResult.getMsg());
+			return result;
+		}
+		JSONObject jsonObject = JSONObject.parseObject(modifyResult.getData());
+		result.setErrorCode(jsonObject.getInteger(ERR_CODE));
+		result.setErrorMsg(WxMaErrorMsgEnum.findMsgByCode(jsonObject.getInteger(ERR_CODE)));
+		return result;
+	}
+
+	@Override
+	public WxResult uploadMedia(String accessToken, String type, File file) {
+		WxResult result = new WxResult<>();
+		String url = WxMaCodeConstant.MEDIA_UPLOAD_URL + "?" + "access_token=" + accessToken + "&type=" + type;
+		Result mediaResult = HttpClientManager.getInstance().uploadWxMedia(url, file);
+		if (!mediaResult.success()) {
+			result.setErrorCode(mediaResult.getCode());
+			result.setErrorMsg(mediaResult.getMsg());
+			return result;
+		}
+		Gson gson = new Gson();
+		WxMaUploadMediaResult mediaInfo = gson.fromJson(mediaResult.getData(), WxMaUploadMediaResult.class);
+		result.setErrorCode(mediaInfo.getErrCode());
+		result.setErrorMsg(WxMaErrorMsgEnum.findMsgByCode(mediaInfo.getErrCode()));
+		return result;
 	}
 
 	private String toJson(Object object) {
diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/resources/bootstrap.yml b/epmet-module/epmet-third/epmet-third-server/src/main/resources/bootstrap.yml
index 56a7c1b6dd..34cba72036 100644
--- a/epmet-module/epmet-third/epmet-third-server/src/main/resources/bootstrap.yml
+++ b/epmet-module/epmet-third/epmet-third-server/src/main/resources/bootstrap.yml
@@ -100,7 +100,13 @@ pagehelper:
   reasonable: false
 third:
   platform:
-    appId: wx9681884b28ed7927
-    appSecret: xxx
+    appId: wxd63ff476314c7c3e
+    appSecret: 4733aa5ba6dfe0efc569ebac7c4fe56b
     aesKey: d6dbde92c67e11eabac1c03fd56f7847qazxswedcvg
-    token: 1ae5f230c67f11eabac1c03fd56f7847
\ No newline at end of file
+    token: 1ae5f230c67f11eabac1c03fd56f7847
+  domain:
+    requestdomain: "https://epmet-cloud.elinkservice.cn"
+    wsrequestdomain: "https://epmet-cloud.elinkservice.cn"
+    uploaddomain: "https://epmet-cloud.elinkservice.cn"
+    downloaddomain: "https://epmet-cloud.elinkservice.cn"
+    webviewdomain: "https://epmet-cloud.elinkservice.cn"
\ No newline at end of file
diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/AuthCodeDao.xml b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/AuthCodeDao.xml
index 4d605df059..b9b9ad4e2e 100644
--- a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/AuthCodeDao.xml
+++ b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/AuthCodeDao.xml
@@ -9,7 +9,7 @@
             (
                 REPLACE ( UUID(), '-', '' ),
                 #{customerId},
-                #{clientType}
+                #{clientType},
                 #{authCode},
                 #{expiresInTime},
                 #{delFlag},
@@ -42,4 +42,14 @@
             AND auth_code = #{authCode}
     
 
+    
+    
+        UPDATE auth_code
+        SET del_flag = 1
+        where
+        del_flag = 0
+        AND customer_id = #{customerId}
+        AND client_type = #{clientType}
+    
+
 
\ No newline at end of file
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 ea012b7f0a..406a9fd06c 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
@@ -14,7 +14,7 @@
                 #{authorizerAccessToken},
                 #{expiresInTime},
                 #{authorizerRefreshToken},
-                #{clientType}
+                #{clientType},
                 #{delFlag},
                 #{createdBy},
                 NOW(),
diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/CodeAuditRecordDao.xml b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/CodeAuditRecordDao.xml
index f0d102d0f4..52fd770f9d 100644
--- a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/CodeAuditRecordDao.xml
+++ b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/CodeAuditRecordDao.xml
@@ -14,16 +14,16 @@
                 #{templateId},
                 #{clientType},
                 #{authAppId},
-                #{toUserName},
-                #{fromUserName},
+                #{ToUserName},
+                #{FromUserName},
                 #{wechatCreateTime},
-                #{msgType},
-                #{event},
-                IFNULL(#{succTime},NULL),
-                IFNULL(#{failTime},NULL),
-                IFNULL(#{delayTime},NULL),
-                IFNULL(#{reason},NULL),
-                IFNULL(#{screenShot},NULL),
+                #{MsgType},
+                #{Event},
+                IFNULL(#{SuccTime},NULL),
+                IFNULL(#{FailTime},NULL),
+                IFNULL(#{DelayTime},NULL),
+                IFNULL(#{Reason},NULL),
+                IFNULL(#{ScreenShot},NULL),
                 #{delFlag},
                 #{revision},
                 #{createdBy},
diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/CodeCustomerDao.xml b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/CodeCustomerDao.xml
index 6761472660..22d77316e6 100644
--- a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/CodeCustomerDao.xml
+++ b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/CodeCustomerDao.xml
@@ -82,6 +82,16 @@
             AND app_id = #{authAppId}
             AND template_id = #{templateId}
     
-
+    
+    
+        UPDATE code_customer
+        SET
+            DEL_FLAG = '1'
+        WHERE CUSTOMER_ID = #{customerId}
+        AND CLIENT_TYPE = #{clientType}
+        AND DEL_FLAG = '0'
+    
 
 
\ No newline at end of file
diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/CodeExtDao.xml b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/CodeExtDao.xml
new file mode 100644
index 0000000000..1afa087a7a
--- /dev/null
+++ b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/CodeExtDao.xml
@@ -0,0 +1,41 @@
+
+
+
+
+
+    
+        
+        
+        
+        
+        
+        
+        
+        
+        
+        
+        
+    
+    
+    
+
+
+
\ No newline at end of file
diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/CodeOperationHistoryDao.xml b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/CodeOperationHistoryDao.xml
new file mode 100644
index 0000000000..277beabe35
--- /dev/null
+++ b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/CodeOperationHistoryDao.xml
@@ -0,0 +1,41 @@
+
+
+
+
+
+    
+        
+        
+        
+        
+        
+        
+        
+        
+        
+        
+        
+        
+    
+    
+        UPDATE code_operation_history SET
+            `DESCRIBE` = #{describe}
+        WHERE CODE_ID = #{codeId}
+        AND OPERATION = 'audit'
+    
+    
+
+
+
\ No newline at end of file
diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/ComponentAccessTokenDao.xml b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/ComponentAccessTokenDao.xml
index e3cda3bc0e..53e1820b8a 100644
--- a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/ComponentAccessTokenDao.xml
+++ b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/ComponentAccessTokenDao.xml
@@ -33,7 +33,7 @@
 
     
     
 
     
@@ -41,11 +41,10 @@
         SELECT
             COUNT(*)
         FROM
-            refresh_authorizer_access_token
+            component_access_token
         WHERE
             del_flag = 0
             AND (UNIX_TIMESTAMP(expires_in_time) - UNIX_TIMESTAMP(NOW()))  900
-            AND (UNIX_TIMESTAMP(expires_in_time) - UNIX_TIMESTAMP(NOW())) > 0
     
 
 
\ No newline at end of file
diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/CustomerCodeOperationHistoryDao.xml b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/CustomerCodeOperationHistoryDao.xml
deleted file mode 100644
index 09ae8b2e78..0000000000
--- a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/CustomerCodeOperationHistoryDao.xml
+++ /dev/null
@@ -1,22 +0,0 @@
-
-
-
-
-
-    
-        
-        
-        
-        
-        
-        
-        
-        
-        
-        
-        
-        
-    
-
-
-
\ No newline at end of file
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 ac7b8b4346..4612ca8c88 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
@@ -27,7 +27,7 @@
         WHERE
             del_flag = '0'
             AND customer_id = #{customerId}
-            AND authorization_flag = 0
+            AND authorization_flag = 1
     
 
     
@@ -74,5 +74,45 @@
         ORDER BY
             customer_id ASC, client ASC
     
+    
+
+    
+
+    
 
 
\ No newline at end of file
diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/FuncInfoDao.xml b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/FuncInfoDao.xml
index c3af697392..b05ed32662 100644
--- a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/FuncInfoDao.xml
+++ b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/FuncInfoDao.xml
@@ -25,7 +25,7 @@
 
     
     
-        update func_info set del_flag = 0 where customer_id = #{customerId}
+        update func_info set del_flag = 0 where customer_id = #{customerId} AND authorization_info_appid = #{authAppId}
     
 
 
\ No newline at end of file
diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/MiniInfoDao.xml b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/MiniInfoDao.xml
index c838415721..bd326a8c0c 100644
--- a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/MiniInfoDao.xml
+++ b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/MiniInfoDao.xml
@@ -15,14 +15,14 @@
                 REPLACE ( UUID(), '-', '' ),
                 #{customerId},
                 #{clientType},
-                #{nickName},
-                #{headImg},
-                #{serviceTypeInfo},
-                #{verifyTypeInfo},
-                #{userName},
-                #{principalName},
+                #{nick_name},
+                #{head_img},
+                #{service_type_info},
+                #{verify_type_info},
+                #{user_name},
+                #{principal_name},
                 #{signature},
-                #{qrcodeUrl},
+                #{qrcode_url},
                 #{delFlag},
                 #{revision},
                 #{createdBy},
diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/PaCustomerAgencyDao.xml b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/PaCustomerAgencyDao.xml
index 99181ddebe..9911ae88ff 100644
--- a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/PaCustomerAgencyDao.xml
+++ b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/PaCustomerAgencyDao.xml
@@ -20,7 +20,22 @@
             id,
             customer_id,
             agency_name,
-            `level`,
+            (
+                CASE
+                WHEN `level` = 'province' THEN
+                    '省级'
+                WHEN `level` = 'city' THEN
+                    '市级'
+                WHEN `level` = 'district' THEN
+                    '区县级'
+                WHEN `level` = 'street' THEN
+                    '乡(镇、街道)级'
+                WHEN `level` = 'community' THEN
+                    '社区级'
+                ELSE
+                    '无'
+                END
+            ) AS "level",
             area_code,
             province,
             city,
@@ -33,4 +48,38 @@
         LIMIT 1
     
 
+    
+
 
\ No newline at end of file
diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/PaCustomerDao.xml b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/PaCustomerDao.xml
index 609937e09f..1d37df5b4d 100644
--- a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/PaCustomerDao.xml
+++ b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/PaCustomerDao.xml
@@ -22,7 +22,22 @@
             pc.id AS "customerId",
             pca.id AS "agencyId",
             pca.agency_name AS "agencyName",
-            pca.`level` AS "level",
+            (
+                CASE
+                WHEN pca.`level` = 'province' THEN
+                    '省级'
+                WHEN pca.`level` = 'city' THEN
+                    '市级'
+                WHEN pca.`level` = 'district' THEN
+                    '区县级'
+                WHEN pca.`level` = 'street' THEN
+                    '乡(镇、街道)级'
+                WHEN pca.`level` = 'community' THEN
+                    '社区级'
+                ELSE
+                    '无'
+                END
+            ) AS "level",
             pca.province AS "province",
             pca.city AS "city",
             pca.district AS "district",
@@ -41,4 +56,33 @@
             pca.CREATED_TIME DESC
     
 
+    
+
+    
+        UPDATE pa_customer
+        SET is_initialize = #{isInitialize}
+        WHERE
+            del_flag = '0'
+        AND id = #{id}
+    
+
 
\ No newline at end of file
diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/PaInfoDao.xml b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/PaInfoDao.xml
index 8715fb65f0..57397dc708 100644
--- a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/PaInfoDao.xml
+++ b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/PaInfoDao.xml
@@ -15,14 +15,14 @@
                 REPLACE ( UUID(), '-', '' ),
                 #{customerId},
                 #{clientType},
-                #{nickName},
-                #{headImg},
-                #{serviceTypeInfo},
-                #{verifyTypeInfo},
-                #{userName},
-                #{principalName},
+                #{nick_name},
+                #{head_img},
+                #{service_type_info},
+                #{verify_type_info},
+                #{user_name},
+                #{principal_name},
                 #{alias},
-                #{qrcodeUrl},
+                #{qrcode_url},
                 #{delFlag},
                 #{revision},
                 #{createdBy},
diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/PaUserDao.xml b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/PaUserDao.xml
index 56db230fa9..f97263c5b0 100644
--- a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/PaUserDao.xml
+++ b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/PaUserDao.xml
@@ -16,4 +16,21 @@
         AND phone = #{phone}
     
 
+    
+
 
\ No newline at end of file
diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/PreAuthTokenDao.xml b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/PreAuthTokenDao.xml
index 319909947d..a7f7113a92 100644
--- a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/PreAuthTokenDao.xml
+++ b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/PreAuthTokenDao.xml
@@ -32,7 +32,7 @@
 
     
     
-        update pre_auth_token set  del_flag = 0
+        update pre_auth_token set  del_flag = 1
     
 
 
\ No newline at end of file
diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/AddAgencyAndStaffFormDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/AddAgencyAndStaffFormDTO.java
new file mode 100644
index 0000000000..65882c543f
--- /dev/null
+++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/AddAgencyAndStaffFormDTO.java
@@ -0,0 +1,48 @@
+/**
+ * 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 com.epmet.dto.CustomerAgencyDTO; +import lombok.Data; +import org.hibernate.validator.constraints.Length; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + + +/** + * 单客户-添加根组织及管理员-接口入参 + * + * @author sun + */ +@Data +public class AddAgencyAndStaffFormDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 根级组织对象 + */ + private CustomerAgencyDTO agencyDTO; + /** + * 客户管理员信息 + */ + private AdminStaffFromDTO staffDTO; + + +} \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/AdminStaffFromDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/AdminStaffFromDTO.java new file mode 100644 index 0000000000..926e17b75e --- /dev/null +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/AdminStaffFromDTO.java @@ -0,0 +1,63 @@ +package com.epmet.dto.form; + +import lombok.Data; +import lombok.NoArgsConstructor; +import org.hibernate.validator.constraints.Length; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Pattern; +import java.io.Serializable; +import java.util.List; + +/** + * @author sun + * @dscription 客户管理员信息 + */ +@NoArgsConstructor +@Data +public class AdminStaffFromDTO implements Serializable { + private static final long serialVersionUID = 1L; + /** + * 客户ID + */ + private String customerId; + /** + * 机关ID + */ + private String agencyId; + /** + * 人员ID + */ + private String staffId; + /** + * 姓名 + */ + @Length(max = 15, message = "姓名仅允许输入15个字符") + private String name; + /** + * 手机 + */ + @Pattern(regexp = "^[1][3,4,5,6,7,8,9][0-9]{9}$", message = "请输入正确的手机号") + private String mobile; + /** + * 性别 + */ + private Integer gender; + /** + * 专兼职 + */ + private String workType; + /** + * 角色id列表 + */ + private List roles; + /** + * 来源app(政府端:gov、居民端:resi、运营端:oper) + */ + private String app; + /** + * 来源client(PC端:web、微信小程序:wxmp) + */ + private String client; +} diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/ThirdCustomerGridListFormDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/ThirdCustomerGridListFormDTO.java new file mode 100644 index 0000000000..5d48df72d7 --- /dev/null +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/ThirdCustomerGridListFormDTO.java @@ -0,0 +1,43 @@ +package com.epmet.dto.form;/** + * Created by 11 on 2020/3/19. + */ + +import lombok.Data; + +import javax.validation.constraints.Min; +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + +/** + * @Description 第三方-陌生人导览查询附近网格传参定义 + * @ClassName ListCustomerGridFormDTO + * @Author sun + */ +@Data +public class ThirdCustomerGridListFormDTO implements Serializable{ + + private static final long serialVersionUID = -1L; + + /** + * 客户Id + * */ + @NotBlank(message = "客户Id不能为空") + private String customerId; + + /** + * 地区编码(城市、区县) + * */ + @NotBlank(message = "地区码不能为空") + private String areaCode; + + /** + * 当前页 + * */ + @Min(value = 1) + private Integer pageNo = 1; + + /** + * 每页显示数量 + * */ + private Integer pageSize = 20; +} diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/PublicCustomerGridForStrangerResultDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/PublicCustomerGridForStrangerResultDTO.java new file mode 100644 index 0000000000..afa1ea9eda --- /dev/null +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/PublicCustomerGridForStrangerResultDTO.java @@ -0,0 +1,29 @@ +package com.epmet.dto.result; + +import lombok.Data; + +import java.io.Serializable; + +/** + * @Description 单客户-陌生人搜索网格-接口返参 + * @Author sun + */ +@Data +public class PublicCustomerGridForStrangerResultDTO implements Serializable { + private static final long serialVersionUID = -1L; + + /** + * 网格ID + * */ + private String gridId; + + /** + * 客户ID + * */ + private String customerId; + + /** + * 网格名称 + * */ + private String gridName; +} diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/feign/GovOrgOpenFeignClient.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/feign/GovOrgOpenFeignClient.java index 99bccaa484..4fbf1e6f59 100644 --- a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/feign/GovOrgOpenFeignClient.java +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/feign/GovOrgOpenFeignClient.java @@ -4,11 +4,9 @@ import com.epmet.commons.tools.constant.ServiceConstant; import com.epmet.commons.tools.utils.Result; import com.epmet.dto.CustomerAgencyDTO; import com.epmet.dto.CustomerPartyBranchDTO; +import com.epmet.dto.form.AddAgencyAndStaffFormDTO; import com.epmet.dto.form.ListPartyBranchFormDTO; -import com.epmet.dto.result.ArticleGridResultDTO; -import com.epmet.dto.result.GridInfoResultDTO; -import com.epmet.dto.result.ListPartyBranchResultDTO; -import com.epmet.dto.result.PublishAgencyListResultDTO; +import com.epmet.dto.result.*; import com.epmet.feign.fallback.GovOrgOpenFeignClientFallback; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.http.MediaType; @@ -131,4 +129,31 @@ public interface GovOrgOpenFeignClient { **/ @GetMapping(value = "gov/org/customerpartybranch/decrPartyBranchMember/{partyBranchId}") Result decrPartyBranchMember(@PathVariable("partyBranchId") String partyBranchId); + + /** + * @param agencyAndStaff + * @return + * @Author sun + * @Description 单客户-添加根组织及客户管理员信息 + **/ + @PostMapping("/gov/org/agency/saverootagency") + Result saveRootAgency(@RequestBody AddAgencyAndStaffFormDTO agencyAndStaff); + + /** + * @param staffId + * @return + * @Author sun + * @Description 查询人员部门列表 + */ + @PostMapping("/gov/org/department/staff/{staffId}/departmentlist") + Result> getDepartmentListByStaffId(@PathVariable("staffId") String staffId); + + /** + * @param staffId + * @return + * @Author sun + * @Description 查询工作人员所有的网格 + */ + @PostMapping("/gov/org/grid/gridsbystaffid/{staffId}") + Result> listGridsbystaffid(@PathVariable("staffId") String staffId); } diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/feign/fallback/GovOrgOpenFeignClientFallback.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/feign/fallback/GovOrgOpenFeignClientFallback.java index bcc224dd86..48fa9c84dc 100644 --- a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/feign/fallback/GovOrgOpenFeignClientFallback.java +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/feign/fallback/GovOrgOpenFeignClientFallback.java @@ -5,11 +5,9 @@ import com.epmet.commons.tools.utils.ModuleUtils; import com.epmet.commons.tools.utils.Result; import com.epmet.dto.CustomerAgencyDTO; import com.epmet.dto.CustomerPartyBranchDTO; +import com.epmet.dto.form.AddAgencyAndStaffFormDTO; import com.epmet.dto.form.ListPartyBranchFormDTO; -import com.epmet.dto.result.ArticleGridResultDTO; -import com.epmet.dto.result.GridInfoResultDTO; -import com.epmet.dto.result.ListPartyBranchResultDTO; -import com.epmet.dto.result.PublishAgencyListResultDTO; +import com.epmet.dto.result.*; import com.epmet.feign.GovOrgOpenFeignClient; import org.springframework.stereotype.Component; @@ -77,4 +75,19 @@ public class GovOrgOpenFeignClientFallback implements GovOrgOpenFeignClient { public Result decrPartyBranchMember(String partyBranchId) { return ModuleUtils.feignConError(ServiceConstant.GOV_ORG_SERVER, "decrPartyBranchMember",partyBranchId); } + + @Override + public Result saveRootAgency(AddAgencyAndStaffFormDTO agencyAndStaff) { + return ModuleUtils.feignConError(ServiceConstant.GOV_ORG_SERVER, "saveRootAgency", agencyAndStaff); + } + + @Override + public Result> getDepartmentListByStaffId(String staffId) { + return ModuleUtils.feignConError(ServiceConstant.GOV_ORG_SERVER, "getDepartmentListByStaffId", staffId); + } + + @Override + public Result> listGridsbystaffid(String staffId) { + return ModuleUtils.feignConError(ServiceConstant.GOV_ORG_SERVER, "listGridsbystaffid", staffId); + } } diff --git a/epmet-module/gov-org/gov-org-server/deploy/docker-compose-dev.yml b/epmet-module/gov-org/gov-org-server/deploy/docker-compose-dev.yml index 67596a1095..d1c7b78043 100644 --- a/epmet-module/gov-org/gov-org-server/deploy/docker-compose-dev.yml +++ b/epmet-module/gov-org/gov-org-server/deploy/docker-compose-dev.yml @@ -2,7 +2,7 @@ version: "3.7" services: gov-org-server: container_name: gov-org-server-dev - image: 192.168.1.130:10080/epmet-cloud-dev/gov-org-server:0.3.74 + image: 192.168.1.130:10080/epmet-cloud-dev/gov-org-server:0.3.75 ports: - "8092:8092" network_mode: host # 使用现有网络 diff --git a/epmet-module/gov-org/gov-org-server/pom.xml b/epmet-module/gov-org/gov-org-server/pom.xml index 730bdf8aa4..191856ef70 100644 --- a/epmet-module/gov-org/gov-org-server/pom.xml +++ b/epmet-module/gov-org/gov-org-server/pom.xml @@ -2,7 +2,7 @@ 4.0.0 - 0.3.74 + 0.3.75 com.epmet gov-org diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/AgencyController.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/AgencyController.java index af64c49645..cb1865ba35 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/AgencyController.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/AgencyController.java @@ -219,4 +219,17 @@ public class AgencyController { return new Result().ok(customerRootAgencies); } + /** + * @param agencyAndStaff + * @return + * @Author sun + * @Description 单客户-添加根组织及客户管理员信息 + * @Date 2020/7/16 17:13 + **/ + @PostMapping("saverootagency") + public Result saveRootAgency(@RequestBody AddAgencyAndStaffFormDTO agencyAndStaff) { + agencyService.saveRootAgency(agencyAndStaff); + return new Result(); + } + } \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/CustomerGridController.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/CustomerGridController.java index 430b560d33..69eecc5d2c 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/CustomerGridController.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/CustomerGridController.java @@ -204,4 +204,16 @@ public class CustomerGridController { return new Result().ok(customerGridService.getGridDataFilterMsg(gridForm)); } + /** + * @return + * @Param + * @Author sun + * @Description 第三方-陌生人导览模块调用-根据地区编码查询客户下的网格列表 + **/ + @PostMapping("querycustomergridlist") + public Result> queryCustomerGridList(@RequestBody ThirdCustomerGridListFormDTO formDTO ){ + ValidatorUtils.validateEntity(formDTO); + return customerGridService.queryCustomerGridList(formDTO); + } + } diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerGridDao.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerGridDao.java index 86303b5b28..09f71efd99 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerGridDao.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerGridDao.java @@ -200,4 +200,20 @@ public interface CustomerGridDao extends BaseDao { * @Description 查询机关下网格列表信息 **/ List selectAgencyGridMsgList(@Param("agencyId") String agencyId); + + /** + * @param listCustomerGridFormDTO + * @return + * @Author sun + * @Description 单客户-查询客户整个城市下的网格 + **/ + List selectThirdGridByCityLike(ThirdCustomerGridListFormDTO listCustomerGridFormDTO); + + /** + * @param map + * @return + * @Author sun + * @Description 单客户-指定区时查询当前城市下除该区之外其余的网格 + **/ + List selectThirdRestGridWithoutGivenAreaCode(Map map); } \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/AgencyService.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/AgencyService.java index 2f187a123d..2eb012ca11 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/AgencyService.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/AgencyService.java @@ -99,4 +99,13 @@ public interface AgencyService { CustomerAgencyDTO getCustomerRootAgency(String customerId); String addRootAgency(AddRootAgencyFormDTO form); + + /** + * @param agencyAndStaff + * @return + * @Author sun + * @Description 单客户-添加根组织及客户管理员信息 + * @Date 2020/7/16 17:13 + **/ + void saveRootAgency(AddAgencyAndStaffFormDTO agencyAndStaff); } \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/CustomerGridService.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/CustomerGridService.java index 6ca09779e1..518e20fdb5 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/CustomerGridService.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/CustomerGridService.java @@ -243,4 +243,12 @@ public interface CustomerGridService extends BaseService { * @date 2020.05.13 11:01 **/ CommonDataFilterResultDTO getGridDataFilterMsg(CommonGridIdFormDTO gridIdFormDTO); + + /** + * @return + * @Param + * @Author sun + * @Description 单客户-陌生人导览模块调用-根据地区编码查询客户下的网格列表 + **/ + Result> queryCustomerGridList(ThirdCustomerGridListFormDTO formDTO); } \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/AgencyServiceImpl.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/AgencyServiceImpl.java index 498aa11b62..4b37250b73 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/AgencyServiceImpl.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/AgencyServiceImpl.java @@ -17,17 +17,23 @@ package com.epmet.service.impl; +import com.alibaba.fastjson.JSON; import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.exception.EpmetErrorCode; import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.Result; import com.epmet.constant.CustomerAgencyConstant; +import com.epmet.constant.RoleKeyConstants; +import com.epmet.constant.UserWorkType; import com.epmet.dao.CustomerAgencyDao; import com.epmet.dto.CustomerAgencyDTO; +import com.epmet.dto.GovStaffRoleDTO; import com.epmet.dto.form.*; import com.epmet.dto.result.*; import com.epmet.entity.CustomerAgencyEntity; +import com.epmet.feign.EpmetUserFeignClient; +import com.epmet.feign.EpmetUserOpenFeignClient; import com.epmet.redis.CustomerAgencyRedis; import com.epmet.service.AgencyService; import com.epmet.service.CustomerAgencyService; @@ -54,9 +60,12 @@ public class AgencyServiceImpl implements AgencyService { private CustomerAgencyDao customerAgencyDao; @Autowired private CustomerAgencyService customerAgencyService; - @Autowired private CustomerAgencyRedis customerAgencyRedis; + @Autowired + private EpmetUserOpenFeignClient epmetUserOpenFeignClient; + @Autowired + private StaffServiceImpl staffServiceImpl; /** * @param formDTO @@ -291,4 +300,58 @@ public class AgencyServiceImpl implements AgencyService { customerAgencyDao.insert(entity); return entity.getId(); } + + /** + * @param agencyAndStaff + * @return + * @Author sun + * @Description 单客户-添加根组织及客户管理员信息 + * @Date 2020/7/16 17:13 + **/ + @Override + @Transactional(rollbackFor = Exception.class) + public void saveRootAgency(AddAgencyAndStaffFormDTO agencyAndStaff) { + CustomerAgencyDTO agencyDTO = agencyAndStaff.getAgencyDTO(); + AdminStaffFromDTO staffDTO = agencyAndStaff.getStaffDTO(); + + //1.判断当前客户是否已存在根级组织 + CustomerAgencyDTO rootAgencyExists = customerAgencyDao.getCustomerRootAgency(agencyDTO.getCustomerId()); + if (rootAgencyExists != null) { + throw new RenException(EpmetErrorCode.OPER_ADD_CUSTOMER_ROOT_AGENCY_EXISTS.getCode(), + EpmetErrorCode.OPER_ADD_CUSTOMER_ROOT_AGENCY_EXISTS.getMsg()); + } + + //2.新增根级组织 + CustomerAgencyEntity entity = ConvertUtils.sourceToTarget(agencyDTO, CustomerAgencyEntity.class); + entity.setPid("0"); + entity.setPids(""); + entity.setAllParentName(""); + entity.setTotalUser(0); + if (customerAgencyDao.insert(entity) < NumConstant.ONE) { + throw new RenException(EpmetErrorCode.OPER_ADD_CUSTOMER_ROOT_AGENCY_ERROR.getCode()); + } + + //3.查询客户具有指定RoleKey的角色信息 + CustomerRoleFormDTO customerRoleForm = new CustomerRoleFormDTO(); + customerRoleForm.setCustomerId(agencyDTO.getCustomerId()); + customerRoleForm.setRoleKey(RoleKeyConstants.ROLE_KEY_MANAGER); + Result getRoleResult = epmetUserOpenFeignClient.getRoleOfCustomer(customerRoleForm); + if (!getRoleResult.success() || getRoleResult.getData() == null) { + log.error("查询客户具有指定RoleKey的角色信息失败:".concat(getRoleResult.toString())); + throw new RenException("查询客户具有指定RoleKey的角色信息失败:".concat(getRoleResult.toString())); + } + + //4.新增客户管理员信息 + StaffSubmitFromDTO staffSubmitFrom = ConvertUtils.sourceToTarget(staffDTO, StaffSubmitFromDTO.class); + staffSubmitFrom.setRoles(Arrays.asList(getRoleResult.getData().getId())); + staffSubmitFrom.setApp("gov"); + staffSubmitFrom.setClient("wxmp"); + Result staffResult = staffServiceImpl.addStaff(staffSubmitFrom); + if (!staffResult.success()) { + log.error(String.format("新增客户管理员失败,调用gov-org-server服务异常%s", JSON.toJSONString(staffResult))); + throw new RenException(EpmetErrorCode.OPER_ADD_CUSTOMER_MANAGER_ERROR.getCode(), staffResult.getMsg()); + } + + } + } \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerGridServiceImpl.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerGridServiceImpl.java index 505114f8b0..403e93f3d1 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerGridServiceImpl.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerGridServiceImpl.java @@ -571,4 +571,48 @@ public class CustomerGridServiceImpl extends BaseServiceImpl> queryCustomerGridList(ThirdCustomerGridListFormDTO formDTO) { + Result> result = new Result<>(); + + String areaCode = formDTO.getAreaCode(); + formDTO.setPageNo((formDTO.getPageNo() - 1) * formDTO.getPageSize()); + + //地区编码如何是00结尾的则查询当前地区数据(实际业务不会存在,因为地区必须选到区县级) + if (areaCode.endsWith(ModuleConstant.LAST_TWO_LETTER_OF_FORMATIVE_CITY_CODE)) { + //城市 - 查全部 + formDTO.setAreaCode(areaCode.substring(0, areaCode.length() - 2)); + List gridList = baseDao.selectThirdGridByCityLike(formDTO); + result.setData(gridList); + result.setCode(ModuleConstant.SUCCESS_CODE_RESULT); + return result; + } else { + //行政区 - 指定行政区在前,所属城市下其余行政区在后 + Map map = new HashMap<>(); + map.put("customerId", formDTO.getCustomerId()); + //地区码格式 六位 [abcxyz] + //ab代表省 + map.put("areaCode", areaCode); + //cx代表市 + map.put("cityCode", areaCode.substring(NumConstant.ZERO, areaCode.length() - NumConstant.TWO)); + //yz代表区 + map.put("provinceCode", areaCode.substring(NumConstant.ZERO, areaCode.length() - NumConstant.FOUR)); + map.put("pageSize", formDTO.getPageSize()); + map.put("pageNo", formDTO.getPageNo()); + + List gridListArea = baseDao.selectThirdRestGridWithoutGivenAreaCode(map); + result.setData(gridListArea); + + return result; + } + + } + } diff --git a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerGridDao.xml b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerGridDao.xml index 52d8e15bc2..ef5998325e 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerGridDao.xml +++ b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerGridDao.xml @@ -397,4 +397,111 @@ AND ca.del_flag = '0' AND cg.pid = #{agencyId} + + + + + \ No newline at end of file diff --git a/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/dto/form/CustomerInitFormDTO.java b/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/dto/form/CustomerInitFormDTO.java new file mode 100644 index 0000000000..93f5146e40 --- /dev/null +++ b/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/dto/form/CustomerInitFormDTO.java @@ -0,0 +1,23 @@ +package com.epmet.dto.form; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; +import java.util.List; + +/** + * @Description 运营端-初始化在公众号注册的客户-接口入参 + * @Author sun + */ +@Data +public class CustomerInitFormDTO implements Serializable { + + public interface GetCustomerDetailGroup { + } + + @NotBlank(message = "客户Id不能为空", groups = {GetCustomerDetailGroup.class}) + private String customerId; + +} + 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 6e0130dee1..1c4f6845ca 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.25 + image: 192.168.1.130:10080/epmet-cloud-dev/oper-crm-server:0.3.28 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 e2b5bca7e2..d1eaf5367f 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.25 + 0.3.28 com.epmet oper-crm @@ -81,6 +81,12 @@ 2.0.0 compile + + com.epmet + epmet-third-client + 2.0.0 + compile + diff --git a/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/controller/CustomerController.java b/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/controller/CustomerController.java index 84574bdf85..c8c17dcfad 100644 --- a/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/controller/CustomerController.java +++ b/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/controller/CustomerController.java @@ -30,10 +30,7 @@ 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.CustomerDTO; -import com.epmet.dto.form.AddRootAgencyFormDTO; -import com.epmet.dto.form.CustomerFormDTO; -import com.epmet.dto.form.CustomerManagerFormDTO; -import com.epmet.dto.form.PageQueryFormDTO; +import com.epmet.dto.form.*; import com.epmet.dto.result.CustomerDetailResultDTO; import com.epmet.dto.result.ValidCustomerResultDTO; import com.epmet.excel.CustomerExcel; @@ -235,4 +232,19 @@ public class CustomerController { ValidatorUtils.validateEntity(formDTO); return new Result().ok(customerService.pageQuery(formDTO)); } + + /** + * @param formDTO + * @return + * @Author sun + * @Description 单客户-运营端-初始化在公众号注册的客户 + * @Date 2020/7/16 17:13 + **/ + @PostMapping("init") + public Result init(@RequestBody CustomerInitFormDTO formDTO) { + ValidatorUtils.validateEntity(formDTO, CustomerInitFormDTO.GetCustomerDetailGroup.class); + customerService.init(formDTO); + return new Result(); + } + } diff --git a/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/feign/OperCustomizeFeignClient.java b/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/feign/OperCustomizeFeignClient.java index b59a5c7a20..015b0d3684 100644 --- a/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/feign/OperCustomizeFeignClient.java +++ b/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/feign/OperCustomizeFeignClient.java @@ -9,7 +9,7 @@ import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; //@FeignClient(name = ServiceConstant.OPER_CUSTOMIZE_SERVER, fallback = OperCustomizeFeignClientFallBack.class, url = "localhost:8089") -@FeignClient(name = ServiceConstant.OPER_CUSTOMIZE_SERVER, fallback = OperCustomizeFeignClientFallBack.class) +@FeignClient(name = ServiceConstant.OPER_CUSTOMIZE_SERVER, fallback = OperCustomizeFeignClientFallBack.class,url="localhost:8089") public interface OperCustomizeFeignClient { /** diff --git a/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/CustomerService.java b/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/CustomerService.java index bf0c569e53..bf486a4ef2 100644 --- a/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/CustomerService.java +++ b/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/CustomerService.java @@ -22,6 +22,7 @@ import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.utils.Result; import com.epmet.dto.CustomerDTO; import com.epmet.dto.form.CustomerFormDTO; +import com.epmet.dto.form.CustomerInitFormDTO; import com.epmet.dto.form.CustomerManagerFormDTO; import com.epmet.dto.form.PageQueryFormDTO; import com.epmet.dto.result.CustomerDetailResultDTO; @@ -158,4 +159,14 @@ public interface CustomerService extends BaseService { * @Description 运营端-客户列表查询 **/ PageData pageQuery(PageQueryFormDTO formDTO); + + /** + * @param formDTO + * @return + * @Author sun + * @Description 单客户-运营端-初始化在公众号注册的客户 + * @Date 2020/7/16 17:13 + **/ + void init(CustomerInitFormDTO formDTO); + } diff --git a/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/impl/CustomerServiceImpl.java b/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/impl/CustomerServiceImpl.java index dbd6c2a666..2dc57cd47f 100644 --- a/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/impl/CustomerServiceImpl.java +++ b/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/impl/CustomerServiceImpl.java @@ -22,6 +22,7 @@ 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.EpmetErrorCode; import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.page.PageData; @@ -30,16 +31,11 @@ import com.epmet.commons.tools.utils.Result; import com.epmet.constant.RoleKeyConstants; import com.epmet.constant.UserWorkType; import com.epmet.dao.CustomerDao; -import com.epmet.dto.CustomerAgencyDTO; -import com.epmet.dto.CustomerDTO; -import com.epmet.dto.CustomerHomeDTO; -import com.epmet.dto.GovStaffRoleDTO; +import com.epmet.dto.*; import com.epmet.dto.form.*; import com.epmet.dto.result.*; import com.epmet.entity.CustomerEntity; -import com.epmet.feign.EpmetUserFeignClient; -import com.epmet.feign.GovOrgFeignClient; -import com.epmet.feign.OperCustomizeFeignClient; +import com.epmet.feign.*; import com.epmet.redis.CustomerRedis; import com.epmet.service.CustomerService; import com.github.pagehelper.PageHelper; @@ -64,18 +60,18 @@ import java.util.stream.Collectors; public class CustomerServiceImpl extends BaseServiceImpl implements CustomerService { private static final Logger log = LoggerFactory.getLogger(CustomerServiceImpl.class); - @Autowired private CustomerRedis customerRedis; - @Autowired private EpmetUserFeignClient epmetUserFeignClient; - @Autowired private GovOrgFeignClient govOrgFeignClient; - @Autowired private OperCustomizeFeignClient operCustomizeFeignClient; + @Autowired + private EpmetThirdFeignClient epmetThirdFeignClient; + @Autowired + private GovOrgOpenFeignClient govOrgOpenFeignClient; @Override public PageData page(Map params) { @@ -394,4 +390,106 @@ public class CustomerServiceImpl extends BaseServiceImpl thirdResult = epmetThirdFeignClient.getCustomerAgencyUser(formDTO.getCustomerId()); + if (!thirdResult.success()) { + throw new RenException(thirdResult.getCode(), thirdResult.getInternalMsg()); + } + InitCustomerResultDTO initCustomer = thirdResult.getData(); + PaCustomerDTO paCustomer = initCustomer.getPaCustomer(); + PaCustomerAgencyDTO paAgency = initCustomer.getPaAgency(); + PaUserDTO paUser = initCustomer.getPaUser(); + + //2.校验当前客户是否已初始化,不存在则初始客户信息 + CustomerEntity entity = baseDao.selectById(formDTO.getCustomerId()); + if (null != entity) { + throw new RenException(EpmetErrorCode.OPER_CUSTOMER_EXISTS.getCode()); + } + //2-1.新增客户信息 + CustomerEntity customerEntity = new CustomerEntity(); + customerEntity.setId(formDTO.getCustomerId()); + customerEntity.setCustomerName(paCustomer.getCustomerName()); + customerEntity.setTitle(""); + customerEntity.setOrganizationNumber(""); + customerEntity.setOrganizationImg(""); + customerEntity.setValidityTime(getValidityTime()); + String level = "5"; + if("province".equals(paAgency.getLevel())){ + level = "0"; + }else if("city".equals(paAgency.getLevel())){ + level = "1"; + }else if("district".equals(paAgency.getLevel())){ + level = "2"; + }else if("street".equals(paAgency.getLevel())){ + level = "3"; + }else if("community".equals(paAgency.getLevel())){ + level = "4"; + } + customerEntity.setOrganizationLevel(level); + customerEntity.setLogo(""); + if (baseDao.insert(customerEntity) < NumConstant.ONE) { + throw new RenException(EpmetErrorCode.OPER_ADD_CUSTOMER_ERROR.getCode()); + } + + //3.调用epmet-user服务,初始化客户对应的角色;调用access服务给角色分配权限信息 + Result initResult = epmetUserFeignClient.initGovStaffRolesForCustomer(formDTO.getCustomerId()); + if (!initResult.success()) { + throw new RenException("客户新增:调用user服务为客户初始化角色数据失败:".concat(initResult.toString())); + } + + //4.调用oper-customize服务,初始化客户定制化首页模板数据 + CustomerHomeDTO initHomeForm = new CustomerHomeDTO(); + initHomeForm.setCustomerId(formDTO.getCustomerId()); + Result initHomeResult = operCustomizeFeignClient.init(initHomeForm); + if (!initHomeResult.success()) { + throw new RenException("初始化客户首页数据失败:".concat(initHomeResult.getInternalMsg())); + } + + //5.调用gov-org服务,初始化客户根级组织信息、客户管理员信息 + AddAgencyAndStaffFormDTO agencyAndStaff = new AddAgencyAndStaffFormDTO(); + //客户组织信息 + CustomerAgencyDTO agencyDTO = new CustomerAgencyDTO(); + agencyDTO.setId(paAgency.getId()); + agencyDTO.setCustomerId(formDTO.getCustomerId()); + agencyDTO.setOrganizationName(paAgency.getAgencyName()); + agencyDTO.setLevel(paAgency.getLevel()); + agencyDTO.setAreaCode(paAgency.getAreaCode()); + agencyDTO.setProvince(paAgency.getProvince()); + agencyDTO.setCity(paAgency.getCity()); + agencyDTO.setDistrict(paAgency.getDistrict()); + agencyAndStaff.setAgencyDTO(agencyDTO); + + //客户管理员信息 + AdminStaffFromDTO staffSubmitFrom = new AdminStaffFromDTO(); + staffSubmitFrom.setCustomerId(formDTO.getCustomerId()); + staffSubmitFrom.setAgencyId(paAgency.getId()); + staffSubmitFrom.setGender(Integer.parseInt(paUser.getGender())); + staffSubmitFrom.setMobile(paUser.getPhone()); + staffSubmitFrom.setName(paUser.getRealName()); + staffSubmitFrom.setWorkType(UserWorkType.FULL_TIME); + agencyAndStaff.setStaffDTO(staffSubmitFrom); + + Result agencyResult = govOrgOpenFeignClient.saveRootAgency(agencyAndStaff); + if (!agencyResult.success()) { + throw new RenException(agencyResult.getCode(), agencyResult.getInternalMsg()); + } + + //6.更新第三方数据库中客户数据状态为已初始化 + Result customerResult = epmetThirdFeignClient.updateCustomer(formDTO.getCustomerId()); + if (!customerResult.success()) { + throw new RenException(customerResult.getCode(), customerResult.getInternalMsg()); + } + + } + } diff --git a/epmet-module/oper-customize/oper-customize-client/src/main/java/com/epmet/feign/fallback/OperCustomizeOpenFeignClientFallback.java b/epmet-module/oper-customize/oper-customize-client/src/main/java/com/epmet/feign/fallback/OperCustomizeOpenFeignClientFallback.java index 7b912afc73..5c2271f1b3 100644 --- a/epmet-module/oper-customize/oper-customize-client/src/main/java/com/epmet/feign/fallback/OperCustomizeOpenFeignClientFallback.java +++ b/epmet-module/oper-customize/oper-customize-client/src/main/java/com/epmet/feign/fallback/OperCustomizeOpenFeignClientFallback.java @@ -11,4 +11,11 @@ import org.springframework.stereotype.Component; */ @Component public class OperCustomizeOpenFeignClientFallback implements OperCustomizeOpenFeignClient { + /** + * 从缓存中查询已登录用户的基本信息以及角色等相关信息 + * + * @return + */ + //@PostMapping(value = "/epmetuser/user/loginuserdetails", consumes = MediaType.APPLICATION_JSON_UTF8_VALUE) + //Result getLoginUserDetails(@RequestBody LoginUserDetailsFormDTO dto); } diff --git a/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/controller/CustomerFunctionController.java b/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/controller/CustomerFunctionController.java index 5af31e8e0b..7c2bbda050 100644 --- a/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/controller/CustomerFunctionController.java +++ b/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/controller/CustomerFunctionController.java @@ -34,6 +34,7 @@ import com.epmet.dto.CustomerFunctionDTO; import com.epmet.dto.form.CustomerFunctionListFormDTO; import com.epmet.dto.form.SaveCustomerFunctionFormDTO; import com.epmet.dto.result.CustomerFunctionListResultDTO; +import com.epmet.dto.result.DefaultFunctionListResultDTO; import com.epmet.excel.CustomerFunctionExcel; import com.epmet.service.CustomerFunctionService; import org.springframework.beans.factory.annotation.Autowired; @@ -126,4 +127,14 @@ public class CustomerFunctionController { customerFunctionService.saveCustomerFunction(formDTO); return new Result(); } + + /** + * desc:获取客户已开通功能列表 + * @param formDTO + * @return + */ + @PostMapping("customeropenedfunction") + public Result> customerOpenedFunction(@RequestBody CustomerFunctionListFormDTO formDTO) { + return new Result>().ok(customerFunctionService.customerOpenedFunction(formDTO)); + } } \ No newline at end of file diff --git a/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/CustomerFunctionService.java b/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/CustomerFunctionService.java index 91c1e3eb1b..17fcb2be66 100644 --- a/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/CustomerFunctionService.java +++ b/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/CustomerFunctionService.java @@ -23,6 +23,7 @@ import com.epmet.dto.CustomerFunctionDTO; import com.epmet.dto.form.CustomerFunctionListFormDTO; import com.epmet.dto.form.SaveCustomerFunctionFormDTO; import com.epmet.dto.result.CustomerFunctionListResultDTO; +import com.epmet.dto.result.DefaultFunctionListResultDTO; import com.epmet.entity.CustomerFunctionEntity; import java.util.List; @@ -111,4 +112,11 @@ public interface CustomerFunctionService extends BaseService customerOpenedFunction(CustomerFunctionListFormDTO formDTO); } \ No newline at end of file diff --git a/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/impl/CustomerFunctionServiceImpl.java b/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/impl/CustomerFunctionServiceImpl.java index deae7d7406..7c68f32ec1 100644 --- a/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/impl/CustomerFunctionServiceImpl.java +++ b/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/impl/CustomerFunctionServiceImpl.java @@ -210,4 +210,9 @@ public class CustomerFunctionServiceImpl extends BaseServiceImpl customerOpenedFunction(CustomerFunctionListFormDTO formDTO) { + return null; + } + } \ No newline at end of file diff --git a/epmet-module/resi-guide/resi-guide-client/src/main/java/com/epmet/dto/form/PublicCustomerGridListFormDTO.java b/epmet-module/resi-guide/resi-guide-client/src/main/java/com/epmet/dto/form/PublicCustomerGridListFormDTO.java new file mode 100644 index 0000000000..6e26721f28 --- /dev/null +++ b/epmet-module/resi-guide/resi-guide-client/src/main/java/com/epmet/dto/form/PublicCustomerGridListFormDTO.java @@ -0,0 +1,71 @@ +package com.epmet.dto.form; + +import com.epmet.commons.tools.validator.group.CustomerClientShowGroup; +import lombok.Data; + +import javax.validation.constraints.Min; +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + +/** + * @Description 单客户-陌生人搜索网格-接口入参 + * @Author sun + */ +@Data +public class PublicCustomerGridListFormDTO implements Serializable { + private static final long serialVersionUID = 1L; + + public interface AddUserInternalGroup { + } + + public interface AddUserShowGroup extends CustomerClientShowGroup { + } + + /** + * 小程序appId + * */ + @NotBlank(message = "小程序appId不能为空", groups = {AddUserShowGroup.class}) + private String appId; + /** + * 当前页 + * */ + @Min(value = 1) + private Integer pageNo; + + /** + * 每页数量 + * */ + private Integer pageSize = 20; + + /** + * 地区码 + * */ + private String areaCode; + + /** + * 选定地区编码 + * */ + private String selectedAreaCode; + + /** + * 是否首次位置授权(0:是 1:否) + */ + private Integer isAuthorized; + + /** + * 前端传递的省份 + * */ + @NotBlank(message = "省份信息不能为空") + private String province; + + /** + * 前端传递的城市 + * */ + @NotBlank(message = "城市信息不能为空") + private String city; + + /** + * 前端传递的地区 + * */ + private String area; +} diff --git a/epmet-module/resi-guide/resi-guide-server/pom.xml b/epmet-module/resi-guide/resi-guide-server/pom.xml index b973b88c1c..d93427f6b0 100644 --- a/epmet-module/resi-guide/resi-guide-server/pom.xml +++ b/epmet-module/resi-guide/resi-guide-server/pom.xml @@ -81,6 +81,12 @@ snakeyaml ${snakeyaml.version} + + com.epmet + epmet-third-client + 2.0.0 + compile + diff --git a/epmet-module/resi-guide/resi-guide-server/src/main/java/com/epmet/controller/StrangerResiGuideController.java b/epmet-module/resi-guide/resi-guide-server/src/main/java/com/epmet/controller/StrangerResiGuideController.java index 57ad839d42..dac2615943 100644 --- a/epmet-module/resi-guide/resi-guide-server/src/main/java/com/epmet/controller/StrangerResiGuideController.java +++ b/epmet-module/resi-guide/resi-guide-server/src/main/java/com/epmet/controller/StrangerResiGuideController.java @@ -22,10 +22,12 @@ import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.validator.ValidatorUtils; import com.epmet.dto.form.CustomerGridListFormDTO; +import com.epmet.dto.form.PublicCustomerGridListFormDTO; import com.epmet.dto.form.StrangerFormDTO; import com.epmet.dto.result.CustomerGridForStrangerResultDTO; import com.epmet.dto.result.HomeDesignByCustomerResultDTO; import com.epmet.dto.result.MarketContactInfoResultDTO; +import com.epmet.dto.result.PublicCustomerGridForStrangerResultDTO; import com.epmet.service.StrangerAccessRecordService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PostMapping; @@ -108,4 +110,26 @@ public class StrangerResiGuideController { return new Result().ok(dto); } + /** + * @param + * @Author sun + * @Description 单客户-陌生访客根据自动定位获取附近网格数据 + **/ + @PostMapping("publiclocationgridlist") + Result> publicLocationGridList(@RequestBody PublicCustomerGridListFormDTO formDTO){ + ValidatorUtils.validateEntity(formDTO); + return strangerAccessRecordService.thirdCustomerGridList(formDTO); + } + + /** + * @param + * @Author sun + * @Description 单客户-陌生访客手动选定位置获取附近网格数据 + **/ + @PostMapping("publiclelectcdgridlist") + Result> publicLelectcdGridList(@RequestBody PublicCustomerGridListFormDTO formDTO){ + ValidatorUtils.validateEntity(formDTO); + return strangerAccessRecordService.thirdCustomerGridList(formDTO); + } + } diff --git a/epmet-module/resi-guide/resi-guide-server/src/main/java/com/epmet/feign/GovOrgFeignClient.java b/epmet-module/resi-guide/resi-guide-server/src/main/java/com/epmet/feign/GovOrgFeignClient.java index 9295571e93..db9e83fe9d 100644 --- a/epmet-module/resi-guide/resi-guide-server/src/main/java/com/epmet/feign/GovOrgFeignClient.java +++ b/epmet-module/resi-guide/resi-guide-server/src/main/java/com/epmet/feign/GovOrgFeignClient.java @@ -4,7 +4,9 @@ package com.epmet.feign; import com.epmet.commons.tools.constant.ServiceConstant; import com.epmet.commons.tools.utils.Result; import com.epmet.dto.form.ListCustomerGridFormDTO; +import com.epmet.dto.form.ThirdCustomerGridListFormDTO; import com.epmet.dto.result.CustomerGridForStrangerResultDTO; +import com.epmet.dto.result.PublicCustomerGridForStrangerResultDTO; import com.epmet.feign.fallback.GovOrgFeignClientFallBack; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.web.bind.annotation.PostMapping; @@ -32,8 +34,13 @@ public interface GovOrgFeignClient { @PostMapping("/gov/org/customergrid/querygridlistbyareacode") Result> queryGridListByAreaCode(@RequestBody ListCustomerGridFormDTO listCustomerGridFormDTO); - - - + /** + * @return + * @Param + * @Author sun + * @Description 单客户-陌生人搜网格-根据地区编码查询客户下的网格列表 + **/ + @PostMapping("/gov/org/customergrid/querycustomergridlist") + Result> queryCustomerGridList(@RequestBody ThirdCustomerGridListFormDTO formDTO); } diff --git a/epmet-module/resi-guide/resi-guide-server/src/main/java/com/epmet/feign/fallback/GovOrgFeignClientFallBack.java b/epmet-module/resi-guide/resi-guide-server/src/main/java/com/epmet/feign/fallback/GovOrgFeignClientFallBack.java index f2370b8c32..589f7c944d 100644 --- a/epmet-module/resi-guide/resi-guide-server/src/main/java/com/epmet/feign/fallback/GovOrgFeignClientFallBack.java +++ b/epmet-module/resi-guide/resi-guide-server/src/main/java/com/epmet/feign/fallback/GovOrgFeignClientFallBack.java @@ -4,7 +4,9 @@ import com.epmet.commons.tools.constant.ServiceConstant; import com.epmet.commons.tools.utils.ModuleUtils; import com.epmet.commons.tools.utils.Result; import com.epmet.dto.form.ListCustomerGridFormDTO; +import com.epmet.dto.form.ThirdCustomerGridListFormDTO; import com.epmet.dto.result.CustomerGridForStrangerResultDTO; +import com.epmet.dto.result.PublicCustomerGridForStrangerResultDTO; import com.epmet.feign.GovOrgFeignClient; import org.springframework.stereotype.Component; @@ -29,4 +31,9 @@ public class GovOrgFeignClientFallBack implements GovOrgFeignClient { public Result> queryGridListByAreaCode(ListCustomerGridFormDTO listCustomerGridFormDTO) { return ModuleUtils.feignConError(ServiceConstant.GOV_ORG_SERVER, "queryGridListByAreaCode",listCustomerGridFormDTO); } + + @Override + public Result> queryCustomerGridList(ThirdCustomerGridListFormDTO formDTO) { + return ModuleUtils.feignConError(ServiceConstant.GOV_ORG_SERVER, "queryCustomerGridList",formDTO); + } } diff --git a/epmet-module/resi-guide/resi-guide-server/src/main/java/com/epmet/service/StrangerAccessRecordService.java b/epmet-module/resi-guide/resi-guide-server/src/main/java/com/epmet/service/StrangerAccessRecordService.java index 6e0479fa9f..9dbd10519d 100644 --- a/epmet-module/resi-guide/resi-guide-server/src/main/java/com/epmet/service/StrangerAccessRecordService.java +++ b/epmet-module/resi-guide/resi-guide-server/src/main/java/com/epmet/service/StrangerAccessRecordService.java @@ -6,9 +6,11 @@ import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.utils.Result; import com.epmet.dto.StrangerAccessRecordDTO; import com.epmet.dto.form.CustomerGridListFormDTO; +import com.epmet.dto.form.PublicCustomerGridListFormDTO; import com.epmet.dto.form.StrangerFormDTO; import com.epmet.dto.result.CustomerGridForStrangerResultDTO; import com.epmet.dto.result.HomeDesignByCustomerResultDTO; +import com.epmet.dto.result.PublicCustomerGridForStrangerResultDTO; import com.epmet.entity.StrangerAccessRecordEntity; import java.util.List; @@ -111,5 +113,11 @@ public interface StrangerAccessRecordService extends BaseService getGridHome(TokenDto tokenDTO, StrangerFormDTO formDTO); - + /** + * @return + * @Param + * @Author sun + * @Description 单客户-陌生人根据地区编码查询附近网格列表 + **/ + Result> thirdCustomerGridList(PublicCustomerGridListFormDTO formDTO); } diff --git a/epmet-module/resi-guide/resi-guide-server/src/main/java/com/epmet/service/impl/StrangerAccessRecordServiceImpl.java b/epmet-module/resi-guide/resi-guide-server/src/main/java/com/epmet/service/impl/StrangerAccessRecordServiceImpl.java index edc0784fa5..e1d44ec93a 100644 --- a/epmet-module/resi-guide/resi-guide-server/src/main/java/com/epmet/service/impl/StrangerAccessRecordServiceImpl.java +++ b/epmet-module/resi-guide/resi-guide-server/src/main/java/com/epmet/service/impl/StrangerAccessRecordServiceImpl.java @@ -14,19 +14,23 @@ import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.Result; import com.epmet.constant.StrangerResiGuideConstant; import com.epmet.dao.StrangerAccessRecordDao; +import com.epmet.dto.PaCustomerDTO; import com.epmet.dto.StrangerAccessRecordDTO; import com.epmet.dto.form.*; import com.epmet.dto.result.CustomerGridForStrangerResultDTO; import com.epmet.dto.result.HomeDesignByCustomerResultDTO; +import com.epmet.dto.result.PublicCustomerGridForStrangerResultDTO; +import com.epmet.dto.result.PublicCustomerResultDTO; import com.epmet.entity.StrangerAccessRecordEntity; +import com.epmet.feign.EpmetThirdFeignClient; import com.epmet.feign.EpmetUserFeignClient; import com.epmet.feign.GovOrgFeignClient; import com.epmet.feign.OperCustomizeFeignClient; import com.epmet.service.StrangerAccessRecordService; +import com.epmet.utils.ModuleConstant; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import com.epmet.utils.ModuleConstant; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -51,6 +55,8 @@ public class StrangerAccessRecordServiceImpl extends BaseServiceImpl> thirdCustomerGridList(PublicCustomerGridListFormDTO formDTO) { + + //0.调用epmet-third服务,根据appId查询客户信息 + Result result = epmetThirdFeignClient.getCustomerMsg(formDTO.getAppId()); + if(!result.success()){ + throw new RenException(result.getCode()); + } + PublicCustomerResultDTO resultDTO = result.getData(); + PaCustomerDTO customer = resultDTO.getCustomer(); + + ThirdCustomerGridListFormDTO third = new ThirdCustomerGridListFormDTO(); + third.setCustomerId(customer.getId()); + //1.参数设置 + //根据是自动定位还是手动定位获取地区编码值 + third.setAreaCode(ModuleConstant.NOT_POSITION_AUTHORIZED == formDTO.getIsAuthorized() ? + formDTO.getSelectedAreaCode() : formDTO.getAreaCode()); + //分页参数设置 + third.setPageNo(null == formDTO.getPageNo() ? ModuleConstant.MIN_CURRENT_PAGE_NO : formDTO.getPageNo()); + third.setPageSize(formDTO.getPageSize()); + + //2.调用gov-org服务,查询客户网格列表数据 + Result> queryResult = govOrgFeignClient.queryCustomerGridList(third); + if(!queryResult.success()){ + logger.error("调用gov_org服务查询指定地区客户下网格列表失败",queryResult.getCode(),queryResult.getMsg()); + return new Result>().error(queryResult.getCode(), queryResult.getMsg()); + } + List queryList = queryResult.getData(); + + //3.陌生人访问记录表新增数据 + if (null != queryResult && queryList.size() > NumConstant.ZERO) { + StrangerAccessRecordEntity strangerTrance = new StrangerAccessRecordEntity(); + //未授权,手动选择 + if (ModuleConstant.NOT_POSITION_AUTHORIZED == formDTO.getIsAuthorized()) { + strangerTrance.setSelectedAreaCode(formDTO.getSelectedAreaCode()); + } else if (ModuleConstant.POSITION_AUTHORIZED == formDTO.getIsAuthorized()) { + //已授权,自动选择 + strangerTrance.setLocationAreaCode(formDTO.getAreaCode()); + } + strangerTrance.setIsAuthorized(formDTO.getIsAuthorized()); + strangerTrance.setGridNumber(queryList.size()); + strangerTrance.setVisitTime(new Date()); + strangerTrance.setProvince(formDTO.getProvince()); + strangerTrance.setCity(formDTO.getCity()); + strangerTrance.setArea(formDTO.getArea()); + insert(strangerTrance); + + return new Result>().ok(queryList); + } else { + //没有查询出结果 + return new Result>().ok(new ArrayList<>()); + } + + } } diff --git a/epmet-module/resi-mine/resi-mine-client/src/main/java/com/epmet/resi/mine/dto/from/GenerateShortUserIdFormDTO.java b/epmet-module/resi-mine/resi-mine-client/src/main/java/com/epmet/resi/mine/dto/from/GenerateShortUserIdFormDTO.java new file mode 100644 index 0000000000..64fce64ec1 --- /dev/null +++ b/epmet-module/resi-mine/resi-mine-client/src/main/java/com/epmet/resi/mine/dto/from/GenerateShortUserIdFormDTO.java @@ -0,0 +1,25 @@ +package com.epmet.resi.mine.dto.from; + +import lombok.Data; + +import java.io.Serializable; + +/** + * @Description + * @ClassName MyResiUserInfoFormDTO + * @Auth wangc + * @Date 2020-05-22 17:27 + */ +@Data +public class GenerateShortUserIdFormDTO implements Serializable { + + /** + * 过期时间 单位秒 + */ + private Integer expires; + + /** + * 场景类型 + */ + private String bizType; +} diff --git a/epmet-module/resi-mine/resi-mine-client/src/main/java/com/epmet/resi/mine/dto/result/ShortUserIdInfoResultDTO.java b/epmet-module/resi-mine/resi-mine-client/src/main/java/com/epmet/resi/mine/dto/result/ShortUserIdInfoResultDTO.java new file mode 100644 index 0000000000..19f2a9235e --- /dev/null +++ b/epmet-module/resi-mine/resi-mine-client/src/main/java/com/epmet/resi/mine/dto/result/ShortUserIdInfoResultDTO.java @@ -0,0 +1,27 @@ +package com.epmet.resi.mine.dto.result; + +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + +/** + * desc: 生成用户短用户标识 result + * + * @date: 2020/7/22 10:50 + * @author: jianjun liu + */ +@Data +public class ShortUserIdInfoResultDTO implements Serializable { + + /** + * 12位用户标识 + */ + private String shortUserId; + /** + * 过期时间 + */ + private Date expiresTime; + + +} diff --git a/epmet-module/resi-mine/resi-mine-server/src/main/java/com/epmet/eums/GenerateShortUserIdBizTypeEnum.java b/epmet-module/resi-mine/resi-mine-server/src/main/java/com/epmet/eums/GenerateShortUserIdBizTypeEnum.java new file mode 100644 index 0000000000..170a11230c --- /dev/null +++ b/epmet-module/resi-mine/resi-mine-server/src/main/java/com/epmet/eums/GenerateShortUserIdBizTypeEnum.java @@ -0,0 +1,41 @@ +package com.epmet.eums; + +/** + * 生成用户唯一标识 枚举类 + * dev|test|prod + * + * @author jianjun liu + * @date 2020-07-03 11:14 + **/ +public enum GenerateShortUserIdBizTypeEnum { + POINT_EXCHANGE("pointExchange", "积分兑换") + ; + + private String code; + private String desc; + + + + GenerateShortUserIdBizTypeEnum(String code, String name) { + this.code = code; + this.desc = name; + } + + public static GenerateShortUserIdBizTypeEnum getEnum(String code) { + GenerateShortUserIdBizTypeEnum[] values = GenerateShortUserIdBizTypeEnum.values(); + for (GenerateShortUserIdBizTypeEnum value : values) { + if (code != null && value.getCode().equals(code)) { + return value; + } + } + return null; + } + + public String getCode() { + return code; + } + + public String getDesc() { + return desc; + } +} diff --git a/epmet-module/resi-mine/resi-mine-server/src/main/java/com/epmet/modules/mine/controller/MineController.java b/epmet-module/resi-mine/resi-mine-server/src/main/java/com/epmet/modules/mine/controller/MineController.java index 174126f074..dccec06857 100644 --- a/epmet-module/resi-mine/resi-mine-server/src/main/java/com/epmet/modules/mine/controller/MineController.java +++ b/epmet-module/resi-mine/resi-mine-server/src/main/java/com/epmet/modules/mine/controller/MineController.java @@ -1,43 +1,91 @@ package com.epmet.modules.mine.controller; +import com.alibaba.fastjson.JSON; import com.epmet.commons.tools.annotation.LoginUser; +import com.epmet.commons.tools.constant.NumConstant; +import com.epmet.commons.tools.exception.EpmetErrorCode; +import com.epmet.commons.tools.exception.RenException; +import com.epmet.commons.tools.redis.RedisKeys; +import com.epmet.commons.tools.redis.RedisUtils; import com.epmet.commons.tools.security.dto.TokenDto; +import com.epmet.commons.tools.utils.DateUtils; +import com.epmet.commons.tools.utils.Md5Util; import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.validator.ValidatorUtils; +import com.epmet.eums.GenerateShortUserIdBizTypeEnum; import com.epmet.modules.feign.EpmetUserFeignClient; +import com.epmet.resi.mine.dto.from.GenerateShortUserIdFormDTO; import com.epmet.resi.mine.dto.from.MyResiUserInfoFormDTO; import com.epmet.resi.mine.dto.result.MyResiUserInfoResultDTO; +import com.epmet.resi.mine.dto.result.ShortUserIdInfoResultDTO; +import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import java.util.Date; + /** * @Description * @ClassName MineController * @Auth wangc * @Date 2020-05-22 18:33 */ +@Slf4j @RestController @RequestMapping("mine") public class MineController { - @Autowired - EpmetUserFeignClient epmetUserFeignClient; + @Autowired + private EpmetUserFeignClient epmetUserFeignClient; + @Autowired + private RedisUtils redisUtils; + + /** + * @param myResiUserInfoFormDTO + * @return MyResiUserInfoResultDTO + * @Description 居民端获取我的信息 + * @author wangc + * @date 2020.05.22 18:37 + **/ + @PostMapping("profile") + Result getMyResiInfo(@LoginUser TokenDto tokenDto, @RequestBody MyResiUserInfoFormDTO myResiUserInfoFormDTO) { + myResiUserInfoFormDTO.setUserId(tokenDto.getUserId()); + ValidatorUtils.validateEntity(myResiUserInfoFormDTO); + return epmetUserFeignClient.resiMyselfMsg(myResiUserInfoFormDTO); + } - /** - * @Description 居民端获取我的信息 - * @param myResiUserInfoFormDTO - * @return MyResiUserInfoResultDTO - * @author wangc - * @date 2020.05.22 18:37 - **/ - @PostMapping("profile") - Result getMyResiInfo(@LoginUser TokenDto tokenDto, @RequestBody MyResiUserInfoFormDTO myResiUserInfoFormDTO){ - myResiUserInfoFormDTO.setUserId(tokenDto.getUserId()); - ValidatorUtils.validateEntity(myResiUserInfoFormDTO); - return epmetUserFeignClient.resiMyselfMsg(myResiUserInfoFormDTO); - } + /** + * desc:生成用户12位唯一标识 默认10分钟过期 + * + * @param tokenDto + * @param formDTO + * @return + */ + @PostMapping("generateshortuserid") + Result generateShortUserId(TokenDto tokenDto, @RequestBody GenerateShortUserIdFormDTO formDTO) { + String userId = tokenDto.getUserId(); + GenerateShortUserIdBizTypeEnum bizTypeEnum = GenerateShortUserIdBizTypeEnum.getEnum(formDTO.getBizType()); + if (bizTypeEnum == null) { + throw new RenException(EpmetErrorCode.INTERNAL_VALIDATE_ERROR.getMsg()); + } + String shortUserId = Md5Util.get12Char(bizTypeEnum.getCode().concat(userId)); + String redisKey = RedisKeys.getShortUserIdKey(shortUserId); + //过期时间 单位:秒 + int expires = formDTO.getExpires() == null ? NumConstant.TEN * NumConstant.SIXTY : formDTO.getExpires(); + if (redisUtils.hasKey(shortUserId)) { + redisUtils.expire(redisKey, expires); + } else { + redisUtils.setString(redisKey, userId, expires); + } + Date expiresDate = DateUtils.addDateSeconds(new Date(), expires); + ShortUserIdInfoResultDTO result = new ShortUserIdInfoResultDTO(); + result.setShortUserId(shortUserId); + result.setExpiresTime(expiresDate); + log.info("generateShortUserId success,result:{}", JSON.toJSONString(result)); + return new Result().ok(result); + } } diff --git a/epmet-module/resi-partymember/resi-partymember-client/src/main/java/com/epmet/resi/partymember/feign/ResiPartyMemberOpenFeignClient.java b/epmet-module/resi-partymember/resi-partymember-client/src/main/java/com/epmet/resi/partymember/feign/ResiPartyMemberOpenFeignClient.java index 5785bf4489..bd54ec1604 100644 --- a/epmet-module/resi-partymember/resi-partymember-client/src/main/java/com/epmet/resi/partymember/feign/ResiPartyMemberOpenFeignClient.java +++ b/epmet-module/resi-partymember/resi-partymember-client/src/main/java/com/epmet/resi/partymember/feign/ResiPartyMemberOpenFeignClient.java @@ -3,6 +3,7 @@ package com.epmet.resi.partymember.feign; import com.epmet.commons.tools.constant.ServiceConstant; import com.epmet.commons.tools.utils.Result; import com.epmet.resi.partymember.dto.partymember.PartymemberBaseInfoDTO; +import com.epmet.resi.partymember.dto.partymember.PartymemberInfoDTO; import com.epmet.resi.partymember.dto.partymember.form.DelPartyMemberBaseInfoFormDTO; import com.epmet.resi.partymember.dto.partymember.form.PartyMemberBaseInfoAddFormDTO; import com.epmet.resi.partymember.dto.partymember.result.PartyMemberBaseInfoDetailResultDTO; @@ -73,4 +74,14 @@ public interface ResiPartyMemberOpenFeignClient { **/ @PostMapping(value = "/resi/partymember/partymemberbaseinfo/delete", consumes = MediaType.APPLICATION_JSON_UTF8_VALUE) Result deltePartyMemberBaseInfo(@RequestBody DelPartyMemberBaseInfoFormDTO formDTO); + + /** + * @return com.epmet.commons.tools.utils.Result> + * @param userIdList + * @author yinzuomei + * @description 根据用户id查询认证通过的党员信息 + * @Date 2020/7/22 12:14 + **/ + @PostMapping(value = "/resi/partymember/partymemberinfo/queryPartymemberInfoByUserId", consumes = MediaType.APPLICATION_JSON_UTF8_VALUE) + Result> queryPartymemberInfoByUserId(@RequestBody List userIdList); } diff --git a/epmet-module/resi-partymember/resi-partymember-client/src/main/java/com/epmet/resi/partymember/feign/fallback/ResiPartyMemberOpenFeignClientFallback.java b/epmet-module/resi-partymember/resi-partymember-client/src/main/java/com/epmet/resi/partymember/feign/fallback/ResiPartyMemberOpenFeignClientFallback.java index 058af67dfa..df60a30abc 100644 --- a/epmet-module/resi-partymember/resi-partymember-client/src/main/java/com/epmet/resi/partymember/feign/fallback/ResiPartyMemberOpenFeignClientFallback.java +++ b/epmet-module/resi-partymember/resi-partymember-client/src/main/java/com/epmet/resi/partymember/feign/fallback/ResiPartyMemberOpenFeignClientFallback.java @@ -4,6 +4,7 @@ import com.epmet.commons.tools.constant.ServiceConstant; import com.epmet.commons.tools.utils.ModuleUtils; import com.epmet.commons.tools.utils.Result; import com.epmet.resi.partymember.dto.partymember.PartymemberBaseInfoDTO; +import com.epmet.resi.partymember.dto.partymember.PartymemberInfoDTO; import com.epmet.resi.partymember.dto.partymember.form.DelPartyMemberBaseInfoFormDTO; import com.epmet.resi.partymember.dto.partymember.form.PartyMemberBaseInfoAddFormDTO; import com.epmet.resi.partymember.dto.partymember.result.PartyMemberBaseInfoDetailResultDTO; @@ -46,4 +47,18 @@ public class ResiPartyMemberOpenFeignClientFallback implements ResiPartyMemberOp public Result deltePartyMemberBaseInfo(DelPartyMemberBaseInfoFormDTO formDTO) { return ModuleUtils.feignConError(ServiceConstant.RESI_PARTYMEMBER_SERVER, "deltePartyMemberBaseInfo", formDTO); } + + /** + * @param userIdList + * @return com.epmet.commons.tools.utils.Result> + * @author yinzuomei + * @description 根据用户id查询认证通过的党员信息 + * @Date 2020/7/22 12:14 + **/ + @Override + public Result> queryPartymemberInfoByUserId(List userIdList) { + return ModuleUtils.feignConError(ServiceConstant.RESI_PARTYMEMBER_SERVER, "queryPartymemberInfoByUserId", userIdList); + } + + } diff --git a/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/controller/PartymemberInfoController.java b/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/controller/PartymemberInfoController.java index ab98cf565a..89b9d7c135 100644 --- a/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/controller/PartymemberInfoController.java +++ b/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/controller/PartymemberInfoController.java @@ -132,4 +132,16 @@ public class PartymemberInfoController { return new Result>().ok(list); } + /** + * @return com.epmet.commons.tools.utils.Result + * @param userIdList + * @author yinzuomei + * @description 根据用户id查询认证通过的党员信息 + * @Date 2020/7/22 12:18 + **/ + @PostMapping(value = "queryPartymemberInfoByUserId") + Result> queryPartymemberInfoByUserId(@RequestBody List userIdList) { + List list = partymemberInfoService.queryPartymemberInfoByUserId(userIdList); + return new Result>().ok(list); + } } \ No newline at end of file diff --git a/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/dao/PartymemberInfoDao.java b/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/dao/PartymemberInfoDao.java index a66092f216..53854d8253 100644 --- a/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/dao/PartymemberInfoDao.java +++ b/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/dao/PartymemberInfoDao.java @@ -67,4 +67,12 @@ public interface PartymemberInfoDao extends BaseDao { */ CertifiedDetailResultDTO certifiedDetail(CertifiedDetailFormDTO formDTO); + /** + * @return com.epmet.resi.partymember.dto.partymember.PartymemberInfoDTO + * @param userId + * @author yinzuomei + * @description 根据用户id查询认证通过的党员信息,此sql用来初始化user_base_info用 + * @Date 2020/7/22 12:19 + **/ + PartymemberInfoDTO queryPartymemberInfoByUserId(String userId); } \ No newline at end of file diff --git a/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/service/PartymemberInfoService.java b/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/service/PartymemberInfoService.java index 0fe2142c08..b8b0b39694 100644 --- a/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/service/PartymemberInfoService.java +++ b/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/service/PartymemberInfoService.java @@ -19,7 +19,6 @@ package com.epmet.modules.partymember.service; import com.epmet.commons.mybatis.service.BaseService; import com.epmet.commons.tools.page.PageData; -import com.epmet.commons.tools.utils.Result; import com.epmet.dto.result.CertifiedResultDTO; import com.epmet.modules.partymember.entity.PartymemberInfoEntity; import com.epmet.resi.partymember.dto.partymember.PartymemberInfoDTO; @@ -27,7 +26,6 @@ import com.epmet.resi.partymember.dto.partymember.form.CertifiedDetailFormDTO; import com.epmet.resi.partymember.dto.partymember.form.CertifiedFormDTO; import com.epmet.resi.partymember.dto.partymember.result.CertifiedDetailResultDTO; import com.epmet.resi.partymember.dto.partymember.result.PartyAuthProcessingCountResultDTO; -import org.springframework.web.bind.annotation.RequestBody; import java.util.List; import java.util.Map; @@ -146,4 +144,13 @@ public interface PartymemberInfoService extends BaseService queryPartyMemberProcessingCount(List gridIdList); + + /** + * @return com.epmet.resi.partymember.dto.partymember.PartymemberInfoDTO + * @param userIdList + * @author yinzuomei + * @description 根据用户id查询认证通过的党员信息 + * @Date 2020/7/22 12:18 + **/ + List queryPartymemberInfoByUserId(List userIdList); } \ No newline at end of file diff --git a/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/service/impl/PartymemberInfoServiceImpl.java b/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/service/impl/PartymemberInfoServiceImpl.java index 4803ebef14..0aea73c30b 100644 --- a/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/service/impl/PartymemberInfoServiceImpl.java +++ b/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/service/impl/PartymemberInfoServiceImpl.java @@ -219,5 +219,27 @@ public class PartymemberInfoServiceImpl extends BaseServiceImpl queryPartymemberInfoByUserId(List userIdList) { + if(null==userIdList||userIdList.size()<1){ + return new ArrayList<>(); + } + List list=new ArrayList<>(); + for(String userId:userIdList){ + PartymemberInfoDTO partymemberInfoDTO=baseDao.queryPartymemberInfoByUserId(userId); + if(null!=partymemberInfoDTO){ + list.add(partymemberInfoDTO); + } + } + return list; + } + } \ No newline at end of file diff --git a/epmet-module/resi-partymember/resi-partymember-server/src/main/resources/mapper/partymember/PartymemberInfoDao.xml b/epmet-module/resi-partymember/resi-partymember-server/src/main/resources/mapper/partymember/PartymemberInfoDao.xml index 61b7a60c9e..35447099f8 100644 --- a/epmet-module/resi-partymember/resi-partymember-server/src/main/resources/mapper/partymember/PartymemberInfoDao.xml +++ b/epmet-module/resi-partymember/resi-partymember-server/src/main/resources/mapper/partymember/PartymemberInfoDao.xml @@ -103,4 +103,17 @@ AND pi.confirm_result IN ( 'auto_confirm_success', 'approved' ) + + \ No newline at end of file diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/UserBaseInfoDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/UserBaseInfoDTO.java index 1ac6a85c85..1530f1f3c9 100644 --- a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/UserBaseInfoDTO.java +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/UserBaseInfoDTO.java @@ -17,9 +17,10 @@ package com.epmet.dto; +import lombok.Data; + import java.io.Serializable; import java.util.Date; -import lombok.Data; /** @@ -54,10 +55,15 @@ public class UserBaseInfoDTO implements Serializable { private String surname; /** - * 名称 + * 名 */ private String name; + /** + * 姓名 + */ + private String realName; + /** * 身份证号 */ diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/UserWechatDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/UserWechatDTO.java index 5f6685c0d6..0a62b41a07 100644 --- a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/UserWechatDTO.java +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/UserWechatDTO.java @@ -1,5 +1,7 @@ package com.epmet.dto; +import com.fasterxml.jackson.annotation.JacksonInject; +import com.fasterxml.jackson.annotation.JsonIgnore; import lombok.Data; import java.io.Serializable; @@ -105,4 +107,7 @@ public class UserWechatDTO implements Serializable{ * 更新时间 */ private Date updatedTime; + + @JsonIgnore + private String sessionKey; } diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/WxUserFormDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/WxUserFormDTO.java new file mode 100644 index 0000000000..48d2ca307c --- /dev/null +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/WxUserFormDTO.java @@ -0,0 +1,26 @@ +package com.epmet.dto.form; + +import com.epmet.dto.UserWechatDTO; +import lombok.Data; + +import java.io.Serializable; + +/** + * @Description 小程序陌生人登陆,新增或更新用户信息-接口入参 + * @Author sun + */ +@Data +public class WxUserFormDTO implements Serializable{ + private static final long serialVersionUID = -7994579456530273809L; + + /** + * 微信用户基本信息 + */ + private UserWechatDTO wechatDTO; + + /** + * 政府端:gov、居民端:resi、运营端:oper + */ + private String app; + +} diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/UserBaseInfoResultDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/UserBaseInfoResultDTO.java new file mode 100644 index 0000000000..19ece1b40f --- /dev/null +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/UserBaseInfoResultDTO.java @@ -0,0 +1,80 @@ +package com.epmet.dto.result; + +import lombok.Data; + +import java.io.Serializable; + +/** + * 用户基本信息-居民录入的基本信息 + * + * @author yinzuomei@elink-cn.com + * @date 2020/7/22 9:26 + */ +@Data +public class UserBaseInfoResultDTO implements Serializable { + private static final long serialVersionUID = 3124057264557384333L; + /** + * 用户id + */ + private String userId; + + /** + * 手机号(注册手机号) + */ + private String mobile; + + /** + * 姓氏 + */ + private String surname; + + /** + * 名 + */ + private String name; + + /** + * 姓名 + */ + private String realName; + + /** + * 身份证号 + */ + private String idNum; + + /** + * 性别(1男2女0未知) + */ + private String gender; + + /** + * 街道 + */ + private String street; + + /** + * 小区名称 + */ + private String district; + + /** + * 楼栋单元 + */ + private String buildingAddress; + + /** + * 昵称(目前来源于微信昵称,后续系统可支持用户有昵称) + */ + private String nickname; + + /** + * 头像(目前来源于微信,后续系统顾客支持上传头像) + */ + private String headImgUrl; + + /** + * 微信基本信息 + */ + private UserWechatResultDTO userWechatResultDTO; +} diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/UserWechatResultDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/UserWechatResultDTO.java new file mode 100644 index 0000000000..e7a9886d41 --- /dev/null +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/UserWechatResultDTO.java @@ -0,0 +1,71 @@ +package com.epmet.dto.result; + +import lombok.Data; + +import java.io.Serializable; + +/** + * 用户基本信息-微信信息 + * + * @author yinzuomei@elink-cn.com + * @date 2020/7/22 9:27 + */ +@Data +public class UserWechatResultDTO implements Serializable { + private static final long serialVersionUID = 5770079291635923923L; + + /** + * 用户ID + * */ + private String userId; + + /** + * 微信openId + */ + private String wxOpenId; + + /** + * 微信unionId + */ + private String unionId; + + /** + * 手机号 + */ + private String mobile; + + /** + * 昵称 + */ + private String nickname; + + /** + * 性别:0.未知 1.男性2女性 + */ + private Integer sex; + + /** + * 头像 + */ + private String headImgUrl; + + /** + * 国家 + */ + private String country; + + /** + * 省份 + */ + private String province; + + /** + * 城市 + */ + private String city; + + /** + * 语言 + */ + private String language; +} 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 0faea1fb73..8a4de9898e 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 @@ -3,11 +3,14 @@ package com.epmet.feign; import com.epmet.commons.tools.constant.ServiceConstant; import com.epmet.commons.tools.utils.Result; import com.epmet.dto.CustomerStaffDTO; +import com.epmet.dto.GovStaffRoleDTO; +import com.epmet.dto.UserDTO; import com.epmet.dto.form.*; import com.epmet.dto.result.*; import com.epmet.feign.fallback.EpmetUserOpenFeignClientFallback; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.http.MediaType; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; @@ -86,4 +89,63 @@ public interface EpmetUserOpenFeignClient { **/ @PostMapping(value = "/epmetuser/customerstaff/resetstaffpassword", consumes = MediaType.APPLICATION_JSON_UTF8_VALUE) Result resetStaffPassword(@RequestBody StaffResetPwFormDTO staffResetPwFormDTO); + + /** + * 根据客户ID和角色key查询角色信息 + * @param form + * @return + */ + @PostMapping("/epmetuser/staffrole/roleofcustomer") + Result getRoleOfCustomer(@RequestBody CustomerRoleFormDTO form); + + /** + * 小程序登陆新增或更新微信用户信息 + * @author sun + */ + @PostMapping(value = "epmetuser/user/savewxuser") + Result saveWxUser(@RequestBody WxUserFormDTO wxUserFormDTO); + + /** + * @param openId + * @return com.epmet.commons.tools.utils.Result + * @Author sun + * @Description 获取当前微信上次登录的账号信息 + **/ + @GetMapping(value = "epmetuser/staffagencyvisited/getlatest/{openId}") + Result getLatestStaffWechatLoginRecord(@PathVariable("openId") String openId); + + /** + * @param staffWechatFormDTO + * @return com.epmet.commons.tools.utils.Result + * @Author sun + * @Description 手机验证码登录时记录微信openId与当前用户的关系 + **/ + @PostMapping(value = "epmetuser/staffwechat/savestaffwechat", consumes = MediaType.APPLICATION_JSON_VALUE) + Result saveStaffWechat(@RequestBody StaffWechatFormDTO staffWechatFormDTO); + + /** + * @param staffLoginHistoryFormDTO + * @return com.epmet.commons.tools.utils.Result + * @Author sun + * @Description 保存登录日志 + **/ + @PostMapping(value = "epmetuser/staffagencyvisited/saveStaffLoginRecord", consumes = MediaType.APPLICATION_JSON_VALUE) + Result saveStaffLoginRecord(StaffLoginAgencyRecordFormDTO staffLoginHistoryFormDTO); + + /** + * @Author sun + * @Description 保存登录日志 + */ + @PostMapping("/epmetuser/staffrole/staffroles") + Result> getRolesOfStaff(StaffRoleFormDTO staffRoleFormDTO); + + /** + * @param userIdList + * @return com.epmet.commons.tools.utils.Result> + * @author yinzuomei + * @description 传入用户id集合,返回用户的基本信息(包含微信基本信息) + * @Date 2020/7/22 9:30 + **/ + @PostMapping("/epmetuser/userbaseinfo/queryuserbaseinfo") + Result> queryUserBaseInfo(@RequestBody List userIdList); } 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 ec9cac1b00..bb2cbe9d77 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 @@ -4,6 +4,8 @@ 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.CustomerStaffDTO; +import com.epmet.dto.GovStaffRoleDTO; +import com.epmet.dto.UserDTO; import com.epmet.dto.form.*; import com.epmet.dto.result.*; import com.epmet.feign.EpmetUserOpenFeignClient; @@ -55,4 +57,45 @@ public class EpmetUserOpenFeignClientFallback implements EpmetUserOpenFeignClien return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "resetStaffPassword", staffResetPwFormDTO); } + @Override + public Result getRoleOfCustomer(CustomerRoleFormDTO form) { + return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "getRoleOfCustomer", form); + } + + @Override + public Result saveWxUser(WxUserFormDTO wxUserFormDTO) { + return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "saveWxUser", wxUserFormDTO); + } + + @Override + public Result getLatestStaffWechatLoginRecord(String openId) { + return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "getLatestStaffWechatLoginRecord", openId); + } + + @Override + public Result saveStaffWechat(StaffWechatFormDTO staffWechatFormDTO) { + return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "saveStaffWechat", staffWechatFormDTO); + } + + @Override + public Result saveStaffLoginRecord(StaffLoginAgencyRecordFormDTO staffLoginHistoryFormDTO) { + return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "saveStaffLoginRecord", staffLoginHistoryFormDTO); + } + + @Override + public Result> getRolesOfStaff(StaffRoleFormDTO staffRoleFormDTO) { + return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "getRolesOfStaff", staffRoleFormDTO); + } + + /** + * @param userIdList + * @return com.epmet.commons.tools.utils.Result> + * @author yinzuomei + * @description 传入用户id集合,返回用户的基本信息(包含微信基本信息) + * @Date 2020/7/22 9:30 + **/ + @Override + public Result> queryUserBaseInfo(List userIdList) { + return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "queryUserBaseInfo", userIdList); + } } 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 171760d417..88d224e76e 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.75 + image: 192.168.1.130:10080/epmet-cloud-dev/epmet-user-server:0.3.76 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 0a4438531d..2c3f938f56 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.75 + 0.3.76 com.epmet epmet-user diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/constant/UserConstant.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/constant/UserConstant.java index 16fb79e8fd..a82038d368 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/constant/UserConstant.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/constant/UserConstant.java @@ -67,4 +67,17 @@ public interface UserConstant { * inactive未激活,active已激活 */ String ACTIVE="active"; + + /** + * user表新增数据失败 + */ + String SAVE_USER = "新增用户信息失败"; + /** + * user_wechat表新增数据失败 + */ + String SAVE_USER_WECHAT = "新增用户微信信息失败"; + /** + * user_wechat表更新数据失败 + */ + String UPDATE_USER_WECHAT = "更新用户微信信息失败"; } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/UserBaseInfoController.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/UserBaseInfoController.java index 44204aa99a..046bc0f071 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/UserBaseInfoController.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/UserBaseInfoController.java @@ -23,9 +23,10 @@ import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.validator.AssertUtils; import com.epmet.commons.tools.validator.ValidatorUtils; import com.epmet.commons.tools.validator.group.AddGroup; -import com.epmet.commons.tools.validator.group.UpdateGroup; import com.epmet.commons.tools.validator.group.DefaultGroup; +import com.epmet.commons.tools.validator.group.UpdateGroup; import com.epmet.dto.UserBaseInfoDTO; +import com.epmet.dto.result.UserBaseInfoResultDTO; import com.epmet.excel.UserBaseInfoExcel; import com.epmet.service.UserBaseInfoService; import org.springframework.beans.factory.annotation.Autowired; @@ -91,4 +92,29 @@ public class UserBaseInfoController { ExcelUtils.exportExcelToTarget(response, null, list, UserBaseInfoExcel.class); } + /** + * @param userIdList + * @return com.epmet.commons.tools.utils.Result> + * @author yinzuomei + * @description 传入用户id集合,返回用户的基本信息(包含微信基本信息) + * @Date 2020/7/22 9:34 + **/ + @PostMapping("queryuserbaseinfo") + public Result> queryUserBaseInfo(@RequestBody List userIdList) { + List list = userBaseInfoService.queryUserBaseInfo(userIdList); + return new Result>().ok(list); + } + + /** + * @return com.epmet.commons.tools.utils.Result + * @param + * @author yinzuomei + * @description 初始化历史用户信息到user_base_info数据 + * @Date 2020/7/22 10:42 + **/ + @PostMapping("initbaseinfo") + public Result initBaseInfo(){ + userBaseInfoService.initBaseInfo(); + return new Result(); + } } \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/UserController.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/UserController.java index a02a38b24a..9c0f40c8ef 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/UserController.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/UserController.java @@ -122,4 +122,14 @@ public class UserController { return new Result().ok(govTokenDto); } + /** + * @param formDTO + * @Author sun + * @Description 小程序微信用户登陆,新增或更新用户信息 + **/ + @PostMapping("savewxuser") + public Result saveWxUser(@RequestBody WxUserFormDTO formDTO){ + return new Result().ok(userService.saveWxUser(formDTO)); + } + } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/UserBaseInfoDao.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/UserBaseInfoDao.java index 02397056e8..f5ca5fc3aa 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/UserBaseInfoDao.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/UserBaseInfoDao.java @@ -18,6 +18,8 @@ package com.epmet.dao; import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.dto.result.UserBaseInfoResultDTO; +import com.epmet.dto.result.UserWechatResultDTO; import com.epmet.entity.UserBaseInfoEntity; import org.apache.ibatis.annotations.Mapper; @@ -29,5 +31,22 @@ import org.apache.ibatis.annotations.Mapper; */ @Mapper public interface UserBaseInfoDao extends BaseDao { - + + /** + * @return com.epmet.dto.result.UserBaseInfoResultDTO + * @param userId + * @author yinzuomei + * @description 根据用户id查询user_base_info基本信息 + * @Date 2020/7/22 9:46 + **/ + UserBaseInfoResultDTO selectListByUserIdList(String userId); + + /** + * @return com.epmet.dto.result.UserWechatResultDTO + * @param userId + * @author yinzuomei + * @description 根据用户id获取user_wechat表微信用户基本信息 + * @Date 2020/7/22 9:46 + **/ + UserWechatResultDTO selectUserWechatByUserId(String userId); } \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/UserResiInfoDao.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/UserResiInfoDao.java index a47f215bdc..acb1ce5ab2 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/UserResiInfoDao.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/UserResiInfoDao.java @@ -78,4 +78,13 @@ public interface UserResiInfoDao extends BaseDao { * @date 2020/5/11 11:18 */ IssueInitiatorResultDTO selectIssueInitiator(IssueInitiatorFormDTO formDTO); + + /** + * @return com.epmet.dto.UserResiInfoDTO + * @param userId + * @author yinzuomei + * @description 根据要用户id,查询用户注册的信息 + * @Date 2020/7/22 10:58 + **/ + UserResiInfoDTO selectByUserId(String userId); } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/UserWechatDao.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/UserWechatDao.java index 6d03a46a9c..fc00b799bf 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/UserWechatDao.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/UserWechatDao.java @@ -55,4 +55,13 @@ public interface UserWechatDao extends BaseDao{ * @CreatedTime 2020/4/26 18:53 */ List selectUserHeadPhotoByUserId(List certifiedResultDTOS); + + /** + * @return com.epmet.entity.UserWechatEntity + * @param + * @author yinzuomei + * @description 查询已经授权的微信用户信息 + * @Date 2020/7/22 10:46 + **/ + List selectAll(); } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/entity/UserBaseInfoEntity.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/entity/UserBaseInfoEntity.java index e6e5d1dcae..882aaeb243 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/entity/UserBaseInfoEntity.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/entity/UserBaseInfoEntity.java @@ -18,13 +18,10 @@ package com.epmet.entity; import com.baomidou.mybatisplus.annotation.TableName; - import com.epmet.commons.mybatis.entity.BaseEpmetEntity; import lombok.Data; import lombok.EqualsAndHashCode; -import java.util.Date; - /** * 用户基础信息 * @@ -63,6 +60,11 @@ public class UserBaseInfoEntity extends BaseEpmetEntity { */ private String name; + /** + * 姓名 + */ + private String realName; + /** * 身份证号 */ diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/UserBaseInfoService.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/UserBaseInfoService.java index ab1ca9d0e8..d4c13a7c1c 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/UserBaseInfoService.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/UserBaseInfoService.java @@ -20,6 +20,7 @@ package com.epmet.service; import com.epmet.commons.mybatis.service.BaseService; import com.epmet.commons.tools.page.PageData; import com.epmet.dto.UserBaseInfoDTO; +import com.epmet.dto.result.UserBaseInfoResultDTO; import com.epmet.entity.UserBaseInfoEntity; import java.util.List; @@ -92,4 +93,22 @@ public interface UserBaseInfoService extends BaseService { * @date 2020-07-19 */ void delete(String[] ids); + + /** + * @return java.util.List + * @param userIdList + * @author yinzuomei + * @description 传入用户id集合,返回用户的基本信息(包含微信基本信息) + * @Date 2020/7/22 9:35 + **/ + List queryUserBaseInfo(List userIdList); + + /** + * @return void + * @param + * @author yinzuomei + * @description 初始化历史用户信息到user_base_info数据 + * @Date 2020/7/22 10:42 + **/ + void initBaseInfo(); } \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/UserService.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/UserService.java index 1df8d94607..e65ced810c 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/UserService.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/UserService.java @@ -76,4 +76,11 @@ public interface UserService extends BaseService { * @return */ LoginUserDetailsResultDTO getLoginUserDetails(String app, String client, String staffId); + + /** + * @param formDTO + * @Author sun + * @Description 小程序微信用户登陆,新增或更新用户信息 + **/ + UserDTO saveWxUser(WxUserFormDTO formDTO); } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/UserBaseInfoServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/UserBaseInfoServiceImpl.java index 17756b8c46..ea1abcfa50 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/UserBaseInfoServiceImpl.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/UserBaseInfoServiceImpl.java @@ -20,19 +20,30 @@ 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.page.PageData; import com.epmet.commons.tools.utils.ConvertUtils; -import com.epmet.commons.tools.constant.FieldConstant; +import com.epmet.commons.tools.utils.Result; import com.epmet.dao.UserBaseInfoDao; +import com.epmet.dao.UserResiInfoDao; +import com.epmet.dao.UserWechatDao; import com.epmet.dto.UserBaseInfoDTO; +import com.epmet.dto.UserResiInfoDTO; +import com.epmet.dto.UserWechatDTO; +import com.epmet.dto.result.UserBaseInfoResultDTO; +import com.epmet.dto.result.UserWechatResultDTO; import com.epmet.entity.UserBaseInfoEntity; import com.epmet.redis.UserBaseInfoRedis; +import com.epmet.resi.partymember.dto.partymember.PartymemberInfoDTO; +import com.epmet.resi.partymember.feign.ResiPartyMemberOpenFeignClient; import com.epmet.service.UserBaseInfoService; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Map; @@ -48,6 +59,12 @@ public class UserBaseInfoServiceImpl extends BaseServiceImpl page(Map params) { @@ -101,4 +118,75 @@ public class UserBaseInfoServiceImpl extends BaseServiceImpl + * @author yinzuomei + * @description 传入用户id集合,返回用户的基本信息(包含微信基本信息) + * @Date 2020/7/22 9:35 + **/ + @Override + public List queryUserBaseInfo(List userIdList) { + if(null==userIdList||userIdList.size()<1){ + return new ArrayList<>(); + } + List userBaseInfoList=new ArrayList<>(); + for(String userId:userIdList){ + UserBaseInfoResultDTO userBaseInfoResultDTO=baseDao.selectListByUserIdList(userId); + if(null!=userBaseInfoResultDTO){ + UserWechatResultDTO userWechatResultDTO=baseDao.selectUserWechatByUserId(userId); + userBaseInfoResultDTO.setUserWechatResultDTO(userWechatResultDTO); + userBaseInfoList.add(userBaseInfoResultDTO); + } + } + return userBaseInfoList; + } + + /** + * @return void + * @author yinzuomei + * @description 初始化历史用户信息到user_base_info数据 + * @Date 2020/7/22 10:42 + **/ + @Override + public void initBaseInfo() { + List userWechatDTOList=userWechatDao.selectAll(); + List userIdList=new ArrayList<>(); + for(UserWechatDTO userWechatDTO:userWechatDTOList){ + userIdList.add(userWechatDTO.getUserId()); + } + Result> partymemberInfoDTOResult=resiPartyMemberOpenFeignClient.queryPartymemberInfoByUserId(userIdList); + List list=new ArrayList<>(); + if(partymemberInfoDTOResult.success()&&null!=partymemberInfoDTOResult.getData()&&partymemberInfoDTOResult.getData().size()>0){ + list=partymemberInfoDTOResult.getData(); + } + for(UserWechatDTO userWechatDTO:userWechatDTOList){ + UserResiInfoDTO userResiInfoDTO=userResiInfoDao.selectByUserId(userWechatDTO.getUserId()); + UserBaseInfoEntity userBaseInfoEntity=new UserBaseInfoEntity(); + + userBaseInfoEntity.setUserId(userResiInfoDTO.getUserId()); + userBaseInfoEntity.setMobile(userResiInfoDTO.getRegMobile()); + userBaseInfoEntity.setSurname(userResiInfoDTO.getSurname()); + userBaseInfoEntity.setName(userResiInfoDTO.getName()); + userBaseInfoEntity.setRealName(userResiInfoDTO.getSurname()+userResiInfoDTO.getName()); + userBaseInfoEntity.setIdNum(NumConstant.EMPTY_STR); + //查询党员信息 + for(PartymemberInfoDTO partymemberInfo:list){ + if(userBaseInfoEntity.getUserId().equals(partymemberInfo.getUserId())){ + userBaseInfoEntity.setIdNum(partymemberInfo.getIdCard()); + break; + } + } + userBaseInfoEntity.setGender(userWechatDTO.getSex().toString()); + userBaseInfoEntity.setStreet(userResiInfoDTO.getStreet()); + userBaseInfoEntity.setDistrict(userResiInfoDTO.getDistrict()); + userBaseInfoEntity.setBuildingAddress(userResiInfoDTO.getBuildingAddress()); + userBaseInfoEntity.setNickname(userWechatDTO.getNickname()); + userBaseInfoEntity.setHeadImgUrl(userWechatDTO.getHeadImgUrl()); + baseDao.insert(userBaseInfoEntity); + } + return; + } + + } \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/UserServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/UserServiceImpl.java index 621259be47..b6d3a63965 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/UserServiceImpl.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/UserServiceImpl.java @@ -1,6 +1,8 @@ package com.epmet.service.impl; import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; +import com.epmet.commons.tools.constant.NumConstant; +import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.CpUserDetailRedis; import com.epmet.commons.tools.utils.Result; @@ -24,11 +26,9 @@ import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; - import java.util.Date; - /** * @Description * @ClassName UserServiceImpl @@ -182,4 +182,55 @@ public class UserServiceImpl extends BaseServiceImpl implem public LoginUserDetailsResultDTO getLoginUserDetails(String app, String client, String userId) { return cpUserDetailRedis.get(app, client, userId, LoginUserDetailsResultDTO.class); } + + /** + * @param formDTO + * @Author sun + * @Description 小程序微信用户登陆,新增或更新用户信息 + **/ + @Override + public UserDTO saveWxUser(WxUserFormDTO formDTO) { + UserDTO resultDTO = new UserDTO(); + UserWechatDTO wechatDTO = formDTO.getWechatDTO(); + //1.校验用户是否已存在 + WxLoginUserInfoFormDTO dto = new WxLoginUserInfoFormDTO(); + dto.setApp(formDTO.getApp()); + dto.setOpenId(wechatDTO.getWxOpenId()); + UserDTO userDTO = userWechatDao.selectUserDTOByOpenId(dto); + + UserWechatEntity userWechatEntity = ConvertUtils.sourceToTarget(wechatDTO, UserWechatEntity.class); + if ("".equals(userWechatEntity.getUnionId())) { + userWechatEntity.setUnionId(null); + } + //2.不存在则新增,存在则更新 + if (null == userDTO || null == userDTO.getId()) { + //user表新增 + UserEntity userEntity = new UserEntity(); + userEntity.setFromApp(UserConstant.APP_RESI); + userEntity.setFromClient(UserConstant.CLIENT_WX); + if (baseDao.insert(userEntity) < NumConstant.ONE) { + log.error("小程序登陆,居民端user表新增数据失败"); + throw new RenException(UserConstant.SAVE_USER); + } + //user_wechat表新增 + userWechatEntity.setUserId(userEntity.getId()); + if (userWechatDao.insert(userWechatEntity) < NumConstant.ONE) { + log.error("小程序登陆,居民端user_wechat表新增数据失败"); + throw new RenException(UserConstant.SAVE_USER_WECHAT); + } + resultDTO.setId(userEntity.getId()); + } else { + wechatDTO.setUserId(userDTO.getId()); + wechatDTO.setUpdatedBy(userDTO.getId()); + wechatDTO.setUpdatedTime(new Date()); + if (userWechatDao.updateByUserId(wechatDTO) < NumConstant.ONE) { + log.error("小程序登陆,居民端user_wechat表更新数据失败"); + throw new RenException(UserConstant.UPDATE_USER_WECHAT); + } + resultDTO.setId(userDTO.getId()); + } + + return resultDTO; + } + } diff --git a/epmet-user/epmet-user-server/src/main/resources/mapper/UserBaseInfoDao.xml b/epmet-user/epmet-user-server/src/main/resources/mapper/UserBaseInfoDao.xml index 87f3520461..3733452b77 100644 --- a/epmet-user/epmet-user-server/src/main/resources/mapper/UserBaseInfoDao.xml +++ b/epmet-user/epmet-user-server/src/main/resources/mapper/UserBaseInfoDao.xml @@ -24,5 +24,46 @@ + + + + \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/resources/mapper/UserResiInfoDao.xml b/epmet-user/epmet-user-server/src/main/resources/mapper/UserResiInfoDao.xml index a95fc89291..724d49a68b 100644 --- a/epmet-user/epmet-user-server/src/main/resources/mapper/UserResiInfoDao.xml +++ b/epmet-user/epmet-user-server/src/main/resources/mapper/UserResiInfoDao.xml @@ -153,4 +153,15 @@ AND uri.del_flag = 0 AND uw.del_flag = 0 + + + diff --git a/epmet-user/epmet-user-server/src/main/resources/mapper/UserWechatDao.xml b/epmet-user/epmet-user-server/src/main/resources/mapper/UserWechatDao.xml index 48786dc58a..6ed041a555 100644 --- a/epmet-user/epmet-user-server/src/main/resources/mapper/UserWechatDao.xml +++ b/epmet-user/epmet-user-server/src/main/resources/mapper/UserWechatDao.xml @@ -79,4 +79,14 @@ AND del_flag = 0 + +