dev
liuguijing 1 year ago
commit b15b9032c5

@ -2,12 +2,13 @@ package com.shxy.xymanager_admin.controller;
import com.shxy.xymanager_common.base.BaseController; import com.shxy.xymanager_common.base.BaseController;
import com.shxy.xymanager_common.base.ResponseReult; 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.DyLevel;
import com.shxy.xymanager_common.entity.TbRole; 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.exception.ApiException;
import com.shxy.xymanager_common.model.RolePermissionModel;
import com.shxy.xymanager_service.service.NewCacheService; import com.shxy.xymanager_service.service.NewCacheService;
import com.shxy.xymanager_service.service.RolePermissionService;
import com.shxy.xymanager_service.service.RoleService; import com.shxy.xymanager_service.service.RoleService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
@ -30,6 +31,8 @@ public class RoleController extends BaseController {
RoleService service; RoleService service;
@Resource @Resource
NewCacheService cacheService; NewCacheService cacheService;
@Resource
RolePermissionService permissionService;
@GetMapping("listAll") @GetMapping("listAll")
@ApiOperation("查询全部列表") @ApiOperation("查询全部列表")
@ -72,4 +75,18 @@ public class RoleController extends BaseController {
return ResponseReult.success(list); return ResponseReult.success(list);
} }
@GetMapping("getPermission")
@ApiOperation("查询权限")
public ResponseReult<List<TbRoleResource>> getPermission(@Validated @NotNull(message = "id不能为空!") Integer id) throws Exception {
List<TbRoleResource> result = permissionService.getPermission(id);
return ResponseReult.success(result);
}
@PostMapping("changePermission")
@ApiOperation("修改权限")
public ResponseReult<String> changePermission(@Validated @RequestBody RolePermissionModel item) throws Exception {
permissionService.changePermission(item.getRoleId(), item.getList());
return ResponseReult.success("OK");
}
} }

@ -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;
}
}

@ -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<Criteria> 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<Criteria> 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<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(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<Integer> values) {
addCriterion("id in", values, "id");
return (Criteria) this;
}
public Criteria andIdNotIn(List<Integer> 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<String> values) {
addCriterion("`key` in", values, "key");
return (Criteria) this;
}
public Criteria andKeyNotIn(List<String> 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<String> values) {
addCriterion("`desc` in", values, "desc");
return (Criteria) this;
}
public Criteria andDescNotIn(List<String> 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);
}
}
}

@ -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;
}
}

@ -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<Criteria> 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<Criteria> 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<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(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<Integer> values) {
addCriterion("id in", values, "id");
return (Criteria) this;
}
public Criteria andIdNotIn(List<Integer> 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<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 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<Integer> values) {
addCriterion("resource_id in", values, "resourceId");
return (Criteria) this;
}
public Criteria andResourceIdNotIn(List<Integer> 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);
}
}
}

@ -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<TbRoleResource> list;
}

@ -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<TbResource> 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);
}

@ -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<TbRoleResource> 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);
}

@ -0,0 +1,239 @@
<?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.shxy.xymanager_dao.dao.TbResourceMapper">
<resultMap id="BaseResultMap" type="com.shxy.xymanager_common.entity.TbResource">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
<id column="id" jdbcType="INTEGER" property="id" />
<result column="key" jdbcType="VARCHAR" property="key" />
<result column="desc" jdbcType="VARCHAR" property="desc" />
</resultMap>
<sql id="Example_Where_Clause">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
<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.
-->
<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.
-->
id, `key`, `desc`
</sql>
<select id="selectByExample" parameterType="com.shxy.xymanager_common.entity.TbResourceExample" resultMap="BaseResultMap">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
select
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List" />
from tb_resource
<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.Integer" resultMap="BaseResultMap">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
select
<include refid="Base_Column_List" />
from tb_resource
where id = #{id,jdbcType=INTEGER}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
delete from tb_resource
where id = #{id,jdbcType=INTEGER}
</delete>
<delete id="deleteByExample" parameterType="com.shxy.xymanager_common.entity.TbResourceExample">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
delete from tb_resource
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</delete>
<insert id="insert" parameterType="com.shxy.xymanager_common.entity.TbResource">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
<selectKey keyProperty="id" order="AFTER" resultType="java.lang.Integer">
SELECT LAST_INSERT_ID()
</selectKey>
insert into tb_resource (`key`, `desc`)
values (#{key,jdbcType=VARCHAR}, #{desc,jdbcType=VARCHAR})
</insert>
<insert id="insertSelective" parameterType="com.shxy.xymanager_common.entity.TbResource">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
<selectKey keyProperty="id" order="AFTER" resultType="java.lang.Integer">
SELECT LAST_INSERT_ID()
</selectKey>
insert into tb_resource
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="key != null">
`key`,
</if>
<if test="desc != null">
`desc`,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="key != null">
#{key,jdbcType=VARCHAR},
</if>
<if test="desc != null">
#{desc,jdbcType=VARCHAR},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="com.shxy.xymanager_common.entity.TbResourceExample" resultType="java.lang.Long">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
select count(*) from tb_resource
<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.
-->
update tb_resource
<set>
<if test="row.id != null">
id = #{row.id,jdbcType=INTEGER},
</if>
<if test="row.key != null">
`key` = #{row.key,jdbcType=VARCHAR},
</if>
<if test="row.desc != null">
`desc` = #{row.desc,jdbcType=VARCHAR},
</if>
</set>
<if test="example != 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.
-->
update tb_resource
set id = #{row.id,jdbcType=INTEGER},
`key` = #{row.key,jdbcType=VARCHAR},
`desc` = #{row.desc,jdbcType=VARCHAR}
<if test="example != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByPrimaryKeySelective" parameterType="com.shxy.xymanager_common.entity.TbResource">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
update tb_resource
<set>
<if test="key != null">
`key` = #{key,jdbcType=VARCHAR},
</if>
<if test="desc != null">
`desc` = #{desc,jdbcType=VARCHAR},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.shxy.xymanager_common.entity.TbResource">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
update tb_resource
set `key` = #{key,jdbcType=VARCHAR},
`desc` = #{desc,jdbcType=VARCHAR}
where id = #{id,jdbcType=INTEGER}
</update>
</mapper>

@ -0,0 +1,239 @@
<?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.shxy.xymanager_dao.dao.TbRoleResourceMapper">
<resultMap id="BaseResultMap" type="com.shxy.xymanager_common.entity.TbRoleResource">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
<id column="id" jdbcType="INTEGER" property="id" />
<result column="role_id" jdbcType="INTEGER" property="roleId" />
<result column="resource_id" jdbcType="INTEGER" property="resourceId" />
</resultMap>
<sql id="Example_Where_Clause">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
<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.
-->
<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.
-->
id, role_id, resource_id
</sql>
<select id="selectByExample" parameterType="com.shxy.xymanager_common.entity.TbRoleResourceExample" resultMap="BaseResultMap">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
select
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List" />
from tb_role_resource
<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.Integer" resultMap="BaseResultMap">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
select
<include refid="Base_Column_List" />
from tb_role_resource
where id = #{id,jdbcType=INTEGER}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
delete from tb_role_resource
where id = #{id,jdbcType=INTEGER}
</delete>
<delete id="deleteByExample" parameterType="com.shxy.xymanager_common.entity.TbRoleResourceExample">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
delete from tb_role_resource
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</delete>
<insert id="insert" parameterType="com.shxy.xymanager_common.entity.TbRoleResource">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
<selectKey keyProperty="id" order="AFTER" resultType="java.lang.Integer">
SELECT LAST_INSERT_ID()
</selectKey>
insert into tb_role_resource (role_id, resource_id)
values (#{roleId,jdbcType=INTEGER}, #{resourceId,jdbcType=INTEGER})
</insert>
<insert id="insertSelective" parameterType="com.shxy.xymanager_common.entity.TbRoleResource">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
<selectKey keyProperty="id" order="AFTER" resultType="java.lang.Integer">
SELECT LAST_INSERT_ID()
</selectKey>
insert into tb_role_resource
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="roleId != null">
role_id,
</if>
<if test="resourceId != null">
resource_id,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="roleId != null">
#{roleId,jdbcType=INTEGER},
</if>
<if test="resourceId != null">
#{resourceId,jdbcType=INTEGER},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="com.shxy.xymanager_common.entity.TbRoleResourceExample" resultType="java.lang.Long">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
select count(*) from tb_role_resource
<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.
-->
update tb_role_resource
<set>
<if test="row.id != null">
id = #{row.id,jdbcType=INTEGER},
</if>
<if test="row.roleId != null">
role_id = #{row.roleId,jdbcType=INTEGER},
</if>
<if test="row.resourceId != null">
resource_id = #{row.resourceId,jdbcType=INTEGER},
</if>
</set>
<if test="example != 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.
-->
update tb_role_resource
set id = #{row.id,jdbcType=INTEGER},
role_id = #{row.roleId,jdbcType=INTEGER},
resource_id = #{row.resourceId,jdbcType=INTEGER}
<if test="example != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByPrimaryKeySelective" parameterType="com.shxy.xymanager_common.entity.TbRoleResource">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
update tb_role_resource
<set>
<if test="roleId != null">
role_id = #{roleId,jdbcType=INTEGER},
</if>
<if test="resourceId != null">
resource_id = #{resourceId,jdbcType=INTEGER},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.shxy.xymanager_common.entity.TbRoleResource">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
update tb_role_resource
set role_id = #{roleId,jdbcType=INTEGER},
resource_id = #{resourceId,jdbcType=INTEGER}
where id = #{id,jdbcType=INTEGER}
</update>
</mapper>

@ -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<TbResource> listAll() {
TbResourceExample example = new TbResourceExample();
TbResourceExample.Criteria criteria = example.createCriteria();
List<TbResource> 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<TbResource> 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<TbResource> 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);
}
}

@ -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<TbRoleResource> getPermission(Integer roleId) {
TbRoleResourceExample example = new TbRoleResourceExample();
TbRoleResourceExample.Criteria criteria = example.createCriteria();
criteria.andRoleIdEqualTo(roleId);
List<TbRoleResource> list = mapper.selectByExample(example);
return list;
}
@Override
public void changePermission(Integer roleId, List<TbRoleResource> 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);
}
}
}
}

@ -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<TbResource> listAll();
boolean add(TbResource item) throws Exception;
void update(TbResource item) throws Exception;
void delete(Integer id) throws Exception;
}

@ -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<TbRoleResource> getPermission(Integer roleId);
void changePermission(Integer roleId, List<TbRoleResource> list) throws Exception;
}
Loading…
Cancel
Save