forked from rongchao/epmet-cloud-rizhao
Browse Source
# Conflicts: # epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/ServiceConstant.java # epmet-gateway/pom.xml # epmet-gateway/src/main/resources/bootstrap.yml # epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/CustomerStaffGridService.java # epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerStaffGridServiceImpl.java # epmet-module/pom.xmldev
298 changed files with 14894 additions and 791 deletions
@ -0,0 +1,97 @@ |
|||
package com.epmet.controller; |
|||
|
|||
import com.epmet.commons.tools.annotation.LoginUser; |
|||
import com.epmet.commons.tools.security.dto.TokenDto; |
|||
import com.epmet.commons.tools.utils.Result; |
|||
import com.epmet.commons.tools.validator.ValidatorUtils; |
|||
import com.epmet.dto.form.GovWxmpEnteOrgFormDTO; |
|||
import com.epmet.dto.form.GovWxmpFormDTO; |
|||
import com.epmet.dto.form.SendSmsCodeFormDTO; |
|||
import com.epmet.dto.form.StaffOrgsFormDTO; |
|||
import com.epmet.dto.result.StaffOrgsResultDTO; |
|||
import com.epmet.dto.result.UserTokenResultDTO; |
|||
import com.epmet.service.GovLoginService; |
|||
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; |
|||
|
|||
/** |
|||
* @Description 政府端登录 |
|||
* @Author yinzuomei |
|||
* @Date 2020/4/20 10:54 |
|||
*/ |
|||
@RestController |
|||
@RequestMapping("gov") |
|||
public class GovLoginController { |
|||
@Autowired |
|||
private GovLoginService govLoginService; |
|||
|
|||
/** |
|||
* @param formDTO |
|||
* @return com.epmet.commons.tools.utils.Result<com.epmet.dto.result.UserTokenResultDTO> |
|||
* @Author yinzuomei |
|||
* @Description 1、政府端小程序根据wxCode获取上一次登录信息,返回token |
|||
* @Date 2020/4/20 11:22 |
|||
**/ |
|||
@PostMapping(value = "/loginwxmp/loginbywxcode") |
|||
public Result<UserTokenResultDTO> loginByWxCode(@RequestBody GovWxmpFormDTO formDTO) { |
|||
ValidatorUtils.validateEntity(formDTO); |
|||
return govLoginService.loginByWxCode(formDTO); |
|||
} |
|||
|
|||
/** |
|||
* @param formDTO 手机号 |
|||
* @return com.epmet.commons.tools.utils.Result |
|||
* @Author yinzuomei |
|||
* @Description 2、政府端微信小程序登录-发送验证码 |
|||
* @Date 2020/4/18 10:58 |
|||
**/ |
|||
@PostMapping(value = "/loginwxmp/sendsmscode") |
|||
public Result sendSmsCode(@RequestBody SendSmsCodeFormDTO formDTO) { |
|||
ValidatorUtils.validateEntity(formDTO); |
|||
return govLoginService.sendSmsCode(formDTO); |
|||
} |
|||
|
|||
/** |
|||
* @param formDTO |
|||
* @return com.epmet.commons.tools.utils.Result<com.epmet.common.token.dto.result.UserTokenResultDTO> |
|||
* @Author yinzuomei |
|||
* @Description 3、手机验证码获取组织 |
|||
* @Date 2020/4/18 21:14 |
|||
**/ |
|||
@PostMapping(value = "/loginwxmp/getmyorg") |
|||
public Result<List<StaffOrgsResultDTO>> getmyorg(@RequestBody StaffOrgsFormDTO formDTO) { |
|||
ValidatorUtils.validateEntity(formDTO); |
|||
return govLoginService.getMyOrg(formDTO); |
|||
} |
|||
|
|||
/** |
|||
* @param formDTO |
|||
* @return com.epmet.commons.tools.utils.Result<com.epmet.dto.result.UserTokenResultDTO> |
|||
* @Author yinzuomei |
|||
* @Description 4、选择组织,进入首页 |
|||
* @Date 2020/4/20 13:07 |
|||
**/ |
|||
@PostMapping(value = "/loginwxmp/enterorg") |
|||
public Result<UserTokenResultDTO> enterOrg(@RequestBody GovWxmpEnteOrgFormDTO formDTO) { |
|||
ValidatorUtils.validateEntity(formDTO); |
|||
return govLoginService.enterOrg(formDTO); |
|||
} |
|||
|
|||
/** |
|||
* @param tokenDto |
|||
* @return com.epmet.commons.tools.utils.Result |
|||
* @Author yinzuomei |
|||
* @Description 政府端小程序退出 |
|||
* @Date 2020/4/21 22:22 |
|||
**/ |
|||
@PostMapping("/loginwxmp/loginout") |
|||
public Result loginOut(@LoginUser TokenDto tokenDto) { |
|||
return govLoginService.loginOut(tokenDto); |
|||
} |
|||
} |
|||
|
|||
@ -0,0 +1,39 @@ |
|||
package com.epmet.dto.form; |
|||
|
|||
import lombok.Data; |
|||
|
|||
import javax.validation.constraints.NotBlank; |
|||
import java.io.Serializable; |
|||
|
|||
/** |
|||
* @Description 选择组织,进入首页入参Dto |
|||
* @Author yinzuomei |
|||
* @Date 2020/4/20 13:03 |
|||
*/ |
|||
@Data |
|||
public class GovWxmpEnteOrgFormDTO implements Serializable { |
|||
/** |
|||
* wxCode |
|||
*/ |
|||
@NotBlank(message = "wxCode不能为空") |
|||
private String wxCode; |
|||
|
|||
/** |
|||
* 手机号 |
|||
*/ |
|||
@NotBlank(message = "手机号不能为空") |
|||
private String mobile; |
|||
|
|||
/** |
|||
* 选择的组织所属的id |
|||
*/ |
|||
@NotBlank(message = "客户id不能为空") |
|||
private String customerId; |
|||
|
|||
/** |
|||
* 选择的要进入的组织(根组织id) |
|||
*/ |
|||
@NotBlank(message = "组织id不能为空") |
|||
private String rootAgencyId; |
|||
} |
|||
|
|||
@ -0,0 +1,22 @@ |
|||
package com.epmet.dto.form; |
|||
|
|||
import lombok.Data; |
|||
|
|||
import javax.validation.constraints.NotBlank; |
|||
import java.io.Serializable; |
|||
|
|||
/** |
|||
* @Description 政府端小程序根据wxCode获取上一次登录信息,返回token |
|||
* @Author yinzuomei |
|||
* @Date 2020/4/20 11:20 |
|||
*/ |
|||
@Data |
|||
public class GovWxmpFormDTO extends LoginCommonFormDTO implements Serializable { |
|||
private static final long serialVersionUID = -207861963128774742L; |
|||
/** |
|||
* wxCode |
|||
*/ |
|||
@NotBlank(message = "wxCode不能为空") |
|||
private String wxCode; |
|||
} |
|||
|
|||
@ -0,0 +1,30 @@ |
|||
package com.epmet.feign; |
|||
|
|||
import com.epmet.commons.tools.constant.ServiceConstant; |
|||
import com.epmet.commons.tools.utils.Result; |
|||
import com.epmet.dto.form.StaffOrgFormDTO; |
|||
import com.epmet.dto.result.StaffOrgsResultDTO; |
|||
import com.epmet.feign.fallback.GovOrgFeignClientFallback; |
|||
import org.springframework.cloud.openfeign.FeignClient; |
|||
import org.springframework.http.MediaType; |
|||
import org.springframework.web.bind.annotation.PostMapping; |
|||
|
|||
import java.util.List; |
|||
|
|||
/** |
|||
* @Description 政府端组织机构模块 |
|||
* @Author yinzuomei |
|||
* @Date 2020/4/20 15:18 |
|||
*/ |
|||
@FeignClient(name = ServiceConstant.GOV_ORG_SERVER, fallback = GovOrgFeignClientFallback.class) |
|||
public interface GovOrgFeignClient { |
|||
/** |
|||
* @return com.epmet.commons.tools.utils.Result<java.util.List<com.epmet.dto.result.StaffOrgsResultDTO>> |
|||
* @param staffOrgFormDTO |
|||
* @Author yinzuomei |
|||
* @Description 获取客户对应的根级组织名称 |
|||
* @Date 2020/4/20 21:37 |
|||
**/ |
|||
@PostMapping(value = "/gov/org/customeragency/getStaffOrgList",consumes = MediaType.APPLICATION_JSON_VALUE) |
|||
Result<List<StaffOrgsResultDTO>> getStaffOrgList(StaffOrgFormDTO staffOrgFormDTO); |
|||
} |
|||
@ -0,0 +1,26 @@ |
|||
package com.epmet.feign.fallback; |
|||
|
|||
import com.epmet.commons.tools.constant.ServiceConstant; |
|||
import com.epmet.commons.tools.utils.ModuleUtils; |
|||
import com.epmet.commons.tools.utils.Result; |
|||
import com.epmet.dto.form.StaffOrgFormDTO; |
|||
import com.epmet.dto.result.StaffOrgsResultDTO; |
|||
import com.epmet.feign.GovOrgFeignClient; |
|||
import org.springframework.stereotype.Component; |
|||
|
|||
import java.util.List; |
|||
|
|||
/** |
|||
* @Description 政府端组织机构模块 |
|||
* @Author yinzuomei |
|||
* @Date 2020/4/20 15:19 |
|||
*/ |
|||
@Component |
|||
public class GovOrgFeignClientFallback implements GovOrgFeignClient { |
|||
|
|||
@Override |
|||
public Result<List<StaffOrgsResultDTO>> getStaffOrgList(StaffOrgFormDTO staffOrgFormDTO) { |
|||
return ModuleUtils.feignConError(ServiceConstant.GOV_ORG_SERVER, "getStaffOrgList", staffOrgFormDTO); |
|||
} |
|||
} |
|||
|
|||
@ -0,0 +1,64 @@ |
|||
package com.epmet.service; |
|||
|
|||
import com.epmet.commons.tools.security.dto.TokenDto; |
|||
import com.epmet.commons.tools.utils.Result; |
|||
import com.epmet.dto.form.GovWxmpEnteOrgFormDTO; |
|||
import com.epmet.dto.form.GovWxmpFormDTO; |
|||
import com.epmet.dto.form.SendSmsCodeFormDTO; |
|||
import com.epmet.dto.form.StaffOrgsFormDTO; |
|||
import com.epmet.dto.result.StaffOrgsResultDTO; |
|||
import com.epmet.dto.result.UserTokenResultDTO; |
|||
|
|||
import java.util.List; |
|||
|
|||
/** |
|||
* @Description 政府端登录服务 |
|||
* @Author yinzuomei |
|||
* @Date 2020/4/20 10:56 |
|||
*/ |
|||
public interface GovLoginService { |
|||
/** |
|||
* @param formDTO |
|||
* @return com.epmet.commons.tools.utils.Result |
|||
* @Author yinzuomei |
|||
* @Description 政府端微信小程序登录-发送验证码 |
|||
* @Date 2020/4/18 10:59 |
|||
**/ |
|||
Result sendSmsCode(SendSmsCodeFormDTO formDTO); |
|||
|
|||
/** |
|||
* @param formDTO |
|||
* @return com.epmet.commons.tools.utils.Result<com.epmet.common.token.dto.result.UserTokenResultDTO> |
|||
* @Author yinzuomei |
|||
* @Description 3、手机验证码获取组织 |
|||
* @Date 2020/4/18 21:11 |
|||
**/ |
|||
Result<List<StaffOrgsResultDTO>> getMyOrg(StaffOrgsFormDTO formDTO); |
|||
|
|||
/** |
|||
* @param formDTO |
|||
* @return com.epmet.commons.tools.utils.Result<com.epmet.dto.result.UserTokenResultDTO> |
|||
* @Author yinzuomei |
|||
* @Description 政府端小程序根据wxCode获取上一次登录信息,返回token |
|||
* @Date 2020/4/20 11:23 |
|||
**/ |
|||
Result<UserTokenResultDTO> loginByWxCode(GovWxmpFormDTO formDTO); |
|||
|
|||
/** |
|||
* @param formDTO |
|||
* @return com.epmet.commons.tools.utils.Result<com.epmet.dto.result.UserTokenResultDTO> |
|||
* @Author yinzuomei |
|||
* @Description 4、选择组织,进入首页 |
|||
* @Date 2020/4/20 13:08 |
|||
**/ |
|||
Result<UserTokenResultDTO> enterOrg(GovWxmpEnteOrgFormDTO formDTO); |
|||
|
|||
/** |
|||
* @return com.epmet.commons.tools.utils.Result |
|||
* @param tokenDto |
|||
* @Author yinzuomei |
|||
* @Description 政府端工作人员退出登录 |
|||
* @Date 2020/4/21 22:08 |
|||
**/ |
|||
Result loginOut(TokenDto tokenDto); |
|||
} |
|||
@ -0,0 +1,290 @@ |
|||
package com.epmet.service.impl; |
|||
|
|||
import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult; |
|||
import com.epmet.common.token.constant.LoginConstant; |
|||
import com.epmet.commons.tools.exception.EpmetErrorCode; |
|||
import com.epmet.commons.tools.exception.RenException; |
|||
import com.epmet.commons.tools.security.dto.GovTokenDto; |
|||
import com.epmet.commons.tools.security.dto.TokenDto; |
|||
import com.epmet.commons.tools.utils.CpUserDetailRedis; |
|||
import com.epmet.commons.tools.utils.DateUtils; |
|||
import com.epmet.commons.tools.utils.Result; |
|||
import com.epmet.commons.tools.validator.PhoneValidatorUtils; |
|||
import com.epmet.dto.CustomerStaffDTO; |
|||
import com.epmet.dto.form.*; |
|||
import com.epmet.dto.result.StaffLatestAgencyResultDTO; |
|||
import com.epmet.dto.result.StaffOrgsResultDTO; |
|||
import com.epmet.dto.result.UserTokenResultDTO; |
|||
import com.epmet.feign.EpmetUserFeignClient; |
|||
import com.epmet.feign.GovOrgFeignClient; |
|||
import com.epmet.feign.MessageFeignClient; |
|||
import com.epmet.jwt.JwtTokenProperties; |
|||
import com.epmet.jwt.JwtTokenUtils; |
|||
import com.epmet.redis.CaptchaRedis; |
|||
import com.epmet.service.GovLoginService; |
|||
import com.epmet.service.LoginService; |
|||
import org.slf4j.Logger; |
|||
import org.slf4j.LoggerFactory; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
import java.util.ArrayList; |
|||
import java.util.HashMap; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* @Description 政府端登录服务 |
|||
* @Author yinzuomei |
|||
* @Date 2020/4/20 10:56 |
|||
*/ |
|||
@Service |
|||
public class GovLoginServiceImpl implements GovLoginService { |
|||
private static final Logger logger = LoggerFactory.getLogger(GovLoginServiceImpl.class); |
|||
private static final String SEND_SMS_CODE_ERROR = "发送短信验证码异常,手机号[%s],code[%s],msg[%s]"; |
|||
@Autowired |
|||
private LoginService loginService; |
|||
@Autowired |
|||
private EpmetUserFeignClient epmetUserFeignClient; |
|||
@Autowired |
|||
private CaptchaRedis captchaRedis; |
|||
@Autowired |
|||
private MessageFeignClient messageFeignClient; |
|||
@Autowired |
|||
private JwtTokenUtils jwtTokenUtils; |
|||
@Autowired |
|||
private JwtTokenProperties jwtTokenProperties; |
|||
@Autowired |
|||
private CpUserDetailRedis cpUserDetailRedis; |
|||
@Autowired |
|||
private GovOrgFeignClient govOrgFeignClient; |
|||
|
|||
/** |
|||
* @param formDTO |
|||
* @return com.epmet.commons.tools.utils.Result |
|||
* @Author yinzuomei |
|||
* @Description 政府端微信小程序登录-发送验证码 |
|||
* @Date 2020/4/18 10:59 |
|||
**/ |
|||
@Override |
|||
public Result sendSmsCode(SendSmsCodeFormDTO formDTO) { |
|||
//1、校验手机号是否符合规范
|
|||
if (!PhoneValidatorUtils.isMobile(formDTO.getMobile())) { |
|||
logger.error(String.format(SEND_SMS_CODE_ERROR, formDTO.getMobile(), EpmetErrorCode.ERROR_PHONE.getCode(), EpmetErrorCode.ERROR_PHONE.getMsg())); |
|||
return new Result().error(EpmetErrorCode.ERROR_PHONE.getCode()); |
|||
} |
|||
//2、根据手机号校验用户是否存在
|
|||
Result<List<CustomerStaffDTO>> customerStaffResult = epmetUserFeignClient.checkCustomerStaff(formDTO.getMobile()); |
|||
if (!customerStaffResult.success()) { |
|||
logger.error(String.format(SEND_SMS_CODE_ERROR, formDTO.getMobile(), customerStaffResult.getCode(), customerStaffResult.getMsg())); |
|||
return new Result().error(customerStaffResult.getCode()); |
|||
} |
|||
//3、发送短信验证码
|
|||
Result<Map<String, String>> smsCodeResult = messageFeignClient.sendSmsCaptcha(formDTO.getMobile()); |
|||
if (!smsCodeResult.success()) { |
|||
logger.error(String.format(SEND_SMS_CODE_ERROR, formDTO.getMobile(), smsCodeResult.getCode(), smsCodeResult.getMsg())); |
|||
return new Result().error(smsCodeResult.getCode()); |
|||
} |
|||
//4、保存短信验证码(删除现有短信验证码、将新的短信验证码存入Redis)
|
|||
captchaRedis.saveSmsCode(formDTO, smsCodeResult.getData().get("code")); |
|||
logger.info(String.format("发送短信验证码成功,手机号[%s]", formDTO.getMobile())); |
|||
return new Result(); |
|||
} |
|||
|
|||
/** |
|||
* @param formDTO |
|||
* @return com.epmet.commons.tools.utils.Result<com.epmet.common.token.dto.result.UserTokenResultDTO> |
|||
* @Author yinzuomei |
|||
* @Description 3、手机验证码获取组织 |
|||
* @Date 2020/4/18 21:11 |
|||
**/ |
|||
@Override |
|||
public Result<List<StaffOrgsResultDTO>> getMyOrg(StaffOrgsFormDTO formDTO) { |
|||
//1、根据手机号查询到用户信息
|
|||
Result<List<CustomerStaffDTO>> customerStaffResult = epmetUserFeignClient.checkCustomerStaff(formDTO.getMobile()); |
|||
if (!customerStaffResult.success()) { |
|||
logger.error(String.format("手机验证码登录异常,手机号[%s],code[%s],msg[%s]", formDTO.getMobile(), customerStaffResult.getCode(), customerStaffResult.getMsg())); |
|||
return new Result().error(customerStaffResult.getCode()); |
|||
} |
|||
//2、验证码是否正确
|
|||
String rightSmsCode = captchaRedis.getSmsCode(formDTO.getMobile()); |
|||
if (!formDTO.getSmsCode().equals(rightSmsCode)) { |
|||
logger.error(String.format("验证码错误code[%s],msg[%s]",EpmetErrorCode.MOBILE_CODE_ERROR.getCode(),EpmetErrorCode.MOBILE_CODE_ERROR.getMsg())); |
|||
return new Result<List<StaffOrgsResultDTO>>().error(EpmetErrorCode.MOBILE_CODE_ERROR.getCode()); |
|||
} |
|||
//3、查询用户所有的组织信息
|
|||
List<String> customerIdList = new ArrayList<>(); |
|||
for (CustomerStaffDTO customerStaffDTO : customerStaffResult.getData()) { |
|||
customerIdList.add(customerStaffDTO.getCustomerId()); |
|||
} |
|||
StaffOrgFormDTO staffOrgFormDTO = new StaffOrgFormDTO(); |
|||
staffOrgFormDTO.setCustomerIdList(customerIdList); |
|||
Result<List<StaffOrgsResultDTO>> result = govOrgFeignClient.getStaffOrgList(staffOrgFormDTO); |
|||
return result; |
|||
} |
|||
|
|||
@Override |
|||
public Result<UserTokenResultDTO> loginByWxCode(GovWxmpFormDTO formDTO) { |
|||
//1、解析微信用户
|
|||
WxMaJscode2SessionResult wxMaJscode2SessionResult = loginService.getWxMaUser(formDTO.getApp(), formDTO.getWxCode()); |
|||
if(null!=wxMaJscode2SessionResult){ |
|||
logger.info(String.format("app=%s,wxCode=%s,openId=%s",formDTO.getApp(),formDTO.getWxCode(),wxMaJscode2SessionResult.getOpenid())); |
|||
} |
|||
Result<StaffLatestAgencyResultDTO> latestStaffWechat = epmetUserFeignClient.getLatestStaffWechatLoginRecord(wxMaJscode2SessionResult.getOpenid()); |
|||
if (!latestStaffWechat.success() || null == latestStaffWechat.getData()) { |
|||
logger.error(String.format("没有获取到用户最近一次登录账户信息,code[%s],msg[%s]", EpmetErrorCode.PLEASE_LOGIN.getCode(), EpmetErrorCode.PLEASE_LOGIN.getMsg())); |
|||
return new Result<UserTokenResultDTO>().error(EpmetErrorCode.PLEASE_LOGIN.getCode()); |
|||
} |
|||
StaffLatestAgencyResultDTO staffLatestAgencyResultDTO = latestStaffWechat.getData(); |
|||
//2、记录staff_wechat
|
|||
this.savestaffwechat(staffLatestAgencyResultDTO.getStaffId(), wxMaJscode2SessionResult.getOpenid()); |
|||
//3、记录登录日志
|
|||
this.saveStaffLoginRecord(staffLatestAgencyResultDTO); |
|||
//4、获取用户token
|
|||
String token = this.generateGovWxmpToken(staffLatestAgencyResultDTO.getStaffId()); |
|||
//5、保存到redis
|
|||
this.saveLatestGovTokenDto(staffLatestAgencyResultDTO, wxMaJscode2SessionResult, token); |
|||
UserTokenResultDTO userTokenResultDTO = new UserTokenResultDTO(); |
|||
userTokenResultDTO.setToken(token); |
|||
return new Result<UserTokenResultDTO>().ok(userTokenResultDTO); |
|||
} |
|||
|
|||
//保存tokenDto到redis
|
|||
private void saveLatestGovTokenDto(StaffLatestAgencyResultDTO staffLatestAgency, |
|||
WxMaJscode2SessionResult wxMaJscode2SessionResult, |
|||
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(wxMaJscode2SessionResult.getOpenid()); |
|||
govTokenDto.setSessionKey(wxMaJscode2SessionResult.getSessionKey()); |
|||
govTokenDto.setUnionId(wxMaJscode2SessionResult.getUnionid()); |
|||
govTokenDto.setToken(token); |
|||
govTokenDto.setUpdateTime(System.currentTimeMillis()); |
|||
govTokenDto.setExpireTime(jwtTokenUtils.getExpiration(token).getTime()); |
|||
govTokenDto.setAgencyId(staffLatestAgency.getAgencyId()); |
|||
govTokenDto.setCustomerId(staffLatestAgency.getCustomerId()); |
|||
cpUserDetailRedis.set(govTokenDto, expire); |
|||
logger.info("截止时间:" + DateUtils.format(jwtTokenUtils.getExpiration(token), "yyyy-MM-dd HH:mm:ss")); |
|||
} |
|||
|
|||
//保存登录日志
|
|||
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 = epmetUserFeignClient.saveStaffLoginRecord(staffLoginAgencyRecordFormDTO); |
|||
return staffLoginRecordResult; |
|||
} |
|||
|
|||
@Override |
|||
public Result<UserTokenResultDTO> enterOrg(GovWxmpEnteOrgFormDTO formDTO) { |
|||
//1、需要校验要登录的客户,是否被禁用
|
|||
CustomerStaffFormDTO customerStaffFormDTO = new CustomerStaffFormDTO(); |
|||
customerStaffFormDTO.setCustomerId(formDTO.getCustomerId()); |
|||
customerStaffFormDTO.setMobile(formDTO.getMobile()); |
|||
Result<CustomerStaffDTO> customerStaffDTOResult = epmetUserFeignClient.getCustomerStaffInfo(customerStaffFormDTO); |
|||
if (!customerStaffDTOResult.success() || null == customerStaffDTOResult.getData()) { |
|||
logger.error(String.format("获取工作人员信息失败,手机号[%s],客户id:[%s],code[%s],msg[%s]", formDTO.getMobile(), formDTO.getCustomerId(), customerStaffDTOResult.getCode(), customerStaffDTOResult.getMsg())); |
|||
return new Result().error(customerStaffDTOResult.getCode()); |
|||
} |
|||
CustomerStaffDTO customerStaff = customerStaffDTOResult.getData(); |
|||
//2、解析微信用户
|
|||
WxMaJscode2SessionResult wxMaJscode2SessionResult = loginService.getWxMaUser(LoginConstant.APP_GOV, formDTO.getWxCode()); |
|||
//3、记录staff_wechat,并记录用户激活状态,激活时间
|
|||
this.savestaffwechat(customerStaff.getUserId(), wxMaJscode2SessionResult.getOpenid()); |
|||
//4、记录登录日志
|
|||
this.saveStaffLoginRecord(formDTO, customerStaff.getUserId(), wxMaJscode2SessionResult.getOpenid()); |
|||
//5.1、获取用户token
|
|||
String token = this.generateGovWxmpToken(customerStaff.getUserId()); |
|||
//5.2、保存到redis
|
|||
this.saveGovTokenDto(formDTO.getRootAgencyId(), formDTO.getCustomerId(), customerStaff.getUserId(), wxMaJscode2SessionResult, token); |
|||
UserTokenResultDTO userTokenResultDTO = new UserTokenResultDTO(); |
|||
userTokenResultDTO.setToken(token); |
|||
return new Result<UserTokenResultDTO>().ok(userTokenResultDTO); |
|||
} |
|||
|
|||
@Override |
|||
public Result loginOut(TokenDto tokenDto) { |
|||
if(null == tokenDto){ |
|||
logger.error("token解析失败,直接跳转重新登录即可"); |
|||
throw new RenException("当前用户信息获取失败"); |
|||
} |
|||
cpUserDetailRedis.logout(tokenDto.getApp() , tokenDto.getClient() , tokenDto.getUserId()); |
|||
return new Result(); |
|||
} |
|||
|
|||
//保存登录日志
|
|||
private Result saveStaffLoginRecord(GovWxmpEnteOrgFormDTO formDTO, String staffId, String openId) { |
|||
StaffLoginAgencyRecordFormDTO staffLoginAgencyRecordFormDTO = new StaffLoginAgencyRecordFormDTO(); |
|||
staffLoginAgencyRecordFormDTO.setCustomerId(formDTO.getCustomerId()); |
|||
staffLoginAgencyRecordFormDTO.setStaffId(staffId); |
|||
staffLoginAgencyRecordFormDTO.setWxOpenId(openId); |
|||
staffLoginAgencyRecordFormDTO.setMobile(formDTO.getMobile()); |
|||
staffLoginAgencyRecordFormDTO.setAgencyId(formDTO.getRootAgencyId()); |
|||
Result staffLoginRecordResult = epmetUserFeignClient.saveStaffLoginRecord(staffLoginAgencyRecordFormDTO); |
|||
return staffLoginRecordResult; |
|||
} |
|||
|
|||
|
|||
/** |
|||
* @param userId |
|||
* @param openid |
|||
* @return com.epmet.commons.tools.utils.Result |
|||
* @Author yinzuomei |
|||
* @Description 保存微信和当前登录用户关系 |
|||
* @Date 2020/4/18 22:54 |
|||
**/ |
|||
private Result savestaffwechat(String userId, String openid) { |
|||
StaffWechatFormDTO staffWechatFormDTO = new StaffWechatFormDTO(); |
|||
staffWechatFormDTO.setUserId(userId); |
|||
staffWechatFormDTO.setWxOpenId(openid); |
|||
return epmetUserFeignClient.saveStaffWechat(staffWechatFormDTO); |
|||
} |
|||
|
|||
/** |
|||
* @Description 生成token |
|||
* @Date 2020/4/18 23:04 |
|||
**/ |
|||
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 生成token |
|||
* @Date 2020/4/18 23:04 |
|||
**/ |
|||
private void saveGovTokenDto(String orgId, |
|||
String customerId, |
|||
String staffId, |
|||
WxMaJscode2SessionResult wxMaJscode2SessionResult, |
|||
String token) { |
|||
int expire = jwtTokenProperties.getExpire(); |
|||
GovTokenDto govTokenDto = new GovTokenDto(); |
|||
govTokenDto.setApp(LoginConstant.APP_GOV); |
|||
govTokenDto.setClient(LoginConstant.CLIENT_WXMP); |
|||
govTokenDto.setUserId(staffId); |
|||
govTokenDto.setOpenId(wxMaJscode2SessionResult.getOpenid()); |
|||
govTokenDto.setSessionKey(wxMaJscode2SessionResult.getSessionKey()); |
|||
govTokenDto.setUnionId(wxMaJscode2SessionResult.getUnionid()); |
|||
govTokenDto.setToken(token); |
|||
govTokenDto.setUpdateTime(System.currentTimeMillis()); |
|||
govTokenDto.setExpireTime(jwtTokenUtils.getExpiration(token).getTime()); |
|||
govTokenDto.setAgencyId(orgId); |
|||
govTokenDto.setCustomerId(customerId); |
|||
cpUserDetailRedis.set(govTokenDto, expire); |
|||
logger.info("截止时间:" + DateUtils.format(jwtTokenUtils.getExpiration(token), "yyyy-MM-dd HH:mm:ss")); |
|||
} |
|||
} |
|||
|
|||
@ -0,0 +1,63 @@ |
|||
package com.epmet; |
|||
|
|||
import com.epmet.common.token.constant.LoginConstant; |
|||
import com.epmet.commons.tools.security.dto.GovTokenDto; |
|||
import com.epmet.commons.tools.utils.CpUserDetailRedis; |
|||
import com.epmet.jwt.JwtTokenProperties; |
|||
import com.epmet.jwt.JwtTokenUtils; |
|||
import org.junit.Test; |
|||
import org.junit.runner.RunWith; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.boot.test.context.SpringBootTest; |
|||
import org.springframework.test.context.junit4.SpringRunner; |
|||
|
|||
import java.util.HashMap; |
|||
import java.util.Map; |
|||
|
|||
@RunWith(SpringRunner.class) |
|||
@SpringBootTest |
|||
public class TokenGenTest { |
|||
|
|||
@Autowired |
|||
private JwtTokenProperties jwtTokenProperties; |
|||
|
|||
@Autowired |
|||
private JwtTokenUtils jwtTokenUtils; |
|||
|
|||
@Autowired |
|||
private CpUserDetailRedis cpUserDetailRedis; |
|||
|
|||
@Test |
|||
public void genToken() { |
|||
String staffId = "wxz"; |
|||
String tokenStr = generateGovWxmpToken(staffId); |
|||
int expire = jwtTokenProperties.getExpire(); |
|||
GovTokenDto govTokenDto = new GovTokenDto(); |
|||
govTokenDto.setApp(LoginConstant.APP_GOV); |
|||
govTokenDto.setClient(LoginConstant.CLIENT_WXMP); |
|||
govTokenDto.setUserId(staffId); |
|||
govTokenDto.setOpenId(""); |
|||
govTokenDto.setSessionKey(""); |
|||
govTokenDto.setUnionId(""); |
|||
govTokenDto.setToken(tokenStr); |
|||
govTokenDto.setUpdateTime(System.currentTimeMillis()); |
|||
govTokenDto.setExpireTime(jwtTokenUtils.getExpiration(tokenStr).getTime()); |
|||
govTokenDto.setAgencyId("1"); |
|||
govTokenDto.setCustomerId("f76def116c9c2dc0269cc17867af122c"); |
|||
cpUserDetailRedis.set(govTokenDto, expire); |
|||
} |
|||
|
|||
/** |
|||
* @Description 生成token |
|||
* @Date 2020/4/18 23:04 |
|||
**/ |
|||
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); |
|||
return token; |
|||
} |
|||
|
|||
} |
|||
@ -1,51 +0,0 @@ |
|||
package com.epmet.common.token.enums; |
|||
|
|||
|
|||
import com.epmet.common.token.error.IErrorCode; |
|||
|
|||
/** |
|||
* client token错误码 |
|||
* |
|||
* @author rongchao |
|||
* @Date 18-11-24 |
|||
*/ |
|||
public enum ErrorCode implements IErrorCode { |
|||
|
|||
SUCCESS(0, "请求成功"), |
|||
|
|||
ERR10001(10001, "token解析失败"), |
|||
ERR10002(10002, "token失效"), |
|||
ERR10003(10003, "token生成失败,请重试。"), |
|||
ERR10004(10004, "返回的Object类型不是EsuaResponse,无法添加token!"), |
|||
ERR10005(10005, "token不能为空"), |
|||
ERR10006(10006, "登录超时,请重新登录"), |
|||
ERR10007(10007, "当前帐号已在别处登录"), |
|||
|
|||
ERR500(500, "Internal Server Error"), |
|||
ERR501(501, "参数绑定异常"), |
|||
ERR401(401, "未授权"), |
|||
|
|||
|
|||
ERR(ErrorCode.COMMON_ERR_CODE, "其他异常"); |
|||
|
|||
private int code; |
|||
|
|||
private String msg; |
|||
|
|||
ErrorCode(final int code, final String msg) { |
|||
this.code = code; |
|||
this.msg = msg; |
|||
} |
|||
|
|||
public static final int COMMON_ERR_CODE = -1; |
|||
|
|||
@Override |
|||
public int getCode() { |
|||
return code; |
|||
} |
|||
|
|||
@Override |
|||
public String getMsg() { |
|||
return msg; |
|||
} |
|||
} |
|||
@ -1,11 +0,0 @@ |
|||
package com.epmet.common.token.error; |
|||
|
|||
/** |
|||
* @author rongchao |
|||
* @Date 18-11-20 |
|||
*/ |
|||
public interface IErrorCode { |
|||
int getCode(); |
|||
|
|||
String getMsg(); |
|||
} |
|||
@ -0,0 +1,106 @@ |
|||
///**
|
|||
// * Copyright (c) 2018 人人开源 All rights reserved.
|
|||
// *
|
|||
// * https://www.renren.io
|
|||
// *
|
|||
// * 版权所有,侵权必究!
|
|||
// */
|
|||
//
|
|||
//package com.epmet.commons.mybatis.aspect;
|
|||
//
|
|||
//import cn.hutool.core.collection.CollUtil;
|
|||
//import com.epmet.commons.mybatis.annotation.DataFilter;
|
|||
//import com.epmet.commons.mybatis.entity.DataScope;
|
|||
//import com.epmet.commons.tools.constant.Constant;
|
|||
//import com.epmet.commons.tools.enums.SuperAdminEnum;
|
|||
//import com.epmet.commons.tools.exception.ErrorCode;
|
|||
//import com.epmet.commons.tools.exception.RenException;
|
|||
//import com.epmet.commons.tools.security.user.SecurityUser;
|
|||
//import com.epmet.commons.tools.security.user.UserDetail;
|
|||
//import org.apache.commons.lang3.StringUtils;
|
|||
//import org.aspectj.lang.JoinPoint;
|
|||
//import org.aspectj.lang.annotation.Aspect;
|
|||
//import org.aspectj.lang.annotation.Before;
|
|||
//import org.aspectj.lang.annotation.Pointcut;
|
|||
//import org.aspectj.lang.reflect.MethodSignature;
|
|||
//import org.springframework.stereotype.Component;
|
|||
//
|
|||
//import java.util.Arrays;
|
|||
//import java.util.List;
|
|||
//import java.util.Map;
|
|||
//
|
|||
///**
|
|||
// * 数据过滤,切面处理类
|
|||
// *
|
|||
// * @author Mark sunlightcs@gmail.com
|
|||
// * @since 1.0.0
|
|||
// */
|
|||
//@Aspect
|
|||
//@Component
|
|||
//public class DataFilterAspectBak {
|
|||
// @Pointcut("@annotation(com.epmet.commons.mybatis.annotation.DataFilter)")
|
|||
// public void dataFilterCut() {
|
|||
//
|
|||
// }
|
|||
//
|
|||
// @Before("dataFilterCut()")
|
|||
// public void dataFilter(JoinPoint point) {
|
|||
// Object params = point.getArgs()[0];
|
|||
// if(params != null && params instanceof Map){
|
|||
// UserDetail user = SecurityUser.getUser();
|
|||
//
|
|||
// //如果不是超级管理员,则进行数据过滤
|
|||
// if(user.getSuperAdmin() == SuperAdminEnum.NO.value()){
|
|||
// Map map = (Map)params;
|
|||
// String sqlFilter = getSqlFilter(user, point);
|
|||
// map.put(Constant.SQL_FILTER, new DataScope(sqlFilter));
|
|||
// }
|
|||
//
|
|||
// return ;
|
|||
// }
|
|||
//
|
|||
// throw new RenException(ErrorCode.DATA_SCOPE_PARAMS_ERROR);
|
|||
// }
|
|||
//
|
|||
// /**
|
|||
// * 获取数据过滤的SQL
|
|||
// */
|
|||
// private String getSqlFilter(UserDetail user, JoinPoint point){
|
|||
// MethodSignature signature = (MethodSignature) point.getSignature();
|
|||
// DataFilter dataFilter = signature.getMethod().getAnnotation(DataFilter.class);
|
|||
// //获取表的别名
|
|||
// String tableAlias = dataFilter.tableAlias();
|
|||
// if(StringUtils.isNotBlank(tableAlias)){
|
|||
// tableAlias += ".";
|
|||
// }
|
|||
//
|
|||
// StringBuilder sqlFilter = new StringBuilder();
|
|||
//
|
|||
// //查询条件前缀
|
|||
// String prefix = dataFilter.prefix();
|
|||
// if(StringUtils.isNotBlank(prefix)){
|
|||
// sqlFilter.append(" ").append(prefix);
|
|||
// }
|
|||
//
|
|||
// sqlFilter.append(" (");
|
|||
//
|
|||
// //部门ID列表
|
|||
// List<Long> deptIdList = user.getDeptIdList();
|
|||
// if(CollUtil.isNotEmpty(deptIdList)){
|
|||
// sqlFilter.append(tableAlias).append(dataFilter.deptId());
|
|||
//
|
|||
// sqlFilter.append(" in(").append(StringUtils.join(deptIdList, ",")).append(")");
|
|||
// }
|
|||
//
|
|||
// //查询本人数据
|
|||
// if (dataFilter.isPendingCreator()) {
|
|||
// if(CollUtil.isNotEmpty(deptIdList)){
|
|||
// sqlFilter.append(" or ");
|
|||
// }
|
|||
// sqlFilter.append(tableAlias).append(dataFilter.userId()).append("=").append(user.getId());
|
|||
// }
|
|||
// sqlFilter.append(")");
|
|||
//
|
|||
// return sqlFilter.toString();
|
|||
// }
|
|||
//}
|
|||
@ -0,0 +1,17 @@ |
|||
package com.epmet.commons.mybatis.constant; |
|||
|
|||
public class OpeScopeConstant { |
|||
//"同级组织的下级"
|
|||
public static final String ORG_EQUAL_SUB = "org_equal_sub"; |
|||
//"同级组织及下级"
|
|||
public static final String ORG_EQUAL_AND_SUB = "org_equal_and_sub"; |
|||
//"同级组织"
|
|||
public static final String ORG_EQUAL = "org_equal"; |
|||
//"本组织的下级"
|
|||
public static final String ORG_CURR_SUB = "org_curr_sub"; |
|||
//"本组织及下级"
|
|||
public static final String ORG_CURR_AND_SUB = "org_curr_and_sub"; |
|||
//"本组织"
|
|||
public static final String ORG_CURR = "org_curr"; |
|||
|
|||
} |
|||
@ -0,0 +1,92 @@ |
|||
/** |
|||
* 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.commons.mybatis.dto.form; |
|||
|
|||
import lombok.Data; |
|||
|
|||
import java.io.Serializable; |
|||
import java.util.Date; |
|||
|
|||
|
|||
/** |
|||
* 权限范围表 |
|||
* |
|||
* @author generator generator@elink-cn.com |
|||
* @since v1.0.0 2020-04-24 |
|||
*/ |
|||
@Data |
|||
public class OperationScopeDTO implements Serializable { |
|||
|
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
/** |
|||
* id |
|||
*/ |
|||
private String id; |
|||
|
|||
/** |
|||
* 角色id |
|||
*/ |
|||
private String roleId; |
|||
|
|||
/** |
|||
* 范围key |
|||
*/ |
|||
private String scopeKey; |
|||
|
|||
/** |
|||
* 范围名称 |
|||
*/ |
|||
private String scopeName; |
|||
|
|||
/** |
|||
* 范围序号 |
|||
*/ |
|||
private String scopeIndex; |
|||
|
|||
/** |
|||
* 是否删除,0:未删除,1:已删除 |
|||
*/ |
|||
private Integer delFlag; |
|||
|
|||
/** |
|||
* 乐观锁 |
|||
*/ |
|||
private Integer revision; |
|||
|
|||
/** |
|||
* 创建者id |
|||
*/ |
|||
private String createdBy; |
|||
|
|||
/** |
|||
* 创建时间 |
|||
*/ |
|||
private Date createdTime; |
|||
|
|||
/** |
|||
* 更新者id |
|||
*/ |
|||
private String updatedBy; |
|||
|
|||
/** |
|||
* 更新时间 |
|||
*/ |
|||
private Date updatedTime; |
|||
|
|||
} |
|||
@ -0,0 +1,18 @@ |
|||
package com.epmet.commons.mybatis.dto.form; |
|||
|
|||
import lombok.Data; |
|||
|
|||
import javax.validation.constraints.NotBlank; |
|||
|
|||
@Data |
|||
public class OperationScopeFormDTO { |
|||
|
|||
public interface ListOperationScopeGroup {} |
|||
|
|||
@NotBlank(message = "角色ID不能为空", groups = {ListOperationScopeGroup.class}) |
|||
private String roleId; |
|||
|
|||
@NotBlank(message = "操作的key不能为空", groups = {ListOperationScopeGroup.class}) |
|||
private String operationKey; |
|||
|
|||
} |
|||
@ -0,0 +1,30 @@ |
|||
package com.epmet.commons.mybatis.dto.form; |
|||
|
|||
import lombok.Data; |
|||
|
|||
import java.util.Set; |
|||
|
|||
@Data |
|||
public class StaffPermCacheResultDTO { |
|||
|
|||
/** |
|||
* 权限列表 |
|||
*/ |
|||
private Set<String> permissions; |
|||
|
|||
/** |
|||
* 角色列表 |
|||
*/ |
|||
private Set<String> roleIdList; |
|||
|
|||
/** |
|||
* 机构Id |
|||
*/ |
|||
private String orgIdPath; |
|||
|
|||
/** |
|||
* 网格ID |
|||
*/ |
|||
private String gridId; |
|||
|
|||
} |
|||
@ -0,0 +1,26 @@ |
|||
package com.epmet.commons.mybatis.dto.form; |
|||
|
|||
import lombok.Data; |
|||
|
|||
import javax.validation.constraints.NotBlank; |
|||
import java.util.Set; |
|||
|
|||
@Data |
|||
public class StaffPermissionFormDTO { |
|||
|
|||
/** |
|||
* 工作人员 id |
|||
*/ |
|||
private String staffId; |
|||
|
|||
/** |
|||
* 登录头信息app |
|||
*/ |
|||
private String app; |
|||
|
|||
/** |
|||
* 登录头信息client |
|||
*/ |
|||
private String client; |
|||
|
|||
} |
|||
@ -0,0 +1,39 @@ |
|||
package com.epmet.commons.mybatis.feign; |
|||
|
|||
import com.epmet.commons.mybatis.dto.form.OperationScopeDTO; |
|||
import com.epmet.commons.mybatis.dto.form.OperationScopeFormDTO; |
|||
import com.epmet.commons.mybatis.dto.form.StaffPermCacheResultDTO; |
|||
import com.epmet.commons.mybatis.dto.form.StaffPermissionFormDTO; |
|||
import com.epmet.commons.mybatis.feign.fallback.GovAccessFeignClientFallback; |
|||
import com.epmet.commons.tools.constant.ServiceConstant; |
|||
import com.epmet.commons.tools.utils.Result; |
|||
import org.springframework.cloud.openfeign.FeignClient; |
|||
import org.springframework.web.bind.annotation.PostMapping; |
|||
import org.springframework.web.bind.annotation.RequestBody; |
|||
|
|||
import java.util.List; |
|||
import java.util.Set; |
|||
|
|||
/** |
|||
* @Description |
|||
* @Author sun |
|||
*/ |
|||
@FeignClient(name = ServiceConstant.GOV_ACCESS_SERVER, fallback = GovAccessFeignClientFallback.class) |
|||
public interface GovAccessFeignClient { |
|||
|
|||
/** |
|||
* 查询用户当前权限列表 |
|||
* @return |
|||
*/ |
|||
@PostMapping("/gov/access/access/getcurrpermissions") |
|||
Result<StaffPermCacheResultDTO> getStaffCurrPermissions(StaffPermissionFormDTO dto); |
|||
|
|||
/** |
|||
* 查询角色的操作key对应操作范围列表 |
|||
* @param operationScopeFormDTO |
|||
* @return |
|||
*/ |
|||
@PostMapping("/gov/access/access/operationscopes") |
|||
Result<Set<OperationScopeDTO>> getOperationScopesByRoleId(OperationScopeFormDTO operationScopeFormDTO); |
|||
|
|||
} |
|||
@ -0,0 +1,33 @@ |
|||
package com.epmet.commons.mybatis.feign.fallback; |
|||
|
|||
import com.epmet.commons.mybatis.dto.form.OperationScopeDTO; |
|||
import com.epmet.commons.mybatis.dto.form.OperationScopeFormDTO; |
|||
import com.epmet.commons.mybatis.dto.form.StaffPermCacheResultDTO; |
|||
import com.epmet.commons.mybatis.dto.form.StaffPermissionFormDTO; |
|||
import com.epmet.commons.mybatis.feign.GovAccessFeignClient; |
|||
import com.epmet.commons.tools.constant.ServiceConstant; |
|||
import com.epmet.commons.tools.utils.ModuleUtils; |
|||
import com.epmet.commons.tools.utils.Result; |
|||
import org.springframework.stereotype.Component; |
|||
|
|||
import java.util.Set; |
|||
|
|||
/** |
|||
* 调用政府端权限 |
|||
* @Author wxz |
|||
* @Description |
|||
* @Date 2020/4/24 11:17 |
|||
**/ |
|||
@Component |
|||
public class GovAccessFeignClientFallback implements GovAccessFeignClient { |
|||
|
|||
@Override |
|||
public Result<StaffPermCacheResultDTO> getStaffCurrPermissions(StaffPermissionFormDTO dto) { |
|||
return ModuleUtils.feignConError(ServiceConstant.GOV_ACCESS_SERVER, "getStaffCurrPermissions", dto); |
|||
} |
|||
|
|||
@Override |
|||
public Result<Set<OperationScopeDTO>> getOperationScopesByRoleId(OperationScopeFormDTO operationScopeFormDTO) { |
|||
return ModuleUtils.feignConError(ServiceConstant.GOV_ACCESS_SERVER, "getOperationScopesByRoleId", operationScopeFormDTO); |
|||
} |
|||
} |
|||
@ -0,0 +1,100 @@ |
|||
///**
|
|||
// * Copyright (c) 2018 人人开源 All rights reserved.
|
|||
// * <p>
|
|||
// * https://www.renren.io
|
|||
// * <p>
|
|||
// * 版权所有,侵权必究!
|
|||
// */
|
|||
//
|
|||
//package com.epmet.commons.mybatis.interceptor;
|
|||
//
|
|||
//import com.baomidou.mybatisplus.core.toolkit.PluginUtils;
|
|||
//import com.baomidou.mybatisplus.extension.handlers.AbstractSqlParserHandler;
|
|||
//import com.epmet.commons.mybatis.entity.DataScope;
|
|||
//import org.apache.ibatis.executor.statement.StatementHandler;
|
|||
//import org.apache.ibatis.mapping.BoundSql;
|
|||
//import org.apache.ibatis.mapping.MappedStatement;
|
|||
//import org.apache.ibatis.mapping.SqlCommandType;
|
|||
//import org.apache.ibatis.plugin.*;
|
|||
//import org.apache.ibatis.reflection.MetaObject;
|
|||
//import org.apache.ibatis.reflection.SystemMetaObject;
|
|||
//
|
|||
//import java.sql.Connection;
|
|||
//import java.util.Map;
|
|||
//import java.util.Properties;
|
|||
//
|
|||
///**
|
|||
// * 数据过滤
|
|||
// *
|
|||
// * @author Mark sunlightcs@gmail.com
|
|||
// * @since 1.0.0
|
|||
// */
|
|||
//@Intercepts({@Signature(type = StatementHandler.class, method = "prepare", args = {Connection.class, Integer.class})})
|
|||
//public class DataFilterInterceptorBak extends AbstractSqlParserHandler implements Interceptor {
|
|||
//
|
|||
// @Override
|
|||
// public Object intercept(Invocation invocation) throws Throwable {
|
|||
// StatementHandler statementHandler = (StatementHandler) PluginUtils.realTarget(invocation.getTarget());
|
|||
// MetaObject metaObject = SystemMetaObject.forObject(statementHandler);
|
|||
//
|
|||
// // SQL解析
|
|||
// this.sqlParser(metaObject);
|
|||
//
|
|||
// // 先判断是不是SELECT操作
|
|||
// MappedStatement mappedStatement = (MappedStatement) metaObject.getValue("delegate.mappedStatement");
|
|||
// if (!SqlCommandType.SELECT.equals(mappedStatement.getSqlCommandType())) {
|
|||
// return invocation.proceed();
|
|||
// }
|
|||
//
|
|||
// // 针对定义了rowBounds,做为mapper接口方法的参数
|
|||
// BoundSql boundSql = (BoundSql) metaObject.getValue("delegate.boundSql");
|
|||
// String originalSql = boundSql.getSql();
|
|||
// Object paramObj = boundSql.getParameterObject();
|
|||
//
|
|||
// // 判断参数里是否有DataScope对象
|
|||
// DataScope scope = null;
|
|||
// if (paramObj instanceof DataScope) {
|
|||
// scope = (DataScope) paramObj;
|
|||
// } else if (paramObj instanceof Map) {
|
|||
// for (Object arg : ((Map) paramObj).values()) {
|
|||
// if (arg instanceof DataScope) {
|
|||
// scope = (DataScope) arg;
|
|||
// break;
|
|||
// }
|
|||
// }
|
|||
// }
|
|||
//
|
|||
// // 不用数据过滤
|
|||
// if (scope == null) {
|
|||
// return invocation.proceed();
|
|||
// }
|
|||
//
|
|||
// // 拼接新SQL
|
|||
// String orderBy = "ORDER BY";
|
|||
// String groupBy = "GROUP BY";
|
|||
// if (originalSql.indexOf(groupBy) > -1) {
|
|||
// originalSql = originalSql.replace(groupBy, scope.getSqlFilter() + groupBy);
|
|||
// } else if (originalSql.indexOf(orderBy) > -1) {
|
|||
// originalSql = originalSql.replace(orderBy, scope.getSqlFilter() + orderBy);
|
|||
// } else {
|
|||
// originalSql = originalSql + scope.getSqlFilter();
|
|||
// }
|
|||
//
|
|||
// // 重写SQL
|
|||
// metaObject.setValue("delegate.boundSql.sql", originalSql);
|
|||
// return invocation.proceed();
|
|||
// }
|
|||
//
|
|||
// @Override
|
|||
// public Object plugin(Object target) {
|
|||
// if (target instanceof StatementHandler) {
|
|||
// return Plugin.wrap(target, this);
|
|||
// }
|
|||
// return target;
|
|||
// }
|
|||
//
|
|||
// @Override
|
|||
// public void setProperties(Properties properties) {
|
|||
//
|
|||
// }
|
|||
//}
|
|||
@ -0,0 +1,36 @@ |
|||
/** |
|||
* Copyright 2018 人人开源 http://www.renren.io
|
|||
* <p> |
|||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not |
|||
* use this file except in compliance with the License. You may obtain a copy of |
|||
* the License at |
|||
* <p> |
|||
* http://www.apache.org/licenses/LICENSE-2.0
|
|||
* <p> |
|||
* Unless required by applicable law or agreed to in writing, software |
|||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
|||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
|||
* License for the specific language governing permissions and limitations under |
|||
* the License. |
|||
*/ |
|||
|
|||
package com.epmet.commons.tools.annotation; |
|||
|
|||
import java.lang.annotation.*; |
|||
|
|||
/** |
|||
* 权限注解 |
|||
* @Author wxz |
|||
* @Description |
|||
* @Date 2020/4/23 16:17 |
|||
**/ |
|||
@Target(ElementType.METHOD) |
|||
@Retention(RetentionPolicy.RUNTIME) |
|||
@Documented |
|||
public @interface RequirePermission { |
|||
|
|||
String key() default ""; |
|||
|
|||
String desc() default ""; |
|||
|
|||
} |
|||
@ -0,0 +1,44 @@ |
|||
/** |
|||
* Copyright (c) 2018 人人开源 All rights reserved. |
|||
* |
|||
* https://www.renren.io
|
|||
* |
|||
* 版权所有,侵权必究! |
|||
*/ |
|||
|
|||
package com.epmet.commons.tools.aspect; |
|||
|
|||
import com.epmet.commons.tools.annotation.RequirePermission; |
|||
import org.aspectj.lang.JoinPoint; |
|||
import org.aspectj.lang.annotation.Aspect; |
|||
import org.aspectj.lang.annotation.Before; |
|||
import org.aspectj.lang.reflect.MethodSignature; |
|||
import org.springframework.stereotype.Component; |
|||
|
|||
/** |
|||
* 每次请求,过滤Api中配置的权限key出来 |
|||
* @Author wxz |
|||
* @Description |
|||
* @Date 2020/4/23 16:16 |
|||
**/ |
|||
@Aspect |
|||
@Component |
|||
public class AccessOpeAspect { |
|||
|
|||
/** |
|||
* 存储所需操作权限的 ThreadLocal |
|||
*/ |
|||
public static final ThreadLocal<String> requirePermissionTl = new ThreadLocal<>(); |
|||
|
|||
@Before("@annotation(com.epmet.commons.tools.annotation.RequirePermission)") |
|||
public void before(JoinPoint point) throws Throwable { |
|||
// 取RequirePermission注解
|
|||
MethodSignature methodSignature = (MethodSignature) point.getSignature(); |
|||
RequirePermission requirePermissionAnno = methodSignature.getMethod().getAnnotation(RequirePermission.class); |
|||
String key = requirePermissionAnno.key(); |
|||
String desc = requirePermissionAnno.desc(); |
|||
|
|||
// 放入ThreadLocal,供DataFilterAspect中使用
|
|||
requirePermissionTl.set(key); |
|||
} |
|||
} |
|||
@ -0,0 +1,42 @@ |
|||
package com.epmet.commons.tools.security.dto; |
|||
|
|||
import lombok.Data; |
|||
|
|||
@Data |
|||
public class BaseTokenDto { |
|||
/** |
|||
* 政府端:gov、居民端:resi、运营端:oper |
|||
*/ |
|||
private String app; |
|||
|
|||
/** |
|||
* PC端:web、微信小程序:wxmp |
|||
*/ |
|||
private String client; |
|||
|
|||
/** |
|||
* 用户ID |
|||
*/ |
|||
private String userId; |
|||
|
|||
/** |
|||
* token字符串 |
|||
*/ |
|||
private String token; |
|||
|
|||
public BaseTokenDto() { |
|||
} |
|||
|
|||
public BaseTokenDto(String app, String client, String userId) { |
|||
this.app = app; |
|||
this.client = client; |
|||
this.userId = userId; |
|||
} |
|||
|
|||
public BaseTokenDto(String app, String client, String userId, String token) { |
|||
this.app = app; |
|||
this.client = client; |
|||
this.userId = userId; |
|||
this.token = token; |
|||
} |
|||
} |
|||
@ -0,0 +1,77 @@ |
|||
package com.epmet.commons.tools.security.dto; |
|||
|
|||
import lombok.Data; |
|||
|
|||
import java.io.Serializable; |
|||
import java.util.List; |
|||
import java.util.Set; |
|||
|
|||
/** |
|||
* @Description 政府端登录信息 |
|||
* @Author yinzuomei |
|||
* @Date 2020/4/20 11:01 |
|||
*/ |
|||
@Data |
|||
public class GovTokenDto extends BaseTokenDto implements Serializable { |
|||
|
|||
/** |
|||
* sessionKey |
|||
*/ |
|||
private String sessionKey; |
|||
|
|||
/** |
|||
* openId |
|||
*/ |
|||
private String openId; |
|||
|
|||
/** |
|||
* unionId |
|||
*/ |
|||
private String unionId; |
|||
|
|||
/** |
|||
* 当前工作人员进入的客户id |
|||
*/ |
|||
private String customerId; |
|||
|
|||
/** |
|||
* 过期时间戳 |
|||
*/ |
|||
private Long expireTime; |
|||
|
|||
/** |
|||
* 最后一次更新时间 |
|||
*/ |
|||
private long updateTime; |
|||
|
|||
/** |
|||
* 当前登录的组织id(顶级) |
|||
*/ |
|||
private String agencyId; |
|||
|
|||
/** |
|||
* 当前网格对应的组织结构id的全路径用:隔开 |
|||
*/ |
|||
private String orgIdPath; |
|||
|
|||
/** |
|||
* 当前所在网格id |
|||
*/ |
|||
private String gridId; |
|||
|
|||
/** |
|||
* 部门id列表 |
|||
*/ |
|||
private List<String> deptIdList; |
|||
|
|||
/** |
|||
* 功能权限列表,实际上是gov_staff => staff_role => role_operation查询到的operationKey |
|||
*/ |
|||
private Set<String> permissions; |
|||
|
|||
/** |
|||
* 角色ID列表 |
|||
*/ |
|||
private Set<String> roleIdList; |
|||
} |
|||
|
|||
@ -1,33 +1,82 @@ |
|||
package com.epmet.commons.tools.security.user; |
|||
|
|||
import com.epmet.commons.tools.constant.Constant; |
|||
import com.epmet.commons.tools.constant.AppClientConstant; |
|||
import com.epmet.commons.tools.utils.HttpContextUtils; |
|||
import org.apache.commons.lang3.StringUtils; |
|||
import org.springframework.web.context.request.RequestAttributes; |
|||
import org.springframework.web.context.request.RequestContextHolder; |
|||
import org.springframework.web.context.request.ServletRequestAttributes; |
|||
import org.springframework.stereotype.Component; |
|||
|
|||
import javax.servlet.http.HttpServletRequest; |
|||
import java.util.List; |
|||
|
|||
/** |
|||
* 登录用户相关工具 |
|||
*/ |
|||
@Component |
|||
public class LoginUserUtil { |
|||
|
|||
//@Autowired
|
|||
//private
|
|||
|
|||
/** |
|||
* 查询登录用户的id |
|||
* @return |
|||
*/ |
|||
public static String getLoginUserId() { |
|||
public String getLoginUserId() { |
|||
HttpServletRequest request = HttpContextUtils.getHttpServletRequest(); |
|||
if (request == null) { |
|||
return null; |
|||
} |
|||
|
|||
String userId = request.getHeader(Constant.USER_KEY); |
|||
String userId = request.getHeader(AppClientConstant.USER_ID); |
|||
if (StringUtils.isBlank(userId)) { |
|||
return null; |
|||
} |
|||
return userId; |
|||
} |
|||
|
|||
/** |
|||
* 登录用户的App头信息 |
|||
* @return |
|||
*/ |
|||
public String getLoginUserApp() { |
|||
HttpServletRequest request = HttpContextUtils.getHttpServletRequest(); |
|||
if (request == null) { |
|||
return null; |
|||
} |
|||
|
|||
String app = request.getHeader(AppClientConstant.APP); |
|||
if (StringUtils.isBlank(app)) { |
|||
return null; |
|||
} |
|||
return app; |
|||
} |
|||
|
|||
/** |
|||
* 获取登录用户client头信息 |
|||
* @return |
|||
*/ |
|||
public String getLoginUserClient() { |
|||
HttpServletRequest request = HttpContextUtils.getHttpServletRequest(); |
|||
if (request == null) { |
|||
return null; |
|||
} |
|||
|
|||
String client = request.getHeader(AppClientConstant.CLIENT); |
|||
if (StringUtils.isBlank(client)) { |
|||
return null; |
|||
} |
|||
return client; |
|||
} |
|||
|
|||
/** |
|||
* 获取用户的部门ID列表 |
|||
* @return |
|||
*/ |
|||
public List<String> getLoginUserDepartments() { |
|||
String loginUserId = getLoginUserId(); |
|||
String loginUserApp = getLoginUserApp(); |
|||
String loginUserClient = getLoginUserClient(); |
|||
// todo
|
|||
return null; |
|||
} |
|||
} |
|||
|
|||
@ -0,0 +1,21 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<project xmlns="http://maven.apache.org/POM/4.0.0" |
|||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
|||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
|||
<parent> |
|||
<artifactId>gov-access</artifactId> |
|||
<groupId>com.epmet</groupId> |
|||
<version>2.0.0</version> |
|||
</parent> |
|||
<modelVersion>4.0.0</modelVersion> |
|||
|
|||
<artifactId>gov-access-client</artifactId> |
|||
|
|||
<dependencies> |
|||
<dependency> |
|||
<groupId>com.epmet</groupId> |
|||
<artifactId>epmet-commons-tools</artifactId> |
|||
<version>2.0.0</version> |
|||
</dependency> |
|||
</dependencies> |
|||
</project> |
|||
@ -0,0 +1,81 @@ |
|||
/** |
|||
* 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-04-24 |
|||
*/ |
|||
@Data |
|||
public class OperationScopeDTO implements Serializable { |
|||
|
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
/** |
|||
* id |
|||
*/ |
|||
private String id; |
|||
|
|||
/** |
|||
* 范围key |
|||
*/ |
|||
private String scopeKey; |
|||
|
|||
/** |
|||
* 范围名称 |
|||
*/ |
|||
private String scopeName; |
|||
|
|||
/** |
|||
* 是否删除,0:未删除,1:已删除 |
|||
*/ |
|||
private Integer delFlag; |
|||
|
|||
/** |
|||
* 乐观锁 |
|||
*/ |
|||
private Integer revision; |
|||
|
|||
/** |
|||
* 创建者id |
|||
*/ |
|||
private String createdBy; |
|||
|
|||
/** |
|||
* 创建时间 |
|||
*/ |
|||
private Date createdTime; |
|||
|
|||
/** |
|||
* 更新者id |
|||
*/ |
|||
private String updatedBy; |
|||
|
|||
/** |
|||
* 更新时间 |
|||
*/ |
|||
private Date updatedTime; |
|||
|
|||
} |
|||
@ -0,0 +1,82 @@ |
|||
/** |
|||
* 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 lombok.Data; |
|||
|
|||
import java.io.Serializable; |
|||
import java.util.Date; |
|||
|
|||
|
|||
/** |
|||
* 角色能进行那些操作 |
|||
* |
|||
* @author generator generator@elink-cn.com |
|||
* @since v1.0.0 2020-04-22 |
|||
*/ |
|||
@Data |
|||
public class RoleOperationDTO implements Serializable { |
|||
|
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
/** |
|||
* |
|||
*/ |
|||
private String id; |
|||
|
|||
/** |
|||
* 角色ID |
|||
*/ |
|||
private String roleId; |
|||
|
|||
/** |
|||
* 操作key |
|||
*/ |
|||
private String operationKey; |
|||
|
|||
/** |
|||
* 是否删除,0:未删除,1:已删除 |
|||
*/ |
|||
private Integer delFlag; |
|||
|
|||
/** |
|||
* 乐观锁 |
|||
*/ |
|||
private Integer revision; |
|||
|
|||
/** |
|||
* 创建者id |
|||
*/ |
|||
private String createdBy; |
|||
|
|||
/** |
|||
* 创建时间 |
|||
*/ |
|||
private Date createdTime; |
|||
|
|||
/** |
|||
* 更新者id |
|||
*/ |
|||
private String updatedBy; |
|||
|
|||
/** |
|||
* 更新时间 |
|||
*/ |
|||
private Date updatedTime; |
|||
|
|||
} |
|||
@ -0,0 +1,86 @@ |
|||
/** |
|||
* 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-04-24 |
|||
*/ |
|||
@Data |
|||
public class RoleScopeDTO implements Serializable { |
|||
|
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
/** |
|||
* |
|||
*/ |
|||
private String id; |
|||
|
|||
/** |
|||
* 角色ID |
|||
*/ |
|||
private String roleId; |
|||
|
|||
/** |
|||
* 操作key |
|||
*/ |
|||
private String operationKey; |
|||
|
|||
/** |
|||
* 范围Key |
|||
*/ |
|||
private String scopeKey; |
|||
|
|||
/** |
|||
* 是否删除,0:未删除,1:已删除 |
|||
*/ |
|||
private Integer delFlag; |
|||
|
|||
/** |
|||
* 乐观锁 |
|||
*/ |
|||
private Integer revision; |
|||
|
|||
/** |
|||
* 创建者id |
|||
*/ |
|||
private String createdBy; |
|||
|
|||
/** |
|||
* 创建时间 |
|||
*/ |
|||
private Date createdTime; |
|||
|
|||
/** |
|||
* 更新者id |
|||
*/ |
|||
private String updatedBy; |
|||
|
|||
/** |
|||
* 更新时间 |
|||
*/ |
|||
private Date updatedTime; |
|||
|
|||
} |
|||
@ -0,0 +1,18 @@ |
|||
package com.epmet.dto.form; |
|||
|
|||
import lombok.Data; |
|||
|
|||
import javax.validation.constraints.NotBlank; |
|||
|
|||
@Data |
|||
public class OperationScopeFormDTO { |
|||
|
|||
public interface ListOperationScopeGroup {} |
|||
|
|||
@NotBlank(message = "角色ID不能为空", groups = {ListOperationScopeGroup.class}) |
|||
private String roleId; |
|||
|
|||
@NotBlank(message = "操作的key不能为空", groups = {ListOperationScopeGroup.class}) |
|||
private String operationKey; |
|||
|
|||
} |
|||
@ -0,0 +1,54 @@ |
|||
package com.epmet.dto.form; |
|||
|
|||
import lombok.Data; |
|||
|
|||
import javax.validation.constraints.NotBlank; |
|||
import java.util.Set; |
|||
|
|||
@Data |
|||
public class StaffPermCacheFormDTO { |
|||
|
|||
/** |
|||
* 更新权限缓存分组 |
|||
*/ |
|||
public interface UpdatePermissionCache {} |
|||
|
|||
/** |
|||
* 查询当前权限列表 |
|||
*/ |
|||
public interface GetStaffCurrPermissions {} |
|||
|
|||
/** |
|||
* 工作人员 id |
|||
*/ |
|||
@NotBlank(message = "工作人员ID不能为空", groups = {UpdatePermissionCache.class, GetStaffCurrPermissions.class}) |
|||
private String staffId; |
|||
|
|||
/** |
|||
* 登录头信息app |
|||
*/ |
|||
@NotBlank(message = "登录头信息app不能为空", groups = {UpdatePermissionCache.class, GetStaffCurrPermissions.class}) |
|||
private String app; |
|||
|
|||
/** |
|||
* 登录头信息client |
|||
*/ |
|||
@NotBlank(message = "登录头信息client不能为空", groups = {UpdatePermissionCache.class, GetStaffCurrPermissions.class}) |
|||
private String client; |
|||
|
|||
/** |
|||
* 组织ID路径 |
|||
*/ |
|||
private String orgIdPath; |
|||
|
|||
/** |
|||
* 权限列表 |
|||
*/ |
|||
private Set<String> permissions; |
|||
|
|||
/** |
|||
* 角色列表 |
|||
*/ |
|||
private Set<String> roleIdList; |
|||
|
|||
} |
|||
@ -0,0 +1,28 @@ |
|||
package com.epmet.dto.result; |
|||
|
|||
import lombok.Data; |
|||
|
|||
@Data |
|||
public class RoleOpeScopeResultDTO { |
|||
|
|||
/** |
|||
* 角色ID |
|||
*/ |
|||
private String roleId; |
|||
|
|||
/** |
|||
* 范围key |
|||
*/ |
|||
private String scopeKey; |
|||
|
|||
/** |
|||
* 范围名称 |
|||
*/ |
|||
private String scopeName; |
|||
|
|||
/** |
|||
* 范围序号 |
|||
*/ |
|||
private String scopeIndex; |
|||
|
|||
} |
|||
@ -0,0 +1,87 @@ |
|||
/** |
|||
* 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.result; |
|||
|
|||
import lombok.Data; |
|||
|
|||
import java.io.Serializable; |
|||
import java.util.Date; |
|||
|
|||
|
|||
/** |
|||
* 角色能进行那些操作 |
|||
* |
|||
* @author generator generator@elink-cn.com |
|||
* @since v1.0.0 2020-04-22 |
|||
*/ |
|||
@Data |
|||
public class RoleOperationResultDTO implements Serializable { |
|||
|
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
/** |
|||
* |
|||
*/ |
|||
private String id; |
|||
|
|||
/** |
|||
* 角色ID |
|||
*/ |
|||
private String roleId; |
|||
|
|||
/** |
|||
* 操作key |
|||
*/ |
|||
private String operationKey; |
|||
|
|||
/** |
|||
* 操作名称 |
|||
*/ |
|||
private String operationName; |
|||
|
|||
/** |
|||
* 是否删除,0:未删除,1:已删除 |
|||
*/ |
|||
private String delFlag; |
|||
|
|||
/** |
|||
* 乐观锁 |
|||
*/ |
|||
private Integer revision; |
|||
|
|||
/** |
|||
* 创建者id |
|||
*/ |
|||
private String createdBy; |
|||
|
|||
/** |
|||
* 创建时间 |
|||
*/ |
|||
private Date createdTime; |
|||
|
|||
/** |
|||
* 更新者id |
|||
*/ |
|||
private String updatedBy; |
|||
|
|||
/** |
|||
* 更新时间 |
|||
*/ |
|||
private Date updatedTime; |
|||
|
|||
} |
|||
@ -0,0 +1,31 @@ |
|||
package com.epmet.dto.result; |
|||
|
|||
import lombok.Data; |
|||
|
|||
import javax.validation.constraints.NotBlank; |
|||
import java.util.Set; |
|||
|
|||
@Data |
|||
public class StaffPermCacheResultDTO { |
|||
|
|||
/** |
|||
* 权限列表 |
|||
*/ |
|||
private Set<String> permissions; |
|||
|
|||
/** |
|||
* 角色列表 |
|||
*/ |
|||
private Set<String> roleIdList; |
|||
|
|||
/** |
|||
* 组织ID |
|||
*/ |
|||
private String orgIdPath; |
|||
|
|||
/** |
|||
* 网格ID |
|||
*/ |
|||
private String gridId; |
|||
|
|||
} |
|||
@ -0,0 +1,182 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<project xmlns="http://maven.apache.org/POM/4.0.0" |
|||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
|||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
|||
<version>0.3.0</version> |
|||
<parent> |
|||
<artifactId>gov-access</artifactId> |
|||
<groupId>com.epmet</groupId> |
|||
<version>2.0.0</version> |
|||
</parent> |
|||
<modelVersion>4.0.0</modelVersion> |
|||
|
|||
<artifactId>gov-access-server</artifactId> |
|||
<packaging>jar</packaging> |
|||
|
|||
<dependencies> |
|||
<dependency> |
|||
<groupId>com.epmet</groupId> |
|||
<artifactId>gov-access-client</artifactId> |
|||
<version>2.0.0</version> |
|||
</dependency> |
|||
<dependency> |
|||
<groupId>com.epmet</groupId> |
|||
<artifactId>epmet-commons-tools</artifactId> |
|||
<version>2.0.0</version> |
|||
</dependency> |
|||
<dependency> |
|||
<groupId>com.epmet</groupId> |
|||
<artifactId>epmet-commons-mybatis</artifactId> |
|||
<version>2.0.0</version> |
|||
</dependency> |
|||
<dependency> |
|||
<groupId>org.springframework.boot</groupId> |
|||
<artifactId>spring-boot-starter-web</artifactId> |
|||
</dependency> |
|||
<dependency> |
|||
<groupId>org.springframework</groupId> |
|||
<artifactId>spring-context-support</artifactId> |
|||
</dependency> |
|||
<dependency> |
|||
<groupId>org.springframework.boot</groupId> |
|||
<artifactId>spring-boot-starter-actuator</artifactId> |
|||
</dependency> |
|||
<dependency> |
|||
<groupId>de.codecentric</groupId> |
|||
<artifactId>spring-boot-admin-starter-client</artifactId> |
|||
<version>${spring.boot.admin.version}</version> |
|||
</dependency> |
|||
<dependency> |
|||
<groupId>com.alibaba.cloud</groupId> |
|||
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId> |
|||
</dependency> |
|||
<dependency> |
|||
<groupId>com.alibaba.cloud</groupId> |
|||
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId> |
|||
</dependency> |
|||
<!-- 替换Feign原生httpclient --> |
|||
<dependency> |
|||
<groupId>io.github.openfeign</groupId> |
|||
<artifactId>feign-httpclient</artifactId> |
|||
<version>10.3.0</version> |
|||
</dependency> |
|||
</dependencies> |
|||
|
|||
<build> |
|||
<finalName>${project.artifactId}</finalName> |
|||
<plugins> |
|||
<plugin> |
|||
<groupId>org.springframework.boot</groupId> |
|||
<artifactId>spring-boot-maven-plugin</artifactId> |
|||
</plugin> |
|||
<plugin> |
|||
<groupId>org.apache.maven.plugins</groupId> |
|||
<artifactId>maven-surefire-plugin</artifactId> |
|||
<configuration> |
|||
<skipTests>true</skipTests> |
|||
</configuration> |
|||
</plugin> |
|||
</plugins> |
|||
<sourceDirectory>${project.basedir}/src/main/java</sourceDirectory> |
|||
<resources> |
|||
<resource> |
|||
<filtering>true</filtering> |
|||
<directory>${basedir}/src/main/resources</directory> |
|||
</resource> |
|||
</resources> |
|||
</build> |
|||
|
|||
<profiles> |
|||
<profile> |
|||
<id>dev-local</id> |
|||
<activation> |
|||
<activeByDefault>true</activeByDefault> |
|||
</activation> |
|||
<properties> |
|||
<server.port>8099</server.port> |
|||
<spring.profiles.active>dev</spring.profiles.active> |
|||
|
|||
<!-- 数据库配置--> |
|||
<spring.datasource.druid.url> |
|||
<![CDATA[jdbc:mysql://192.168.1.130:3306/epmet_gov_access?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai]]> |
|||
</spring.datasource.druid.url> |
|||
<spring.datasource.druid.username>epmet_gov_access_user</spring.datasource.druid.username> |
|||
<spring.datasource.druid.password>EpmEt-db-UsEr</spring.datasource.druid.password> |
|||
<!-- redis配置 --> |
|||
<spring.redis.index>0</spring.redis.index> |
|||
<spring.redis.host>192.168.1.130</spring.redis.host> |
|||
<spring.redis.port>6379</spring.redis.port> |
|||
<spring.redis.password>123456</spring.redis.password> |
|||
<!-- nacos --> |
|||
<nacos.register-enabled>false</nacos.register-enabled> |
|||
<nacos.server-addr>122.152.200.70:8848</nacos.server-addr> |
|||
<nacos.discovery.namespace>fcd6fc8f-ca3a-4b01-8026-2b05cdc5976b</nacos.discovery.namespace> |
|||
<nacos.config.namespace></nacos.config.namespace> |
|||
<nacos.config.group></nacos.config.group> |
|||
<nacos.config-enabled>false</nacos.config-enabled> |
|||
<nacos.ip/> |
|||
</properties> |
|||
</profile> |
|||
<profile> |
|||
<id>dev</id> |
|||
<!--<activation> |
|||
<activeByDefault>true</activeByDefault> |
|||
</activation>--> |
|||
<properties> |
|||
<server.port>8099</server.port> |
|||
<spring.profiles.active>dev</spring.profiles.active> |
|||
|
|||
<!-- 数据库配置--> |
|||
<spring.datasource.druid.url> |
|||
<![CDATA[jdbc:mysql://rm-m5ef9t617j6o5eup7.mysql.rds.aliyuncs.com:3306/epmet_gov_access_dev?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai]]> |
|||
</spring.datasource.druid.url> |
|||
<spring.datasource.druid.username>epmet</spring.datasource.druid.username> |
|||
<spring.datasource.druid.password>elink@833066</spring.datasource.druid.password> |
|||
<!-- redis配置 --> |
|||
<spring.redis.index>0</spring.redis.index> |
|||
<spring.redis.host>r-m5eoz5b6tkx09y6bpz.redis.rds.aliyuncs.com</spring.redis.host> |
|||
<spring.redis.port>6379</spring.redis.port> |
|||
<spring.redis.password>EpmEtrEdIs!q@w</spring.redis.password> |
|||
<!-- nacos --> |
|||
<nacos.register-enabled>true</nacos.register-enabled> |
|||
<nacos.server-addr>192.168.10.150:8848</nacos.server-addr> |
|||
<nacos.discovery.namespace>67e3c350-533e-4d7c-9f8f-faf1b4aa82ae</nacos.discovery.namespace> |
|||
<nacos.config.namespace></nacos.config.namespace> |
|||
<nacos.config.group></nacos.config.group> |
|||
<nacos.config-enabled>false</nacos.config-enabled> |
|||
<nacos.ip/> |
|||
</properties> |
|||
</profile> |
|||
<profile> |
|||
<id>test</id> |
|||
<!--<activation> |
|||
<activeByDefault>true</activeByDefault> |
|||
</activation>--> |
|||
<properties> |
|||
<server.port>8099</server.port> |
|||
<spring.profiles.active>test</spring.profiles.active> |
|||
|
|||
<!-- 数据库配置--> |
|||
<spring.datasource.druid.url> |
|||
<![CDATA[jdbc:mysql://47.104.224.45:3308/epmet_gov_access?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai]]> |
|||
</spring.datasource.druid.url> |
|||
<spring.datasource.druid.username>epmet</spring.datasource.druid.username> |
|||
<spring.datasource.druid.password>elink@833066</spring.datasource.druid.password> |
|||
<!-- redis配置 --> |
|||
<spring.redis.index>0</spring.redis.index> |
|||
<spring.redis.host>10.10.10.248</spring.redis.host> |
|||
<spring.redis.port>6379</spring.redis.port> |
|||
<spring.redis.password>123456</spring.redis.password> |
|||
<!-- nacos --> |
|||
<nacos.register-enabled>true</nacos.register-enabled> |
|||
<nacos.server-addr>122.152.200.70:8848</nacos.server-addr> |
|||
<nacos.discovery.namespace>fcd6fc8f-ca3a-4b01-8026-2b05cdc5976b</nacos.discovery.namespace> |
|||
<nacos.config.namespace></nacos.config.namespace> |
|||
<nacos.config.group></nacos.config.group> |
|||
<nacos.config-enabled>false</nacos.config-enabled> |
|||
<nacos.ip/> |
|||
</properties> |
|||
</profile> |
|||
</profiles> |
|||
|
|||
</project> |
|||
@ -0,0 +1,20 @@ |
|||
package com.epmet; |
|||
|
|||
import org.springframework.boot.SpringApplication; |
|||
import org.springframework.boot.autoconfigure.SpringBootApplication; |
|||
import org.springframework.cloud.client.discovery.EnableDiscoveryClient; |
|||
import org.springframework.cloud.openfeign.EnableFeignClients; |
|||
|
|||
/** |
|||
* |
|||
* @author Mark sunlightcs@gmail.com |
|||
* @since 1.0.0 |
|||
*/ |
|||
@SpringBootApplication |
|||
@EnableDiscoveryClient |
|||
@EnableFeignClients |
|||
public class GovAccessApplication { |
|||
public static void main(String[] args) { |
|||
SpringApplication.run(GovAccessApplication.class, args); |
|||
} |
|||
} |
|||
@ -0,0 +1,26 @@ |
|||
/** |
|||
* Copyright (c) 2018 人人开源 All rights reserved. |
|||
* <p> |
|||
* https://www.renren.io
|
|||
* <p> |
|||
* 版权所有,侵权必究! |
|||
*/ |
|||
|
|||
package com.epmet.config; |
|||
|
|||
import com.epmet.commons.tools.config.ModuleConfig; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
/** |
|||
* 模块配置信息-新闻公告模块 |
|||
* |
|||
* @author Mark sunlightcs@gmail.com |
|||
* @since 1.0.0 |
|||
*/ |
|||
@Service |
|||
public class ModuleConfigImpl implements ModuleConfig { |
|||
@Override |
|||
public String getName() { |
|||
return "govaccess"; |
|||
} |
|||
} |
|||
@ -0,0 +1,81 @@ |
|||
package com.epmet.controller; |
|||
|
|||
import com.epmet.commons.tools.security.dto.GovTokenDto; |
|||
import com.epmet.commons.tools.utils.Result; |
|||
import com.epmet.commons.tools.validator.ValidatorUtils; |
|||
import com.epmet.dto.OperationScopeDTO; |
|||
import com.epmet.dto.form.OperationScopeFormDTO; |
|||
import com.epmet.dto.form.StaffPermCacheFormDTO; |
|||
import com.epmet.dto.result.RoleOpeScopeResultDTO; |
|||
import com.epmet.dto.result.StaffPermCacheResultDTO; |
|||
import com.epmet.entity.OperationScopeEntity; |
|||
import com.epmet.service.AccessService; |
|||
import org.springframework.beans.BeanUtils; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.web.bind.annotation.*; |
|||
|
|||
import java.util.ArrayList; |
|||
import java.util.List; |
|||
import java.util.Set; |
|||
|
|||
/** |
|||
* 权限相关Api |
|||
* @Author wxz |
|||
* @Description |
|||
* @Date 2020/4/23 17:54 |
|||
**/ |
|||
@RestController |
|||
@RequestMapping("access") |
|||
public class AccessController { |
|||
|
|||
@Autowired |
|||
private AccessService accessService; |
|||
|
|||
/** |
|||
* 更新工作人员权限缓存 |
|||
* @param staffPermCacheFormDTO |
|||
* @return |
|||
*/ |
|||
@PostMapping("updatepermissioncache") |
|||
public Result updatePermissionCache(@RequestBody StaffPermCacheFormDTO staffPermCacheFormDTO) { |
|||
ValidatorUtils.validateEntity(staffPermCacheFormDTO, StaffPermCacheFormDTO.UpdatePermissionCache.class); |
|||
String staffId = staffPermCacheFormDTO.getStaffId(); |
|||
String app = staffPermCacheFormDTO.getApp(); |
|||
String client = staffPermCacheFormDTO.getClient(); |
|||
Set<String> permissions = staffPermCacheFormDTO.getPermissions(); |
|||
Set<String> roleIdList = staffPermCacheFormDTO.getRoleIdList(); |
|||
String orgId = staffPermCacheFormDTO.getOrgIdPath(); |
|||
accessService.updatePermissionCache(staffId, app, client, permissions, roleIdList, orgId); |
|||
return new Result(); |
|||
} |
|||
|
|||
/** |
|||
* 查询用户当前权限列表(DataFilterAspect中用到) |
|||
* @return |
|||
*/ |
|||
@PostMapping("getcurrpermissions") |
|||
public Result<StaffPermCacheResultDTO> getStaffCurrPermissions(@RequestBody StaffPermCacheFormDTO dto) { |
|||
ValidatorUtils.validateEntity(dto, StaffPermCacheFormDTO.GetStaffCurrPermissions.class); |
|||
GovTokenDto govTokenDto = accessService.listStaffCurrPermissions(dto.getApp(), dto.getClient(), dto.getStaffId()); |
|||
StaffPermCacheResultDTO resultDTO = null; |
|||
if (govTokenDto != null) { |
|||
resultDTO = new StaffPermCacheResultDTO(); |
|||
resultDTO.setPermissions(govTokenDto.getPermissions()); |
|||
resultDTO.setRoleIdList(govTokenDto.getRoleIdList()); |
|||
resultDTO.setOrgIdPath(govTokenDto.getOrgIdPath()); |
|||
resultDTO.setGridId(govTokenDto.getGridId()); |
|||
} |
|||
return new Result<StaffPermCacheResultDTO>().ok(resultDTO); |
|||
} |
|||
|
|||
/** |
|||
* 查询角色的操作key对应操作范围列表(缓存) |
|||
* @return |
|||
*/ |
|||
@PostMapping("operationscopes") |
|||
public Result<Set<RoleOpeScopeResultDTO>> getOperationScopesByRoleId(@RequestBody OperationScopeFormDTO operationScopeFormDTO) { |
|||
ValidatorUtils.validateEntity(operationScopeFormDTO, OperationScopeFormDTO.ListOperationScopeGroup.class); |
|||
Set<RoleOpeScopeResultDTO> scopes = accessService.listOperationScopesByRoleId(operationScopeFormDTO.getRoleId(), operationScopeFormDTO.getOperationKey()); |
|||
return new Result<Set<RoleOpeScopeResultDTO>>().ok(scopes); |
|||
} |
|||
} |
|||
@ -0,0 +1,33 @@ |
|||
package com.epmet.controller; |
|||
|
|||
import com.epmet.commons.tools.utils.Result; |
|||
import com.epmet.dto.result.RoleOperationResultDTO; |
|||
import com.epmet.service.RoleOperationService; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.web.bind.annotation.PathVariable; |
|||
import org.springframework.web.bind.annotation.PostMapping; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
|
|||
import java.util.List; |
|||
|
|||
@RestController |
|||
@RequestMapping("role") |
|||
public class RoleController { |
|||
|
|||
@Autowired |
|||
private RoleOperationService roleOperationService; |
|||
|
|||
/** |
|||
* 查询角色对应的操作列表 |
|||
* @param roleId |
|||
* @return |
|||
*/ |
|||
@PostMapping("operations/{roleId}") |
|||
public Result<List<RoleOperationResultDTO>> listOperationsByRoleId(@PathVariable("roleId") String roleId) { |
|||
List<RoleOperationResultDTO> roleOperationResultDTOS = roleOperationService.listOperationsByRoleId(roleId); |
|||
return new Result<List<RoleOperationResultDTO>>().ok(roleOperationResultDTOS); |
|||
} |
|||
|
|||
|
|||
} |
|||
@ -0,0 +1,17 @@ |
|||
package com.epmet.controller; |
|||
|
|||
import org.springframework.web.bind.annotation.GetMapping; |
|||
import org.springframework.web.bind.annotation.PostMapping; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
|
|||
@RestController |
|||
@RequestMapping("test") |
|||
public class TestController { |
|||
|
|||
@GetMapping("test") |
|||
public void test() { |
|||
System.out.println(666); |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,47 @@ |
|||
/** |
|||
* 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.dao; |
|||
|
|||
import com.epmet.commons.mybatis.dao.BaseDao; |
|||
import com.epmet.dto.result.RoleOpeScopeResultDTO; |
|||
import com.epmet.entity.OperationScopeEntity; |
|||
import org.apache.ibatis.annotations.Mapper; |
|||
import org.apache.ibatis.annotations.Param; |
|||
import org.springframework.context.annotation.Scope; |
|||
|
|||
import java.util.List; |
|||
import java.util.Set; |
|||
|
|||
/** |
|||
* 权限范围表 |
|||
* |
|||
* @author generator generator@elink-cn.com |
|||
* @since v1.0.0 2020-04-24 |
|||
*/ |
|||
@Mapper |
|||
public interface OperationScopeDao extends BaseDao<OperationScopeEntity> { |
|||
|
|||
/** |
|||
* 查询角色的操作key对应操作范围列表 |
|||
* @param roleId 角色id |
|||
* @param operationKey 操作key |
|||
* @return |
|||
*/ |
|||
Set<RoleOpeScopeResultDTO> listOperationScopesByRoleId(@Param("roleId") String roleId, |
|||
@Param("operationKey") String operationKey); |
|||
} |
|||
@ -0,0 +1,38 @@ |
|||
/** |
|||
* 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.dao; |
|||
|
|||
import com.epmet.commons.mybatis.dao.BaseDao; |
|||
import com.epmet.dto.result.RoleOperationResultDTO; |
|||
import com.epmet.entity.RoleOperationEntity; |
|||
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-04-22 |
|||
*/ |
|||
@Mapper |
|||
public interface RoleOperationDao extends BaseDao<RoleOperationEntity> { |
|||
|
|||
List<RoleOperationResultDTO> listOperationsByRoleId(@Param("roleId") String roleId); |
|||
} |
|||
@ -0,0 +1,33 @@ |
|||
/** |
|||
* 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.dao; |
|||
|
|||
import com.epmet.commons.mybatis.dao.BaseDao; |
|||
import com.epmet.entity.RoleScopeEntity; |
|||
import org.apache.ibatis.annotations.Mapper; |
|||
|
|||
/** |
|||
* 角色能操作哪些范围 |
|||
* |
|||
* @author generator generator@elink-cn.com |
|||
* @since v1.0.0 2020-04-24 |
|||
*/ |
|||
@Mapper |
|||
public interface RoleScopeDao extends BaseDao<RoleScopeEntity> { |
|||
|
|||
} |
|||
@ -0,0 +1,51 @@ |
|||
/** |
|||
* 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.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-04-24 |
|||
*/ |
|||
@Data |
|||
@EqualsAndHashCode(callSuper=false) |
|||
@TableName("operation_scope") |
|||
public class OperationScopeEntity extends BaseEpmetEntity { |
|||
|
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
/** |
|||
* 范围key |
|||
*/ |
|||
private String scopeKey; |
|||
|
|||
/** |
|||
* 范围名称 |
|||
*/ |
|||
private String scopeName; |
|||
|
|||
} |
|||
@ -0,0 +1,51 @@ |
|||
/** |
|||
* 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.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-04-22 |
|||
*/ |
|||
@Data |
|||
@EqualsAndHashCode(callSuper=false) |
|||
@TableName("role_operation") |
|||
public class RoleOperationEntity extends BaseEpmetEntity { |
|||
|
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
/** |
|||
* 角色ID |
|||
*/ |
|||
private String roleId; |
|||
|
|||
/** |
|||
* 操作key |
|||
*/ |
|||
private String operationKey; |
|||
|
|||
} |
|||
@ -0,0 +1,56 @@ |
|||
/** |
|||
* 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.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-04-24 |
|||
*/ |
|||
@Data |
|||
@EqualsAndHashCode(callSuper=false) |
|||
@TableName("role_scope") |
|||
public class RoleScopeEntity extends BaseEpmetEntity { |
|||
|
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
/** |
|||
* 角色ID |
|||
*/ |
|||
private String roleId; |
|||
|
|||
/** |
|||
* 操作key |
|||
*/ |
|||
private String operationKey; |
|||
|
|||
/** |
|||
* 范围Key |
|||
*/ |
|||
private String scopeKey; |
|||
|
|||
} |
|||
@ -0,0 +1,62 @@ |
|||
/** |
|||
* 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.excel; |
|||
|
|||
import cn.afterturn.easypoi.excel.annotation.Excel; |
|||
import lombok.Data; |
|||
|
|||
import java.util.Date; |
|||
|
|||
/** |
|||
* 角色能进行那些操作 |
|||
* |
|||
* @author generator generator@elink-cn.com |
|||
* @since v1.0.0 2020-04-22 |
|||
*/ |
|||
@Data |
|||
public class RoleOperationExcel { |
|||
|
|||
@Excel(name = "") |
|||
private String id; |
|||
|
|||
@Excel(name = "角色ID") |
|||
private String roleId; |
|||
|
|||
@Excel(name = "操作key") |
|||
private String operationKey; |
|||
|
|||
@Excel(name = "是否删除,0:未删除,1:已删除") |
|||
private Integer delFlag; |
|||
|
|||
@Excel(name = "乐观锁") |
|||
private Integer revision; |
|||
|
|||
@Excel(name = "创建者id") |
|||
private String createdBy; |
|||
|
|||
@Excel(name = "创建时间") |
|||
private Date createdTime; |
|||
|
|||
@Excel(name = "更新者id") |
|||
private String updatedBy; |
|||
|
|||
@Excel(name = "更新时间") |
|||
private Date updatedTime; |
|||
|
|||
|
|||
} |
|||
@ -0,0 +1,43 @@ |
|||
package com.epmet.redis; |
|||
|
|||
import cn.hutool.core.bean.BeanUtil; |
|||
import com.epmet.commons.tools.redis.RedisKeys; |
|||
import com.epmet.commons.tools.redis.RedisUtils; |
|||
import com.epmet.dto.result.RoleOpeScopeResultDTO; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Component; |
|||
|
|||
import java.util.Set; |
|||
|
|||
/** |
|||
* 角色的操作权限对应的操作范围Redis |
|||
*/ |
|||
@Component |
|||
public class RoleOpeScopeRedis { |
|||
|
|||
@Autowired |
|||
private RedisUtils redisUtils; |
|||
|
|||
/** |
|||
* 缓存角色操作范围 |
|||
* @param roleId |
|||
* @param opeKey |
|||
* @param scopes |
|||
*/ |
|||
public void setRoleOpeScopes(String roleId, String opeKey, Set<RoleOpeScopeResultDTO> scopes) { |
|||
String roleOpeScopesKey = RedisKeys.getRoleOpeScopesKey(roleId, opeKey); |
|||
redisUtils.set(roleOpeScopesKey, scopes); |
|||
} |
|||
|
|||
/** |
|||
* 查询角色操作范围 |
|||
* @param roleId |
|||
* @param opeKey |
|||
* @return |
|||
*/ |
|||
public Set<RoleOpeScopeResultDTO> getRoleOpeScopes(String roleId, String opeKey) { |
|||
String roleOpeScopesKey = RedisKeys.getRoleOpeScopesKey(roleId, opeKey); |
|||
return (Set<RoleOpeScopeResultDTO>)redisUtils.get(roleOpeScopesKey); |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,31 @@ |
|||
package com.epmet.service; |
|||
|
|||
import com.epmet.commons.tools.security.dto.GovTokenDto; |
|||
import com.epmet.dto.result.RoleOpeScopeResultDTO; |
|||
import com.epmet.entity.OperationScopeEntity; |
|||
|
|||
import java.util.List; |
|||
import java.util.Set; |
|||
|
|||
public interface AccessService { |
|||
/** |
|||
* 更新权限缓存 |
|||
* @param staffId |
|||
* @param permissions |
|||
*/ |
|||
void updatePermissionCache(String staffId, String app, String client, Set<String> permissions, Set<String> roleIdList, String orgIdPath); |
|||
|
|||
/** |
|||
* 查询用户当前权限列表 |
|||
* @return |
|||
*/ |
|||
GovTokenDto listStaffCurrPermissions(String app, String client, String staffId); |
|||
|
|||
/** |
|||
* 查询角色的操作key对应操作范围列表 |
|||
* @param roleId |
|||
* @param operationKey |
|||
* @return |
|||
*/ |
|||
Set<RoleOpeScopeResultDTO> listOperationScopesByRoleId(String roleId, String operationKey); |
|||
} |
|||
@ -0,0 +1,95 @@ |
|||
/** |
|||
* 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.service; |
|||
|
|||
import com.epmet.commons.mybatis.service.BaseService; |
|||
import com.epmet.commons.tools.page.PageData; |
|||
import com.epmet.dto.OperationScopeDTO; |
|||
import com.epmet.entity.OperationScopeEntity; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* 权限范围表 |
|||
* |
|||
* @author generator generator@elink-cn.com |
|||
* @since v1.0.0 2020-04-24 |
|||
*/ |
|||
public interface OperationScopeService extends BaseService<OperationScopeEntity> { |
|||
|
|||
/** |
|||
* 默认分页 |
|||
* |
|||
* @param params |
|||
* @return PageData<OperationScopeDTO> |
|||
* @author generator |
|||
* @date 2020-04-24 |
|||
*/ |
|||
PageData<OperationScopeDTO> page(Map<String, Object> params); |
|||
|
|||
/** |
|||
* 默认查询 |
|||
* |
|||
* @param params |
|||
* @return java.util.List<OperationScopeDTO> |
|||
* @author generator |
|||
* @date 2020-04-24 |
|||
*/ |
|||
List<OperationScopeDTO> list(Map<String, Object> params); |
|||
|
|||
/** |
|||
* 单条查询 |
|||
* |
|||
* @param id |
|||
* @return OperationScopeDTO |
|||
* @author generator |
|||
* @date 2020-04-24 |
|||
*/ |
|||
OperationScopeDTO get(String id); |
|||
|
|||
/** |
|||
* 默认保存 |
|||
* |
|||
* @param dto |
|||
* @return void |
|||
* @author generator |
|||
* @date 2020-04-24 |
|||
*/ |
|||
void save(OperationScopeDTO dto); |
|||
|
|||
/** |
|||
* 默认更新 |
|||
* |
|||
* @param dto |
|||
* @return void |
|||
* @author generator |
|||
* @date 2020-04-24 |
|||
*/ |
|||
void update(OperationScopeDTO dto); |
|||
|
|||
/** |
|||
* 批量删除 |
|||
* |
|||
* @param ids |
|||
* @return void |
|||
* @author generator |
|||
* @date 2020-04-24 |
|||
*/ |
|||
void delete(String[] ids); |
|||
} |
|||
@ -0,0 +1,103 @@ |
|||
/** |
|||
* 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.service; |
|||
|
|||
import com.epmet.commons.mybatis.service.BaseService; |
|||
import com.epmet.commons.tools.page.PageData; |
|||
import com.epmet.dto.RoleOperationDTO; |
|||
import com.epmet.dto.result.RoleOperationResultDTO; |
|||
import com.epmet.entity.RoleOperationEntity; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* 角色能进行那些操作 |
|||
* |
|||
* @author generator generator@elink-cn.com |
|||
* @since v1.0.0 2020-04-22 |
|||
*/ |
|||
public interface RoleOperationService extends BaseService<RoleOperationEntity> { |
|||
|
|||
/** |
|||
* 默认分页 |
|||
* |
|||
* @param params |
|||
* @return PageData<RoleOperationDTO> |
|||
* @author generator |
|||
* @date 2020-04-22 |
|||
*/ |
|||
PageData<RoleOperationDTO> page(Map<String, Object> params); |
|||
|
|||
/** |
|||
* 默认查询 |
|||
* |
|||
* @param params |
|||
* @return java.util.List<RoleOperationDTO> |
|||
* @author generator |
|||
* @date 2020-04-22 |
|||
*/ |
|||
List<RoleOperationDTO> list(Map<String, Object> params); |
|||
|
|||
/** |
|||
* 单条查询 |
|||
* |
|||
* @param id |
|||
* @return RoleOperationDTO |
|||
* @author generator |
|||
* @date 2020-04-22 |
|||
*/ |
|||
RoleOperationDTO get(String id); |
|||
|
|||
/** |
|||
* 默认保存 |
|||
* |
|||
* @param dto |
|||
* @return void |
|||
* @author generator |
|||
* @date 2020-04-22 |
|||
*/ |
|||
void save(RoleOperationDTO dto); |
|||
|
|||
/** |
|||
* 默认更新 |
|||
* |
|||
* @param dto |
|||
* @return void |
|||
* @author generator |
|||
* @date 2020-04-22 |
|||
*/ |
|||
void update(RoleOperationDTO dto); |
|||
|
|||
/** |
|||
* 批量删除 |
|||
* |
|||
* @param ids |
|||
* @return void |
|||
* @author generator |
|||
* @date 2020-04-22 |
|||
*/ |
|||
void delete(String[] ids); |
|||
|
|||
/** |
|||
* 查询角色对应的操作列表 |
|||
* @param roleId |
|||
* @return |
|||
*/ |
|||
List<RoleOperationResultDTO> listOperationsByRoleId(String roleId); |
|||
} |
|||
@ -0,0 +1,95 @@ |
|||
/** |
|||
* 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.service; |
|||
|
|||
import com.epmet.commons.mybatis.service.BaseService; |
|||
import com.epmet.commons.tools.page.PageData; |
|||
import com.epmet.dto.RoleScopeDTO; |
|||
import com.epmet.entity.RoleScopeEntity; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* 角色能操作哪些范围 |
|||
* |
|||
* @author generator generator@elink-cn.com |
|||
* @since v1.0.0 2020-04-24 |
|||
*/ |
|||
public interface RoleScopeService extends BaseService<RoleScopeEntity> { |
|||
|
|||
/** |
|||
* 默认分页 |
|||
* |
|||
* @param params |
|||
* @return PageData<RoleScopeDTO> |
|||
* @author generator |
|||
* @date 2020-04-24 |
|||
*/ |
|||
PageData<RoleScopeDTO> page(Map<String, Object> params); |
|||
|
|||
/** |
|||
* 默认查询 |
|||
* |
|||
* @param params |
|||
* @return java.util.List<RoleScopeDTO> |
|||
* @author generator |
|||
* @date 2020-04-24 |
|||
*/ |
|||
List<RoleScopeDTO> list(Map<String, Object> params); |
|||
|
|||
/** |
|||
* 单条查询 |
|||
* |
|||
* @param id |
|||
* @return RoleScopeDTO |
|||
* @author generator |
|||
* @date 2020-04-24 |
|||
*/ |
|||
RoleScopeDTO get(String id); |
|||
|
|||
/** |
|||
* 默认保存 |
|||
* |
|||
* @param dto |
|||
* @return void |
|||
* @author generator |
|||
* @date 2020-04-24 |
|||
*/ |
|||
void save(RoleScopeDTO dto); |
|||
|
|||
/** |
|||
* 默认更新 |
|||
* |
|||
* @param dto |
|||
* @return void |
|||
* @author generator |
|||
* @date 2020-04-24 |
|||
*/ |
|||
void update(RoleScopeDTO dto); |
|||
|
|||
/** |
|||
* 批量删除 |
|||
* |
|||
* @param ids |
|||
* @return void |
|||
* @author generator |
|||
* @date 2020-04-24 |
|||
*/ |
|||
void delete(String[] ids); |
|||
} |
|||
@ -0,0 +1,80 @@ |
|||
package com.epmet.service.impl; |
|||
|
|||
import com.epmet.commons.tools.exception.ExceptionUtils; |
|||
import com.epmet.commons.tools.security.dto.GovTokenDto; |
|||
import com.epmet.commons.tools.utils.CpUserDetailRedis; |
|||
import com.epmet.dao.OperationScopeDao; |
|||
import com.epmet.dto.result.RoleOpeScopeResultDTO; |
|||
import com.epmet.redis.RoleOpeScopeRedis; |
|||
import com.epmet.service.AccessService; |
|||
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.Set; |
|||
|
|||
@Service |
|||
public class AccessServiceImpl implements AccessService { |
|||
|
|||
private static Logger logger = LoggerFactory.getLogger(AccessServiceImpl.class); |
|||
|
|||
@Autowired |
|||
private CpUserDetailRedis cpUserDetailRedis; |
|||
|
|||
@Autowired |
|||
private OperationScopeDao operationScopeDao; |
|||
|
|||
@Autowired |
|||
private RoleOpeScopeRedis roleOpeScopeRedis; |
|||
|
|||
/** |
|||
* 更新权限缓存 |
|||
* @param staffId |
|||
* @param permissions |
|||
*/ |
|||
@Override |
|||
public void updatePermissionCache(String staffId, String app, String client, Set<String> permissions, Set<String> roleIdList, String orgIdPath) { |
|||
GovTokenDto govTokenDto = cpUserDetailRedis.get(app, client, staffId, GovTokenDto.class); |
|||
if (govTokenDto == null) { |
|||
logger.warn("更新[{}]用户缓存:Redis中不存在该用户TokenDto缓存信息", staffId); |
|||
return ; |
|||
} |
|||
// 将权限,角色列表,和当前组织ID存入TokenDto
|
|||
govTokenDto.setPermissions(permissions); |
|||
govTokenDto.setRoleIdList(roleIdList); |
|||
govTokenDto.setOrgIdPath(orgIdPath); |
|||
|
|||
// 将新的TokenDto更新到redis中
|
|||
long expire = cpUserDetailRedis.getExpire(app, client, staffId); |
|||
cpUserDetailRedis.set(govTokenDto, expire); |
|||
logger.warn("更新[{}]用户缓存成功。", staffId); |
|||
} |
|||
|
|||
@Override |
|||
public GovTokenDto listStaffCurrPermissions(String app, String client, String staffId) { |
|||
return cpUserDetailRedis.get(app, client, staffId, GovTokenDto.class); |
|||
} |
|||
|
|||
/** |
|||
* 查询角色的操作key对应操作范围列表 |
|||
* @param roleId |
|||
* @param operationKey |
|||
* @return |
|||
*/ |
|||
public Set<RoleOpeScopeResultDTO> listOperationScopesByRoleId(String roleId, String operationKey) { |
|||
Set<RoleOpeScopeResultDTO> roleOpeScopes = roleOpeScopeRedis.getRoleOpeScopes(roleId, operationKey); |
|||
if (roleOpeScopes != null) { |
|||
return roleOpeScopes; |
|||
} |
|||
Set<RoleOpeScopeResultDTO> scopes = operationScopeDao.listOperationScopesByRoleId(roleId, operationKey); |
|||
try { |
|||
roleOpeScopeRedis.setRoleOpeScopes(roleId, operationKey, scopes); |
|||
} catch (Exception e) { |
|||
String errorStackTrace = ExceptionUtils.getErrorStackTrace(e); |
|||
logger.error("GovAccess:查询角色的操作范围:缓存范围出错:{}", errorStackTrace); |
|||
} |
|||
return scopes; |
|||
} |
|||
} |
|||
@ -0,0 +1,101 @@ |
|||
/** |
|||
* 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.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.OperationScopeDao; |
|||
import com.epmet.dto.OperationScopeDTO; |
|||
import com.epmet.entity.OperationScopeEntity; |
|||
import com.epmet.service.OperationScopeService; |
|||
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-04-24 |
|||
*/ |
|||
@Service |
|||
public class OperationScopeServiceImpl extends BaseServiceImpl<OperationScopeDao, OperationScopeEntity> implements OperationScopeService { |
|||
|
|||
|
|||
@Override |
|||
public PageData<OperationScopeDTO> page(Map<String, Object> params) { |
|||
IPage<OperationScopeEntity> page = baseDao.selectPage( |
|||
getPage(params, FieldConstant.CREATED_TIME, false), |
|||
getWrapper(params) |
|||
); |
|||
return getPageData(page, OperationScopeDTO.class); |
|||
} |
|||
|
|||
@Override |
|||
public List<OperationScopeDTO> list(Map<String, Object> params) { |
|||
List<OperationScopeEntity> entityList = baseDao.selectList(getWrapper(params)); |
|||
|
|||
return ConvertUtils.sourceToTarget(entityList, OperationScopeDTO.class); |
|||
} |
|||
|
|||
private QueryWrapper<OperationScopeEntity> getWrapper(Map<String, Object> params){ |
|||
String id = (String)params.get(FieldConstant.ID_HUMP); |
|||
|
|||
QueryWrapper<OperationScopeEntity> wrapper = new QueryWrapper<>(); |
|||
wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); |
|||
|
|||
return wrapper; |
|||
} |
|||
|
|||
@Override |
|||
public OperationScopeDTO get(String id) { |
|||
OperationScopeEntity entity = baseDao.selectById(id); |
|||
return ConvertUtils.sourceToTarget(entity, OperationScopeDTO.class); |
|||
} |
|||
|
|||
@Override |
|||
@Transactional(rollbackFor = Exception.class) |
|||
public void save(OperationScopeDTO dto) { |
|||
OperationScopeEntity entity = ConvertUtils.sourceToTarget(dto, OperationScopeEntity.class); |
|||
insert(entity); |
|||
} |
|||
|
|||
@Override |
|||
@Transactional(rollbackFor = Exception.class) |
|||
public void update(OperationScopeDTO dto) { |
|||
OperationScopeEntity entity = ConvertUtils.sourceToTarget(dto, OperationScopeEntity.class); |
|||
updateById(entity); |
|||
} |
|||
|
|||
@Override |
|||
@Transactional(rollbackFor = Exception.class) |
|||
public void delete(String[] ids) { |
|||
// 逻辑删除(@TableLogic 注解)
|
|||
baseDao.deleteBatchIds(Arrays.asList(ids)); |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,106 @@ |
|||
/** |
|||
* 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.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.RoleOperationDao; |
|||
import com.epmet.dto.RoleOperationDTO; |
|||
import com.epmet.dto.result.RoleOperationResultDTO; |
|||
import com.epmet.entity.RoleOperationEntity; |
|||
import com.epmet.service.RoleOperationService; |
|||
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-04-22 |
|||
*/ |
|||
@Service |
|||
public class RoleOperationServiceImpl extends BaseServiceImpl<RoleOperationDao, RoleOperationEntity> implements RoleOperationService { |
|||
|
|||
@Override |
|||
public PageData<RoleOperationDTO> page(Map<String, Object> params) { |
|||
IPage<RoleOperationEntity> page = baseDao.selectPage( |
|||
getPage(params, FieldConstant.CREATED_TIME, false), |
|||
getWrapper(params) |
|||
); |
|||
return getPageData(page, RoleOperationDTO.class); |
|||
} |
|||
|
|||
@Override |
|||
public List<RoleOperationDTO> list(Map<String, Object> params) { |
|||
List<RoleOperationEntity> entityList = baseDao.selectList(getWrapper(params)); |
|||
|
|||
return ConvertUtils.sourceToTarget(entityList, RoleOperationDTO.class); |
|||
} |
|||
|
|||
private QueryWrapper<RoleOperationEntity> getWrapper(Map<String, Object> params){ |
|||
String id = (String)params.get(FieldConstant.ID_HUMP); |
|||
|
|||
QueryWrapper<RoleOperationEntity> wrapper = new QueryWrapper<>(); |
|||
wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); |
|||
|
|||
return wrapper; |
|||
} |
|||
|
|||
@Override |
|||
public RoleOperationDTO get(String id) { |
|||
RoleOperationEntity entity = baseDao.selectById(id); |
|||
return ConvertUtils.sourceToTarget(entity, RoleOperationDTO.class); |
|||
} |
|||
|
|||
@Override |
|||
@Transactional(rollbackFor = Exception.class) |
|||
public void save(RoleOperationDTO dto) { |
|||
RoleOperationEntity entity = ConvertUtils.sourceToTarget(dto, RoleOperationEntity.class); |
|||
insert(entity); |
|||
} |
|||
|
|||
@Override |
|||
@Transactional(rollbackFor = Exception.class) |
|||
public void update(RoleOperationDTO dto) { |
|||
RoleOperationEntity entity = ConvertUtils.sourceToTarget(dto, RoleOperationEntity.class); |
|||
updateById(entity); |
|||
} |
|||
|
|||
@Override |
|||
@Transactional(rollbackFor = Exception.class) |
|||
public void delete(String[] ids) { |
|||
// 逻辑删除(@TableLogic 注解)
|
|||
baseDao.deleteBatchIds(Arrays.asList(ids)); |
|||
} |
|||
|
|||
@Override |
|||
public List<RoleOperationResultDTO> listOperationsByRoleId(String roleId) { |
|||
return baseDao.listOperationsByRoleId(roleId); |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,100 @@ |
|||
/** |
|||
* 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.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.RoleScopeDao; |
|||
import com.epmet.dto.RoleScopeDTO; |
|||
import com.epmet.entity.RoleScopeEntity; |
|||
import com.epmet.service.RoleScopeService; |
|||
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-04-24 |
|||
*/ |
|||
@Service |
|||
public class RoleScopeServiceImpl extends BaseServiceImpl<RoleScopeDao, RoleScopeEntity> implements RoleScopeService { |
|||
|
|||
@Override |
|||
public PageData<RoleScopeDTO> page(Map<String, Object> params) { |
|||
IPage<RoleScopeEntity> page = baseDao.selectPage( |
|||
getPage(params, FieldConstant.CREATED_TIME, false), |
|||
getWrapper(params) |
|||
); |
|||
return getPageData(page, RoleScopeDTO.class); |
|||
} |
|||
|
|||
@Override |
|||
public List<RoleScopeDTO> list(Map<String, Object> params) { |
|||
List<RoleScopeEntity> entityList = baseDao.selectList(getWrapper(params)); |
|||
|
|||
return ConvertUtils.sourceToTarget(entityList, RoleScopeDTO.class); |
|||
} |
|||
|
|||
private QueryWrapper<RoleScopeEntity> getWrapper(Map<String, Object> params){ |
|||
String id = (String)params.get(FieldConstant.ID_HUMP); |
|||
|
|||
QueryWrapper<RoleScopeEntity> wrapper = new QueryWrapper<>(); |
|||
wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); |
|||
|
|||
return wrapper; |
|||
} |
|||
|
|||
@Override |
|||
public RoleScopeDTO get(String id) { |
|||
RoleScopeEntity entity = baseDao.selectById(id); |
|||
return ConvertUtils.sourceToTarget(entity, RoleScopeDTO.class); |
|||
} |
|||
|
|||
@Override |
|||
@Transactional(rollbackFor = Exception.class) |
|||
public void save(RoleScopeDTO dto) { |
|||
RoleScopeEntity entity = ConvertUtils.sourceToTarget(dto, RoleScopeEntity.class); |
|||
insert(entity); |
|||
} |
|||
|
|||
@Override |
|||
@Transactional(rollbackFor = Exception.class) |
|||
public void update(RoleScopeDTO dto) { |
|||
RoleScopeEntity entity = ConvertUtils.sourceToTarget(dto, RoleScopeEntity.class); |
|||
updateById(entity); |
|||
} |
|||
|
|||
@Override |
|||
@Transactional(rollbackFor = Exception.class) |
|||
public void delete(String[] ids) { |
|||
// 逻辑删除(@TableLogic 注解)
|
|||
baseDao.deleteBatchIds(Arrays.asList(ids)); |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,103 @@ |
|||
server: |
|||
port: @server.port@ |
|||
servlet: |
|||
context-path: /gov/access |
|||
|
|||
spring: |
|||
main: |
|||
allow-bean-definition-overriding: true |
|||
application: |
|||
name: gov-access-server |
|||
#环境 dev|test|prod |
|||
profiles: |
|||
active: dev |
|||
jackson: |
|||
time-zone: GMT+8 |
|||
date-format: yyyy-MM-dd HH:mm:ss |
|||
redis: |
|||
database: @spring.redis.index@ |
|||
host: @spring.redis.host@ |
|||
port: @spring.redis.port@ |
|||
password: @spring.redis.password@ |
|||
timeout: 30s |
|||
datasource: |
|||
druid: |
|||
#MySQL |
|||
driver-class-name: com.mysql.cj.jdbc.Driver |
|||
url: @spring.datasource.druid.url@ |
|||
username: @spring.datasource.druid.username@ |
|||
password: @spring.datasource.druid.password@ |
|||
cloud: |
|||
nacos: |
|||
discovery: |
|||
server-addr: @nacos.server-addr@ |
|||
#nacos的命名空间ID,默认是public |
|||
namespace: @nacos.discovery.namespace@ |
|||
#不把自己注册到注册中心的地址 |
|||
register-enabled: @nacos.register-enabled@ |
|||
ip: @nacos.ip@ |
|||
config: |
|||
enabled: @nacos.config-enabled@ |
|||
server-addr: @nacos.server-addr@ |
|||
namespace: @nacos.config.namespace@ |
|||
group: @nacos.config.group@ |
|||
file-extension: yaml |
|||
#指定共享配置,且支持动态刷新 |
|||
# ext-config: |
|||
# - data-id: datasource.yaml |
|||
# group: ${spring.cloud.nacos.config.group} |
|||
# refresh: true |
|||
# - data-id: common.yaml |
|||
# group: ${spring.cloud.nacos.config.group} |
|||
# refresh: true |
|||
management: |
|||
endpoints: |
|||
web: |
|||
exposure: |
|||
include: "*" |
|||
endpoint: |
|||
health: |
|||
show-details: ALWAYS |
|||
|
|||
mybatis-plus: |
|||
mapper-locations: classpath:/mapper/**/*.xml |
|||
#实体扫描,多个package用逗号或者分号分隔 |
|||
typeAliasesPackage: com.epmet.entity |
|||
global-config: |
|||
#数据库相关配置 |
|||
db-config: |
|||
#主键类型 AUTO:"数据库ID自增", INPUT:"用户输入ID", ID_WORKER:"全局唯一ID (数字类型唯一ID)", UUID:"全局唯一ID UUID"; |
|||
id-type: ID_WORKER |
|||
#字段策略 IGNORED:"忽略判断",NOT_NULL:"非 NULL 判断"),NOT_EMPTY:"非空判断" |
|||
field-strategy: NOT_NULL |
|||
#驼峰下划线转换 |
|||
column-underline: true |
|||
banner: false |
|||
#原生配置 |
|||
configuration: |
|||
map-underscore-to-camel-case: true |
|||
cache-enabled: false |
|||
call-setters-on-nulls: true |
|||
jdbc-type-for-null: 'null' |
|||
|
|||
feign: |
|||
hystrix: |
|||
enabled: true |
|||
client: |
|||
config: |
|||
default: |
|||
loggerLevel: BASIC |
|||
httpclient: |
|||
enabled: true |
|||
|
|||
hystrix: |
|||
command: |
|||
default: |
|||
execution: |
|||
isolation: |
|||
thread: |
|||
timeoutInMilliseconds: 60000 #缺省为1000 |
|||
|
|||
ribbon: |
|||
ReadTimeout: 300000 |
|||
ConnectTimeout: 300000 |
|||
@ -0,0 +1,76 @@ |
|||
/* |
|||
Date: 22/04/2020 12:13:38 |
|||
*/ |
|||
|
|||
-- SET NAMES utf8mb4; |
|||
-- #SET FOREIGN_KEY_CHECKS = 0; |
|||
|
|||
-- DROP TABLE IF EXISTS `permission_scope`; |
|||
CREATE TABLE `operation_scope` ( |
|||
`ID` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT 'id', |
|||
`SCOPE_KEY` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '范围key', |
|||
`SCOPE_NAME` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '范围名称', |
|||
`SCOPE_INDEX` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '范围序号', |
|||
`DEL_FLAG` tinyint(1) NULL DEFAULT NULL COMMENT '是否删除,0:未删除,1:已删除', |
|||
`REVISION` int(10) NULL DEFAULT NULL COMMENT '乐观锁', |
|||
`CREATED_BY` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '创建者id', |
|||
`CREATED_TIME` datetime(0) NULL DEFAULT NULL COMMENT '创建时间', |
|||
`UPDATED_BY` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '更新者id', |
|||
`UPDATED_TIME` datetime(0) NULL DEFAULT NULL COMMENT '更新时间', |
|||
PRIMARY KEY (`ID`) USING BTREE |
|||
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '权限范围表' ROW_FORMAT = Dynamic; |
|||
|
|||
-- ---------------------------- |
|||
-- Table structure for resource_ope |
|||
-- ---------------------------- |
|||
-- DROP TABLE IF EXISTS `operation`; |
|||
CREATE TABLE `operation` ( |
|||
`ID` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, |
|||
`OPERATION_KEY` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, |
|||
`OPERATION_NAME` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL, |
|||
`BRIEF` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '操作简介', |
|||
`DEL_FLAG` tinyint(1) NULL DEFAULT NULL, |
|||
`REVISION` int(10) NULL DEFAULT NULL, |
|||
`CREATED_BY` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL, |
|||
`CREATED_TIME` datetime(0) NULL DEFAULT NULL, |
|||
`UPDATED_BY` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL, |
|||
`UPDATED_TIME` datetime(0) NULL DEFAULT NULL, |
|||
PRIMARY KEY (`ID`) USING BTREE |
|||
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '操作类型表' ROW_FORMAT = Dynamic; |
|||
|
|||
-- ---------------------------- |
|||
-- Table structure for role_operation |
|||
-- ---------------------------- |
|||
-- DROP TABLE IF EXISTS `role_operation`; |
|||
CREATE TABLE `role_operation` ( |
|||
`ID` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, |
|||
`ROLE_ID` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '角色ID', |
|||
`OPERATION_KEY` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '操作key', |
|||
`DEL_FLAG` tinyint(1) NULL DEFAULT NULL COMMENT '是否删除,0:未删除,1:已删除', |
|||
`REVISION` int(10) NULL DEFAULT NULL COMMENT '乐观锁', |
|||
`CREATED_BY` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '创建者id', |
|||
`CREATED_TIME` datetime(0) NULL DEFAULT NULL COMMENT '创建时间', |
|||
`UPDATED_BY` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '更新者id', |
|||
`UPDATED_TIME` datetime(0) NULL DEFAULT NULL COMMENT '更新时间', |
|||
PRIMARY KEY (`ID`) USING BTREE |
|||
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '角色能进行那些操作' ROW_FORMAT = Dynamic; |
|||
|
|||
-- ---------------------------- |
|||
-- Table structure for role_scope |
|||
-- ---------------------------- |
|||
-- DROP TABLE IF EXISTS `role_scope`; |
|||
CREATE TABLE `role_scope` ( |
|||
`ID` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, |
|||
`ROLE_ID` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '角色ID', |
|||
`OPERATION_KEY` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '操作Key', |
|||
`SCOPE_KEY` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '范围Key', |
|||
`DEL_FLAG` tinyint(1) NULL DEFAULT NULL COMMENT '是否删除,0:未删除,1:已删除', |
|||
`REVISION` int(10) NULL DEFAULT NULL COMMENT '乐观锁', |
|||
`CREATED_BY` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '创建者id', |
|||
`CREATED_TIME` datetime(0) NULL DEFAULT NULL COMMENT '创建时间', |
|||
`UPDATED_BY` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '更新者id', |
|||
`UPDATED_TIME` datetime(0) NULL DEFAULT NULL COMMENT '更新时间', |
|||
PRIMARY KEY (`ID`) USING BTREE |
|||
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '角色能操作哪些范围' ROW_FORMAT = Dynamic; |
|||
|
|||
-- SET FOREIGN_KEY_CHECKS = 1; |
|||
@ -0,0 +1,159 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<configuration> |
|||
<include resource="org/springframework/boot/logging/logback/base.xml"/> |
|||
|
|||
<property name="log.path" value="logs/gov-access"/> |
|||
|
|||
<!-- 彩色日志格式 --> |
|||
<property name="CONSOLE_LOG_PATTERN" |
|||
value="${CONSOLE_LOG_PATTERN:-%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(${LOG_LEVEL_PATTERN:-%5p}) %clr(${PID:- }){magenta} %clr(---){faint} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}}"/> |
|||
|
|||
<!--1. 输出到控制台--> |
|||
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender"> |
|||
<!--此日志appender是为开发使用,只配置最底级别,控制台输出的日志级别是大于或等于此级别的日志信息--> |
|||
<filter class="ch.qos.logback.classic.filter.ThresholdFilter"> |
|||
<level>debug</level> |
|||
</filter> |
|||
<encoder> |
|||
<Pattern>${CONSOLE_LOG_PATTERN}</Pattern> |
|||
<!-- 设置字符集 --> |
|||
<charset>UTF-8</charset> |
|||
</encoder> |
|||
</appender> |
|||
|
|||
<!--2. 输出到文档--> |
|||
<!-- 2.1 level为 DEBUG 日志,时间滚动输出 --> |
|||
<appender name="DEBUG_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> |
|||
<!-- 正在记录的日志文档的路径及文档名 --> |
|||
<file>${log.path}/debug.log</file> |
|||
<!--日志文档输出格式--> |
|||
<encoder> |
|||
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern> |
|||
<charset>UTF-8</charset> <!-- 设置字符集 --> |
|||
</encoder> |
|||
<!-- 日志记录器的滚动策略,按日期,按大小记录 --> |
|||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> |
|||
<!-- 日志归档 --> |
|||
<fileNamePattern>${log.path}/debug-%d{yyyy-MM-dd}.%i.log</fileNamePattern> |
|||
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"> |
|||
<maxFileSize>100MB</maxFileSize> |
|||
</timeBasedFileNamingAndTriggeringPolicy> |
|||
<!--日志文档保留天数--> |
|||
<maxHistory>15</maxHistory> |
|||
</rollingPolicy> |
|||
<!-- 此日志文档只记录debug级别的 --> |
|||
<filter class="ch.qos.logback.classic.filter.LevelFilter"> |
|||
<level>debug</level> |
|||
<onMatch>ACCEPT</onMatch> |
|||
<onMismatch>DENY</onMismatch> |
|||
</filter> |
|||
</appender> |
|||
|
|||
<!-- 2.2 level为 INFO 日志,时间滚动输出 --> |
|||
<appender name="INFO_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> |
|||
<!-- 正在记录的日志文档的路径及文档名 --> |
|||
<file>${log.path}/info.log</file> |
|||
<!--日志文档输出格式--> |
|||
<encoder> |
|||
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern> |
|||
<charset>UTF-8</charset> |
|||
</encoder> |
|||
<!-- 日志记录器的滚动策略,按日期,按大小记录 --> |
|||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> |
|||
<!-- 每天日志归档路径以及格式 --> |
|||
<fileNamePattern>${log.path}/info-%d{yyyy-MM-dd}.%i.log</fileNamePattern> |
|||
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"> |
|||
<maxFileSize>100MB</maxFileSize> |
|||
</timeBasedFileNamingAndTriggeringPolicy> |
|||
<!--日志文档保留天数--> |
|||
<maxHistory>15</maxHistory> |
|||
</rollingPolicy> |
|||
<!-- 此日志文档只记录info级别的 --> |
|||
<filter class="ch.qos.logback.classic.filter.LevelFilter"> |
|||
<level>info</level> |
|||
<onMatch>ACCEPT</onMatch> |
|||
<onMismatch>DENY</onMismatch> |
|||
</filter> |
|||
</appender> |
|||
|
|||
<!-- 2.3 level为 WARN 日志,时间滚动输出 --> |
|||
<appender name="WARN_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> |
|||
<!-- 正在记录的日志文档的路径及文档名 --> |
|||
<file>${log.path}/warn.log</file> |
|||
<!--日志文档输出格式--> |
|||
<encoder> |
|||
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern> |
|||
<charset>UTF-8</charset> <!-- 此处设置字符集 --> |
|||
</encoder> |
|||
<!-- 日志记录器的滚动策略,按日期,按大小记录 --> |
|||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> |
|||
<fileNamePattern>${log.path}/warn-%d{yyyy-MM-dd}.%i.log</fileNamePattern> |
|||
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"> |
|||
<maxFileSize>100MB</maxFileSize> |
|||
</timeBasedFileNamingAndTriggeringPolicy> |
|||
<!--日志文档保留天数--> |
|||
<maxHistory>15</maxHistory> |
|||
</rollingPolicy> |
|||
<!-- 此日志文档只记录warn级别的 --> |
|||
<filter class="ch.qos.logback.classic.filter.LevelFilter"> |
|||
<level>warn</level> |
|||
<onMatch>ACCEPT</onMatch> |
|||
<onMismatch>DENY</onMismatch> |
|||
</filter> |
|||
</appender> |
|||
|
|||
<!-- 2.4 level为 ERROR 日志,时间滚动输出 --> |
|||
<appender name="ERROR_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> |
|||
<!-- 正在记录的日志文档的路径及文档名 --> |
|||
<file>${log.path}/error.log</file> |
|||
<!--日志文档输出格式--> |
|||
<encoder> |
|||
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern> |
|||
<charset>UTF-8</charset> <!-- 此处设置字符集 --> |
|||
</encoder> |
|||
<!-- 日志记录器的滚动策略,按日期,按大小记录 --> |
|||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> |
|||
<fileNamePattern>${log.path}/error-%d{yyyy-MM-dd}.%i.log</fileNamePattern> |
|||
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"> |
|||
<maxFileSize>100MB</maxFileSize> |
|||
</timeBasedFileNamingAndTriggeringPolicy> |
|||
<!--日志文档保留天数--> |
|||
<maxHistory>15</maxHistory> |
|||
</rollingPolicy> |
|||
<!-- 此日志文档只记录ERROR级别的 --> |
|||
<filter class="ch.qos.logback.classic.filter.LevelFilter"> |
|||
<level>ERROR</level> |
|||
<onMatch>ACCEPT</onMatch> |
|||
<onMismatch>DENY</onMismatch> |
|||
</filter> |
|||
</appender> |
|||
|
|||
<!-- 开发、测试环境 --> |
|||
<springProfile name="dev,test"> |
|||
<logger name="org.springframework.web" level="INFO"/> |
|||
<logger name="org.springboot.sample" level="INFO"/> |
|||
<logger name="com.epmet.dao" level="INFO"/> |
|||
<logger name="com.epmet.dao" level="DEBUG"/> |
|||
<root level="INFO"> |
|||
<appender-ref ref="DEBUG_FILE"/> |
|||
<appender-ref ref="INFO_FILE"/> |
|||
<appender-ref ref="WARN_FILE"/> |
|||
<appender-ref ref="ERROR_FILE"/> |
|||
</root> |
|||
</springProfile> |
|||
|
|||
<!-- 生产环境 --> |
|||
<springProfile name="prod"> |
|||
<logger name="org.springframework.web" level="INFO"/> |
|||
<logger name="org.springboot.sample" level="INFO"/> |
|||
<logger name="com.epmet.dao" level="INFO"/> |
|||
<root level="INFO"> |
|||
<appender-ref ref="CONSOLE"/> |
|||
<appender-ref ref="DEBUG_FILE"/> |
|||
<appender-ref ref="INFO_FILE"/> |
|||
<appender-ref ref="WARN_FILE"/> |
|||
<appender-ref ref="ERROR_FILE"/> |
|||
</root> |
|||
</springProfile> |
|||
|
|||
</configuration> |
|||
@ -0,0 +1,29 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
|||
|
|||
<mapper namespace="com.epmet.dao.OperationScopeDao"> |
|||
|
|||
<resultMap type="com.epmet.entity.OperationScopeEntity" id="operationScopeMap"> |
|||
<result property="id" column="ID"/> |
|||
<result property="scopeKey" column="SCOPE_KEY"/> |
|||
<result property="scopeName" column="SCOPE_NAME"/> |
|||
<result property="delFlag" column="DEL_FLAG"/> |
|||
<result property="revision" column="REVISION"/> |
|||
<result property="createdBy" column="CREATED_BY"/> |
|||
<result property="createdTime" column="CREATED_TIME"/> |
|||
<result property="updatedBy" column="UPDATED_BY"/> |
|||
<result property="updatedTime" column="UPDATED_TIME"/> |
|||
</resultMap> |
|||
|
|||
<!--查询角色的操作key对应操作范围列表--> |
|||
<select id="listOperationScopesByRoleId" resultType="com.epmet.dto.result.RoleOpeScopeResultDTO"> |
|||
select os.SCOPE_KEY, os.SCOPE_NAME, rs.ROLE_ID, os.SCOPE_INDEX |
|||
from role_scope rs |
|||
inner join operation_scope os |
|||
on (rs.SCOPE_KEY = os.SCOPE_KEY) |
|||
where rs.ROLE_ID = #{roleId} |
|||
and rs.OPERATION_KEY = #{operationKey} |
|||
</select> |
|||
|
|||
|
|||
</mapper> |
|||
@ -0,0 +1,33 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
|||
|
|||
<mapper namespace="com.epmet.dao.RoleOperationDao"> |
|||
|
|||
<resultMap type="com.epmet.entity.RoleOperationEntity" id="roleOperationMap"> |
|||
<result property="id" column="ID"/> |
|||
<result property="roleId" column="ROLE_ID"/> |
|||
<result property="operationKey" column="OPERATION_KEY"/> |
|||
<result property="delFlag" column="DEL_FLAG"/> |
|||
<result property="revision" column="REVISION"/> |
|||
<result property="createdBy" column="CREATED_BY"/> |
|||
<result property="createdTime" column="CREATED_TIME"/> |
|||
<result property="updatedBy" column="UPDATED_BY"/> |
|||
<result property="updatedTime" column="UPDATED_TIME"/> |
|||
</resultMap> |
|||
<resultMap id="RoleOperationResultDTO" type="com.epmet.dto.result.RoleOperationResultDTO" extends="roleOperationMap"> |
|||
<result property="operationName" column="OPERATION_NAME"/> |
|||
</resultMap> |
|||
|
|||
<select id="listOperationsByRoleId" resultMap="RoleOperationResultDTO"> |
|||
SELECT |
|||
ro.*, |
|||
o.OPERATION_NAME |
|||
FROM |
|||
role_operation ro |
|||
INNER JOIN operation o ON ( ro.OPERATION_KEY = o.OPERATION_KEY ) |
|||
WHERE |
|||
ro.ROLE_ID = #{roleId} |
|||
</select> |
|||
|
|||
|
|||
</mapper> |
|||
@ -0,0 +1,20 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
|||
|
|||
<mapper namespace="com.epmet.dao.RoleScopeDao"> |
|||
|
|||
<resultMap type="com.epmet.entity.RoleScopeEntity" id="roleScopeMap"> |
|||
<result property="id" column="ID"/> |
|||
<result property="roleId" column="ROLE_ID"/> |
|||
<result property="operationKey" column="OPERATION_KEY"/> |
|||
<result property="scopeKey" column="SCOPE_KEY"/> |
|||
<result property="delFlag" column="DEL_FLAG"/> |
|||
<result property="revision" column="REVISION"/> |
|||
<result property="createdBy" column="CREATED_BY"/> |
|||
<result property="createdTime" column="CREATED_TIME"/> |
|||
<result property="updatedBy" column="UPDATED_BY"/> |
|||
<result property="updatedTime" column="UPDATED_TIME"/> |
|||
</resultMap> |
|||
|
|||
|
|||
</mapper> |
|||
@ -0,0 +1,21 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<project xmlns="http://maven.apache.org/POM/4.0.0" |
|||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
|||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
|||
<parent> |
|||
<artifactId>epmet-module</artifactId> |
|||
<groupId>com.epmet</groupId> |
|||
<version>2.0.0</version> |
|||
</parent> |
|||
<modelVersion>4.0.0</modelVersion> |
|||
|
|||
<artifactId>gov-access</artifactId> |
|||
<packaging>pom</packaging> |
|||
|
|||
<modules> |
|||
<module>gov-access-client</module> |
|||
<module>gov-access-server</module> |
|||
</modules> |
|||
|
|||
|
|||
</project> |
|||
@ -0,0 +1,35 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<project xmlns="http://maven.apache.org/POM/4.0.0" |
|||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
|||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
|||
<parent> |
|||
<groupId>com.epmet</groupId> |
|||
<artifactId>gov-mine</artifactId> |
|||
<version>2.0.0</version> |
|||
</parent> |
|||
<modelVersion>4.0.0</modelVersion> |
|||
|
|||
<artifactId>gov-mine-client</artifactId> |
|||
|
|||
<dependencies> |
|||
<dependency> |
|||
<groupId>com.epmet</groupId> |
|||
<artifactId>epmet-commons-tools</artifactId> |
|||
<version>2.0.0</version> |
|||
</dependency> |
|||
<dependency> |
|||
<groupId>io.springfox</groupId> |
|||
<artifactId>springfox-swagger2</artifactId> |
|||
</dependency> |
|||
<dependency> |
|||
<groupId>io.springfox</groupId> |
|||
<artifactId>springfox-swagger-ui</artifactId> |
|||
</dependency> |
|||
</dependencies> |
|||
|
|||
<build> |
|||
<finalName>${project.artifactId}</finalName> |
|||
</build> |
|||
|
|||
|
|||
</project> |
|||
@ -0,0 +1,13 @@ |
|||
package com.epmet.dto.form; |
|||
|
|||
import lombok.Data; |
|||
|
|||
@Data |
|||
public class StaffOperationDTO { |
|||
|
|||
//@NotBlank(message = "角色所属组织ID不能为空")
|
|||
private String agencyId; |
|||
|
|||
//@NotBlank(message = "角色所属网格ID不能为空")
|
|||
private String gridId; |
|||
} |
|||
@ -0,0 +1,9 @@ |
|||
package com.epmet.dto.form; |
|||
|
|||
import lombok.Data; |
|||
|
|||
@Data |
|||
public class StaffRoleFormDTO { |
|||
private String staffId; |
|||
private String orgId; |
|||
} |
|||
@ -0,0 +1,35 @@ |
|||
package com.epmet.dto.form; |
|||
|
|||
import lombok.Data; |
|||
|
|||
import javax.validation.constraints.NotBlank; |
|||
import java.io.Serializable; |
|||
|
|||
/** |
|||
* @Description 切换网格入参 |
|||
* @Author yinzuomei |
|||
* @Date 2020/4/23 10:41 |
|||
*/ |
|||
@Data |
|||
public class SwitchGridFormDTO implements Serializable { |
|||
private static final long serialVersionUID = -2898130727929596798L; |
|||
|
|||
/** |
|||
* customerId |
|||
*/ |
|||
@NotBlank(message = "customerId不能为空") |
|||
private String customerId; |
|||
|
|||
/** |
|||
* gridId |
|||
*/ |
|||
@NotBlank(message = "gridId不能为空") |
|||
private String gridId; |
|||
|
|||
/** |
|||
* staffId从tokenTto获取 |
|||
*/ |
|||
@NotBlank(message = "staffId不能为空") |
|||
private String staffId; |
|||
} |
|||
|
|||
@ -0,0 +1,181 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<project xmlns="http://maven.apache.org/POM/4.0.0" |
|||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
|||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
|||
<version>0.3.0</version> |
|||
<parent> |
|||
<groupId>com.epmet</groupId> |
|||
<artifactId>gov-mine</artifactId> |
|||
<version>2.0.0</version> |
|||
</parent> |
|||
<modelVersion>4.0.0</modelVersion> |
|||
|
|||
<artifactId>gov-mine-server</artifactId> |
|||
|
|||
<dependencies> |
|||
<dependency> |
|||
<groupId>com.epmet</groupId> |
|||
<artifactId>gov-mine-client</artifactId> |
|||
<version>2.0.0</version> |
|||
</dependency> |
|||
<dependency> |
|||
<groupId>com.epmet</groupId> |
|||
<artifactId>oper-customize-client</artifactId> |
|||
<version>2.0.0</version> |
|||
</dependency> |
|||
<dependency> |
|||
<groupId>com.epmet</groupId> |
|||
<artifactId>epmet-commons-tools</artifactId> |
|||
<version>2.0.0</version> |
|||
</dependency> |
|||
<dependency> |
|||
<groupId>org.springframework.boot</groupId> |
|||
<artifactId>spring-boot-starter-web</artifactId> |
|||
</dependency> |
|||
<dependency> |
|||
<groupId>org.springframework</groupId> |
|||
<artifactId>spring-context-support</artifactId> |
|||
</dependency> |
|||
<dependency> |
|||
<groupId>org.springframework.boot</groupId> |
|||
<artifactId>spring-boot-starter-actuator</artifactId> |
|||
</dependency> |
|||
<dependency> |
|||
<groupId>de.codecentric</groupId> |
|||
<artifactId>spring-boot-admin-starter-client</artifactId> |
|||
<version>${spring.boot.admin.version}</version> |
|||
</dependency> |
|||
<dependency> |
|||
<groupId>com.alibaba.cloud</groupId> |
|||
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId> |
|||
</dependency> |
|||
<dependency> |
|||
<groupId>com.alibaba.cloud</groupId> |
|||
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId> |
|||
</dependency> |
|||
<!-- 替换Feign原生httpclient --> |
|||
<dependency> |
|||
<groupId>io.github.openfeign</groupId> |
|||
<artifactId>feign-httpclient</artifactId> |
|||
<version>10.3.0</version> |
|||
</dependency> |
|||
<dependency> |
|||
<groupId>com.epmet</groupId> |
|||
<artifactId>gov-org-client</artifactId> |
|||
<version>2.0.0</version> |
|||
<scope>compile</scope> |
|||
</dependency> |
|||
<dependency> |
|||
<groupId>com.epmet</groupId> |
|||
<artifactId>epmet-user-client</artifactId> |
|||
<version>2.0.0</version> |
|||
<scope>compile</scope> |
|||
</dependency> |
|||
<dependency> |
|||
<groupId>com.epmet</groupId> |
|||
<artifactId>gov-access-client</artifactId> |
|||
<version>2.0.0</version> |
|||
<scope>compile</scope> |
|||
</dependency> |
|||
</dependencies> |
|||
|
|||
<build> |
|||
<finalName>${project.artifactId}</finalName> |
|||
<plugins> |
|||
<plugin> |
|||
<groupId>org.springframework.boot</groupId> |
|||
<artifactId>spring-boot-maven-plugin</artifactId> |
|||
</plugin> |
|||
<plugin> |
|||
<groupId>org.apache.maven.plugins</groupId> |
|||
<artifactId>maven-surefire-plugin</artifactId> |
|||
<configuration> |
|||
<skipTests>true</skipTests> |
|||
</configuration> |
|||
</plugin> |
|||
</plugins> |
|||
<sourceDirectory>${project.basedir}/src/main/java</sourceDirectory> |
|||
<resources> |
|||
<resource> |
|||
<filtering>true</filtering> |
|||
<directory>${basedir}/src/main/resources</directory> |
|||
</resource> |
|||
</resources> |
|||
</build> |
|||
|
|||
<profiles> |
|||
<profile> |
|||
<id>dev-local</id> |
|||
<activation> |
|||
<activeByDefault>true</activeByDefault> |
|||
</activation> |
|||
<properties> |
|||
<server.port>8098</server.port> |
|||
<spring.profiles.active>dev</spring.profiles.active> |
|||
|
|||
<!-- redis配置 --> |
|||
<spring.redis.index>0</spring.redis.index> |
|||
<spring.redis.host>192.168.1.130</spring.redis.host> |
|||
<spring.redis.port>6379</spring.redis.port> |
|||
<spring.redis.password>123456</spring.redis.password> |
|||
<!-- nacos --> |
|||
<nacos.register-enabled>false</nacos.register-enabled> |
|||
<nacos.server-addr>122.152.200.70:8848</nacos.server-addr> |
|||
<nacos.discovery.namespace>fcd6fc8f-ca3a-4b01-8026-2b05cdc5976b</nacos.discovery.namespace> |
|||
<nacos.config.namespace></nacos.config.namespace> |
|||
<nacos.config.group></nacos.config.group> |
|||
<nacos.config-enabled>false</nacos.config-enabled> |
|||
<nacos.ip/> |
|||
</properties> |
|||
</profile> |
|||
<profile> |
|||
<id>dev</id> |
|||
<!--<activation> |
|||
<activeByDefault>true</activeByDefault> |
|||
</activation>--> |
|||
<properties> |
|||
<server.port>8098</server.port> |
|||
<spring.profiles.active>dev</spring.profiles.active> |
|||
|
|||
<!-- redis配置 --> |
|||
<spring.redis.index>0</spring.redis.index> |
|||
<spring.redis.host>r-m5eoz5b6tkx09y6bpz.redis.rds.aliyuncs.com</spring.redis.host> |
|||
<spring.redis.port>6379</spring.redis.port> |
|||
<spring.redis.password>EpmEtrEdIs!q@w</spring.redis.password> |
|||
<!-- nacos --> |
|||
<nacos.register-enabled>true</nacos.register-enabled> |
|||
<nacos.server-addr>192.168.10.150:8848</nacos.server-addr> |
|||
<nacos.discovery.namespace>67e3c350-533e-4d7c-9f8f-faf1b4aa82ae</nacos.discovery.namespace> |
|||
<nacos.config.namespace></nacos.config.namespace> |
|||
<nacos.config.group></nacos.config.group> |
|||
<nacos.config-enabled>false</nacos.config-enabled> |
|||
<nacos.ip/> |
|||
</properties> |
|||
</profile> |
|||
<profile> |
|||
<id>test</id> |
|||
<!--<activation> |
|||
<activeByDefault>true</activeByDefault> |
|||
</activation>--> |
|||
<properties> |
|||
<server.port>8098</server.port> |
|||
<spring.profiles.active>test</spring.profiles.active> |
|||
|
|||
<!-- redis配置 --> |
|||
<spring.redis.index>0</spring.redis.index> |
|||
<spring.redis.host>10.10.10.248</spring.redis.host> |
|||
<spring.redis.port>6379</spring.redis.port> |
|||
<spring.redis.password>123456</spring.redis.password> |
|||
<!-- nacos --> |
|||
<nacos.register-enabled>true</nacos.register-enabled> |
|||
<nacos.server-addr>122.152.200.70:8848</nacos.server-addr> |
|||
<nacos.discovery.namespace>fcd6fc8f-ca3a-4b01-8026-2b05cdc5976b</nacos.discovery.namespace> |
|||
<nacos.config.namespace></nacos.config.namespace> |
|||
<nacos.config.group></nacos.config.group> |
|||
<nacos.config-enabled>false</nacos.config-enabled> |
|||
<nacos.ip/> |
|||
</properties> |
|||
</profile> |
|||
</profiles> |
|||
|
|||
</project> |
|||
@ -0,0 +1,17 @@ |
|||
package com.epmet; |
|||
|
|||
import org.springframework.boot.SpringApplication; |
|||
import org.springframework.boot.autoconfigure.SpringBootApplication; |
|||
import org.springframework.cloud.client.discovery.EnableDiscoveryClient; |
|||
import org.springframework.cloud.openfeign.EnableFeignClients; |
|||
|
|||
@SpringBootApplication |
|||
@EnableDiscoveryClient |
|||
@EnableFeignClients |
|||
public class GovMineApplication { |
|||
|
|||
public static void main(String[] args) { |
|||
SpringApplication.run(GovMineApplication.class, args); |
|||
} |
|||
|
|||
} |
|||
Some files were not shown because too many files changed in this diff
Loading…
Reference in new issue