parent
d41f1c42b7
commit
961531a459
@ -1,104 +0,0 @@
|
||||
package ${basePackage}.action.ajax.system;
|
||||
|
||||
import com.fasterxml.jackson.core.TreeNode;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import ${basePackage}.frame.auth.LocalData;
|
||||
import ${basePackage}.frame.base.BaseResponse;
|
||||
import ${basePackage}.frame.base.ErrorType;
|
||||
import ${basePackage}.frame.excel.WSheet;
|
||||
import ${basePackage}.frame.excel.exception.ReadErrorException;
|
||||
import ${basePackage}.frame.excel.exception.TemplateNotMatchException;
|
||||
import ${basePackage}.frame.utils.LogUtil;
|
||||
import ${basePackage}.frame.utils.MapperUtil;
|
||||
import ${basePackage}.frame.utils.ResponseUtil;
|
||||
import ${basePackage}.frame.utils.ValidationUtil;
|
||||
import ${basePackage}.module.system.ent.Resource;
|
||||
import ${basePackage}.module.system.mgr.ResourceManager;
|
||||
import ${basePackage}.module.system.req.ResourceCreateRequest;
|
||||
import ${basePackage}.module.system.req.ResourceDeleteRequest;
|
||||
import ${basePackage}.module.system.req.ResourceFindRequest;
|
||||
import ${basePackage}.module.system.req.ResourceGetRequest;
|
||||
import ${basePackage}.module.system.req.ResourceTreeRequest;
|
||||
import ${basePackage}.module.system.req.ResourceUpdateRequest;
|
||||
import ${basePackage}.module.system.rsp.ResourceCreateResponse;
|
||||
import ${basePackage}.module.system.rsp.ResourceDeleteResponse;
|
||||
import ${basePackage}.module.system.rsp.ResourceFindResponse;
|
||||
import ${basePackage}.module.system.rsp.ResourceGetResponse;
|
||||
import ${basePackage}.module.system.rsp.ResourceTreeResponse;
|
||||
import ${basePackage}.module.system.rsp.ResourceUpdateResponse;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
public class ResourceAjax {
|
||||
|
||||
@Autowired
|
||||
private ResourceManager resourceManager;
|
||||
|
||||
public ResourceCreateResponse create(ResourceCreateRequest request) {
|
||||
return resourceManager.create(request, LocalData.getToken());
|
||||
}
|
||||
|
||||
public ResourceDeleteResponse delete(ResourceDeleteRequest request) {
|
||||
return resourceManager.delete(request, LocalData.getToken());
|
||||
}
|
||||
|
||||
public ResourceUpdateResponse update(ResourceUpdateRequest request) {
|
||||
return resourceManager.update(request, LocalData.getToken());
|
||||
}
|
||||
|
||||
public ResourceFindResponse find(ResourceFindRequest request) {
|
||||
return resourceManager.find(request, LocalData.getToken());
|
||||
}
|
||||
|
||||
public ResourceGetResponse get(ResourceGetRequest request) {
|
||||
return resourceManager.get(request, LocalData.getToken());
|
||||
}
|
||||
|
||||
public ResourceTreeResponse tree(ResourceTreeRequest request) {
|
||||
return resourceManager.tree(request, LocalData.getToken());
|
||||
}
|
||||
|
||||
public Object template() {
|
||||
return ResponseUtil.apply(new WSheet<>(Resource.class));
|
||||
}
|
||||
|
||||
public Object exports(TreeNode jsonParam) {
|
||||
ResourceFindRequest request = MapperUtil.toJava(jsonParam, ResourceFindRequest.class);
|
||||
ResourceFindResponse response = resourceManager.find(request, LocalData.getToken());
|
||||
if (response.hasError()) {
|
||||
return response;
|
||||
} else if (response.getTotalCount() == 0) {
|
||||
response.addError(ErrorType.BUSINESS_ERROR, "导出数据为空");
|
||||
return response;
|
||||
}
|
||||
return ResponseUtil.apply(new WSheet<>(response.getResult()));
|
||||
}
|
||||
|
||||
public Object imports(MultipartFile file) {
|
||||
BaseResponse baseResponse = new BaseResponse();
|
||||
try {
|
||||
WSheet<Resource> sheet = new WSheet<>(file.getBytes(), Resource.class, new WSheet.Validator<Resource>() {
|
||||
@Override
|
||||
public List<String> validate(Resource o) {
|
||||
ResourceCreateRequest request = MapperUtil.map(o, ResourceCreateRequest.class);
|
||||
return ValidationUtil.validate(request);
|
||||
}
|
||||
});
|
||||
|
||||
if (sheet.hasError()) {
|
||||
return ResponseUtil.apply(sheet.getBytes(), sheet.getName() + "-检查.xlsx");
|
||||
} else {
|
||||
return baseResponse;
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
LogUtil.dumpException(e);
|
||||
baseResponse.addError(ErrorType.BUSINESS_ERROR, "上传文件出错");
|
||||
} catch (TemplateNotMatchException | ReadErrorException e) {
|
||||
baseResponse.addError(ErrorType.BUSINESS_ERROR, e.getMessage());
|
||||
}
|
||||
return baseResponse;
|
||||
}
|
||||
}
|
@ -1,50 +0,0 @@
|
||||
package ${basePackage}.action.ajax.system;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import ${basePackage}.frame.auth.LocalData;
|
||||
import ${basePackage}.module.system.mgr.RoleResourceManager;
|
||||
import ${basePackage}.module.system.req.RoleResourceCheckRequest;
|
||||
import ${basePackage}.module.system.req.RoleResourceCreateRequest;
|
||||
import ${basePackage}.module.system.req.RoleResourceDeleteRequest;
|
||||
import ${basePackage}.module.system.req.RoleResourceFindRequest;
|
||||
import ${basePackage}.module.system.req.RoleResourceGetRequest;
|
||||
import ${basePackage}.module.system.req.RoleResourceUpdateRequest;
|
||||
import ${basePackage}.module.system.rsp.RoleResourceCheckResponse;
|
||||
import ${basePackage}.module.system.rsp.RoleResourceCreateResponse;
|
||||
import ${basePackage}.module.system.rsp.RoleResourceDeleteResponse;
|
||||
import ${basePackage}.module.system.rsp.RoleResourceFindResponse;
|
||||
import ${basePackage}.module.system.rsp.RoleResourceGetResponse;
|
||||
import ${basePackage}.module.system.rsp.RoleResourceUpdateResponse;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
public class RoleResourceAjax{
|
||||
|
||||
@Autowired
|
||||
private RoleResourceManager roleResourceManager;
|
||||
|
||||
public RoleResourceCreateResponse create(RoleResourceCreateRequest request) {
|
||||
return roleResourceManager.create(request, LocalData.getToken());
|
||||
}
|
||||
|
||||
public RoleResourceDeleteResponse delete(RoleResourceDeleteRequest request) {
|
||||
return roleResourceManager.delete(request, LocalData.getToken());
|
||||
}
|
||||
|
||||
public RoleResourceUpdateResponse update(RoleResourceUpdateRequest request) {
|
||||
return roleResourceManager.update(request, LocalData.getToken());
|
||||
}
|
||||
|
||||
public RoleResourceFindResponse find(RoleResourceFindRequest request) {
|
||||
return roleResourceManager.find(request, LocalData.getToken());
|
||||
}
|
||||
|
||||
public RoleResourceGetResponse get(RoleResourceGetRequest request) {
|
||||
return roleResourceManager.get(request, LocalData.getToken());
|
||||
}
|
||||
|
||||
public RoleResourceCheckResponse check(RoleResourceCheckRequest request) {
|
||||
return roleResourceManager.check(request, LocalData.getToken());
|
||||
}
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
package ${basePackage}.action.api.system;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import ${basePackage}.frame.auth.LocalData;
|
||||
import ${basePackage}.module.system.mgr.ResManager;
|
||||
import ${basePackage}.module.system.req.ResCreateRequest;
|
||||
import ${basePackage}.module.system.req.ResDeleteRequest;
|
||||
import ${basePackage}.module.system.req.ResFindRequest;
|
||||
import ${basePackage}.module.system.req.ResGetRequest;
|
||||
import ${basePackage}.module.system.req.ResTreeRequest;
|
||||
import ${basePackage}.module.system.req.ResUpdateRequest;
|
||||
import ${basePackage}.module.system.rsp.ResCreateResponse;
|
||||
import ${basePackage}.module.system.rsp.ResDeleteResponse;
|
||||
import ${basePackage}.module.system.rsp.ResFindResponse;
|
||||
import ${basePackage}.module.system.rsp.ResGetResponse;
|
||||
import ${basePackage}.module.system.rsp.ResTreeResponse;
|
||||
import ${basePackage}.module.system.rsp.ResUpdateResponse;
|
||||
|
||||
public class ResApi {
|
||||
|
||||
@Autowired
|
||||
private ResManager resManager;
|
||||
|
||||
public ResCreateResponse create(ResCreateRequest request) {
|
||||
return resManager.create(request, LocalData.getToken());
|
||||
}
|
||||
|
||||
public ResDeleteResponse delete(ResDeleteRequest request) {
|
||||
return resManager.delete(request, LocalData.getToken());
|
||||
}
|
||||
|
||||
public ResUpdateResponse update(ResUpdateRequest request) {
|
||||
return resManager.update(request, LocalData.getToken());
|
||||
}
|
||||
|
||||
public ResFindResponse find(ResFindRequest request) {
|
||||
return resManager.find(request, LocalData.getToken());
|
||||
}
|
||||
|
||||
public ResGetResponse get(ResGetRequest request) {
|
||||
return resManager.get(request, LocalData.getToken());
|
||||
}
|
||||
|
||||
public ResTreeResponse tree(ResTreeRequest request) {
|
||||
return resManager.tree(request, LocalData.getToken());
|
||||
}
|
||||
}
|
@ -1,33 +0,0 @@
|
||||
package ${basePackage}.action.api.system;
|
||||
|
||||
import ${basePackage}.frame.auth.LocalData;
|
||||
import ${basePackage}.module.system.mgr.ResourceManager;
|
||||
import ${basePackage}.module.system.req.*;
|
||||
import ${basePackage}.module.system.rsp.*;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
public class ResourceApi{
|
||||
|
||||
@Autowired
|
||||
private ResourceManager resourceManager;
|
||||
|
||||
public ResourceCreateResponse create(ResourceCreateRequest request) {
|
||||
return resourceManager.create(request, LocalData.getToken());
|
||||
}
|
||||
|
||||
public ResourceDeleteResponse delete(ResourceDeleteRequest request) {
|
||||
return resourceManager.delete(request, LocalData.getToken());
|
||||
}
|
||||
|
||||
public ResourceUpdateResponse update(ResourceUpdateRequest request) {
|
||||
return resourceManager.update(request, LocalData.getToken());
|
||||
}
|
||||
|
||||
public ResourceFindResponse find(ResourceFindRequest request) {
|
||||
return resourceManager.find(request, LocalData.getToken());
|
||||
}
|
||||
|
||||
public ResourceGetResponse get(ResourceGetRequest request) {
|
||||
return resourceManager.get(request, LocalData.getToken());
|
||||
}
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
package ${basePackage}.action.ajax.system;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import ${basePackage}.frame.auth.LocalData;
|
||||
import ${basePackage}.module.system.mgr.RoleResManager;
|
||||
import ${basePackage}.module.system.req.RoleResCreateRequest;
|
||||
import ${basePackage}.module.system.req.RoleResDeleteRequest;
|
||||
import ${basePackage}.module.system.req.RoleResFindRequest;
|
||||
import ${basePackage}.module.system.req.RoleResGetRequest;
|
||||
import ${basePackage}.module.system.req.RoleResUpdateRequest;
|
||||
import ${basePackage}.module.system.rsp.RoleResCreateResponse;
|
||||
import ${basePackage}.module.system.rsp.RoleResDeleteResponse;
|
||||
import ${basePackage}.module.system.rsp.RoleResFindResponse;
|
||||
import ${basePackage}.module.system.rsp.RoleResGetResponse;
|
||||
import ${basePackage}.module.system.rsp.RoleResUpdateResponse;
|
||||
|
||||
public class RoleResApi{
|
||||
|
||||
@Autowired
|
||||
private RoleResManager roleResManager;
|
||||
|
||||
public RoleResCreateResponse create(RoleResCreateRequest request) {
|
||||
return roleResManager.create(request, LocalData.getToken());
|
||||
}
|
||||
|
||||
public RoleResDeleteResponse delete(RoleResDeleteRequest request) {
|
||||
return roleResManager.delete(request, LocalData.getToken());
|
||||
}
|
||||
|
||||
public RoleResUpdateResponse update(RoleResUpdateRequest request) {
|
||||
return roleResManager.update(request, LocalData.getToken());
|
||||
}
|
||||
|
||||
public RoleResFindResponse find(RoleResFindRequest request) {
|
||||
return roleResManager.find(request, LocalData.getToken());
|
||||
}
|
||||
|
||||
public RoleResGetResponse get(RoleResGetRequest request) {
|
||||
return roleResManager.get(request, LocalData.getToken());
|
||||
}
|
||||
}
|
@ -1,33 +0,0 @@
|
||||
package ${basePackage}.action.api.system;
|
||||
|
||||
import ${basePackage}.frame.auth.LocalData;
|
||||
import ${basePackage}.module.system.mgr.RoleResourceManager;
|
||||
import ${basePackage}.module.system.req.*;
|
||||
import ${basePackage}.module.system.rsp.*;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
public class RoleResourceApi{
|
||||
|
||||
@Autowired
|
||||
private RoleResourceManager roleResourceManager;
|
||||
|
||||
public RoleResourceCreateResponse create(RoleResourceCreateRequest request) {
|
||||
return roleResourceManager.create(request, LocalData.getToken());
|
||||
}
|
||||
|
||||
public RoleResourceDeleteResponse delete(RoleResourceDeleteRequest request) {
|
||||
return roleResourceManager.delete(request, LocalData.getToken());
|
||||
}
|
||||
|
||||
public RoleResourceUpdateResponse update(RoleResourceUpdateRequest request) {
|
||||
return roleResourceManager.update(request, LocalData.getToken());
|
||||
}
|
||||
|
||||
public RoleResourceFindResponse find(RoleResourceFindRequest request) {
|
||||
return roleResourceManager.find(request, LocalData.getToken());
|
||||
}
|
||||
|
||||
public RoleResourceGetResponse get(RoleResourceGetRequest request) {
|
||||
return roleResourceManager.get(request, LocalData.getToken());
|
||||
}
|
||||
}
|
@ -1,88 +0,0 @@
|
||||
package ${basePackage}.module.system.ent;
|
||||
|
||||
import ${basePackage}.frame.excel.annotation.ColumnDescription;
|
||||
import ${basePackage}.frame.excel.annotation.ColumnName;
|
||||
import ${basePackage}.frame.excel.annotation.SheetName;
|
||||
import ${basePackage}.frame.base.BaseEntity;
|
||||
|
||||
/**
|
||||
* RESOURCE - 资源
|
||||
*
|
||||
* @author wangbing
|
||||
* @version 0.0.1
|
||||
* @since 2019-12-27
|
||||
*/
|
||||
@SheetName("资源")
|
||||
public class Resource extends BaseEntity {
|
||||
|
||||
/**
|
||||
* CODE - 资源代码
|
||||
*/
|
||||
@ColumnName("资源代码")
|
||||
@ColumnDescription("")
|
||||
private String code;
|
||||
/**
|
||||
* VALUE - 资源内容
|
||||
*/
|
||||
@ColumnName("资源内容")
|
||||
@ColumnDescription("")
|
||||
private String value;
|
||||
/**
|
||||
* COMMENT - 资源描述
|
||||
*/
|
||||
@ColumnName("资源描述")
|
||||
@ColumnDescription("")
|
||||
private String comment;
|
||||
/**
|
||||
* RESOURCE_TYPE - 资源类型
|
||||
*/
|
||||
@ColumnName("资源类型")
|
||||
@ColumnDescription("")
|
||||
private String resourceType;
|
||||
/**
|
||||
* VALID - 是否有效
|
||||
*/
|
||||
@ColumnName("是否有效")
|
||||
@ColumnDescription("")
|
||||
private Boolean valid;
|
||||
|
||||
public String getCode() {
|
||||
return this.code;
|
||||
}
|
||||
|
||||
public void setCode(String code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getComment() {
|
||||
return this.comment;
|
||||
}
|
||||
|
||||
public void setComment(String comment) {
|
||||
this.comment = comment;
|
||||
}
|
||||
|
||||
public String getResourceType() {
|
||||
return this.resourceType;
|
||||
}
|
||||
|
||||
public void setResourceType(String resourceType) {
|
||||
this.resourceType = resourceType;
|
||||
}
|
||||
|
||||
public Boolean getValid() {
|
||||
return this.valid;
|
||||
}
|
||||
|
||||
public void setValid(Boolean valid) {
|
||||
this.valid = valid;
|
||||
}
|
||||
}
|
@ -1,27 +0,0 @@
|
||||
package ${basePackage}.module.system.ent;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ResourceTree extends Resource {
|
||||
|
||||
private Long pId;
|
||||
|
||||
private List<ResourceTree> children = new ArrayList<>();
|
||||
|
||||
public Long getpId() {
|
||||
return pId;
|
||||
}
|
||||
|
||||
public void setpId(Long pId) {
|
||||
this.pId = pId;
|
||||
}
|
||||
|
||||
public List<ResourceTree> getChildren() {
|
||||
return children;
|
||||
}
|
||||
|
||||
public void setChildren(List<ResourceTree> children) {
|
||||
this.children = children;
|
||||
}
|
||||
}
|
@ -1,38 +0,0 @@
|
||||
package ${basePackage}.module.system.ent;
|
||||
|
||||
import ${basePackage}.frame.base.BaseEntity;
|
||||
|
||||
/**
|
||||
* ROLE_RESOURCE - 角色资源关系
|
||||
*
|
||||
* @author wangbing
|
||||
* @version 0.0.1
|
||||
* @since 2017-01-01
|
||||
*/
|
||||
public class RoleResource extends BaseEntity {
|
||||
|
||||
/**
|
||||
* ROLE_ID - 角色主键
|
||||
*/
|
||||
private Long roleId;
|
||||
/**
|
||||
* RESOURCE_ID - 资源主键
|
||||
*/
|
||||
private Long resourceId;
|
||||
|
||||
public Long getRoleId() {
|
||||
return this.roleId;
|
||||
}
|
||||
|
||||
public void setRoleId(Long roleId) {
|
||||
this.roleId = roleId;
|
||||
}
|
||||
|
||||
public Long getResourceId() {
|
||||
return this.resourceId;
|
||||
}
|
||||
|
||||
public void setResourceId(Long resourceId) {
|
||||
this.resourceId = resourceId;
|
||||
}
|
||||
}
|
@ -1,79 +0,0 @@
|
||||
package ${basePackage}.module.system.mgr;
|
||||
|
||||
import ${basePackage}.frame.base.Token;
|
||||
import ${basePackage}.module.system.req.ResourceCreateRequest;
|
||||
import ${basePackage}.module.system.req.ResourceDeleteRequest;
|
||||
import ${basePackage}.module.system.req.ResourceFindRequest;
|
||||
import ${basePackage}.module.system.req.ResourceGetRequest;
|
||||
import ${basePackage}.module.system.req.ResourceTreeRequest;
|
||||
import ${basePackage}.module.system.req.ResourceUpdateRequest;
|
||||
import ${basePackage}.module.system.rsp.ResourceCreateResponse;
|
||||
import ${basePackage}.module.system.rsp.ResourceDeleteResponse;
|
||||
import ${basePackage}.module.system.rsp.ResourceFindResponse;
|
||||
import ${basePackage}.module.system.rsp.ResourceGetResponse;
|
||||
import ${basePackage}.module.system.rsp.ResourceTreeResponse;
|
||||
import ${basePackage}.module.system.rsp.ResourceUpdateResponse;
|
||||
|
||||
/**
|
||||
* 资源
|
||||
*
|
||||
* @author author
|
||||
* @version 0.0.1
|
||||
* @since 2017-01-01
|
||||
*/
|
||||
public interface ResourceManager {
|
||||
|
||||
/**
|
||||
* 插入
|
||||
*
|
||||
* @param request 请求对象
|
||||
* @param token 令牌
|
||||
* @return
|
||||
*/
|
||||
ResourceCreateResponse create(ResourceCreateRequest request, Token token);
|
||||
|
||||
/**
|
||||
* 逻辑删除
|
||||
*
|
||||
* @param request 请求对象
|
||||
* @param token 令牌
|
||||
* @return
|
||||
*/
|
||||
ResourceDeleteResponse delete(ResourceDeleteRequest request, Token token);
|
||||
|
||||
/**
|
||||
* 更新
|
||||
*
|
||||
* @param request 请求对象
|
||||
* @param token 令牌
|
||||
* @return
|
||||
*/
|
||||
ResourceUpdateResponse update(ResourceUpdateRequest request, Token token);
|
||||
|
||||
/**
|
||||
* 查询
|
||||
*
|
||||
* @param request 请求对象
|
||||
* @param token 令牌
|
||||
* @return
|
||||
*/
|
||||
ResourceFindResponse find(ResourceFindRequest request, Token token);
|
||||
|
||||
/**
|
||||
* 获得对象
|
||||
*
|
||||
* @param request 请求对象
|
||||
* @param token 令牌
|
||||
* @return
|
||||
*/
|
||||
ResourceGetResponse get(ResourceGetRequest request, Token token);
|
||||
|
||||
/**
|
||||
* 获得资源树
|
||||
*
|
||||
* @param request 请求对象
|
||||
* @param token 令牌
|
||||
* @return
|
||||
*/
|
||||
ResourceTreeResponse tree(ResourceTreeRequest request, Token token);
|
||||
}
|
@ -1,252 +0,0 @@
|
||||
package ${basePackage}.module.system.mgr;
|
||||
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.github.pagehelper.util.StringUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import ${basePackage}.frame.base.ErrorType;
|
||||
import ${basePackage}.frame.base.SortType;
|
||||
import ${basePackage}.frame.base.Token;
|
||||
import ${basePackage}.frame.utils.IDgenerator;
|
||||
import ${basePackage}.frame.utils.MapperUtil;
|
||||
import ${basePackage}.frame.utils.Message;
|
||||
import ${basePackage}.frame.utils.ValidationUtil;
|
||||
import ${basePackage}.module.system.ent.Resource;
|
||||
import ${basePackage}.module.system.ent.ResourceTree;
|
||||
import ${basePackage}.module.system.mpr.ResourceMapper;
|
||||
import ${basePackage}.module.system.req.ResourceCreateRequest;
|
||||
import ${basePackage}.module.system.req.ResourceDeleteRequest;
|
||||
import ${basePackage}.module.system.req.ResourceFindRequest;
|
||||
import ${basePackage}.module.system.req.ResourceGetRequest;
|
||||
import ${basePackage}.module.system.req.ResourceTreeRequest;
|
||||
import ${basePackage}.module.system.req.ResourceUpdateRequest;
|
||||
import ${basePackage}.module.system.rsp.ResourceCreateResponse;
|
||||
import ${basePackage}.module.system.rsp.ResourceDeleteResponse;
|
||||
import ${basePackage}.module.system.rsp.ResourceFindResponse;
|
||||
import ${basePackage}.module.system.rsp.ResourceGetResponse;
|
||||
import ${basePackage}.module.system.rsp.ResourceTreeResponse;
|
||||
import ${basePackage}.module.system.rsp.ResourceUpdateResponse;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* RESOURCE - 资源
|
||||
*
|
||||
* @author author
|
||||
* @version 0.0.1
|
||||
* @since 2017-01-01
|
||||
*/
|
||||
@Transactional
|
||||
@Service
|
||||
public class ResourceManagerImpl implements ResourceManager {
|
||||
|
||||
@Autowired
|
||||
private ResourceMapper resourceMapper;
|
||||
@Autowired
|
||||
private DictItemManager dictItemManager;
|
||||
|
||||
/**
|
||||
* 插入
|
||||
*
|
||||
* @param request 请求对象
|
||||
* @param token 令牌
|
||||
* @return 响应
|
||||
*/
|
||||
public ResourceCreateResponse create(ResourceCreateRequest request, Token token) {
|
||||
ResourceCreateResponse response = new ResourceCreateResponse();
|
||||
|
||||
ValidationUtil.validate(request, response);
|
||||
if (response.hasError()) {
|
||||
return response;
|
||||
}
|
||||
|
||||
long id = IDgenerator.nextId();
|
||||
Resource entity = MapperUtil.map(request, Resource.class);
|
||||
entity.setId(id);
|
||||
|
||||
long result = resourceMapper.insert(entity, token);
|
||||
if (1L != result) {
|
||||
response.addError(ErrorType.BUSINESS_ERROR, Message.CREATE_FAILURE);
|
||||
return response;
|
||||
}
|
||||
response.setId(id);
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* 逻辑删除
|
||||
*
|
||||
* @param request 请求对象
|
||||
* @param token 令牌
|
||||
* @return 响应
|
||||
*/
|
||||
public ResourceDeleteResponse delete(ResourceDeleteRequest request, Token token) {
|
||||
ResourceDeleteResponse response = new ResourceDeleteResponse();
|
||||
|
||||
ValidationUtil.validate(request, response);
|
||||
if (response.hasError()) {
|
||||
return response;
|
||||
}
|
||||
|
||||
long result = resourceMapper.delete(request, token);
|
||||
if (1L != result) {
|
||||
response.addError(ErrorType.BUSINESS_ERROR, Message.DELETE_FAILURE);
|
||||
return response;
|
||||
}
|
||||
response.setResult(result);
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新
|
||||
*
|
||||
* @param request 请求对象
|
||||
* @param token 令牌
|
||||
* @return 响应
|
||||
*/
|
||||
public ResourceUpdateResponse update(ResourceUpdateRequest request, Token token) {
|
||||
ResourceUpdateResponse response = new ResourceUpdateResponse();
|
||||
|
||||
ValidationUtil.validate(request, response);
|
||||
if (response.hasError()) {
|
||||
return response;
|
||||
}
|
||||
|
||||
long result = resourceMapper.update(request, token);
|
||||
if (1L != result) {
|
||||
response.addError(ErrorType.BUSINESS_ERROR, Message.UPDATE_FAILURE);
|
||||
return response;
|
||||
}
|
||||
response.setResult(result);
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询
|
||||
*
|
||||
* @param request 请求对象
|
||||
* @param token 令牌
|
||||
* @return 响应
|
||||
*/
|
||||
@Transactional(readOnly = true)
|
||||
public ResourceFindResponse find(ResourceFindRequest request, Token token) {
|
||||
ResourceFindResponse response = new ResourceFindResponse();
|
||||
|
||||
ValidationUtil.validate(request, response);
|
||||
if (response.hasError()) {
|
||||
return response;
|
||||
}
|
||||
|
||||
PageHelper.startPage(request.getPageNumber(), request.getPageSize());
|
||||
if (StringUtil.isNotEmpty(request.getSortKey())) {
|
||||
PageHelper.orderBy(request.getSortKey() + " " + request.getSortType());
|
||||
}
|
||||
PageInfo<Resource> pageInfo = new PageInfo<>(resourceMapper.find(request, token));
|
||||
|
||||
response.setResult(pageInfo.getList());
|
||||
response.setTotalCount(pageInfo.getTotal());
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得对象
|
||||
*
|
||||
* @param request 请求对象
|
||||
* @param token 令牌
|
||||
* @return 响应
|
||||
*/
|
||||
@Transactional(readOnly = true)
|
||||
public ResourceGetResponse get(ResourceGetRequest request, Token token) {
|
||||
ResourceGetResponse response = new ResourceGetResponse();
|
||||
|
||||
ValidationUtil.validate(request, response);
|
||||
if (response.hasError()) {
|
||||
return response;
|
||||
}
|
||||
|
||||
Resource po = resourceMapper.get(request, token);
|
||||
|
||||
if (po != null) {
|
||||
response.setResource(po);
|
||||
} else {
|
||||
response.addError(ErrorType.BUSINESS_ERROR, Message.GET_FAILURE);
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceTreeResponse tree(ResourceTreeRequest request, Token token) {
|
||||
ResourceTreeResponse response = new ResourceTreeResponse();
|
||||
|
||||
ValidationUtil.validate(request, response);
|
||||
if (response.hasError()) {
|
||||
return response;
|
||||
}
|
||||
|
||||
ResourceFindRequest resourceFindRequest = new ResourceFindRequest();
|
||||
resourceFindRequest.setPageSize(0);
|
||||
resourceFindRequest.setValid(true);
|
||||
resourceFindRequest.setSortType(SortType.ASC);
|
||||
resourceFindRequest.setSortKey("CODE");
|
||||
ResourceFindResponse resourceFindResponse = this.find(resourceFindRequest, token);
|
||||
|
||||
if (resourceFindResponse.hasError()) {
|
||||
response.addErrors(resourceFindResponse.getErrors());
|
||||
return response;
|
||||
}
|
||||
|
||||
List<ResourceTree> data = new ArrayList<>();
|
||||
Map<String, ResourceTree> allMap = new HashMap<>();
|
||||
List<Resource> result = resourceFindResponse.getResult();
|
||||
// 获取最顶级资源
|
||||
int level = 1;
|
||||
while (result.size() > 0) {
|
||||
Iterator<Resource> iterator = result.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
Resource next = iterator.next();
|
||||
ResourceTree tree = new ResourceTree();
|
||||
tree.setId(next.getId());
|
||||
tree.setCode(next.getCode());
|
||||
tree.setResourceType(next.getResourceType());
|
||||
tree.setValid(next.getValid());
|
||||
tree.setComment(next.getComment());
|
||||
tree.setValue(next.getValue());
|
||||
tree.setRowVersion(next.getRowVersion());
|
||||
|
||||
if (next.getCode() != null && next.getCode().split("_").length == level) {
|
||||
allMap.put(tree.getCode(), tree);
|
||||
iterator.remove();
|
||||
//尝试获取上级资源
|
||||
String code = next.getCode();
|
||||
ResourceTree Ptree = null;
|
||||
while (code.contains("_")) {
|
||||
code = code.substring(0, code.lastIndexOf("_"));
|
||||
Ptree = allMap.get(code);
|
||||
if (Ptree != null) break;
|
||||
}
|
||||
if (Ptree != null) {
|
||||
tree.setpId(Ptree.getId());
|
||||
Ptree.getChildren().add(tree);
|
||||
} else {
|
||||
data.add(tree);
|
||||
}
|
||||
}
|
||||
}
|
||||
level++;
|
||||
}
|
||||
|
||||
response.setResult(data);
|
||||
return response;
|
||||
}
|
||||
}
|
@ -1,79 +0,0 @@
|
||||
package ${basePackage}.module.system.mgr;
|
||||
|
||||
import ${basePackage}.frame.base.Token;
|
||||
import ${basePackage}.module.system.req.RoleResourceCheckRequest;
|
||||
import ${basePackage}.module.system.req.RoleResourceCreateRequest;
|
||||
import ${basePackage}.module.system.req.RoleResourceDeleteRequest;
|
||||
import ${basePackage}.module.system.req.RoleResourceFindRequest;
|
||||
import ${basePackage}.module.system.req.RoleResourceGetRequest;
|
||||
import ${basePackage}.module.system.req.RoleResourceUpdateRequest;
|
||||
import ${basePackage}.module.system.rsp.RoleResourceCheckResponse;
|
||||
import ${basePackage}.module.system.rsp.RoleResourceCreateResponse;
|
||||
import ${basePackage}.module.system.rsp.RoleResourceDeleteResponse;
|
||||
import ${basePackage}.module.system.rsp.RoleResourceFindResponse;
|
||||
import ${basePackage}.module.system.rsp.RoleResourceGetResponse;
|
||||
import ${basePackage}.module.system.rsp.RoleResourceUpdateResponse;
|
||||
|
||||
/**
|
||||
* 角色资源关系
|
||||
*
|
||||
* @author wangbing
|
||||
* @version 0.0.1
|
||||
* @since 2017-01-01
|
||||
*/
|
||||
public interface RoleResourceManager {
|
||||
|
||||
/**
|
||||
* 插入
|
||||
*
|
||||
* @param request 请求对象
|
||||
* @param token 令牌
|
||||
* @return
|
||||
*/
|
||||
RoleResourceCreateResponse create(RoleResourceCreateRequest request, Token token);
|
||||
|
||||
/**
|
||||
* 逻辑删除
|
||||
*
|
||||
* @param request 请求对象
|
||||
* @param token 令牌
|
||||
* @return
|
||||
*/
|
||||
RoleResourceDeleteResponse delete(RoleResourceDeleteRequest request, Token token);
|
||||
|
||||
/**
|
||||
* 更新
|
||||
*
|
||||
* @param request 请求对象
|
||||
* @param token 令牌
|
||||
* @return
|
||||
*/
|
||||
RoleResourceUpdateResponse update(RoleResourceUpdateRequest request, Token token);
|
||||
|
||||
/**
|
||||
* 查询
|
||||
*
|
||||
* @param request 请求对象
|
||||
* @param token 令牌
|
||||
* @return
|
||||
*/
|
||||
RoleResourceFindResponse find(RoleResourceFindRequest request, Token token);
|
||||
|
||||
/**
|
||||
* 获得对象
|
||||
*
|
||||
* @param request 请求对象
|
||||
* @param token 令牌
|
||||
* @return
|
||||
*/
|
||||
RoleResourceGetResponse get(RoleResourceGetRequest request, Token token);
|
||||
|
||||
/**
|
||||
* 选中或取消资源
|
||||
*
|
||||
* @param request 请求对象
|
||||
* @param token 令牌
|
||||
* @return 响应
|
||||
*/
|
||||
RoleResourceCheckResponse check(RoleResourceCheckRequest request, Token token);
|
||||
}
|
@ -1,227 +0,0 @@
|
||||
package ${basePackage}.module.system.mgr;
|
||||
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.github.pagehelper.util.StringUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
||||
import ${basePackage}.frame.base.ErrorType;
|
||||
import ${basePackage}.frame.base.Token;
|
||||
import ${basePackage}.frame.utils.IDgenerator;
|
||||
import ${basePackage}.frame.utils.MapperUtil;
|
||||
import ${basePackage}.frame.utils.Message;
|
||||
import ${basePackage}.frame.utils.ValidationUtil;
|
||||
import ${basePackage}.module.system.ent.RoleResource;
|
||||
import ${basePackage}.module.system.mpr.RoleResourceMapper;
|
||||
import ${basePackage}.module.system.req.RoleResourceCheckRequest;
|
||||
import ${basePackage}.module.system.req.RoleResourceCreateRequest;
|
||||
import ${basePackage}.module.system.req.RoleResourceDeleteRequest;
|
||||
import ${basePackage}.module.system.req.RoleResourceFindRequest;
|
||||
import ${basePackage}.module.system.req.RoleResourceGetRequest;
|
||||
import ${basePackage}.module.system.req.RoleResourceUpdateRequest;
|
||||
import ${basePackage}.module.system.rsp.RoleResourceCheckResponse;
|
||||
import ${basePackage}.module.system.rsp.RoleResourceCreateResponse;
|
||||
import ${basePackage}.module.system.rsp.RoleResourceDeleteResponse;
|
||||
import ${basePackage}.module.system.rsp.RoleResourceFindResponse;
|
||||
import ${basePackage}.module.system.rsp.RoleResourceGetResponse;
|
||||
import ${basePackage}.module.system.rsp.RoleResourceUpdateResponse;
|
||||
|
||||
/**
|
||||
* ROLE_RESOURCE - 角色资源关系
|
||||
*
|
||||
* @author wangbing
|
||||
* @version 0.0.1
|
||||
* @since 2017-01-01
|
||||
*/
|
||||
@Transactional
|
||||
@Service
|
||||
public class RoleResourceManagerImpl implements RoleResourceManager {
|
||||
|
||||
@Autowired
|
||||
private RoleResourceMapper roleResourceMapper;
|
||||
|
||||
/**
|
||||
* 插入
|
||||
*
|
||||
* @param request 请求对象
|
||||
* @param token 令牌
|
||||
* @return 响应
|
||||
*/
|
||||
public RoleResourceCreateResponse create(RoleResourceCreateRequest request, Token token) {
|
||||
RoleResourceCreateResponse response = new RoleResourceCreateResponse();
|
||||
|
||||
ValidationUtil.validate(request, response);
|
||||
if (response.hasError()) {
|
||||
return response;
|
||||
}
|
||||
|
||||
long id = IDgenerator.nextId();
|
||||
RoleResource entity = MapperUtil.map(request, RoleResource.class);
|
||||
entity.setId(id);
|
||||
|
||||
long result = roleResourceMapper.insert(entity, token);
|
||||
if (1L != result) {
|
||||
response.addError(ErrorType.BUSINESS_ERROR, Message.CREATE_FAILURE);
|
||||
return response;
|
||||
}
|
||||
response.setId(id);
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* 逻辑删除
|
||||
*
|
||||
* @param request 请求对象
|
||||
* @param token 令牌
|
||||
* @return 响应
|
||||
*/
|
||||
public RoleResourceDeleteResponse delete(RoleResourceDeleteRequest request, Token token) {
|
||||
RoleResourceDeleteResponse response = new RoleResourceDeleteResponse();
|
||||
|
||||
ValidationUtil.validate(request, response);
|
||||
if (response.hasError()) {
|
||||
return response;
|
||||
}
|
||||
|
||||
long result = roleResourceMapper.delete(request, token);
|
||||
if (1L != result) {
|
||||
response.addError(ErrorType.BUSINESS_ERROR, Message.DELETE_FAILURE);
|
||||
return response;
|
||||
}
|
||||
response.setResult(result);
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新
|
||||
*
|
||||
* @param request 请求对象
|
||||
* @param token 令牌
|
||||
* @return 响应
|
||||
*/
|
||||
public RoleResourceUpdateResponse update(RoleResourceUpdateRequest request, Token token) {
|
||||
RoleResourceUpdateResponse response = new RoleResourceUpdateResponse();
|
||||
|
||||
ValidationUtil.validate(request, response);
|
||||
if (response.hasError()) {
|
||||
return response;
|
||||
}
|
||||
|
||||
long result = roleResourceMapper.update(request, token);
|
||||
if (1L != result) {
|
||||
response.addError(ErrorType.BUSINESS_ERROR, Message.UPDATE_FAILURE);
|
||||
return response;
|
||||
}
|
||||
response.setResult(result);
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询
|
||||
*
|
||||
* @param request 请求对象
|
||||
* @param token 令牌
|
||||
* @return 响应
|
||||
*/
|
||||
@Transactional(readOnly = true)
|
||||
public RoleResourceFindResponse find(RoleResourceFindRequest request, Token token) {
|
||||
RoleResourceFindResponse response = new RoleResourceFindResponse();
|
||||
|
||||
ValidationUtil.validate(request, response);
|
||||
if (response.hasError()) {
|
||||
return response;
|
||||
}
|
||||
|
||||
PageHelper.startPage(request.getPageNumber(), request.getPageSize());
|
||||
if (StringUtil.isNotEmpty(request.getSortKey())) {
|
||||
PageHelper.orderBy(request.getSortKey() + " " + request.getSortType());
|
||||
}
|
||||
PageInfo<RoleResource> pageInfo = new PageInfo<>(roleResourceMapper.find(request, token));
|
||||
|
||||
response.setResult(pageInfo.getList());
|
||||
response.setTotalCount(pageInfo.getTotal());
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得对象
|
||||
*
|
||||
* @param request 请求对象
|
||||
* @param token 令牌
|
||||
* @return 响应
|
||||
*/
|
||||
@Transactional(readOnly = true)
|
||||
public RoleResourceGetResponse get(RoleResourceGetRequest request, Token token) {
|
||||
RoleResourceGetResponse response = new RoleResourceGetResponse();
|
||||
|
||||
ValidationUtil.validate(request, response);
|
||||
if (response.hasError()) {
|
||||
return response;
|
||||
}
|
||||
|
||||
RoleResource po = roleResourceMapper.get(request, token);
|
||||
|
||||
if (po != null) {
|
||||
response.setRoleResource(po);
|
||||
} else {
|
||||
response.addError(ErrorType.BUSINESS_ERROR, Message.GET_FAILURE);
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* 选中或取消资源
|
||||
*
|
||||
* @param request 请求对象
|
||||
* @param token 令牌
|
||||
* @return 响应
|
||||
*/
|
||||
public RoleResourceCheckResponse check(RoleResourceCheckRequest request, Token token) {
|
||||
RoleResourceCheckResponse response = new RoleResourceCheckResponse();
|
||||
|
||||
ValidationUtil.validate(request, response);
|
||||
if (response.hasError()) {
|
||||
return response;
|
||||
}
|
||||
|
||||
RoleResourceFindRequest roleResourceFindRequest = new RoleResourceFindRequest();
|
||||
roleResourceFindRequest.setRoleId(request.getRoleId());
|
||||
roleResourceFindRequest.setResourceId(request.getResourceId());
|
||||
RoleResourceFindResponse roleResourceFindResponse = this.find(roleResourceFindRequest, token);
|
||||
if (roleResourceFindResponse.hasError()) {
|
||||
response.addErrors(roleResourceFindResponse.getErrors());
|
||||
return response;
|
||||
}
|
||||
|
||||
if (request.getChecked() && roleResourceFindResponse.getResult().size() == 0) {
|
||||
RoleResourceCreateRequest roleResourceCreateRequest = new RoleResourceCreateRequest();
|
||||
roleResourceCreateRequest.setRoleId(request.getRoleId());
|
||||
roleResourceCreateRequest.setResourceId(request.getResourceId());
|
||||
RoleResourceCreateResponse roleResourceCreateResponse = this.create(roleResourceCreateRequest, token);
|
||||
if (roleResourceCreateResponse.hasError()) {
|
||||
response.addErrors(roleResourceCreateResponse.getErrors());
|
||||
return response;
|
||||
}
|
||||
} else if (!request.getChecked() && roleResourceFindResponse.getResult().size() > 0) {
|
||||
for (RoleResource roleResource : roleResourceFindResponse.getResult()) {
|
||||
RoleResourceDeleteRequest roleResourceDeleteRequest = new RoleResourceDeleteRequest();
|
||||
roleResourceDeleteRequest.setId(roleResource.getId());
|
||||
RoleResourceDeleteResponse roleResourceDeleteResponse = this.delete(roleResourceDeleteRequest, token);
|
||||
if (roleResourceDeleteResponse.hasError()) {
|
||||
response.addErrors(roleResourceDeleteResponse.getErrors());
|
||||
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
||||
return response;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
}
|
@ -1,147 +0,0 @@
|
||||
<?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="${basePackage}.module.system.mpr.ResourceMapper">
|
||||
|
||||
<sql id="table">`SYS_RESOURCE`</sql>
|
||||
|
||||
<sql id="entityColumnList">
|
||||
`ID`,`CODE`,`VALUE`,`COMMENT`,`RESOURCE_TYPE`,`VALID`,`ROW_VERSION`,`IS_DELETED`,`CREATE_BY`,`CREATE_TIME`,`LAST_UPDATE_BY`,`LAST_UPDATE_TIME`
|
||||
</sql>
|
||||
|
||||
<resultMap id="resource" type="${basePackage}.module.system.ent.Resource">
|
||||
<result column="ID" jdbcType="BIGINT" property="id"/>
|
||||
<result column="CODE" jdbcType="VARCHAR" property="code"/>
|
||||
<result column="VALUE" jdbcType="VARCHAR" property="value"/>
|
||||
<result column="COMMENT" jdbcType="VARCHAR" property="comment"/>
|
||||
<result column="RESOURCE_TYPE" jdbcType="VARCHAR" property="resourceType"/>
|
||||
<result column="VALID" jdbcType="BIT" property="valid"/>
|
||||
<result column="ROW_VERSION" jdbcType="BIGINT" property="rowVersion"/>
|
||||
<result column="IS_DELETED" jdbcType="BIT" property="isDeleted"/>
|
||||
<result column="CREATE_BY" jdbcType="BIGINT" property="createBy"/>
|
||||
<result column="CREATE_TIME" jdbcType="TIMESTAMP" property="createTime"/>
|
||||
<result column="LAST_UPDATE_BY" jdbcType="BIGINT" property="lastUpdateBy"/>
|
||||
<result column="LAST_UPDATE_TIME" jdbcType="TIMESTAMP" property="lastUpdateTime"/>
|
||||
</resultMap>
|
||||
|
||||
<select id="find" resultMap="resource">
|
||||
SELECT
|
||||
<include refid="entityColumnList"/>
|
||||
FROM
|
||||
<include refid="table"/>
|
||||
WHERE
|
||||
`IS_DELETED` = 0
|
||||
<if test="request.code != null and request.code != ''">
|
||||
AND `CODE` = ${r"#"}{request.code}
|
||||
</if>
|
||||
<if test="request.value != null and request.value != ''">
|
||||
AND `VALUE` = ${r"#"}{request.value}
|
||||
</if>
|
||||
<if test="request.comment != null and request.comment != ''">
|
||||
AND `COMMENT` = ${r"#"}{request.comment}
|
||||
</if>
|
||||
<if test="request.resourceType != null and request.resourceType != ''">
|
||||
AND `RESOURCE_TYPE` = ${r"#"}{request.resourceType}
|
||||
</if>
|
||||
<if test="request.valid != null">
|
||||
AND `VALID` = ${r"#"}{request.valid}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="search" resultMap="resource">
|
||||
SELECT
|
||||
<include refid="entityColumnList"/>
|
||||
FROM
|
||||
<include refid="table"/>
|
||||
WHERE
|
||||
`IS_DELETED` = 0
|
||||
<if test="request.keyword != null and request.keyword != ''">
|
||||
1 = 2
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<insert id="insert">
|
||||
INSERT INTO
|
||||
<include refid="table"/>
|
||||
(
|
||||
<include refid="entityColumnList"/>
|
||||
)
|
||||
VALUES
|
||||
(
|
||||
${r"#"}{request.id},
|
||||
${r"#"}{request.code,jdbcType=VARCHAR},
|
||||
${r"#"}{request.value,jdbcType=VARCHAR},
|
||||
${r"#"}{request.comment,jdbcType=VARCHAR},
|
||||
${r"#"}{request.resourceType,jdbcType=VARCHAR},
|
||||
${r"#"}{request.valid,jdbcType=BIT},
|
||||
0,
|
||||
0,
|
||||
${r"#"}{token.userId,jdbcType=NUMERIC},
|
||||
sysdate(),
|
||||
NULL,
|
||||
NULL
|
||||
)
|
||||
</insert>
|
||||
|
||||
<insert id="insertBatch">
|
||||
INSERT INTO
|
||||
<include refid="table"/>
|
||||
(
|
||||
<include refid="entityColumnList"/>
|
||||
)
|
||||
VALUES
|
||||
<foreach collection="list" item= "item" index ="index" separator=",">
|
||||
(
|
||||
${r"#"}{item.id},
|
||||
${r"#"}{item.code,jdbcType=VARCHAR},
|
||||
${r"#"}{item.value,jdbcType=VARCHAR},
|
||||
${r"#"}{item.comment,jdbcType=VARCHAR},
|
||||
${r"#"}{item.resourceType,jdbcType=VARCHAR},
|
||||
${r"#"}{item.valid,jdbcType=BIT},
|
||||
0,
|
||||
0,
|
||||
${r"#"}{token.userId,jdbcType=NUMERIC},
|
||||
sysdate(),
|
||||
NULL,
|
||||
NULL
|
||||
)
|
||||
</foreach >
|
||||
</insert>
|
||||
|
||||
<update id="delete">
|
||||
UPDATE
|
||||
<include refid="table"/>
|
||||
SET `IS_DELETED` = 1
|
||||
WHERE `IS_DELETED` = 0
|
||||
AND `ID` = ${r"#"}{request.id}
|
||||
</update>
|
||||
|
||||
<update id="update">
|
||||
UPDATE
|
||||
<include refid="table"/>
|
||||
SET
|
||||
`CODE` = ${r"#"}{request.code,jdbcType=VARCHAR},
|
||||
`VALUE` = ${r"#"}{request.value,jdbcType=VARCHAR},
|
||||
`COMMENT` = ${r"#"}{request.comment,jdbcType=VARCHAR},
|
||||
`RESOURCE_TYPE` = ${r"#"}{request.resourceType,jdbcType=VARCHAR},
|
||||
`VALID` = ${r"#"}{request.valid,jdbcType=BIT},
|
||||
`ROW_VERSION` = `ROW_VERSION` + 1,
|
||||
`LAST_UPDATE_BY` = ${r"#"}{token.userId},
|
||||
`LAST_UPDATE_TIME` = sysdate()
|
||||
WHERE
|
||||
`IS_DELETED` = 0
|
||||
AND `ID` = ${r"#"}{request.id}
|
||||
AND `ROW_VERSION` = ${r"#"}{request.rowVersion}
|
||||
</update>
|
||||
|
||||
<select id="get" resultMap="resource">
|
||||
SELECT
|
||||
<include refid="entityColumnList"/>
|
||||
FROM
|
||||
<include refid="table"/>
|
||||
WHERE
|
||||
`IS_DELETED` = 0
|
||||
AND `ID` = ${r"#"}{request.id}
|
||||
</select>
|
||||
</mapper>
|
@ -1,126 +0,0 @@
|
||||
<?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="${basePackage}.module.system.mpr.RoleResourceMapper">
|
||||
|
||||
<sql id="table">`SYS_ROLE_RESOURCE`</sql>
|
||||
|
||||
<sql id="entityColumnList">
|
||||
`ID`,`ROLE_ID`,`RESOURCE_ID`,`ROW_VERSION`,`IS_DELETED`,`CREATE_BY`,`CREATE_TIME`,`LAST_UPDATE_BY`,`LAST_UPDATE_TIME`
|
||||
</sql>
|
||||
|
||||
<resultMap id="roleResource" type="${basePackage}.module.system.ent.RoleResource">
|
||||
<result column="ID" jdbcType="BIGINT" property="id"/>
|
||||
<result column="ROLE_ID" jdbcType="BIGINT" property="roleId"/>
|
||||
<result column="RESOURCE_ID" jdbcType="BIGINT" property="resourceId"/>
|
||||
<result column="ROW_VERSION" jdbcType="BIGINT" property="rowVersion"/>
|
||||
<result column="IS_DELETED" jdbcType="BIT" property="isDeleted"/>
|
||||
<result column="CREATE_BY" jdbcType="BIGINT" property="createBy"/>
|
||||
<result column="CREATE_TIME" jdbcType="TIMESTAMP" property="createTime"/>
|
||||
<result column="LAST_UPDATE_BY" jdbcType="BIGINT" property="lastUpdateBy"/>
|
||||
<result column="LAST_UPDATE_TIME" jdbcType="TIMESTAMP" property="lastUpdateTime"/>
|
||||
</resultMap>
|
||||
|
||||
<select id="find" resultMap="roleResource">
|
||||
SELECT
|
||||
<include refid="entityColumnList"/>
|
||||
FROM
|
||||
<include refid="table"/>
|
||||
WHERE
|
||||
`IS_DELETED` = 0
|
||||
<if test="request.roleId != null and request.roleId != 0">
|
||||
AND `ROLE_ID` = ${r"#"}{request.roleId}
|
||||
</if>
|
||||
<if test="request.resourceId != null and request.resourceId != 0">
|
||||
AND `RESOURCE_ID` = ${r"#"}{request.resourceId}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="search" resultMap="roleResource">
|
||||
SELECT
|
||||
<include refid="entityColumnList"/>
|
||||
FROM
|
||||
<include refid="table"/>
|
||||
WHERE
|
||||
`IS_DELETED` = 0
|
||||
<if test="request.keyword != null and request.keyword != ''">
|
||||
1 = 2
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<insert id="insert">
|
||||
INSERT INTO
|
||||
<include refid="table"/>
|
||||
(
|
||||
<include refid="entityColumnList"/>
|
||||
)
|
||||
VALUES
|
||||
(
|
||||
${r"#"}{request.id},
|
||||
${r"#"}{request.roleId,jdbcType=BIGINT},
|
||||
${r"#"}{request.resourceId,jdbcType=BIGINT},
|
||||
0,
|
||||
0,
|
||||
${r"#"}{token.userId,jdbcType=NUMERIC},
|
||||
sysdate(),
|
||||
NULL,
|
||||
NULL
|
||||
)
|
||||
</insert>
|
||||
|
||||
<insert id="insertBatch">
|
||||
INSERT INTO
|
||||
<include refid="table"/>
|
||||
(
|
||||
<include refid="entityColumnList"/>
|
||||
)
|
||||
VALUES
|
||||
<foreach collection="list" item= "item" index ="index" separator=",">
|
||||
(
|
||||
${r"#"}{item.id},
|
||||
${r"#"}{item.roleId,jdbcType=BIGINT},
|
||||
${r"#"}{item.resourceId,jdbcType=BIGINT},
|
||||
0,
|
||||
0,
|
||||
${r"#"}{token.userId,jdbcType=NUMERIC},
|
||||
sysdate(),
|
||||
NULL,
|
||||
NULL
|
||||
)
|
||||
</foreach >
|
||||
</insert>
|
||||
|
||||
<update id="delete">
|
||||
UPDATE
|
||||
<include refid="table"/>
|
||||
SET `IS_DELETED` = 1
|
||||
WHERE `IS_DELETED` = 0
|
||||
AND `ID` = ${r"#"}{request.id}
|
||||
</update>
|
||||
|
||||
<update id="update">
|
||||
UPDATE
|
||||
<include refid="table"/>
|
||||
SET
|
||||
`ROLE_ID` = ${r"#"}{request.roleId,jdbcType=BIGINT},
|
||||
`RESOURCE_ID` = ${r"#"}{request.resourceId,jdbcType=BIGINT},
|
||||
`ROW_VERSION` = `ROW_VERSION` + 1,
|
||||
`LAST_UPDATE_BY` = ${r"#"}{token.userId},
|
||||
`LAST_UPDATE_TIME` = sysdate()
|
||||
WHERE
|
||||
`IS_DELETED` = 0
|
||||
AND `ID` = ${r"#"}{request.id}
|
||||
AND `ROW_VERSION` = ${r"#"}{request.rowVersion}
|
||||
</update>
|
||||
|
||||
<select id="get" resultMap="roleResource">
|
||||
SELECT
|
||||
<include refid="entityColumnList"/>
|
||||
FROM
|
||||
<include refid="table"/>
|
||||
WHERE
|
||||
`IS_DELETED` = 0
|
||||
AND `ID` = ${r"#"}{request.id}
|
||||
</select>
|
||||
</mapper>
|
@ -1,76 +0,0 @@
|
||||
package ${basePackage}.module.system.mpr;
|
||||
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import ${basePackage}.frame.base.Token;
|
||||
import ${basePackage}.module.system.ent.Resource;
|
||||
import ${basePackage}.module.system.req.ResourceDeleteRequest;
|
||||
import ${basePackage}.module.system.req.ResourceFindRequest;
|
||||
import ${basePackage}.module.system.req.ResourceGetRequest;
|
||||
import ${basePackage}.module.system.req.ResourceUpdateRequest;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* RESOURCE - 资源
|
||||
*
|
||||
* @author author
|
||||
* @date 2019-12-19
|
||||
*/
|
||||
@Mapper
|
||||
public interface ResourceMapper {
|
||||
|
||||
/**
|
||||
* 插入
|
||||
*
|
||||
* @param request 请求对象
|
||||
* @param token 令牌
|
||||
* @return 返回数量
|
||||
*/
|
||||
long insert(@Param("request") Resource request, @Param("token") Token token);
|
||||
|
||||
/**
|
||||
* 批量插入
|
||||
*
|
||||
* @param request 请求对象
|
||||
* @param token 令牌
|
||||
* @return 返回数量
|
||||
*/
|
||||
long insertBatch(@Param("list") List<Resource> request, @Param("token") Token token);
|
||||
|
||||
/**
|
||||
* 逻辑删除
|
||||
*
|
||||
* @param request 请求对象
|
||||
* @param token 令牌
|
||||
* @return 返回数量
|
||||
*/
|
||||
long delete(@Param("request") ResourceDeleteRequest request, @Param("token") Token token);
|
||||
|
||||
/**
|
||||
* 更新
|
||||
*
|
||||
* @param request 请求对象
|
||||
* @param token 令牌
|
||||
* @return 返回数量
|
||||
*/
|
||||
long update(@Param("request") ResourceUpdateRequest request, @Param("token") Token token);
|
||||
|
||||
/**
|
||||
* 查询
|
||||
*
|
||||
* @param request 请求对象
|
||||
* @param token 令牌
|
||||
* @return 返回对象
|
||||
*/
|
||||
List<Resource> find(@Param("request") ResourceFindRequest request, @Param("token") Token token);
|
||||
|
||||
/**
|
||||
* 获得对象
|
||||
*
|
||||
* @param request 请求对象
|
||||
* @param token 令牌
|
||||
* @return 返回对象
|
||||
*/
|
||||
Resource get(@Param("request") ResourceGetRequest request, @Param("token") Token token);
|
||||
}
|
@ -1,76 +0,0 @@
|
||||
package ${basePackage}.module.system.mpr;
|
||||
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import ${basePackage}.frame.base.Token;
|
||||
import ${basePackage}.module.system.ent.RoleResource;
|
||||
import ${basePackage}.module.system.req.RoleResourceDeleteRequest;
|
||||
import ${basePackage}.module.system.req.RoleResourceFindRequest;
|
||||
import ${basePackage}.module.system.req.RoleResourceGetRequest;
|
||||
import ${basePackage}.module.system.req.RoleResourceUpdateRequest;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* ROLE_RESOURCE - 角色资源关系
|
||||
*
|
||||
* @author wangbing
|
||||
* @date 2019-12-20
|
||||
*/
|
||||
@Mapper
|
||||
public interface RoleResourceMapper {
|
||||
|
||||
/**
|
||||
* 插入
|
||||
*
|
||||
* @param request 请求对象
|
||||
* @param token 令牌
|
||||
* @return 返回数量
|
||||
*/
|
||||
long insert(@Param("request") RoleResource request, @Param("token") Token token);
|
||||
|
||||
/**
|
||||
* 批量插入
|
||||
*
|
||||
* @param request 请求对象
|
||||
* @param token 令牌
|
||||
* @return 返回数量
|
||||
*/
|
||||
long insertBatch(@Param("list") List<RoleResource> request, @Param("token") Token token);
|
||||
|
||||
/**
|
||||
* 逻辑删除
|
||||
*
|
||||
* @param request 请求对象
|
||||
* @param token 令牌
|
||||
* @return 返回数量
|
||||
*/
|
||||
long delete(@Param("request") RoleResourceDeleteRequest request, @Param("token") Token token);
|
||||
|
||||
/**
|
||||
* 更新
|
||||
*
|
||||
* @param request 请求对象
|
||||
* @param token 令牌
|
||||
* @return 返回数量
|
||||
*/
|
||||
long update(@Param("request") RoleResourceUpdateRequest request, @Param("token") Token token);
|
||||
|
||||
/**
|
||||
* 查询
|
||||
*
|
||||
* @param request 请求对象
|
||||
* @param token 令牌
|
||||
* @return 返回对象
|
||||
*/
|
||||
List<RoleResource> find(@Param("request") RoleResourceFindRequest request, @Param("token") Token token);
|
||||
|
||||
/**
|
||||
* 获得对象
|
||||
*
|
||||
* @param request 请求对象
|
||||
* @param token 令牌
|
||||
* @return 返回对象
|
||||
*/
|
||||
RoleResource get(@Param("request") RoleResourceGetRequest request, @Param("token") Token token);
|
||||
}
|
@ -1,90 +0,0 @@
|
||||
package ${basePackage}.module.system.req;
|
||||
|
||||
import ${basePackage}.frame.base.BaseRequest;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
import ${basePackage}.frame.validation.Dict;
|
||||
|
||||
/**
|
||||
* ResourceCreateRequest - 资源新增
|
||||
*
|
||||
* @author wangbing
|
||||
* @version 0.0.1
|
||||
* @since 2019-12-27
|
||||
*/
|
||||
public class ResourceCreateRequest extends BaseRequest {
|
||||
|
||||
/**
|
||||
* 资源代码
|
||||
*/
|
||||
@NotEmpty(message = "[code]资源代码不能为空")
|
||||
@Length(min = 0, max = 50, message = "[code]资源代码长度不合法(0-50)")
|
||||
private String code;
|
||||
|
||||
/**
|
||||
* 资源内容
|
||||
*/
|
||||
@NotEmpty(message = "[value]资源内容不能为空")
|
||||
@Length(min = 0, max = 100, message = "[value]资源内容长度不合法(0-100)")
|
||||
private String value;
|
||||
|
||||
/**
|
||||
* 资源描述
|
||||
*/
|
||||
@Length(min = 0, max = 255, message = "[comment]资源描述长度不合法(0-255)")
|
||||
private String comment;
|
||||
|
||||
/**
|
||||
* 资源类型
|
||||
*/
|
||||
@NotNull(message = "[resourceType]资源类型不能为NULL")
|
||||
@Dict(name = "RESOURCE_TYPE")
|
||||
private String resourceType;
|
||||
|
||||
/**
|
||||
* 是否有效
|
||||
*/
|
||||
@NotNull(message = "[valid]是否有效不能为NULL")
|
||||
private Boolean valid;
|
||||
|
||||
public String getCode() {
|
||||
return this.code;
|
||||
}
|
||||
|
||||
public void setCode(String code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getComment() {
|
||||
return this.comment;
|
||||
}
|
||||
|
||||
public void setComment(String comment) {
|
||||
this.comment = comment;
|
||||
}
|
||||
|
||||
public String getResourceType() {
|
||||
return this.resourceType;
|
||||
}
|
||||
|
||||
public void setResourceType(String resourceType) {
|
||||
this.resourceType = resourceType;
|
||||
}
|
||||
|
||||
public Boolean getValid() {
|
||||
return this.valid;
|
||||
}
|
||||
|
||||
public void setValid(Boolean valid) {
|
||||
this.valid = valid;
|
||||
}
|
||||
}
|
@ -1,28 +0,0 @@
|
||||
package ${basePackage}.module.system.req;
|
||||
|
||||
import ${basePackage}.frame.base.BaseUpdateRequest;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* ResourceDeleteRequest - 资源删除
|
||||
*
|
||||
* @author wangbing
|
||||
* @version 0.0.1
|
||||
* @since 2019-12-27
|
||||
*/
|
||||
public class ResourceDeleteRequest extends BaseUpdateRequest {
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@NotNull(message = "[id]主键不能为空")
|
||||
private long id;
|
||||
|
||||
public long getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public void setId(long id) {
|
||||
this.id = id;
|
||||
}
|
||||
}
|
@ -1,80 +0,0 @@
|
||||
package ${basePackage}.module.system.req;
|
||||
|
||||
import ${basePackage}.frame.base.BaseFindRequest;
|
||||
import ${basePackage}.frame.validation.Dict;
|
||||
|
||||
/**
|
||||
* ResourceRequest - 资源查询
|
||||
*
|
||||
* @author wangbing
|
||||
* @version 0.0.1
|
||||
* @since 2019-12-27
|
||||
*/
|
||||
public class ResourceFindRequest extends BaseFindRequest {
|
||||
|
||||
/**
|
||||
* 资源代码
|
||||
*/
|
||||
private String code;
|
||||
|
||||
/**
|
||||
* 资源内容
|
||||
*/
|
||||
private String value;
|
||||
|
||||
/**
|
||||
* 资源描述
|
||||
*/
|
||||
private String comment;
|
||||
|
||||
/**
|
||||
* 资源类型
|
||||
*/
|
||||
@Dict(name = "RESOURCE_TYPE")
|
||||
private String resourceType;
|
||||
|
||||
/**
|
||||
* 是否有效
|
||||
*/
|
||||
private Boolean valid;
|
||||
|
||||
public String getCode() {
|
||||
return this.code;
|
||||
}
|
||||
|
||||
public void setCode(String code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getComment() {
|
||||
return this.comment;
|
||||
}
|
||||
|
||||
public void setComment(String comment) {
|
||||
this.comment = comment;
|
||||
}
|
||||
|
||||
public String getResourceType() {
|
||||
return this.resourceType;
|
||||
}
|
||||
|
||||
public void setResourceType(String resourceType) {
|
||||
this.resourceType = resourceType;
|
||||
}
|
||||
|
||||
public Boolean getValid() {
|
||||
return this.valid;
|
||||
}
|
||||
|
||||
public void setValid(Boolean valid) {
|
||||
this.valid = valid;
|
||||
}
|
||||
}
|
@ -1,28 +0,0 @@
|
||||
package ${basePackage}.module.system.req;
|
||||
|
||||
import ${basePackage}.frame.base.BaseRequest;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* ResourceGetRequest - 资源获取
|
||||
*
|
||||
* @author wangbing
|
||||
* @version 0.0.1
|
||||
* @since 2019-12-27
|
||||
*/
|
||||
public class ResourceGetRequest extends BaseRequest {
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@NotNull(message = "[id]主键不能为空")
|
||||
private long id;
|
||||
|
||||
public long getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public void setId(long id) {
|
||||
this.id = id;
|
||||
}
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
package ${basePackage}.module.system.req;
|
||||
|
||||
import ${basePackage}.frame.base.BaseRequest;
|
||||
|
||||
/**
|
||||
* ResourceTreeRequest - 资源获取
|
||||
*
|
||||
* @author wangbing
|
||||
* @version 0.0.1
|
||||
* @since 2019-12-26
|
||||
*/
|
||||
public class ResourceTreeRequest extends BaseRequest {
|
||||
|
||||
}
|
@ -1,104 +0,0 @@
|
||||
package ${basePackage}.module.system.req;
|
||||
|
||||
import ${basePackage}.frame.base.BaseUpdateRequest;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import ${basePackage}.frame.validation.Dict;
|
||||
|
||||
/**
|
||||
* ResourceUpdateRequest - 资源更新
|
||||
*
|
||||
* @author wangbing
|
||||
* @version 0.0.1
|
||||
* @since 2019-12-27
|
||||
*/
|
||||
public class ResourceUpdateRequest extends BaseUpdateRequest {
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@NotNull(message = "[id]主键不能为NULL")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 资源代码
|
||||
*/
|
||||
@NotEmpty(message = "[code]资源代码不能为空")
|
||||
@Length(min = 0, max = 50, message = "[code]资源代码长度不合法(0-50)")
|
||||
private String code;
|
||||
|
||||
/**
|
||||
* 资源内容
|
||||
*/
|
||||
@NotEmpty(message = "[value]资源内容不能为空")
|
||||
@Length(min = 0, max = 100, message = "[value]资源内容长度不合法(0-100)")
|
||||
private String value;
|
||||
|
||||
/**
|
||||
* 资源描述
|
||||
*/
|
||||
@Length(min = 0, max = 255, message = "[comment]资源描述长度不合法(0-255)")
|
||||
private String comment;
|
||||
|
||||
/**
|
||||
* 资源类型
|
||||
*/
|
||||
@NotNull(message = "[resourceType]资源类型不能为NULL")
|
||||
@Dict(name = "RESOURCE_TYPE")
|
||||
private String resourceType;
|
||||
|
||||
/**
|
||||
* 是否有效
|
||||
*/
|
||||
@NotNull(message = "[valid]是否有效不能为NULL")
|
||||
private Boolean valid;
|
||||
|
||||
public Long getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return this.code;
|
||||
}
|
||||
|
||||
public void setCode(String code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getComment() {
|
||||
return this.comment;
|
||||
}
|
||||
|
||||
public void setComment(String comment) {
|
||||
this.comment = comment;
|
||||
}
|
||||
|
||||
public String getResourceType() {
|
||||
return this.resourceType;
|
||||
}
|
||||
|
||||
public void setResourceType(String resourceType) {
|
||||
this.resourceType = resourceType;
|
||||
}
|
||||
|
||||
public Boolean getValid() {
|
||||
return this.valid;
|
||||
}
|
||||
|
||||
public void setValid(Boolean valid) {
|
||||
this.valid = valid;
|
||||
}
|
||||
}
|
@ -0,0 +1,87 @@
|
||||
package ${basePackage}.module.system.req;
|
||||
|
||||
import ${basePackage}.frame.base.BaseUpdateRequest;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* RoleResCheckRequest - 角色资源切换
|
||||
*
|
||||
* @author wangbing
|
||||
* @version 0.0.1
|
||||
* @since 2017-01-01
|
||||
*/
|
||||
public class RoleResCheckRequest extends BaseUpdateRequest {
|
||||
|
||||
/**
|
||||
* 角色主键
|
||||
*/
|
||||
@NotNull(message = "[roleId]资源主键不能为NULL")
|
||||
private Long roleId;
|
||||
|
||||
/**
|
||||
* 角色代码
|
||||
*/
|
||||
@NotBlank(message = "[roleCode]资源代码不能为NULL")
|
||||
private String roleCode;
|
||||
|
||||
/**
|
||||
* 资源主键
|
||||
*/
|
||||
@NotNull(message = "[resId]资源主键不能为NULL")
|
||||
private Long resId;
|
||||
|
||||
/**
|
||||
* 资源代码
|
||||
*/
|
||||
@NotBlank(message = "[resCode]资源代码不能为NULL")
|
||||
private String resCode;
|
||||
|
||||
/**
|
||||
* 是否选中
|
||||
*/
|
||||
@NotNull(message = "[checked]是否选中不能为NULL")
|
||||
private Boolean checked;
|
||||
|
||||
public Long getRoleId() {
|
||||
return roleId;
|
||||
}
|
||||
|
||||
public void setRoleId(Long roleId) {
|
||||
this.roleId = roleId;
|
||||
}
|
||||
|
||||
public String getRoleCode() {
|
||||
return roleCode;
|
||||
}
|
||||
|
||||
public void setRoleCode(String roleCode) {
|
||||
this.roleCode = roleCode;
|
||||
}
|
||||
|
||||
public Long getResId() {
|
||||
return resId;
|
||||
}
|
||||
|
||||
public void setResId(Long resId) {
|
||||
this.resId = resId;
|
||||
}
|
||||
|
||||
public String getResCode() {
|
||||
return resCode;
|
||||
}
|
||||
|
||||
public void setResCode(String resCode) {
|
||||
this.resCode = resCode;
|
||||
}
|
||||
|
||||
public Boolean getChecked() {
|
||||
return checked;
|
||||
}
|
||||
|
||||
public void setChecked(Boolean checked) {
|
||||
this.checked = checked;
|
||||
}
|
||||
}
|
||||
|
@ -1,58 +0,0 @@
|
||||
package ${basePackage}.module.system.req;
|
||||
|
||||
import ${basePackage}.frame.base.BaseUpdateRequest;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* RoleResourceUpdateRequest - 角色资源关系更新
|
||||
*
|
||||
* @author wangbing
|
||||
* @version 0.0.1
|
||||
* @since 2017-01-01
|
||||
*/
|
||||
public class RoleResourceCheckRequest extends BaseUpdateRequest {
|
||||
|
||||
/**
|
||||
* 角色主键
|
||||
*/
|
||||
@NotNull(message = "[roleId]角色主键不能为NULL")
|
||||
private Long roleId;
|
||||
|
||||
/**
|
||||
* 资源主键
|
||||
*/
|
||||
@NotNull(message = "[resourceId]资源主键不能为NULL")
|
||||
private Long resourceId;
|
||||
|
||||
/**
|
||||
* 是否选中
|
||||
*/
|
||||
@NotNull(message = "[checked]是否选中不能为NULL")
|
||||
private Boolean checked;
|
||||
|
||||
public Long getRoleId() {
|
||||
return this.roleId;
|
||||
}
|
||||
|
||||
public void setRoleId(Long roleId) {
|
||||
this.roleId = roleId;
|
||||
}
|
||||
|
||||
public Long getResourceId() {
|
||||
return this.resourceId;
|
||||
}
|
||||
|
||||
public void setResourceId(Long resourceId) {
|
||||
this.resourceId = resourceId;
|
||||
}
|
||||
|
||||
public Boolean getChecked() {
|
||||
return checked;
|
||||
}
|
||||
|
||||
public void setChecked(Boolean checked) {
|
||||
this.checked = checked;
|
||||
}
|
||||
}
|
||||
|
@ -1,44 +0,0 @@
|
||||
package ${basePackage}.module.system.req;
|
||||
|
||||
import ${basePackage}.frame.base.BaseRequest;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
|
||||
/**
|
||||
* RoleResourceCreateRequest - 角色资源关系新增
|
||||
*
|
||||
* @author wangbing
|
||||
* @version 0.0.1
|
||||
* @since 2017-01-01
|
||||
*/
|
||||
public class RoleResourceCreateRequest extends BaseRequest {
|
||||
|
||||
/**
|
||||
* 角色主键
|
||||
*/
|
||||
@NotNull(message = "[roleId]角色主键不能为NULL")
|
||||
private Long roleId;
|
||||
|
||||
/**
|
||||
* 资源主键
|
||||
*/
|
||||
@NotNull(message = "[resourceId]资源主键不能为NULL")
|
||||
private Long resourceId;
|
||||
|
||||
public Long getRoleId() {
|
||||
return this.roleId;
|
||||
}
|
||||
|
||||
public void setRoleId(Long roleId) {
|
||||
this.roleId = roleId;
|
||||
}
|
||||
|
||||
public Long getResourceId() {
|
||||
return this.resourceId;
|
||||
}
|
||||
|
||||
public void setResourceId(Long resourceId) {
|
||||
this.resourceId = resourceId;
|
||||
}
|
||||
}
|
@ -1,28 +0,0 @@
|
||||
package ${basePackage}.module.system.req;
|
||||
|
||||
import ${basePackage}.frame.base.BaseUpdateRequest;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* RoleResourceDeleteRequest - 角色资源关系删除
|
||||
*
|
||||
* @author wangbing
|
||||
* @version 0.0.1
|
||||
* @since 2017-01-01
|
||||
*/
|
||||
public class RoleResourceDeleteRequest extends BaseUpdateRequest {
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@NotNull(message = "[id]主键不能为空")
|
||||
private long id;
|
||||
|
||||
public long getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public void setId(long id) {
|
||||
this.id = id;
|
||||
}
|
||||
}
|
@ -1,39 +0,0 @@
|
||||
package ${basePackage}.module.system.req;
|
||||
|
||||
import ${basePackage}.frame.base.BaseFindRequest;
|
||||
|
||||
/**
|
||||
* RoleResourceRequest - 角色资源关系查询
|
||||
*
|
||||
* @author wangbing
|
||||
* @version 0.0.1
|
||||
* @since 2017-01-01
|
||||
*/
|
||||
public class RoleResourceFindRequest extends BaseFindRequest {
|
||||
|
||||
/**
|
||||
* 角色主键
|
||||
*/
|
||||
private Long roleId;
|
||||
|
||||
/**
|
||||
* 资源主键
|
||||
*/
|
||||
private Long resourceId;
|
||||
|
||||
public Long getRoleId() {
|
||||
return this.roleId;
|
||||
}
|
||||
|
||||
public void setRoleId(Long roleId) {
|
||||
this.roleId = roleId;
|
||||
}
|
||||
|
||||
public Long getResourceId() {
|
||||
return this.resourceId;
|
||||
}
|
||||
|
||||
public void setResourceId(Long resourceId) {
|
||||
this.resourceId = resourceId;
|
||||
}
|
||||
}
|
@ -1,28 +0,0 @@
|
||||
package ${basePackage}.module.system.req;
|
||||
|
||||
import ${basePackage}.frame.base.BaseRequest;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* RoleResourceGetRequest - 角色资源关系获取
|
||||
*
|
||||
* @author wangbing
|
||||
* @version 0.0.1
|
||||
* @since 2017-01-01
|
||||
*/
|
||||
public class RoleResourceGetRequest extends BaseRequest {
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@NotNull(message = "[id]主键不能为空")
|
||||
private long id;
|
||||
|
||||
public long getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public void setId(long id) {
|
||||
this.id = id;
|
||||
}
|
||||
}
|
@ -1,58 +0,0 @@
|
||||
package ${basePackage}.module.system.req;
|
||||
|
||||
import ${basePackage}.frame.base.BaseUpdateRequest;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
|
||||
/**
|
||||
* RoleResourceUpdateRequest - 角色资源关系更新
|
||||
*
|
||||
* @author wangbing
|
||||
* @version 0.0.1
|
||||
* @since 2017-01-01
|
||||
*/
|
||||
public class RoleResourceUpdateRequest extends BaseUpdateRequest {
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@NotNull(message = "[id]主键不能为NULL")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 角色主键
|
||||
*/
|
||||
@NotNull(message = "[roleId]角色主键不能为NULL")
|
||||
private Long roleId;
|
||||
|
||||
/**
|
||||
* 资源主键
|
||||
*/
|
||||
@NotNull(message = "[resourceId]资源主键不能为NULL")
|
||||
private Long resourceId;
|
||||
|
||||
public Long getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Long getRoleId() {
|
||||
return this.roleId;
|
||||
}
|
||||
|
||||
public void setRoleId(Long roleId) {
|
||||
this.roleId = roleId;
|
||||
}
|
||||
|
||||
public Long getResourceId() {
|
||||
return this.resourceId;
|
||||
}
|
||||
|
||||
public void setResourceId(Long resourceId) {
|
||||
this.resourceId = resourceId;
|
||||
}
|
||||
}
|
@ -1,26 +0,0 @@
|
||||
package ${basePackage}.module.system.rsp;
|
||||
|
||||
import ${basePackage}.frame.base.BaseResponse;
|
||||
|
||||
/**
|
||||
* ResourceCreateResponse - 资源
|
||||
*
|
||||
* @author author
|
||||
* @version 0.0.1
|
||||
* @since 2017-01-01
|
||||
*/
|
||||
public class ResourceCreateResponse extends BaseResponse {
|
||||
|
||||
/**
|
||||
* ID
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
}
|
@ -1,26 +0,0 @@
|
||||
package ${basePackage}.module.system.rsp;
|
||||
|
||||
import ${basePackage}.frame.base.BaseResponse;
|
||||
|
||||
/**
|
||||
* ResourceDeleteResponse - 资源
|
||||
*
|
||||
* @author author
|
||||
* @version 0.0.1
|
||||
* @since 2017-01-01
|
||||
*/
|
||||
public class ResourceDeleteResponse extends BaseResponse {
|
||||
|
||||
/**
|
||||
* 删除数目
|
||||
*/
|
||||
private Long result;
|
||||
|
||||
public Long getResult() {
|
||||
return this.result;
|
||||
}
|
||||
|
||||
public void setResult(Long result) {
|
||||
this.result = result;
|
||||
}
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
package ${basePackage}.module.system.rsp;
|
||||
|
||||
import ${basePackage}.frame.base.BaseFindResponse;
|
||||
import ${basePackage}.module.system.ent.Resource;
|
||||
|
||||
/**
|
||||
* ResourceFindResponse - 资源
|
||||
*
|
||||
* @author author
|
||||
* @version 0.0.1
|
||||
* @since 2017-01-01
|
||||
*/
|
||||
public class ResourceFindResponse extends BaseFindResponse<Resource> {
|
||||
}
|
@ -1,27 +0,0 @@
|
||||
package ${basePackage}.module.system.rsp;
|
||||
|
||||
import ${basePackage}.module.system.ent.Resource;
|
||||
import ${basePackage}.frame.base.BaseResponse;
|
||||
|
||||
/**
|
||||
* ResourceGetResponse - 资源
|
||||
*
|
||||
* @author author
|
||||
* @version 0.0.1
|
||||
* @since 2017-01-01
|
||||
*/
|
||||
public class ResourceGetResponse extends BaseResponse {
|
||||
|
||||
/**
|
||||
* 资源
|
||||
*/
|
||||
private Resource resource;
|
||||
|
||||
public Resource getResource() {
|
||||
return this.resource;
|
||||
}
|
||||
|
||||
public void setResource(Resource resource) {
|
||||
this.resource = resource;
|
||||
}
|
||||
}
|
@ -1,15 +0,0 @@
|
||||
package ${basePackage}.module.system.rsp;
|
||||
|
||||
import ${basePackage}.frame.base.BaseFindResponse;
|
||||
import ${basePackage}.module.system.ent.ResourceTree;
|
||||
|
||||
/**
|
||||
* ResourceTreeResponse - 资源
|
||||
*
|
||||
* @author author
|
||||
* @version 0.0.1
|
||||
* @since 2017-01-01
|
||||
*/
|
||||
public class ResourceTreeResponse extends BaseFindResponse<ResourceTree> {
|
||||
|
||||
}
|
@ -1,26 +0,0 @@
|
||||
package ${basePackage}.module.system.rsp;
|
||||
|
||||
import ${basePackage}.frame.base.BaseResponse;
|
||||
|
||||
/**
|
||||
* ResourceUpdateResponse - 资源
|
||||
*
|
||||
* @author author
|
||||
* @version 0.0.1
|
||||
* @since 2017-01-01
|
||||
*/
|
||||
public class ResourceUpdateResponse extends BaseResponse {
|
||||
|
||||
/**
|
||||
* 更新数目
|
||||
*/
|
||||
private Long result;
|
||||
|
||||
public Long getResult() {
|
||||
return this.result;
|
||||
}
|
||||
|
||||
public void setResult(Long result) {
|
||||
this.result = result;
|
||||
}
|
||||
}
|
@ -1,26 +0,0 @@
|
||||
package ${basePackage}.module.system.rsp;
|
||||
|
||||
import ${basePackage}.frame.base.BaseResponse;
|
||||
|
||||
/**
|
||||
* RoleResourceCreateResponse - 角色资源关系
|
||||
*
|
||||
* @author wangbing
|
||||
* @version 0.0.1
|
||||
* @since 2017-01-01
|
||||
*/
|
||||
public class RoleResourceCreateResponse extends BaseResponse {
|
||||
|
||||
/**
|
||||
* ID
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
}
|
@ -1,26 +0,0 @@
|
||||
package ${basePackage}.module.system.rsp;
|
||||
|
||||
import ${basePackage}.frame.base.BaseResponse;
|
||||
|
||||
/**
|
||||
* RoleResourceDeleteResponse - 角色资源关系
|
||||
*
|
||||
* @author wangbing
|
||||
* @version 0.0.1
|
||||
* @since 2017-01-01
|
||||
*/
|
||||
public class RoleResourceDeleteResponse extends BaseResponse {
|
||||
|
||||
/**
|
||||
* 删除数目
|
||||
*/
|
||||
private Long result;
|
||||
|
||||
public Long getResult() {
|
||||
return this.result;
|
||||
}
|
||||
|
||||
public void setResult(Long result) {
|
||||
this.result = result;
|
||||
}
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
package ${basePackage}.module.system.rsp;
|
||||
|
||||
import ${basePackage}.frame.base.BaseFindResponse;
|
||||
import ${basePackage}.module.system.ent.RoleResource;
|
||||
|
||||
/**
|
||||
* RoleResourceFindResponse - 角色资源关系
|
||||
*
|
||||
* @author wangbing
|
||||
* @version 0.0.1
|
||||
* @since 2017-01-01
|
||||
*/
|
||||
public class RoleResourceFindResponse extends BaseFindResponse<RoleResource> {
|
||||
}
|
@ -1,27 +0,0 @@
|
||||
package ${basePackage}.module.system.rsp;
|
||||
|
||||
import ${basePackage}.module.system.ent.RoleResource;
|
||||
import ${basePackage}.frame.base.BaseResponse;
|
||||
|
||||
/**
|
||||
* RoleResourceGetResponse - 角色资源关系
|
||||
*
|
||||
* @author wangbing
|
||||
* @version 0.0.1
|
||||
* @since 2017-01-01
|
||||
*/
|
||||
public class RoleResourceGetResponse extends BaseResponse {
|
||||
|
||||
/**
|
||||
* 角色资源关系
|
||||
*/
|
||||
private RoleResource roleResource;
|
||||
|
||||
public RoleResource getRoleResource() {
|
||||
return this.roleResource;
|
||||
}
|
||||
|
||||
public void setRoleResource(RoleResource roleResource) {
|
||||
this.roleResource = roleResource;
|
||||
}
|
||||
}
|
@ -1,26 +0,0 @@
|
||||
package ${basePackage}.module.system.rsp;
|
||||
|
||||
import ${basePackage}.frame.base.BaseResponse;
|
||||
|
||||
/**
|
||||
* RoleResourceUpdateResponse - 角色资源关系
|
||||
*
|
||||
* @author wangbing
|
||||
* @version 0.0.1
|
||||
* @since 2017-01-01
|
||||
*/
|
||||
public class RoleResourceUpdateResponse extends BaseResponse {
|
||||
|
||||
/**
|
||||
* 更新数目
|
||||
*/
|
||||
private Long result;
|
||||
|
||||
public Long getResult() {
|
||||
return this.result;
|
||||
}
|
||||
|
||||
public void setResult(Long result) {
|
||||
this.result = result;
|
||||
}
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
-- ----------------------------
|
||||
-- Table structure for RESOURCE - 资源
|
||||
-- Target : MySQL
|
||||
-- Author : wangbing
|
||||
-- Date: : 2019-12-27
|
||||
-- ----------------------------
|
||||
CREATE TABLE `SYS_RESOURCE` (
|
||||
`ID` BIGINT(20) NOT NULL COMMENT '主键',
|
||||
`CODE` VARCHAR(50) NOT NULL COMMENT '资源代码',
|
||||
`VALUE` VARCHAR(100) NOT NULL COMMENT '资源内容',
|
||||
`COMMENT` VARCHAR(250) COMMENT '资源描述',
|
||||
`RESOURCE_TYPE` VARCHAR(20) NOT NULL COMMENT '资源类型',
|
||||
`VALID` TINYINT(1) NOT NULL COMMENT '是否有效',
|
||||
`ROW_VERSION` BIGINT(20) NOT NULL DEFAULT 0 COMMENT '行版本',
|
||||
`IS_DELETED` TINYINT(1) NOT NULL DEFAULT 0 COMMENT '是否已删除',
|
||||
`CREATE_BY` BIGINT(20) NOT NULL COMMENT '创建用户',
|
||||
`CREATE_TIME` DATETIME NOT NULL COMMENT '创建时间',
|
||||
`LAST_UPDATE_BY` BIGINT(20) DEFAULT NULL COMMENT '最后更新用户',
|
||||
`LAST_UPDATE_TIME` DATETIME DEFAULT NULL COMMENT '最后更新时间',
|
||||
PRIMARY KEY (`ID`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='资源';
|
@ -0,0 +1,145 @@
|
||||
package ${basePackage}.system;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import ${basePackage}.frame.base.Token;
|
||||
import ${basePackage}.module.system.mgr.ResManager;
|
||||
import ${basePackage}.module.system.req.ResCreateRequest;
|
||||
import ${basePackage}.module.system.req.ResDeleteRequest;
|
||||
import ${basePackage}.module.system.req.ResFindRequest;
|
||||
import ${basePackage}.module.system.req.ResGetRequest;
|
||||
import ${basePackage}.module.system.req.ResUpdateRequest;
|
||||
import ${basePackage}.module.system.rsp.ResCreateResponse;
|
||||
import ${basePackage}.module.system.rsp.ResDeleteResponse;
|
||||
import ${basePackage}.module.system.rsp.ResFindResponse;
|
||||
import ${basePackage}.module.system.rsp.ResGetResponse;
|
||||
import ${basePackage}.module.system.rsp.ResUpdateResponse;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
/**
|
||||
* ResTest - - 资源测试用例
|
||||
*
|
||||
* @author wangbing
|
||||
* @version 0.0.1
|
||||
* @since 2020-01-05
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest
|
||||
@Transactional
|
||||
public class ResTest {
|
||||
|
||||
@Autowired
|
||||
private Token token;
|
||||
|
||||
@Autowired
|
||||
private ResManager resManager;
|
||||
|
||||
@Test
|
||||
public void testCreate() {
|
||||
ResCreateRequest request = new ResCreateRequest();
|
||||
request.setResCode("资源代码");
|
||||
request.setResName("资源名称");
|
||||
request.setResType("code");
|
||||
request.setResValue("资源内容");
|
||||
request.setValid(true);
|
||||
|
||||
ResCreateResponse response = resManager.create(request, token);
|
||||
|
||||
assertTrue(!response.hasError());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDelete() {
|
||||
|
||||
//创建数据
|
||||
ResCreateRequest createRequest = new ResCreateRequest();
|
||||
createRequest.setResCode("资源代码");
|
||||
createRequest.setResName("资源名称");
|
||||
createRequest.setResType("code");
|
||||
createRequest.setResValue("资源内容");
|
||||
createRequest.setValid(true);
|
||||
|
||||
ResCreateResponse createResponse = resManager.create(createRequest, token);
|
||||
|
||||
assertTrue(!createResponse.hasError() && createResponse.getId() > 0);
|
||||
//删除数据
|
||||
ResDeleteRequest request = new ResDeleteRequest();
|
||||
request.setId(createResponse.getId());
|
||||
|
||||
ResDeleteResponse response = resManager.delete(request, token);
|
||||
|
||||
assertTrue(!response.hasError() && response.getResult() == 1L);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdate() {
|
||||
//创建数据
|
||||
ResCreateRequest createRequest = new ResCreateRequest();
|
||||
createRequest.setResCode("资源代码");
|
||||
createRequest.setResName("资源名称");
|
||||
createRequest.setResType("code");
|
||||
createRequest.setResValue("资源内容");
|
||||
createRequest.setValid(true);
|
||||
|
||||
ResCreateResponse createResponse = resManager.create(createRequest, token);
|
||||
|
||||
assertTrue(!createResponse.hasError());
|
||||
|
||||
//更新数据
|
||||
ResUpdateRequest request = new ResUpdateRequest();
|
||||
request.setId(createResponse.getId());
|
||||
request.setResCode("资源代码");
|
||||
request.setResName("资源名称");
|
||||
request.setResType("code");
|
||||
request.setResValue("资源内容");
|
||||
request.setValid(true);
|
||||
|
||||
ResUpdateResponse response = resManager.update(request, token);
|
||||
|
||||
assertTrue(!response.hasError() && response.getResult() == 1L);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFind() {
|
||||
ResFindRequest request = new ResFindRequest();
|
||||
request.setResCode("资源代码");
|
||||
request.setResName("资源名称");
|
||||
request.setResType("code");
|
||||
request.setResValue("资源内容");
|
||||
request.setSupCode("上级代码");
|
||||
request.setSupName("上级名称");
|
||||
request.setValid(true);
|
||||
|
||||
ResFindResponse response = resManager.find(request, token);
|
||||
|
||||
assertTrue(!response.hasError());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGet() {
|
||||
//创建数据
|
||||
ResCreateRequest createRequest = new ResCreateRequest();
|
||||
createRequest.setResCode("资源代码");
|
||||
createRequest.setResName("资源名称");
|
||||
createRequest.setResType("code");
|
||||
createRequest.setResValue("资源内容");
|
||||
createRequest.setValid(true);
|
||||
|
||||
ResCreateResponse createResponse = resManager.create(createRequest, token);
|
||||
|
||||
assertTrue(!createResponse.hasError());
|
||||
|
||||
//获得数据
|
||||
ResGetRequest request = new ResGetRequest();
|
||||
request.setId(createResponse.getId());
|
||||
|
||||
ResGetResponse response = resManager.get(request, token);
|
||||
|
||||
assertTrue(!response.hasError() && response.getRes() != null);
|
||||
}
|
||||
}
|
@ -0,0 +1,137 @@
|
||||
package ${basePackage}.system;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import ${basePackage}.frame.base.Token;
|
||||
import ${basePackage}.module.system.mgr.RoleResManager;
|
||||
import ${basePackage}.module.system.req.RoleResCreateRequest;
|
||||
import ${basePackage}.module.system.req.RoleResDeleteRequest;
|
||||
import ${basePackage}.module.system.req.RoleResFindRequest;
|
||||
import ${basePackage}.module.system.req.RoleResGetRequest;
|
||||
import ${basePackage}.module.system.req.RoleResUpdateRequest;
|
||||
import ${basePackage}.module.system.rsp.RoleResCreateResponse;
|
||||
import ${basePackage}.module.system.rsp.RoleResDeleteResponse;
|
||||
import ${basePackage}.module.system.rsp.RoleResFindResponse;
|
||||
import ${basePackage}.module.system.rsp.RoleResGetResponse;
|
||||
import ${basePackage}.module.system.rsp.RoleResUpdateResponse;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
/**
|
||||
* RoleResTest - - 角色资源关系测试用例
|
||||
*
|
||||
* @author wangbing
|
||||
* @version 0.0.1
|
||||
* @since 2020-01-05
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest
|
||||
@Transactional
|
||||
public class RoleResTest {
|
||||
|
||||
@Autowired
|
||||
private Token token;
|
||||
|
||||
@Autowired
|
||||
private RoleResManager roleResManager;
|
||||
|
||||
@Test
|
||||
public void testCreate() {
|
||||
RoleResCreateRequest request = new RoleResCreateRequest();
|
||||
request.setRoleId(1L);
|
||||
request.setRoleCode("角色代码");
|
||||
request.setResId(1L);
|
||||
request.setResCode("资源代码");
|
||||
|
||||
RoleResCreateResponse response = roleResManager.create(request, token);
|
||||
|
||||
assertTrue(!response.hasError());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDelete() {
|
||||
|
||||
//创建数据
|
||||
RoleResCreateRequest createRequest = new RoleResCreateRequest();
|
||||
createRequest.setRoleId(1L);
|
||||
createRequest.setRoleCode("角色代码");
|
||||
createRequest.setResId(1L);
|
||||
createRequest.setResCode("资源代码");
|
||||
|
||||
RoleResCreateResponse createResponse = roleResManager.create(createRequest, token);
|
||||
|
||||
assertTrue(!createResponse.hasError() && createResponse.getId() > 0);
|
||||
//删除数据
|
||||
RoleResDeleteRequest request = new RoleResDeleteRequest();
|
||||
request.setId(createResponse.getId());
|
||||
|
||||
RoleResDeleteResponse response = roleResManager.delete(request, token);
|
||||
|
||||
assertTrue(!response.hasError() && response.getResult() == 1L);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdate() {
|
||||
//创建数据
|
||||
RoleResCreateRequest createRequest = new RoleResCreateRequest();
|
||||
createRequest.setRoleId(1L);
|
||||
createRequest.setRoleCode("角色代码");
|
||||
createRequest.setResId(1L);
|
||||
createRequest.setResCode("资源代码");
|
||||
|
||||
RoleResCreateResponse createResponse = roleResManager.create(createRequest, token);
|
||||
|
||||
assertTrue(!createResponse.hasError());
|
||||
|
||||
//更新数据
|
||||
RoleResUpdateRequest request = new RoleResUpdateRequest();
|
||||
request.setId(createResponse.getId());
|
||||
request.setRoleId(1L);
|
||||
request.setRoleCode("角色代码");
|
||||
request.setResId(1L);
|
||||
request.setResCode("资源代码");
|
||||
|
||||
RoleResUpdateResponse response = roleResManager.update(request, token);
|
||||
|
||||
assertTrue(!response.hasError() && response.getResult() == 1L);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFind() {
|
||||
RoleResFindRequest request = new RoleResFindRequest();
|
||||
request.setRoleId(1L);
|
||||
request.setRoleCode("角色代码");
|
||||
request.setResId(1L);
|
||||
request.setResCode("资源代码");
|
||||
|
||||
RoleResFindResponse response = roleResManager.find(request, token);
|
||||
|
||||
assertTrue(!response.hasError());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGet() {
|
||||
//创建数据
|
||||
RoleResCreateRequest createRequest = new RoleResCreateRequest();
|
||||
createRequest.setRoleId(1L);
|
||||
createRequest.setRoleCode("角色代码");
|
||||
createRequest.setResId(1L);
|
||||
createRequest.setResCode("资源代码");
|
||||
|
||||
RoleResCreateResponse createResponse = roleResManager.create(createRequest, token);
|
||||
|
||||
assertTrue(!createResponse.hasError());
|
||||
|
||||
//获得数据
|
||||
RoleResGetRequest request = new RoleResGetRequest();
|
||||
request.setId(createResponse.getId());
|
||||
|
||||
RoleResGetResponse response = roleResManager.get(request, token);
|
||||
|
||||
assertTrue(!response.hasError() && response.getRoleRes() != null);
|
||||
}
|
||||
}
|
Loading…
Reference in new issue