系统权限控制切面工程实现
parent
1dece8a55a
commit
b60ba37fd6
@ -0,0 +1,86 @@
|
||||
package com.sztzjy.forex.trading_trading.annotation.aspect;
|
||||
|
||||
import com.sztzjy.forex.trading_trading.annotation.Permission;
|
||||
import com.sztzjy.forex.trading_trading.config.security.JwtUser;
|
||||
import com.sztzjy.forex.trading_trading.config.security.TokenProvider;
|
||||
import com.sztzjy.forex.trading_trading.service.RoleAuthorityService;
|
||||
import org.aspectj.lang.JoinPoint;
|
||||
import org.aspectj.lang.ProceedingJoinPoint;
|
||||
import org.aspectj.lang.annotation.*;
|
||||
import org.aspectj.lang.reflect.MethodSignature;
|
||||
import org.springframework.core.Ordered;
|
||||
import org.springframework.security.access.AccessDeniedException;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 系统权限拦截控制切面实现
|
||||
*
|
||||
* @author 陈沅
|
||||
*/
|
||||
@Aspect
|
||||
@Component
|
||||
public class PermissionAspect implements Ordered{
|
||||
|
||||
@Resource
|
||||
private HttpServletRequest request;
|
||||
|
||||
@Resource
|
||||
private RoleAuthorityService roleAuthorityService;
|
||||
|
||||
@Pointcut("@annotation(com.sztzjy.forex.trading_trading.annotation.Permission)")
|
||||
public void authPointcut() {
|
||||
}
|
||||
|
||||
|
||||
@Around("authPointcut()")
|
||||
public Object around(ProceedingJoinPoint point) throws Throwable {
|
||||
Object result = point.proceed();
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@Before("authPointcut()")
|
||||
public void before(JoinPoint joinPoint) {
|
||||
JwtUser onlineUser = TokenProvider.getJWTUser(request);
|
||||
if (onlineUser == null) {
|
||||
throw new AccessDeniedException("当前用户未登录");
|
||||
}
|
||||
// 获取注解参数
|
||||
MethodSignature sign = (MethodSignature) joinPoint.getSignature();
|
||||
Method method = sign.getMethod();
|
||||
Permission permission = method.getAnnotation(Permission.class);
|
||||
//限制权限类型
|
||||
String[] codes = permission.codes();
|
||||
if(onlineUser.getRoleId()==0){
|
||||
throw new AccessDeniedException("权限不足");
|
||||
}
|
||||
//角色绑定的权限列表
|
||||
List<String> codeList = roleAuthorityService.getAuthorityByRoleId(onlineUser.getRoleId());
|
||||
boolean hasPermission = false;
|
||||
for (String code : codes){
|
||||
if(codeList.contains(code)){
|
||||
hasPermission=true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!hasPermission){
|
||||
throw new AccessDeniedException("权限不足");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@After("authPointcut()")
|
||||
public void after() {
|
||||
//log.info("======>>> 后置通知:执行结束");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOrder() {
|
||||
return Ordered.HIGHEST_PRECEDENCE + 1;
|
||||
}
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
package com.sztzjy.forex.trading_trading.annotation.aspect;
|
||||
|
||||
|
||||
/**
|
||||
* 系统权限静态资源配置
|
||||
* author:陈沅
|
||||
*/
|
||||
public class PermissionType {
|
||||
|
||||
public final static String DATA_STATISTICS = "DATA_STATISTICS";
|
||||
public final static String QUOTATION_TRADING = "QUOTATION_TRADING";
|
||||
public final static String TERMINAL_MANAGEMENT = "TERMINAL_MANAGEMENT";
|
||||
public final static String TRADING = "TRADING";
|
||||
public final static String TRAINING_MANAGEMENT = "TRAINING_MANAGEMENT";
|
||||
public final static String TRAINING_MANAGEMENT_ADD = "TRAINING_MANAGEMENT_ADD";
|
||||
public final static String TRAINING_MANAGEMENT_DEL = "TRAINING_MANAGEMENT_DEL";
|
||||
public final static String TRAINING_MANAGEMENT_EDIT = "TRAINING_MANAGEMENT_EDIT";
|
||||
public final static String TRAINING_MANAGEMENT_SEARCH = "TRAINING_MANAGEMENT_SEARCH";
|
||||
public final static String TRAINING_PLAN_MANAGEMENT = "TRAINING_PLAN_MANAGEMENT";
|
||||
public final static String TRAINING_PLAN_MANAGEMENT_ADD = "TRAINING_PLAN_MANAGEMENT_ADD";
|
||||
public final static String TRAINING_PLAN_MANAGEMENT_DEL = "TRAINING_PLAN_MANAGEMENT_DEL";
|
||||
public final static String TRAINING_PLAN_MANAGEMENT_EDIT = "TRAINING_PLAN_MANAGEMENT_EDIT";
|
||||
public final static String TRAINING_PLAN_MANAGEMENT_SEARCH = "TRAINING_PLAN_MANAGEMENT_SEARCH";
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,102 @@
|
||||
package com.sztzjy.forex.trading_trading.entity;
|
||||
|
||||
public class RoleAuthority {
|
||||
/**
|
||||
*
|
||||
* This field was generated by MyBatis Generator.
|
||||
* This field corresponds to the database column sys_role_authority.id
|
||||
*
|
||||
* @mbg.generated Fri Jun 30 00:09:22 CST 2023
|
||||
*/
|
||||
private String id;
|
||||
|
||||
/**
|
||||
*
|
||||
* This field was generated by MyBatis Generator.
|
||||
* This field corresponds to the database column sys_role_authority.role_id
|
||||
*
|
||||
* @mbg.generated Fri Jun 30 00:09:22 CST 2023
|
||||
*/
|
||||
private Integer roleId;
|
||||
|
||||
/**
|
||||
*
|
||||
* This field was generated by MyBatis Generator.
|
||||
* This field corresponds to the database column sys_role_authority.authority_id
|
||||
*
|
||||
* @mbg.generated Fri Jun 30 00:09:22 CST 2023
|
||||
*/
|
||||
private String authorityId;
|
||||
|
||||
/**
|
||||
* This method was generated by MyBatis Generator.
|
||||
* This method returns the value of the database column sys_role_authority.id
|
||||
*
|
||||
* @return the value of sys_role_authority.id
|
||||
*
|
||||
* @mbg.generated Fri Jun 30 00:09:22 CST 2023
|
||||
*/
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method was generated by MyBatis Generator.
|
||||
* This method sets the value of the database column sys_role_authority.id
|
||||
*
|
||||
* @param id the value for sys_role_authority.id
|
||||
*
|
||||
* @mbg.generated Fri Jun 30 00:09:22 CST 2023
|
||||
*/
|
||||
public void setId(String id) {
|
||||
this.id = id == null ? null : id.trim();
|
||||
}
|
||||
|
||||
/**
|
||||
* This method was generated by MyBatis Generator.
|
||||
* This method returns the value of the database column sys_role_authority.role_id
|
||||
*
|
||||
* @return the value of sys_role_authority.role_id
|
||||
*
|
||||
* @mbg.generated Fri Jun 30 00:09:22 CST 2023
|
||||
*/
|
||||
public Integer getRoleId() {
|
||||
return roleId;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method was generated by MyBatis Generator.
|
||||
* This method sets the value of the database column sys_role_authority.role_id
|
||||
*
|
||||
* @param roleId the value for sys_role_authority.role_id
|
||||
*
|
||||
* @mbg.generated Fri Jun 30 00:09:22 CST 2023
|
||||
*/
|
||||
public void setRoleId(Integer roleId) {
|
||||
this.roleId = roleId;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method was generated by MyBatis Generator.
|
||||
* This method returns the value of the database column sys_role_authority.authority_id
|
||||
*
|
||||
* @return the value of sys_role_authority.authority_id
|
||||
*
|
||||
* @mbg.generated Fri Jun 30 00:09:22 CST 2023
|
||||
*/
|
||||
public String getAuthorityId() {
|
||||
return authorityId;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method was generated by MyBatis Generator.
|
||||
* This method sets the value of the database column sys_role_authority.authority_id
|
||||
*
|
||||
* @param authorityId the value for sys_role_authority.authority_id
|
||||
*
|
||||
* @mbg.generated Fri Jun 30 00:09:22 CST 2023
|
||||
*/
|
||||
public void setAuthorityId(String authorityId) {
|
||||
this.authorityId = authorityId == null ? null : authorityId.trim();
|
||||
}
|
||||
}
|
@ -0,0 +1,501 @@
|
||||
package com.sztzjy.forex.trading_trading.entity;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class RoleAuthorityExample {
|
||||
/**
|
||||
* This field was generated by MyBatis Generator.
|
||||
* This field corresponds to the database table sys_role_authority
|
||||
*
|
||||
* @mbg.generated Fri Jun 30 00:09:22 CST 2023
|
||||
*/
|
||||
protected String orderByClause;
|
||||
|
||||
/**
|
||||
* This field was generated by MyBatis Generator.
|
||||
* This field corresponds to the database table sys_role_authority
|
||||
*
|
||||
* @mbg.generated Fri Jun 30 00:09:22 CST 2023
|
||||
*/
|
||||
protected boolean distinct;
|
||||
|
||||
/**
|
||||
* This field was generated by MyBatis Generator.
|
||||
* This field corresponds to the database table sys_role_authority
|
||||
*
|
||||
* @mbg.generated Fri Jun 30 00:09:22 CST 2023
|
||||
*/
|
||||
protected List<Criteria> oredCriteria;
|
||||
|
||||
/**
|
||||
* This method was generated by MyBatis Generator.
|
||||
* This method corresponds to the database table sys_role_authority
|
||||
*
|
||||
* @mbg.generated Fri Jun 30 00:09:22 CST 2023
|
||||
*/
|
||||
public RoleAuthorityExample() {
|
||||
oredCriteria = new ArrayList<>();
|
||||
}
|
||||
|
||||
/**
|
||||
* This method was generated by MyBatis Generator.
|
||||
* This method corresponds to the database table sys_role_authority
|
||||
*
|
||||
* @mbg.generated Fri Jun 30 00:09:22 CST 2023
|
||||
*/
|
||||
public void setOrderByClause(String orderByClause) {
|
||||
this.orderByClause = orderByClause;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method was generated by MyBatis Generator.
|
||||
* This method corresponds to the database table sys_role_authority
|
||||
*
|
||||
* @mbg.generated Fri Jun 30 00:09:22 CST 2023
|
||||
*/
|
||||
public String getOrderByClause() {
|
||||
return orderByClause;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method was generated by MyBatis Generator.
|
||||
* This method corresponds to the database table sys_role_authority
|
||||
*
|
||||
* @mbg.generated Fri Jun 30 00:09:22 CST 2023
|
||||
*/
|
||||
public void setDistinct(boolean distinct) {
|
||||
this.distinct = distinct;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method was generated by MyBatis Generator.
|
||||
* This method corresponds to the database table sys_role_authority
|
||||
*
|
||||
* @mbg.generated Fri Jun 30 00:09:22 CST 2023
|
||||
*/
|
||||
public boolean isDistinct() {
|
||||
return distinct;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method was generated by MyBatis Generator.
|
||||
* This method corresponds to the database table sys_role_authority
|
||||
*
|
||||
* @mbg.generated Fri Jun 30 00:09:22 CST 2023
|
||||
*/
|
||||
public List<Criteria> getOredCriteria() {
|
||||
return oredCriteria;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method was generated by MyBatis Generator.
|
||||
* This method corresponds to the database table sys_role_authority
|
||||
*
|
||||
* @mbg.generated Fri Jun 30 00:09:22 CST 2023
|
||||
*/
|
||||
public void or(Criteria criteria) {
|
||||
oredCriteria.add(criteria);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method was generated by MyBatis Generator.
|
||||
* This method corresponds to the database table sys_role_authority
|
||||
*
|
||||
* @mbg.generated Fri Jun 30 00:09:22 CST 2023
|
||||
*/
|
||||
public Criteria or() {
|
||||
Criteria criteria = createCriteriaInternal();
|
||||
oredCriteria.add(criteria);
|
||||
return criteria;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method was generated by MyBatis Generator.
|
||||
* This method corresponds to the database table sys_role_authority
|
||||
*
|
||||
* @mbg.generated Fri Jun 30 00:09:22 CST 2023
|
||||
*/
|
||||
public Criteria createCriteria() {
|
||||
Criteria criteria = createCriteriaInternal();
|
||||
if (oredCriteria.size() == 0) {
|
||||
oredCriteria.add(criteria);
|
||||
}
|
||||
return criteria;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method was generated by MyBatis Generator.
|
||||
* This method corresponds to the database table sys_role_authority
|
||||
*
|
||||
* @mbg.generated Fri Jun 30 00:09:22 CST 2023
|
||||
*/
|
||||
protected Criteria createCriteriaInternal() {
|
||||
Criteria criteria = new Criteria();
|
||||
return criteria;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method was generated by MyBatis Generator.
|
||||
* This method corresponds to the database table sys_role_authority
|
||||
*
|
||||
* @mbg.generated Fri Jun 30 00:09:22 CST 2023
|
||||
*/
|
||||
public void clear() {
|
||||
oredCriteria.clear();
|
||||
orderByClause = null;
|
||||
distinct = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* This class was generated by MyBatis Generator.
|
||||
* This class corresponds to the database table sys_role_authority
|
||||
*
|
||||
* @mbg.generated Fri Jun 30 00:09:22 CST 2023
|
||||
*/
|
||||
protected abstract static class GeneratedCriteria {
|
||||
protected List<Criterion> criteria;
|
||||
|
||||
protected GeneratedCriteria() {
|
||||
super();
|
||||
criteria = new ArrayList<>();
|
||||
}
|
||||
|
||||
public boolean isValid() {
|
||||
return criteria.size() > 0;
|
||||
}
|
||||
|
||||
public List<Criterion> getAllCriteria() {
|
||||
return criteria;
|
||||
}
|
||||
|
||||
public List<Criterion> getCriteria() {
|
||||
return criteria;
|
||||
}
|
||||
|
||||
protected void addCriterion(String condition) {
|
||||
if (condition == null) {
|
||||
throw new RuntimeException("Value for condition cannot be null");
|
||||
}
|
||||
criteria.add(new Criterion(condition));
|
||||
}
|
||||
|
||||
protected void addCriterion(String condition, Object value, String property) {
|
||||
if (value == null) {
|
||||
throw new RuntimeException("Value for " + property + " cannot be null");
|
||||
}
|
||||
criteria.add(new Criterion(condition, value));
|
||||
}
|
||||
|
||||
protected void addCriterion(String condition, Object value1, Object value2, String property) {
|
||||
if (value1 == null || value2 == null) {
|
||||
throw new RuntimeException("Between values for " + property + " cannot be null");
|
||||
}
|
||||
criteria.add(new Criterion(condition, value1, value2));
|
||||
}
|
||||
|
||||
public Criteria andIdIsNull() {
|
||||
addCriterion("id is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdIsNotNull() {
|
||||
addCriterion("id is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdEqualTo(String value) {
|
||||
addCriterion("id =", value, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdNotEqualTo(String value) {
|
||||
addCriterion("id <>", value, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdGreaterThan(String value) {
|
||||
addCriterion("id >", value, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdGreaterThanOrEqualTo(String value) {
|
||||
addCriterion("id >=", value, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdLessThan(String value) {
|
||||
addCriterion("id <", value, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdLessThanOrEqualTo(String value) {
|
||||
addCriterion("id <=", value, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdLike(String value) {
|
||||
addCriterion("id like", value, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdNotLike(String value) {
|
||||
addCriterion("id not like", value, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdIn(List<String> values) {
|
||||
addCriterion("id in", values, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdNotIn(List<String> values) {
|
||||
addCriterion("id not in", values, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdBetween(String value1, String value2) {
|
||||
addCriterion("id between", value1, value2, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdNotBetween(String value1, String value2) {
|
||||
addCriterion("id not between", value1, value2, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andRoleIdIsNull() {
|
||||
addCriterion("role_id is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andRoleIdIsNotNull() {
|
||||
addCriterion("role_id is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andRoleIdEqualTo(Integer value) {
|
||||
addCriterion("role_id =", value, "roleId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andRoleIdNotEqualTo(Integer value) {
|
||||
addCriterion("role_id <>", value, "roleId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andRoleIdGreaterThan(Integer value) {
|
||||
addCriterion("role_id >", value, "roleId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andRoleIdGreaterThanOrEqualTo(Integer value) {
|
||||
addCriterion("role_id >=", value, "roleId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andRoleIdLessThan(Integer value) {
|
||||
addCriterion("role_id <", value, "roleId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andRoleIdLessThanOrEqualTo(Integer value) {
|
||||
addCriterion("role_id <=", value, "roleId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andRoleIdIn(List<Integer> values) {
|
||||
addCriterion("role_id in", values, "roleId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andRoleIdNotIn(List<Integer> values) {
|
||||
addCriterion("role_id not in", values, "roleId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andRoleIdBetween(Integer value1, Integer value2) {
|
||||
addCriterion("role_id between", value1, value2, "roleId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andRoleIdNotBetween(Integer value1, Integer value2) {
|
||||
addCriterion("role_id not between", value1, value2, "roleId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andAuthorityIdIsNull() {
|
||||
addCriterion("authority_id is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andAuthorityIdIsNotNull() {
|
||||
addCriterion("authority_id is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andAuthorityIdEqualTo(String value) {
|
||||
addCriterion("authority_id =", value, "authorityId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andAuthorityIdNotEqualTo(String value) {
|
||||
addCriterion("authority_id <>", value, "authorityId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andAuthorityIdGreaterThan(String value) {
|
||||
addCriterion("authority_id >", value, "authorityId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andAuthorityIdGreaterThanOrEqualTo(String value) {
|
||||
addCriterion("authority_id >=", value, "authorityId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andAuthorityIdLessThan(String value) {
|
||||
addCriterion("authority_id <", value, "authorityId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andAuthorityIdLessThanOrEqualTo(String value) {
|
||||
addCriterion("authority_id <=", value, "authorityId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andAuthorityIdLike(String value) {
|
||||
addCriterion("authority_id like", value, "authorityId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andAuthorityIdNotLike(String value) {
|
||||
addCriterion("authority_id not like", value, "authorityId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andAuthorityIdIn(List<String> values) {
|
||||
addCriterion("authority_id in", values, "authorityId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andAuthorityIdNotIn(List<String> values) {
|
||||
addCriterion("authority_id not in", values, "authorityId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andAuthorityIdBetween(String value1, String value2) {
|
||||
addCriterion("authority_id between", value1, value2, "authorityId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andAuthorityIdNotBetween(String value1, String value2) {
|
||||
addCriterion("authority_id not between", value1, value2, "authorityId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This class was generated by MyBatis Generator.
|
||||
* This class corresponds to the database table sys_role_authority
|
||||
*
|
||||
* @mbg.generated do_not_delete_during_merge Fri Jun 30 00:09:22 CST 2023
|
||||
*/
|
||||
public static class Criteria extends GeneratedCriteria {
|
||||
protected Criteria() {
|
||||
super();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This class was generated by MyBatis Generator.
|
||||
* This class corresponds to the database table sys_role_authority
|
||||
*
|
||||
* @mbg.generated Fri Jun 30 00:09:22 CST 2023
|
||||
*/
|
||||
public static class Criterion {
|
||||
private String condition;
|
||||
|
||||
private Object value;
|
||||
|
||||
private Object secondValue;
|
||||
|
||||
private boolean noValue;
|
||||
|
||||
private boolean singleValue;
|
||||
|
||||
private boolean betweenValue;
|
||||
|
||||
private boolean listValue;
|
||||
|
||||
private String typeHandler;
|
||||
|
||||
public String getCondition() {
|
||||
return condition;
|
||||
}
|
||||
|
||||
public Object getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public Object getSecondValue() {
|
||||
return secondValue;
|
||||
}
|
||||
|
||||
public boolean isNoValue() {
|
||||
return noValue;
|
||||
}
|
||||
|
||||
public boolean isSingleValue() {
|
||||
return singleValue;
|
||||
}
|
||||
|
||||
public boolean isBetweenValue() {
|
||||
return betweenValue;
|
||||
}
|
||||
|
||||
public boolean isListValue() {
|
||||
return listValue;
|
||||
}
|
||||
|
||||
public String getTypeHandler() {
|
||||
return typeHandler;
|
||||
}
|
||||
|
||||
protected Criterion(String condition) {
|
||||
super();
|
||||
this.condition = condition;
|
||||
this.typeHandler = null;
|
||||
this.noValue = true;
|
||||
}
|
||||
|
||||
protected Criterion(String condition, Object value, String typeHandler) {
|
||||
super();
|
||||
this.condition = condition;
|
||||
this.value = value;
|
||||
this.typeHandler = typeHandler;
|
||||
if (value instanceof List<?>) {
|
||||
this.listValue = true;
|
||||
} else {
|
||||
this.singleValue = true;
|
||||
}
|
||||
}
|
||||
|
||||
protected Criterion(String condition, Object value) {
|
||||
this(condition, value, null);
|
||||
}
|
||||
|
||||
protected Criterion(String condition, Object value, Object secondValue, String typeHandler) {
|
||||
super();
|
||||
this.condition = condition;
|
||||
this.value = value;
|
||||
this.secondValue = secondValue;
|
||||
this.typeHandler = typeHandler;
|
||||
this.betweenValue = true;
|
||||
}
|
||||
|
||||
protected Criterion(String condition, Object value, Object secondValue) {
|
||||
this(condition, value, secondValue, null);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,104 @@
|
||||
package com.sztzjy.forex.trading_trading.mappers;
|
||||
|
||||
import com.sztzjy.forex.trading_trading.entity.RoleAuthority;
|
||||
import com.sztzjy.forex.trading_trading.entity.RoleAuthorityExample;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
@Mapper
|
||||
public interface RoleAuthorityMapper {
|
||||
/**
|
||||
* This method was generated by MyBatis Generator.
|
||||
* This method corresponds to the database table sys_role_authority
|
||||
*
|
||||
* @mbg.generated Fri Jun 30 00:09:22 CST 2023
|
||||
*/
|
||||
long countByExample(RoleAuthorityExample example);
|
||||
|
||||
/**
|
||||
* This method was generated by MyBatis Generator.
|
||||
* This method corresponds to the database table sys_role_authority
|
||||
*
|
||||
* @mbg.generated Fri Jun 30 00:09:22 CST 2023
|
||||
*/
|
||||
int deleteByExample(RoleAuthorityExample example);
|
||||
|
||||
/**
|
||||
* This method was generated by MyBatis Generator.
|
||||
* This method corresponds to the database table sys_role_authority
|
||||
*
|
||||
* @mbg.generated Fri Jun 30 00:09:22 CST 2023
|
||||
*/
|
||||
int deleteByPrimaryKey(String id);
|
||||
|
||||
/**
|
||||
* This method was generated by MyBatis Generator.
|
||||
* This method corresponds to the database table sys_role_authority
|
||||
*
|
||||
* @mbg.generated Fri Jun 30 00:09:22 CST 2023
|
||||
*/
|
||||
int insert(RoleAuthority record);
|
||||
|
||||
/**
|
||||
* This method was generated by MyBatis Generator.
|
||||
* This method corresponds to the database table sys_role_authority
|
||||
*
|
||||
* @mbg.generated Fri Jun 30 00:09:22 CST 2023
|
||||
*/
|
||||
int insertSelective(RoleAuthority record);
|
||||
|
||||
/**
|
||||
* This method was generated by MyBatis Generator.
|
||||
* This method corresponds to the database table sys_role_authority
|
||||
*
|
||||
* @mbg.generated Fri Jun 30 00:09:22 CST 2023
|
||||
*/
|
||||
List<RoleAuthority> selectByExample(RoleAuthorityExample example);
|
||||
|
||||
/**
|
||||
* This method was generated by MyBatis Generator.
|
||||
* This method corresponds to the database table sys_role_authority
|
||||
*
|
||||
* @mbg.generated Fri Jun 30 00:09:22 CST 2023
|
||||
*/
|
||||
RoleAuthority selectByPrimaryKey(String id);
|
||||
|
||||
/**
|
||||
* This method was generated by MyBatis Generator.
|
||||
* This method corresponds to the database table sys_role_authority
|
||||
*
|
||||
* @mbg.generated Fri Jun 30 00:09:22 CST 2023
|
||||
*/
|
||||
int updateByExampleSelective(@Param("record") RoleAuthority record, @Param("example") RoleAuthorityExample example);
|
||||
|
||||
/**
|
||||
* This method was generated by MyBatis Generator.
|
||||
* This method corresponds to the database table sys_role_authority
|
||||
*
|
||||
* @mbg.generated Fri Jun 30 00:09:22 CST 2023
|
||||
*/
|
||||
int updateByExample(@Param("record") RoleAuthority record, @Param("example") RoleAuthorityExample example);
|
||||
|
||||
/**
|
||||
* This method was generated by MyBatis Generator.
|
||||
* This method corresponds to the database table sys_role_authority
|
||||
*
|
||||
* @mbg.generated Fri Jun 30 00:09:22 CST 2023
|
||||
*/
|
||||
int updateByPrimaryKeySelective(RoleAuthority record);
|
||||
|
||||
/**
|
||||
* This method was generated by MyBatis Generator.
|
||||
* This method corresponds to the database table sys_role_authority
|
||||
*
|
||||
* @mbg.generated Fri Jun 30 00:09:22 CST 2023
|
||||
*/
|
||||
int updateByPrimaryKey(RoleAuthority record);
|
||||
|
||||
|
||||
@Select("select authority_id from sys_role_authority where role_id = #{roleId}")
|
||||
List<String> getAuthorityCode(@Param("roleId") Integer roleId);
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package com.sztzjy.forex.trading_trading.service;
|
||||
|
||||
|
||||
import com.sztzjy.forex.trading_trading.mappers.RoleAuthorityMapper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class RoleAuthorityService {
|
||||
|
||||
|
||||
@Autowired
|
||||
RoleAuthorityMapper roleAuthorityMapper;
|
||||
|
||||
|
||||
public List<String> getAuthorityByRoleId(Integer roleId) {
|
||||
return roleAuthorityMapper.getAuthorityCode(roleId);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,256 @@
|
||||
<?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.sztzjy.forex.trading_trading.mappers.RoleAuthorityMapper">
|
||||
<resultMap id="BaseResultMap" type="com.sztzjy.forex.trading_trading.entity.RoleAuthority">
|
||||
<!--
|
||||
WARNING - @mbg.generated
|
||||
This element is automatically generated by MyBatis Generator, do not modify.
|
||||
This element was generated on Fri Jun 30 00:09:22 CST 2023.
|
||||
-->
|
||||
<id column="id" jdbcType="VARCHAR" property="id" />
|
||||
<result column="role_id" jdbcType="INTEGER" property="roleId" />
|
||||
<result column="authority_id" jdbcType="VARCHAR" property="authorityId" />
|
||||
</resultMap>
|
||||
<sql id="Example_Where_Clause">
|
||||
<!--
|
||||
WARNING - @mbg.generated
|
||||
This element is automatically generated by MyBatis Generator, do not modify.
|
||||
This element was generated on Fri Jun 30 00:09:22 CST 2023.
|
||||
-->
|
||||
<where>
|
||||
<foreach collection="oredCriteria" item="criteria" separator="or">
|
||||
<if test="criteria.valid">
|
||||
<trim prefix="(" prefixOverrides="and" suffix=")">
|
||||
<foreach collection="criteria.criteria" item="criterion">
|
||||
<choose>
|
||||
<when test="criterion.noValue">
|
||||
and ${criterion.condition}
|
||||
</when>
|
||||
<when test="criterion.singleValue">
|
||||
and ${criterion.condition} #{criterion.value}
|
||||
</when>
|
||||
<when test="criterion.betweenValue">
|
||||
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
|
||||
</when>
|
||||
<when test="criterion.listValue">
|
||||
and ${criterion.condition}
|
||||
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
|
||||
#{listItem}
|
||||
</foreach>
|
||||
</when>
|
||||
</choose>
|
||||
</foreach>
|
||||
</trim>
|
||||
</if>
|
||||
</foreach>
|
||||
</where>
|
||||
</sql>
|
||||
<sql id="Update_By_Example_Where_Clause">
|
||||
<!--
|
||||
WARNING - @mbg.generated
|
||||
This element is automatically generated by MyBatis Generator, do not modify.
|
||||
This element was generated on Fri Jun 30 00:09:22 CST 2023.
|
||||
-->
|
||||
<where>
|
||||
<foreach collection="example.oredCriteria" item="criteria" separator="or">
|
||||
<if test="criteria.valid">
|
||||
<trim prefix="(" prefixOverrides="and" suffix=")">
|
||||
<foreach collection="criteria.criteria" item="criterion">
|
||||
<choose>
|
||||
<when test="criterion.noValue">
|
||||
and ${criterion.condition}
|
||||
</when>
|
||||
<when test="criterion.singleValue">
|
||||
and ${criterion.condition} #{criterion.value}
|
||||
</when>
|
||||
<when test="criterion.betweenValue">
|
||||
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
|
||||
</when>
|
||||
<when test="criterion.listValue">
|
||||
and ${criterion.condition}
|
||||
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
|
||||
#{listItem}
|
||||
</foreach>
|
||||
</when>
|
||||
</choose>
|
||||
</foreach>
|
||||
</trim>
|
||||
</if>
|
||||
</foreach>
|
||||
</where>
|
||||
</sql>
|
||||
<sql id="Base_Column_List">
|
||||
<!--
|
||||
WARNING - @mbg.generated
|
||||
This element is automatically generated by MyBatis Generator, do not modify.
|
||||
This element was generated on Fri Jun 30 00:09:22 CST 2023.
|
||||
-->
|
||||
id, role_id, authority_id
|
||||
</sql>
|
||||
<select id="selectByExample" parameterType="com.sztzjy.forex.trading_trading.entity.RoleAuthorityExample" resultMap="BaseResultMap">
|
||||
<!--
|
||||
WARNING - @mbg.generated
|
||||
This element is automatically generated by MyBatis Generator, do not modify.
|
||||
This element was generated on Fri Jun 30 00:09:22 CST 2023.
|
||||
-->
|
||||
select
|
||||
<if test="distinct">
|
||||
distinct
|
||||
</if>
|
||||
<include refid="Base_Column_List" />
|
||||
from sys_role_authority
|
||||
<if test="_parameter != null">
|
||||
<include refid="Example_Where_Clause" />
|
||||
</if>
|
||||
<if test="orderByClause != null">
|
||||
order by ${orderByClause}
|
||||
</if>
|
||||
</select>
|
||||
<select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
|
||||
<!--
|
||||
WARNING - @mbg.generated
|
||||
This element is automatically generated by MyBatis Generator, do not modify.
|
||||
This element was generated on Fri Jun 30 00:09:22 CST 2023.
|
||||
-->
|
||||
select
|
||||
<include refid="Base_Column_List" />
|
||||
from sys_role_authority
|
||||
where id = #{id,jdbcType=VARCHAR}
|
||||
</select>
|
||||
<delete id="deleteByPrimaryKey" parameterType="java.lang.String">
|
||||
<!--
|
||||
WARNING - @mbg.generated
|
||||
This element is automatically generated by MyBatis Generator, do not modify.
|
||||
This element was generated on Fri Jun 30 00:09:22 CST 2023.
|
||||
-->
|
||||
delete from sys_role_authority
|
||||
where id = #{id,jdbcType=VARCHAR}
|
||||
</delete>
|
||||
<delete id="deleteByExample" parameterType="com.sztzjy.forex.trading_trading.entity.RoleAuthorityExample">
|
||||
<!--
|
||||
WARNING - @mbg.generated
|
||||
This element is automatically generated by MyBatis Generator, do not modify.
|
||||
This element was generated on Fri Jun 30 00:09:22 CST 2023.
|
||||
-->
|
||||
delete from sys_role_authority
|
||||
<if test="_parameter != null">
|
||||
<include refid="Example_Where_Clause" />
|
||||
</if>
|
||||
</delete>
|
||||
<insert id="insert" parameterType="com.sztzjy.forex.trading_trading.entity.RoleAuthority">
|
||||
<!--
|
||||
WARNING - @mbg.generated
|
||||
This element is automatically generated by MyBatis Generator, do not modify.
|
||||
This element was generated on Fri Jun 30 00:09:22 CST 2023.
|
||||
-->
|
||||
insert into sys_role_authority (id, role_id, authority_id
|
||||
)
|
||||
values (#{id,jdbcType=VARCHAR}, #{roleId,jdbcType=INTEGER}, #{authorityId,jdbcType=VARCHAR}
|
||||
)
|
||||
</insert>
|
||||
<insert id="insertSelective" parameterType="com.sztzjy.forex.trading_trading.entity.RoleAuthority">
|
||||
<!--
|
||||
WARNING - @mbg.generated
|
||||
This element is automatically generated by MyBatis Generator, do not modify.
|
||||
This element was generated on Fri Jun 30 00:09:22 CST 2023.
|
||||
-->
|
||||
insert into sys_role_authority
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">
|
||||
id,
|
||||
</if>
|
||||
<if test="roleId != null">
|
||||
role_id,
|
||||
</if>
|
||||
<if test="authorityId != null">
|
||||
authority_id,
|
||||
</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">
|
||||
#{id,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="roleId != null">
|
||||
#{roleId,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="authorityId != null">
|
||||
#{authorityId,jdbcType=VARCHAR},
|
||||
</if>
|
||||
</trim>
|
||||
</insert>
|
||||
<select id="countByExample" parameterType="com.sztzjy.forex.trading_trading.entity.RoleAuthorityExample" resultType="java.lang.Long">
|
||||
<!--
|
||||
WARNING - @mbg.generated
|
||||
This element is automatically generated by MyBatis Generator, do not modify.
|
||||
This element was generated on Fri Jun 30 00:09:22 CST 2023.
|
||||
-->
|
||||
select count(*) from sys_role_authority
|
||||
<if test="_parameter != null">
|
||||
<include refid="Example_Where_Clause" />
|
||||
</if>
|
||||
</select>
|
||||
<update id="updateByExampleSelective" parameterType="map">
|
||||
<!--
|
||||
WARNING - @mbg.generated
|
||||
This element is automatically generated by MyBatis Generator, do not modify.
|
||||
This element was generated on Fri Jun 30 00:09:22 CST 2023.
|
||||
-->
|
||||
update sys_role_authority
|
||||
<set>
|
||||
<if test="record.id != null">
|
||||
id = #{record.id,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="record.roleId != null">
|
||||
role_id = #{record.roleId,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="record.authorityId != null">
|
||||
authority_id = #{record.authorityId,jdbcType=VARCHAR},
|
||||
</if>
|
||||
</set>
|
||||
<if test="_parameter != null">
|
||||
<include refid="Update_By_Example_Where_Clause" />
|
||||
</if>
|
||||
</update>
|
||||
<update id="updateByExample" parameterType="map">
|
||||
<!--
|
||||
WARNING - @mbg.generated
|
||||
This element is automatically generated by MyBatis Generator, do not modify.
|
||||
This element was generated on Fri Jun 30 00:09:22 CST 2023.
|
||||
-->
|
||||
update sys_role_authority
|
||||
set id = #{record.id,jdbcType=VARCHAR},
|
||||
role_id = #{record.roleId,jdbcType=INTEGER},
|
||||
authority_id = #{record.authorityId,jdbcType=VARCHAR}
|
||||
<if test="_parameter != null">
|
||||
<include refid="Update_By_Example_Where_Clause" />
|
||||
</if>
|
||||
</update>
|
||||
<update id="updateByPrimaryKeySelective" parameterType="com.sztzjy.forex.trading_trading.entity.RoleAuthority">
|
||||
<!--
|
||||
WARNING - @mbg.generated
|
||||
This element is automatically generated by MyBatis Generator, do not modify.
|
||||
This element was generated on Fri Jun 30 00:09:22 CST 2023.
|
||||
-->
|
||||
update sys_role_authority
|
||||
<set>
|
||||
<if test="roleId != null">
|
||||
role_id = #{roleId,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="authorityId != null">
|
||||
authority_id = #{authorityId,jdbcType=VARCHAR},
|
||||
</if>
|
||||
</set>
|
||||
where id = #{id,jdbcType=VARCHAR}
|
||||
</update>
|
||||
<update id="updateByPrimaryKey" parameterType="com.sztzjy.forex.trading_trading.entity.RoleAuthority">
|
||||
<!--
|
||||
WARNING - @mbg.generated
|
||||
This element is automatically generated by MyBatis Generator, do not modify.
|
||||
This element was generated on Fri Jun 30 00:09:22 CST 2023.
|
||||
-->
|
||||
update sys_role_authority
|
||||
set role_id = #{roleId,jdbcType=INTEGER},
|
||||
authority_id = #{authorityId,jdbcType=VARCHAR}
|
||||
where id = #{id,jdbcType=VARCHAR}
|
||||
</update>
|
||||
</mapper>
|
Loading…
Reference in New Issue