diff --git a/xymanager_admin/src/main/java/com/shxy/xymanager_admin/controller/RoleController.java b/xymanager_admin/src/main/java/com/shxy/xymanager_admin/controller/RoleController.java index 3e453f2..90c26d3 100644 --- a/xymanager_admin/src/main/java/com/shxy/xymanager_admin/controller/RoleController.java +++ b/xymanager_admin/src/main/java/com/shxy/xymanager_admin/controller/RoleController.java @@ -2,12 +2,13 @@ package com.shxy.xymanager_admin.controller; import com.shxy.xymanager_common.base.BaseController; import com.shxy.xymanager_common.base.ResponseReult; -import com.shxy.xymanager_common.bean.ServiceBody; -import com.shxy.xymanager_common.bean.ServiceStatus; import com.shxy.xymanager_common.entity.DyLevel; import com.shxy.xymanager_common.entity.TbRole; +import com.shxy.xymanager_common.entity.TbRoleResource; import com.shxy.xymanager_common.exception.ApiException; +import com.shxy.xymanager_common.model.RolePermissionModel; import com.shxy.xymanager_service.service.NewCacheService; +import com.shxy.xymanager_service.service.RolePermissionService; import com.shxy.xymanager_service.service.RoleService; import io.swagger.annotations.Api; @@ -30,6 +31,8 @@ public class RoleController extends BaseController { RoleService service; @Resource NewCacheService cacheService; + @Resource + RolePermissionService permissionService; @GetMapping("listAll") @ApiOperation("查询全部列表") @@ -72,4 +75,18 @@ public class RoleController extends BaseController { return ResponseReult.success(list); } + @GetMapping("getPermission") + @ApiOperation("查询权限") + public ResponseReult> getPermission(@Validated @NotNull(message = "id不能为空!") Integer id) throws Exception { + List result = permissionService.getPermission(id); + return ResponseReult.success(result); + } + + @PostMapping("changePermission") + @ApiOperation("修改权限") + public ResponseReult changePermission(@Validated @RequestBody RolePermissionModel item) throws Exception { + permissionService.changePermission(item.getRoleId(), item.getList()); + return ResponseReult.success("OK"); + } + } diff --git a/xymanager_common/src/main/java/com/shxy/xymanager_common/entity/TbResource.java b/xymanager_common/src/main/java/com/shxy/xymanager_common/entity/TbResource.java new file mode 100644 index 0000000..f138bfb --- /dev/null +++ b/xymanager_common/src/main/java/com/shxy/xymanager_common/entity/TbResource.java @@ -0,0 +1,102 @@ +package com.shxy.xymanager_common.entity; + +public class TbResource { + /** + * + * This field was generated by MyBatis Generator. + * This field corresponds to the database column tb_resource.id + * + * @mbg.generated + */ + private Integer id; + + /** + * + * This field was generated by MyBatis Generator. + * This field corresponds to the database column tb_resource.key + * + * @mbg.generated + */ + private String key; + + /** + * + * This field was generated by MyBatis Generator. + * This field corresponds to the database column tb_resource.desc + * + * @mbg.generated + */ + private String desc; + + /** + * This method was generated by MyBatis Generator. + * This method returns the value of the database column tb_resource.id + * + * @return the value of tb_resource.id + * + * @mbg.generated + */ + public Integer getId() { + return id; + } + + /** + * This method was generated by MyBatis Generator. + * This method sets the value of the database column tb_resource.id + * + * @param id the value for tb_resource.id + * + * @mbg.generated + */ + public void setId(Integer id) { + this.id = id; + } + + /** + * This method was generated by MyBatis Generator. + * This method returns the value of the database column tb_resource.key + * + * @return the value of tb_resource.key + * + * @mbg.generated + */ + public String getKey() { + return key; + } + + /** + * This method was generated by MyBatis Generator. + * This method sets the value of the database column tb_resource.key + * + * @param key the value for tb_resource.key + * + * @mbg.generated + */ + public void setKey(String key) { + this.key = key; + } + + /** + * This method was generated by MyBatis Generator. + * This method returns the value of the database column tb_resource.desc + * + * @return the value of tb_resource.desc + * + * @mbg.generated + */ + public String getDesc() { + return desc; + } + + /** + * This method was generated by MyBatis Generator. + * This method sets the value of the database column tb_resource.desc + * + * @param desc the value for tb_resource.desc + * + * @mbg.generated + */ + public void setDesc(String desc) { + this.desc = desc; + } +} \ No newline at end of file diff --git a/xymanager_common/src/main/java/com/shxy/xymanager_common/entity/TbResourceExample.java b/xymanager_common/src/main/java/com/shxy/xymanager_common/entity/TbResourceExample.java new file mode 100644 index 0000000..d1f5704 --- /dev/null +++ b/xymanager_common/src/main/java/com/shxy/xymanager_common/entity/TbResourceExample.java @@ -0,0 +1,501 @@ +package com.shxy.xymanager_common.entity; + +import java.util.ArrayList; +import java.util.List; + +public class TbResourceExample { + /** + * This field was generated by MyBatis Generator. + * This field corresponds to the database table tb_resource + * + * @mbg.generated + */ + protected String orderByClause; + + /** + * This field was generated by MyBatis Generator. + * This field corresponds to the database table tb_resource + * + * @mbg.generated + */ + protected boolean distinct; + + /** + * This field was generated by MyBatis Generator. + * This field corresponds to the database table tb_resource + * + * @mbg.generated + */ + protected List oredCriteria; + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table tb_resource + * + * @mbg.generated + */ + public TbResourceExample() { + oredCriteria = new ArrayList<>(); + } + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table tb_resource + * + * @mbg.generated + */ + public void setOrderByClause(String orderByClause) { + this.orderByClause = orderByClause; + } + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table tb_resource + * + * @mbg.generated + */ + public String getOrderByClause() { + return orderByClause; + } + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table tb_resource + * + * @mbg.generated + */ + public void setDistinct(boolean distinct) { + this.distinct = distinct; + } + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table tb_resource + * + * @mbg.generated + */ + public boolean isDistinct() { + return distinct; + } + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table tb_resource + * + * @mbg.generated + */ + public List getOredCriteria() { + return oredCriteria; + } + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table tb_resource + * + * @mbg.generated + */ + public void or(Criteria criteria) { + oredCriteria.add(criteria); + } + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table tb_resource + * + * @mbg.generated + */ + 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 tb_resource + * + * @mbg.generated + */ + 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 tb_resource + * + * @mbg.generated + */ + protected Criteria createCriteriaInternal() { + Criteria criteria = new Criteria(); + return criteria; + } + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table tb_resource + * + * @mbg.generated + */ + public void clear() { + oredCriteria.clear(); + orderByClause = null; + distinct = false; + } + + /** + * This class was generated by MyBatis Generator. + * This class corresponds to the database table tb_resource + * + * @mbg.generated + */ + protected abstract static class GeneratedCriteria { + protected List criteria; + + protected GeneratedCriteria() { + super(); + criteria = new ArrayList<>(); + } + + public boolean isValid() { + return criteria.size() > 0; + } + + public List getAllCriteria() { + return criteria; + } + + public List 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(Integer value) { + addCriterion("id =", value, "id"); + return (Criteria) this; + } + + public Criteria andIdNotEqualTo(Integer value) { + addCriterion("id <>", value, "id"); + return (Criteria) this; + } + + public Criteria andIdGreaterThan(Integer value) { + addCriterion("id >", value, "id"); + return (Criteria) this; + } + + public Criteria andIdGreaterThanOrEqualTo(Integer value) { + addCriterion("id >=", value, "id"); + return (Criteria) this; + } + + public Criteria andIdLessThan(Integer value) { + addCriterion("id <", value, "id"); + return (Criteria) this; + } + + public Criteria andIdLessThanOrEqualTo(Integer value) { + addCriterion("id <=", value, "id"); + return (Criteria) this; + } + + public Criteria andIdIn(List values) { + addCriterion("id in", values, "id"); + return (Criteria) this; + } + + public Criteria andIdNotIn(List values) { + addCriterion("id not in", values, "id"); + return (Criteria) this; + } + + public Criteria andIdBetween(Integer value1, Integer value2) { + addCriterion("id between", value1, value2, "id"); + return (Criteria) this; + } + + public Criteria andIdNotBetween(Integer value1, Integer value2) { + addCriterion("id not between", value1, value2, "id"); + return (Criteria) this; + } + + public Criteria andKeyIsNull() { + addCriterion("`key` is null"); + return (Criteria) this; + } + + public Criteria andKeyIsNotNull() { + addCriterion("`key` is not null"); + return (Criteria) this; + } + + public Criteria andKeyEqualTo(String value) { + addCriterion("`key` =", value, "key"); + return (Criteria) this; + } + + public Criteria andKeyNotEqualTo(String value) { + addCriterion("`key` <>", value, "key"); + return (Criteria) this; + } + + public Criteria andKeyGreaterThan(String value) { + addCriterion("`key` >", value, "key"); + return (Criteria) this; + } + + public Criteria andKeyGreaterThanOrEqualTo(String value) { + addCriterion("`key` >=", value, "key"); + return (Criteria) this; + } + + public Criteria andKeyLessThan(String value) { + addCriterion("`key` <", value, "key"); + return (Criteria) this; + } + + public Criteria andKeyLessThanOrEqualTo(String value) { + addCriterion("`key` <=", value, "key"); + return (Criteria) this; + } + + public Criteria andKeyLike(String value) { + addCriterion("`key` like", value, "key"); + return (Criteria) this; + } + + public Criteria andKeyNotLike(String value) { + addCriterion("`key` not like", value, "key"); + return (Criteria) this; + } + + public Criteria andKeyIn(List values) { + addCriterion("`key` in", values, "key"); + return (Criteria) this; + } + + public Criteria andKeyNotIn(List values) { + addCriterion("`key` not in", values, "key"); + return (Criteria) this; + } + + public Criteria andKeyBetween(String value1, String value2) { + addCriterion("`key` between", value1, value2, "key"); + return (Criteria) this; + } + + public Criteria andKeyNotBetween(String value1, String value2) { + addCriterion("`key` not between", value1, value2, "key"); + return (Criteria) this; + } + + public Criteria andDescIsNull() { + addCriterion("`desc` is null"); + return (Criteria) this; + } + + public Criteria andDescIsNotNull() { + addCriterion("`desc` is not null"); + return (Criteria) this; + } + + public Criteria andDescEqualTo(String value) { + addCriterion("`desc` =", value, "desc"); + return (Criteria) this; + } + + public Criteria andDescNotEqualTo(String value) { + addCriterion("`desc` <>", value, "desc"); + return (Criteria) this; + } + + public Criteria andDescGreaterThan(String value) { + addCriterion("`desc` >", value, "desc"); + return (Criteria) this; + } + + public Criteria andDescGreaterThanOrEqualTo(String value) { + addCriterion("`desc` >=", value, "desc"); + return (Criteria) this; + } + + public Criteria andDescLessThan(String value) { + addCriterion("`desc` <", value, "desc"); + return (Criteria) this; + } + + public Criteria andDescLessThanOrEqualTo(String value) { + addCriterion("`desc` <=", value, "desc"); + return (Criteria) this; + } + + public Criteria andDescLike(String value) { + addCriterion("`desc` like", value, "desc"); + return (Criteria) this; + } + + public Criteria andDescNotLike(String value) { + addCriterion("`desc` not like", value, "desc"); + return (Criteria) this; + } + + public Criteria andDescIn(List values) { + addCriterion("`desc` in", values, "desc"); + return (Criteria) this; + } + + public Criteria andDescNotIn(List values) { + addCriterion("`desc` not in", values, "desc"); + return (Criteria) this; + } + + public Criteria andDescBetween(String value1, String value2) { + addCriterion("`desc` between", value1, value2, "desc"); + return (Criteria) this; + } + + public Criteria andDescNotBetween(String value1, String value2) { + addCriterion("`desc` not between", value1, value2, "desc"); + return (Criteria) this; + } + } + + /** + * This class was generated by MyBatis Generator. + * This class corresponds to the database table tb_resource + * + * @mbg.generated do_not_delete_during_merge + */ + public static class Criteria extends GeneratedCriteria { + protected Criteria() { + super(); + } + } + + /** + * This class was generated by MyBatis Generator. + * This class corresponds to the database table tb_resource + * + * @mbg.generated + */ + 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); + } + } +} \ No newline at end of file diff --git a/xymanager_common/src/main/java/com/shxy/xymanager_common/entity/TbRoleResource.java b/xymanager_common/src/main/java/com/shxy/xymanager_common/entity/TbRoleResource.java new file mode 100644 index 0000000..5eda667 --- /dev/null +++ b/xymanager_common/src/main/java/com/shxy/xymanager_common/entity/TbRoleResource.java @@ -0,0 +1,102 @@ +package com.shxy.xymanager_common.entity; + +public class TbRoleResource { + /** + * + * This field was generated by MyBatis Generator. + * This field corresponds to the database column tb_role_resource.id + * + * @mbg.generated + */ + private Integer id; + + /** + * + * This field was generated by MyBatis Generator. + * This field corresponds to the database column tb_role_resource.role_id + * + * @mbg.generated + */ + private Integer roleId; + + /** + * + * This field was generated by MyBatis Generator. + * This field corresponds to the database column tb_role_resource.resource_id + * + * @mbg.generated + */ + private Integer resourceId; + + /** + * This method was generated by MyBatis Generator. + * This method returns the value of the database column tb_role_resource.id + * + * @return the value of tb_role_resource.id + * + * @mbg.generated + */ + public Integer getId() { + return id; + } + + /** + * This method was generated by MyBatis Generator. + * This method sets the value of the database column tb_role_resource.id + * + * @param id the value for tb_role_resource.id + * + * @mbg.generated + */ + public void setId(Integer id) { + this.id = id; + } + + /** + * This method was generated by MyBatis Generator. + * This method returns the value of the database column tb_role_resource.role_id + * + * @return the value of tb_role_resource.role_id + * + * @mbg.generated + */ + public Integer getRoleId() { + return roleId; + } + + /** + * This method was generated by MyBatis Generator. + * This method sets the value of the database column tb_role_resource.role_id + * + * @param roleId the value for tb_role_resource.role_id + * + * @mbg.generated + */ + public void setRoleId(Integer roleId) { + this.roleId = roleId; + } + + /** + * This method was generated by MyBatis Generator. + * This method returns the value of the database column tb_role_resource.resource_id + * + * @return the value of tb_role_resource.resource_id + * + * @mbg.generated + */ + public Integer getResourceId() { + return resourceId; + } + + /** + * This method was generated by MyBatis Generator. + * This method sets the value of the database column tb_role_resource.resource_id + * + * @param resourceId the value for tb_role_resource.resource_id + * + * @mbg.generated + */ + public void setResourceId(Integer resourceId) { + this.resourceId = resourceId; + } +} \ No newline at end of file diff --git a/xymanager_common/src/main/java/com/shxy/xymanager_common/entity/TbRoleResourceExample.java b/xymanager_common/src/main/java/com/shxy/xymanager_common/entity/TbRoleResourceExample.java new file mode 100644 index 0000000..b2d50e9 --- /dev/null +++ b/xymanager_common/src/main/java/com/shxy/xymanager_common/entity/TbRoleResourceExample.java @@ -0,0 +1,481 @@ +package com.shxy.xymanager_common.entity; + +import java.util.ArrayList; +import java.util.List; + +public class TbRoleResourceExample { + /** + * This field was generated by MyBatis Generator. + * This field corresponds to the database table tb_role_resource + * + * @mbg.generated + */ + protected String orderByClause; + + /** + * This field was generated by MyBatis Generator. + * This field corresponds to the database table tb_role_resource + * + * @mbg.generated + */ + protected boolean distinct; + + /** + * This field was generated by MyBatis Generator. + * This field corresponds to the database table tb_role_resource + * + * @mbg.generated + */ + protected List oredCriteria; + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table tb_role_resource + * + * @mbg.generated + */ + public TbRoleResourceExample() { + oredCriteria = new ArrayList<>(); + } + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table tb_role_resource + * + * @mbg.generated + */ + public void setOrderByClause(String orderByClause) { + this.orderByClause = orderByClause; + } + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table tb_role_resource + * + * @mbg.generated + */ + public String getOrderByClause() { + return orderByClause; + } + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table tb_role_resource + * + * @mbg.generated + */ + public void setDistinct(boolean distinct) { + this.distinct = distinct; + } + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table tb_role_resource + * + * @mbg.generated + */ + public boolean isDistinct() { + return distinct; + } + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table tb_role_resource + * + * @mbg.generated + */ + public List getOredCriteria() { + return oredCriteria; + } + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table tb_role_resource + * + * @mbg.generated + */ + public void or(Criteria criteria) { + oredCriteria.add(criteria); + } + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table tb_role_resource + * + * @mbg.generated + */ + 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 tb_role_resource + * + * @mbg.generated + */ + 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 tb_role_resource + * + * @mbg.generated + */ + protected Criteria createCriteriaInternal() { + Criteria criteria = new Criteria(); + return criteria; + } + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table tb_role_resource + * + * @mbg.generated + */ + public void clear() { + oredCriteria.clear(); + orderByClause = null; + distinct = false; + } + + /** + * This class was generated by MyBatis Generator. + * This class corresponds to the database table tb_role_resource + * + * @mbg.generated + */ + protected abstract static class GeneratedCriteria { + protected List criteria; + + protected GeneratedCriteria() { + super(); + criteria = new ArrayList<>(); + } + + public boolean isValid() { + return criteria.size() > 0; + } + + public List getAllCriteria() { + return criteria; + } + + public List 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(Integer value) { + addCriterion("id =", value, "id"); + return (Criteria) this; + } + + public Criteria andIdNotEqualTo(Integer value) { + addCriterion("id <>", value, "id"); + return (Criteria) this; + } + + public Criteria andIdGreaterThan(Integer value) { + addCriterion("id >", value, "id"); + return (Criteria) this; + } + + public Criteria andIdGreaterThanOrEqualTo(Integer value) { + addCriterion("id >=", value, "id"); + return (Criteria) this; + } + + public Criteria andIdLessThan(Integer value) { + addCriterion("id <", value, "id"); + return (Criteria) this; + } + + public Criteria andIdLessThanOrEqualTo(Integer value) { + addCriterion("id <=", value, "id"); + return (Criteria) this; + } + + public Criteria andIdIn(List values) { + addCriterion("id in", values, "id"); + return (Criteria) this; + } + + public Criteria andIdNotIn(List values) { + addCriterion("id not in", values, "id"); + return (Criteria) this; + } + + public Criteria andIdBetween(Integer value1, Integer value2) { + addCriterion("id between", value1, value2, "id"); + return (Criteria) this; + } + + public Criteria andIdNotBetween(Integer value1, Integer 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 values) { + addCriterion("role_id in", values, "roleId"); + return (Criteria) this; + } + + public Criteria andRoleIdNotIn(List 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 andResourceIdIsNull() { + addCriterion("resource_id is null"); + return (Criteria) this; + } + + public Criteria andResourceIdIsNotNull() { + addCriterion("resource_id is not null"); + return (Criteria) this; + } + + public Criteria andResourceIdEqualTo(Integer value) { + addCriterion("resource_id =", value, "resourceId"); + return (Criteria) this; + } + + public Criteria andResourceIdNotEqualTo(Integer value) { + addCriterion("resource_id <>", value, "resourceId"); + return (Criteria) this; + } + + public Criteria andResourceIdGreaterThan(Integer value) { + addCriterion("resource_id >", value, "resourceId"); + return (Criteria) this; + } + + public Criteria andResourceIdGreaterThanOrEqualTo(Integer value) { + addCriterion("resource_id >=", value, "resourceId"); + return (Criteria) this; + } + + public Criteria andResourceIdLessThan(Integer value) { + addCriterion("resource_id <", value, "resourceId"); + return (Criteria) this; + } + + public Criteria andResourceIdLessThanOrEqualTo(Integer value) { + addCriterion("resource_id <=", value, "resourceId"); + return (Criteria) this; + } + + public Criteria andResourceIdIn(List values) { + addCriterion("resource_id in", values, "resourceId"); + return (Criteria) this; + } + + public Criteria andResourceIdNotIn(List values) { + addCriterion("resource_id not in", values, "resourceId"); + return (Criteria) this; + } + + public Criteria andResourceIdBetween(Integer value1, Integer value2) { + addCriterion("resource_id between", value1, value2, "resourceId"); + return (Criteria) this; + } + + public Criteria andResourceIdNotBetween(Integer value1, Integer value2) { + addCriterion("resource_id not between", value1, value2, "resourceId"); + return (Criteria) this; + } + } + + /** + * This class was generated by MyBatis Generator. + * This class corresponds to the database table tb_role_resource + * + * @mbg.generated do_not_delete_during_merge + */ + public static class Criteria extends GeneratedCriteria { + protected Criteria() { + super(); + } + } + + /** + * This class was generated by MyBatis Generator. + * This class corresponds to the database table tb_role_resource + * + * @mbg.generated + */ + 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); + } + } +} \ No newline at end of file diff --git a/xymanager_common/src/main/java/com/shxy/xymanager_common/model/RolePermissionModel.java b/xymanager_common/src/main/java/com/shxy/xymanager_common/model/RolePermissionModel.java new file mode 100644 index 0000000..8d47c5e --- /dev/null +++ b/xymanager_common/src/main/java/com/shxy/xymanager_common/model/RolePermissionModel.java @@ -0,0 +1,14 @@ +package com.shxy.xymanager_common.model; + +import com.shxy.xymanager_common.entity.TbRoleResource; +import lombok.Data; + +import javax.validation.constraints.NotNull; +import java.util.List; + +@Data +public class RolePermissionModel { + @NotNull(message = "roleId不能为空") + private Integer roleId; + private List list; +} diff --git a/xymanager_dao/src/main/java/com/shxy/xymanager_dao/dao/TbResourceMapper.java b/xymanager_dao/src/main/java/com/shxy/xymanager_dao/dao/TbResourceMapper.java new file mode 100644 index 0000000..36128c6 --- /dev/null +++ b/xymanager_dao/src/main/java/com/shxy/xymanager_dao/dao/TbResourceMapper.java @@ -0,0 +1,97 @@ +package com.shxy.xymanager_dao.dao; + +import com.shxy.xymanager_common.entity.TbResource; +import com.shxy.xymanager_common.entity.TbResourceExample; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +public interface TbResourceMapper { + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table tb_resource + * + * @mbg.generated + */ + long countByExample(TbResourceExample example); + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table tb_resource + * + * @mbg.generated + */ + int deleteByExample(TbResourceExample example); + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table tb_resource + * + * @mbg.generated + */ + int deleteByPrimaryKey(Integer id); + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table tb_resource + * + * @mbg.generated + */ + int insert(TbResource row); + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table tb_resource + * + * @mbg.generated + */ + int insertSelective(TbResource row); + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table tb_resource + * + * @mbg.generated + */ + List selectByExample(TbResourceExample example); + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table tb_resource + * + * @mbg.generated + */ + TbResource selectByPrimaryKey(Integer id); + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table tb_resource + * + * @mbg.generated + */ + int updateByExampleSelective(@Param("row") TbResource row, @Param("example") TbResourceExample example); + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table tb_resource + * + * @mbg.generated + */ + int updateByExample(@Param("row") TbResource row, @Param("example") TbResourceExample example); + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table tb_resource + * + * @mbg.generated + */ + int updateByPrimaryKeySelective(TbResource row); + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table tb_resource + * + * @mbg.generated + */ + int updateByPrimaryKey(TbResource row); +} \ No newline at end of file diff --git a/xymanager_dao/src/main/java/com/shxy/xymanager_dao/dao/TbRoleResourceMapper.java b/xymanager_dao/src/main/java/com/shxy/xymanager_dao/dao/TbRoleResourceMapper.java new file mode 100644 index 0000000..d39da33 --- /dev/null +++ b/xymanager_dao/src/main/java/com/shxy/xymanager_dao/dao/TbRoleResourceMapper.java @@ -0,0 +1,97 @@ +package com.shxy.xymanager_dao.dao; + +import com.shxy.xymanager_common.entity.TbRoleResource; +import com.shxy.xymanager_common.entity.TbRoleResourceExample; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +public interface TbRoleResourceMapper { + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table tb_role_resource + * + * @mbg.generated + */ + long countByExample(TbRoleResourceExample example); + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table tb_role_resource + * + * @mbg.generated + */ + int deleteByExample(TbRoleResourceExample example); + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table tb_role_resource + * + * @mbg.generated + */ + int deleteByPrimaryKey(Integer id); + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table tb_role_resource + * + * @mbg.generated + */ + int insert(TbRoleResource row); + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table tb_role_resource + * + * @mbg.generated + */ + int insertSelective(TbRoleResource row); + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table tb_role_resource + * + * @mbg.generated + */ + List selectByExample(TbRoleResourceExample example); + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table tb_role_resource + * + * @mbg.generated + */ + TbRoleResource selectByPrimaryKey(Integer id); + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table tb_role_resource + * + * @mbg.generated + */ + int updateByExampleSelective(@Param("row") TbRoleResource row, @Param("example") TbRoleResourceExample example); + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table tb_role_resource + * + * @mbg.generated + */ + int updateByExample(@Param("row") TbRoleResource row, @Param("example") TbRoleResourceExample example); + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table tb_role_resource + * + * @mbg.generated + */ + int updateByPrimaryKeySelective(TbRoleResource row); + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table tb_role_resource + * + * @mbg.generated + */ + int updateByPrimaryKey(TbRoleResource row); +} \ No newline at end of file diff --git a/xymanager_dao/src/main/resources/mappers/TbResourceMapper.xml b/xymanager_dao/src/main/resources/mappers/TbResourceMapper.xml new file mode 100644 index 0000000..b5f5557 --- /dev/null +++ b/xymanager_dao/src/main/resources/mappers/TbResourceMapper.xml @@ -0,0 +1,239 @@ + + + + + + + + + + + + + + + + + + + and ${criterion.condition} + + + and ${criterion.condition} #{criterion.value} + + + and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} + + + and ${criterion.condition} + + #{listItem} + + + + + + + + + + + + + + + + + + + and ${criterion.condition} + + + and ${criterion.condition} #{criterion.value} + + + and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} + + + and ${criterion.condition} + + #{listItem} + + + + + + + + + + + + id, `key`, `desc` + + + + + + delete from tb_resource + where id = #{id,jdbcType=INTEGER} + + + + delete from tb_resource + + + + + + + + SELECT LAST_INSERT_ID() + + insert into tb_resource (`key`, `desc`) + values (#{key,jdbcType=VARCHAR}, #{desc,jdbcType=VARCHAR}) + + + + + SELECT LAST_INSERT_ID() + + insert into tb_resource + + + `key`, + + + `desc`, + + + + + #{key,jdbcType=VARCHAR}, + + + #{desc,jdbcType=VARCHAR}, + + + + + + + update tb_resource + + + id = #{row.id,jdbcType=INTEGER}, + + + `key` = #{row.key,jdbcType=VARCHAR}, + + + `desc` = #{row.desc,jdbcType=VARCHAR}, + + + + + + + + + update tb_resource + set id = #{row.id,jdbcType=INTEGER}, + `key` = #{row.key,jdbcType=VARCHAR}, + `desc` = #{row.desc,jdbcType=VARCHAR} + + + + + + + update tb_resource + + + `key` = #{key,jdbcType=VARCHAR}, + + + `desc` = #{desc,jdbcType=VARCHAR}, + + + where id = #{id,jdbcType=INTEGER} + + + + update tb_resource + set `key` = #{key,jdbcType=VARCHAR}, + `desc` = #{desc,jdbcType=VARCHAR} + where id = #{id,jdbcType=INTEGER} + + \ No newline at end of file diff --git a/xymanager_dao/src/main/resources/mappers/TbRoleResourceMapper.xml b/xymanager_dao/src/main/resources/mappers/TbRoleResourceMapper.xml new file mode 100644 index 0000000..3781853 --- /dev/null +++ b/xymanager_dao/src/main/resources/mappers/TbRoleResourceMapper.xml @@ -0,0 +1,239 @@ + + + + + + + + + + + + + + + + + + + and ${criterion.condition} + + + and ${criterion.condition} #{criterion.value} + + + and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} + + + and ${criterion.condition} + + #{listItem} + + + + + + + + + + + + + + + + + + + and ${criterion.condition} + + + and ${criterion.condition} #{criterion.value} + + + and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} + + + and ${criterion.condition} + + #{listItem} + + + + + + + + + + + + id, role_id, resource_id + + + + + + delete from tb_role_resource + where id = #{id,jdbcType=INTEGER} + + + + delete from tb_role_resource + + + + + + + + SELECT LAST_INSERT_ID() + + insert into tb_role_resource (role_id, resource_id) + values (#{roleId,jdbcType=INTEGER}, #{resourceId,jdbcType=INTEGER}) + + + + + SELECT LAST_INSERT_ID() + + insert into tb_role_resource + + + role_id, + + + resource_id, + + + + + #{roleId,jdbcType=INTEGER}, + + + #{resourceId,jdbcType=INTEGER}, + + + + + + + update tb_role_resource + + + id = #{row.id,jdbcType=INTEGER}, + + + role_id = #{row.roleId,jdbcType=INTEGER}, + + + resource_id = #{row.resourceId,jdbcType=INTEGER}, + + + + + + + + + update tb_role_resource + set id = #{row.id,jdbcType=INTEGER}, + role_id = #{row.roleId,jdbcType=INTEGER}, + resource_id = #{row.resourceId,jdbcType=INTEGER} + + + + + + + update tb_role_resource + + + role_id = #{roleId,jdbcType=INTEGER}, + + + resource_id = #{resourceId,jdbcType=INTEGER}, + + + where id = #{id,jdbcType=INTEGER} + + + + update tb_role_resource + set role_id = #{roleId,jdbcType=INTEGER}, + resource_id = #{resourceId,jdbcType=INTEGER} + where id = #{id,jdbcType=INTEGER} + + \ No newline at end of file diff --git a/xymanager_service/src/main/java/com/shxy/xymanager_service/impl/ResourceServiceImpl.java b/xymanager_service/src/main/java/com/shxy/xymanager_service/impl/ResourceServiceImpl.java new file mode 100644 index 0000000..1135bab --- /dev/null +++ b/xymanager_service/src/main/java/com/shxy/xymanager_service/impl/ResourceServiceImpl.java @@ -0,0 +1,64 @@ +package com.shxy.xymanager_service.impl; + +import com.shxy.xymanager_common.entity.TbResource; +import com.shxy.xymanager_common.entity.TbResourceExample; +import com.shxy.xymanager_common.exception.ApiException; +import com.shxy.xymanager_dao.dao.TbResourceMapper; +import com.shxy.xymanager_service.service.ResourceService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import javax.annotation.Resource; +import java.util.List; + + +@Service +@Slf4j +@Transactional(rollbackFor = Exception.class) +public class ResourceServiceImpl implements ResourceService { + + @Resource + TbResourceMapper mapper; + + + @Override + public List listAll() { + TbResourceExample example = new TbResourceExample(); + TbResourceExample.Criteria criteria = example.createCriteria(); + List list = mapper.selectByExample(example); + return list; + } + + @Override + public boolean add(TbResource item) throws Exception { + TbResourceExample example = new TbResourceExample(); + TbResourceExample.Criteria criteria = example.createCriteria(); + criteria.andKeyEqualTo(item.getKey()); + List list = mapper.selectByExample(example); + if (list.size() > 0) { + throw new ApiException("唯一标识key已存在"); + } + int r = mapper.insertSelective(item); + return r > 0; + } + + @Override + public void update(TbResource item) throws Exception { + TbResourceExample example = new TbResourceExample(); + TbResourceExample.Criteria criteria = example.createCriteria(); + criteria.andKeyEqualTo(item.getKey()); + criteria.andIdNotEqualTo(item.getId()); + List list = mapper.selectByExample(example); + if (list.size() > 0) { + throw new ApiException("唯一标识key已存在"); + } + mapper.updateByPrimaryKey(item); + } + + @Override + public void delete(Integer id) throws Exception { + mapper.deleteByPrimaryKey(id); + } + +} diff --git a/xymanager_service/src/main/java/com/shxy/xymanager_service/impl/RolePermissionServiceImpl.java b/xymanager_service/src/main/java/com/shxy/xymanager_service/impl/RolePermissionServiceImpl.java new file mode 100644 index 0000000..ff069dd --- /dev/null +++ b/xymanager_service/src/main/java/com/shxy/xymanager_service/impl/RolePermissionServiceImpl.java @@ -0,0 +1,53 @@ +package com.shxy.xymanager_service.impl; + +import com.shxy.xymanager_common.bean.PermissionDetail; +import com.shxy.xymanager_common.entity.TbPermission; +import com.shxy.xymanager_common.entity.TbPermissionExample; +import com.shxy.xymanager_common.entity.TbRoleResource; +import com.shxy.xymanager_common.entity.TbRoleResourceExample; +import com.shxy.xymanager_common.enums.PermissionDetailEnum; +import com.shxy.xymanager_dao.dao.TbPermissionMapper; +import com.shxy.xymanager_dao.dao.TbRoleResourceMapper; +import com.shxy.xymanager_service.service.RolePermissionService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.cache.annotation.CacheEvict; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import javax.annotation.Resource; +import java.util.List; + +@Service +@Slf4j +@Transactional(rollbackFor = Exception.class) +public class RolePermissionServiceImpl implements RolePermissionService { + + @Resource + TbRoleResourceMapper mapper; + + + @Override + public List getPermission(Integer roleId) { + TbRoleResourceExample example = new TbRoleResourceExample(); + TbRoleResourceExample.Criteria criteria = example.createCriteria(); + criteria.andRoleIdEqualTo(roleId); + List list = mapper.selectByExample(example); + return list; + } + + @Override + public void changePermission(Integer roleId, List list) throws Exception { + TbRoleResourceExample example = new TbRoleResourceExample(); + TbRoleResourceExample.Criteria criteria = example.createCriteria(); + criteria.andRoleIdEqualTo(roleId); + mapper.deleteByExample(example); + + if (list != null) { + for (TbRoleResource permission : list) { + permission.setRoleId(roleId); + mapper.insert(permission); + } + } + } + +} diff --git a/xymanager_service/src/main/java/com/shxy/xymanager_service/service/ResourceService.java b/xymanager_service/src/main/java/com/shxy/xymanager_service/service/ResourceService.java new file mode 100644 index 0000000..9d43992 --- /dev/null +++ b/xymanager_service/src/main/java/com/shxy/xymanager_service/service/ResourceService.java @@ -0,0 +1,17 @@ +package com.shxy.xymanager_service.service; + +import com.shxy.xymanager_common.entity.TbResource; + +import java.util.List; + +public interface ResourceService { + + List listAll(); + + boolean add(TbResource item) throws Exception; + + void update(TbResource item) throws Exception; + + void delete(Integer id) throws Exception; + +} diff --git a/xymanager_service/src/main/java/com/shxy/xymanager_service/service/RolePermissionService.java b/xymanager_service/src/main/java/com/shxy/xymanager_service/service/RolePermissionService.java new file mode 100644 index 0000000..4e02fbb --- /dev/null +++ b/xymanager_service/src/main/java/com/shxy/xymanager_service/service/RolePermissionService.java @@ -0,0 +1,13 @@ +package com.shxy.xymanager_service.service; + +import com.shxy.xymanager_common.entity.TbRoleResource; + +import java.util.List; + +public interface RolePermissionService { + + List getPermission(Integer roleId); + + void changePermission(Integer roleId, List list) throws Exception; + +}