Browse Source
# Conflicts: # epmet-module/epmet-third/epmet-third-server/deploy/docker-compose-dev.ymlfeature/evaluate
216 changed files with 5981 additions and 1235 deletions
@ -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<UserTokenResultDTO> resiLogin(@RequestBody LoginFormDTO formDTO) { |
|||
ValidatorUtils.validateEntity(formDTO); |
|||
return new Result<UserTokenResultDTO>().ok(thirdLoginService.resiLogin(formDTO)); |
|||
} |
|||
|
|||
/** |
|||
* @param formDTO |
|||
* @return |
|||
* @Author sun |
|||
* @Description 单客户-政府端微信小程序登录 |
|||
**/ |
|||
@PostMapping("worklogin") |
|||
public Result<UserTokenResultDTO> workLogin(@RequestBody LoginFormDTO formDTO) { |
|||
ValidatorUtils.validateEntity(formDTO); |
|||
return new Result<UserTokenResultDTO>().ok(thirdLoginService.workLogin(formDTO)); |
|||
} |
|||
|
|||
} |
@ -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; |
|||
|
|||
} |
@ -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); |
|||
} |
@ -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<UserWechatDTO> 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<UserDTO> 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<String, Object> 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<UserWechatDTO> result = epmetThirdFeignClient.resiAndWorkLogin(resiLoginFormDTO); |
|||
if (!result.success()) { |
|||
logger.error("工作端小程序登陆,调用epmet_third服务获取数据失败"); |
|||
throw new RenException(result.getCode()); |
|||
} |
|||
UserWechatDTO userWechatDTO = result.getData(); |
|||
|
|||
//2.根据openid查询用户是否存在历史登陆信息
|
|||
Result<StaffLatestAgencyResultDTO> 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<String, Object> 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<String> getDeptartmentIdList(String staffId) { |
|||
try { |
|||
Result<List<DepartmentListResultDTO>> deptListResult = govOrgOpenFeignClient.getDepartmentListByStaffId(staffId); |
|||
if (deptListResult.success()) { |
|||
if (!CollectionUtils.isEmpty(deptListResult.getData())) { |
|||
Set<String> 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<String> getGridIdList(String staffId) { |
|||
Result<List<GridByStaffResultDTO>> result = govOrgOpenFeignClient.listGridsbystaffid(staffId); |
|||
if (!result.success()) { |
|||
logger.error("登录:查询网格列表,远程调用返回错误:{}", result.getMsg()); |
|||
return null; |
|||
} else { |
|||
List<GridByStaffResultDTO> grids = result.getData(); |
|||
return grids.stream().map(grid -> grid.getGridId()).collect(Collectors.toSet()); |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* 根据staffId查询所属的组织机构 |
|||
* |
|||
* @param staffId |
|||
*/ |
|||
public CustomerAgencyDTO getAgencyByStaffId(String staffId) { |
|||
Result<CustomerAgencyDTO> result = govOrgOpenFeignClient.getAgencyByStaff(staffId); |
|||
if (!result.success()) { |
|||
logger.error("登录:查询登录人所属的机关OrgIdPath失败:{}", result.getMsg()); |
|||
return null; |
|||
} |
|||
return result.getData(); |
|||
} |
|||
|
|||
/** |
|||
* 查询人员在某机关单位下的角色列表 |
|||
* |
|||
* @param staffId orgId |
|||
*/ |
|||
public List<GovTokenDto.Role> queryGovStaffRoles(String staffId, String orgId) { |
|||
StaffRoleFormDTO formDTO = new StaffRoleFormDTO(); |
|||
formDTO.setStaffId(staffId); |
|||
formDTO.setOrgId(orgId); |
|||
Result<List<GovStaffRoleDTO>> 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<CustomerAgencyDTO> 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; |
|||
} |
|||
|
|||
} |
@ -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; |
|||
} |
|||
} |
@ -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(); |
|||
|
|||
} |
@ -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(); |
|||
|
|||
} |
@ -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(); |
|||
} |
|||
} |
@ -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(); |
|||
} |
|||
} |
@ -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()); |
|||
} |
|||
} |
|||
} |
@ -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()); |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,91 @@ |
|||
/** |
|||
* Copyright 2018 人人开源 https://www.renren.io
|
|||
* <p> |
|||
* 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. |
|||
* <p> |
|||
* 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. |
|||
* <p> |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
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; |
|||
|
|||
} |
@ -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; |
|||
} |
@ -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; |
|||
} |
@ -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; |
|||
|
|||
} |
@ -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; |
|||
|
|||
} |
@ -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; |
|||
|
|||
} |
@ -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; |
|||
} |
@ -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; |
|||
|
|||
} |
@ -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; |
|||
} |
@ -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; |
|||
|
|||
} |
@ -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; |
|||
} |
@ -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<String> screenshotUrl; |
|||
} |
@ -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; |
|||
|
|||
} |
@ -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"; |
|||
|
|||
} |
@ -0,0 +1,84 @@ |
|||
/** |
|||
* Copyright 2018 人人开源 https://www.renren.io
|
|||
* <p> |
|||
* 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. |
|||
* <p> |
|||
* 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. |
|||
* <p> |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
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<PageData<CodeExtDTO>> page(@RequestParam Map<String, Object> params){ |
|||
PageData<CodeExtDTO> page = codeExtService.page(params); |
|||
return new Result<PageData<CodeExtDTO>>().ok(page); |
|||
} |
|||
|
|||
@GetMapping("{id}") |
|||
public Result<CodeExtDTO> get(@PathVariable("id") String id){ |
|||
CodeExtDTO data = codeExtService.get(id); |
|||
return new Result<CodeExtDTO>().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(); |
|||
} |
|||
|
|||
} |
Some files were not shown because too many files changed in this diff
Loading…
Reference in new issue