Former-commit-id: c87dd8780ad723fcb2e4e8ab540ea29f1d4d0dd2
master
wangbing 5 years ago
parent d41f1c42b7
commit 961531a459

@ -3,16 +3,16 @@ package ${basePackage}.action.ajax.system;
import com.fasterxml.jackson.core.TreeNode; import com.fasterxml.jackson.core.TreeNode;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import ${basePackage}.frame.excel.WSheet;
import ${basePackage}.frame.utils.LogUtil;
import ${basePackage}.frame.auth.LocalData; import ${basePackage}.frame.auth.LocalData;
import ${basePackage}.frame.base.BaseResponse;
import ${basePackage}.frame.base.ErrorType; 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.MapperUtil;
import ${basePackage}.frame.base.BaseResponse;
import ${basePackage}.frame.utils.ResponseUtil; import ${basePackage}.frame.utils.ResponseUtil;
import ${basePackage}.frame.utils.ValidationUtil; import ${basePackage}.frame.utils.ValidationUtil;
import ${basePackage}.frame.excel.exception.ReadErrorException;
import ${basePackage}.frame.excel.exception.TemplateNotMatchException;
import ${basePackage}.module.system.ent.Dict; import ${basePackage}.module.system.ent.Dict;
import ${basePackage}.module.system.mgr.DictManager; import ${basePackage}.module.system.mgr.DictManager;
import ${basePackage}.module.system.req.DictCreateRequest; import ${basePackage}.module.system.req.DictCreateRequest;
@ -60,7 +60,7 @@ public class DictAjax {
return dictManager.load(request, LocalData.getToken()); return dictManager.load(request, LocalData.getToken());
} }
public Object template(){ public Object template() {
return ResponseUtil.apply(new WSheet<>(Dict.class)); return ResponseUtil.apply(new WSheet<>(Dict.class));
} }

@ -3,16 +3,16 @@ package ${basePackage}.action.ajax.system;
import com.fasterxml.jackson.core.TreeNode; import com.fasterxml.jackson.core.TreeNode;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import ${basePackage}.frame.excel.WSheet;
import ${basePackage}.frame.utils.LogUtil;
import ${basePackage}.frame.auth.LocalData; import ${basePackage}.frame.auth.LocalData;
import ${basePackage}.frame.base.BaseResponse;
import ${basePackage}.frame.base.ErrorType; 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.MapperUtil;
import ${basePackage}.frame.base.BaseResponse;
import ${basePackage}.frame.utils.ResponseUtil; import ${basePackage}.frame.utils.ResponseUtil;
import ${basePackage}.frame.utils.ValidationUtil; import ${basePackage}.frame.utils.ValidationUtil;
import ${basePackage}.frame.excel.exception.ReadErrorException;
import ${basePackage}.frame.excel.exception.TemplateNotMatchException;
import ${basePackage}.module.system.ent.DictItem; import ${basePackage}.module.system.ent.DictItem;
import ${basePackage}.module.system.mgr.DictItemManager; import ${basePackage}.module.system.mgr.DictItemManager;
import ${basePackage}.module.system.req.DictItemCreateRequest; import ${basePackage}.module.system.req.DictItemCreateRequest;
@ -54,7 +54,7 @@ public class DictItemAjax {
return dictItemManager.get(request, LocalData.getToken()); return dictItemManager.get(request, LocalData.getToken());
} }
public Object template(){ public Object template() {
return ResponseUtil.apply(new WSheet<>(DictItem.class)); return ResponseUtil.apply(new WSheet<>(DictItem.class));
} }

@ -1,5 +1,12 @@
package ${basePackage}.action.ajax.system; package ${basePackage}.action.ajax.system;
import com.fasterxml.jackson.core.TreeNode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.multipart.MultipartFile;
import ${basePackage}.frame.auth.LocalData; import ${basePackage}.frame.auth.LocalData;
import ${basePackage}.frame.base.BaseResponse; import ${basePackage}.frame.base.BaseResponse;
import ${basePackage}.frame.base.ErrorType; import ${basePackage}.frame.base.ErrorType;
@ -21,13 +28,6 @@ import ${basePackage}.module.system.rsp.FileDeleteResponse;
import ${basePackage}.module.system.rsp.FileFindResponse; import ${basePackage}.module.system.rsp.FileFindResponse;
import ${basePackage}.module.system.rsp.FileGetResponse; import ${basePackage}.module.system.rsp.FileGetResponse;
import ${basePackage}.module.system.rsp.FileUploadResponse; import ${basePackage}.module.system.rsp.FileUploadResponse;
import com.fasterxml.jackson.core.TreeNode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.multipart.MultipartFile;
import java.io.IOException; import java.io.IOException;
import java.net.URLEncoder; import java.net.URLEncoder;
@ -54,7 +54,7 @@ public class FileAjax {
return fileManager.get(request, LocalData.getToken()); return fileManager.get(request, LocalData.getToken());
} }
public Object template(){ public Object template() {
return ResponseUtil.apply(new WSheet<>(File.class)); return ResponseUtil.apply(new WSheet<>(File.class));
} }

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

@ -3,16 +3,16 @@ package ${basePackage}.action.ajax.system;
import com.fasterxml.jackson.core.TreeNode; import com.fasterxml.jackson.core.TreeNode;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import ${basePackage}.frame.excel.WSheet;
import ${basePackage}.frame.utils.LogUtil;
import ${basePackage}.frame.auth.LocalData; import ${basePackage}.frame.auth.LocalData;
import ${basePackage}.frame.base.BaseResponse;
import ${basePackage}.frame.base.ErrorType; 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.MapperUtil;
import ${basePackage}.frame.base.BaseResponse;
import ${basePackage}.frame.utils.ResponseUtil; import ${basePackage}.frame.utils.ResponseUtil;
import ${basePackage}.frame.utils.ValidationUtil; import ${basePackage}.frame.utils.ValidationUtil;
import ${basePackage}.frame.excel.exception.ReadErrorException;
import ${basePackage}.frame.excel.exception.TemplateNotMatchException;
import ${basePackage}.module.system.ent.Role; import ${basePackage}.module.system.ent.Role;
import ${basePackage}.module.system.mgr.RoleManager; import ${basePackage}.module.system.mgr.RoleManager;
import ${basePackage}.module.system.req.RoleCreateRequest; import ${basePackage}.module.system.req.RoleCreateRequest;
@ -29,7 +29,7 @@ import ${basePackage}.module.system.rsp.RoleUpdateResponse;
import java.io.IOException; import java.io.IOException;
import java.util.List; import java.util.List;
public class RoleAjax{ public class RoleAjax {
@Autowired @Autowired
private RoleManager roleManager; private RoleManager roleManager;
@ -54,7 +54,7 @@ public class RoleAjax{
return roleManager.get(request, LocalData.getToken()); return roleManager.get(request, LocalData.getToken());
} }
public Object template(){ public Object template() {
return ResponseUtil.apply(new WSheet<>(Role.class)); return ResponseUtil.apply(new WSheet<>(Role.class));
} }

@ -1,27 +1,22 @@
package ${basePackage}.action.ajax.system; package ${basePackage}.action.ajax.system;
import com.fasterxml.jackson.core.TreeNode;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.multipart.MultipartFile;
import ${basePackage}.frame.excel.WSheet;
import ${basePackage}.frame.utils.LogUtil;
import ${basePackage}.frame.auth.LocalData; import ${basePackage}.frame.auth.LocalData;
import ${basePackage}.frame.base.ErrorType;
import ${basePackage}.frame.utils.MapperUtil;
import ${basePackage}.frame.base.BaseResponse;
import ${basePackage}.frame.utils.ResponseUtil;
import ${basePackage}.frame.utils.ValidationUtil;
import ${basePackage}.frame.excel.exception.ReadErrorException;
import ${basePackage}.frame.excel.exception.TemplateNotMatchException;
import ${basePackage}.module.system.ent.RoleRes;
import ${basePackage}.module.system.mgr.RoleResManager; import ${basePackage}.module.system.mgr.RoleResManager;
import ${basePackage}.module.system.req.*; import ${basePackage}.module.system.req.RoleResCheckRequest;
import ${basePackage}.module.system.rsp.*; import ${basePackage}.module.system.req.RoleResCreateRequest;
import ${basePackage}.module.system.req.RoleResDeleteRequest;
import java.io.IOException; import ${basePackage}.module.system.req.RoleResFindRequest;
import java.util.List; import ${basePackage}.module.system.req.RoleResGetRequest;
import ${basePackage}.module.system.req.RoleResUpdateRequest;
public class RoleResAjax{ import ${basePackage}.module.system.rsp.RoleResCheckResponse;
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 RoleResAjax {
@Autowired @Autowired
private RoleResManager roleResManager; private RoleResManager roleResManager;
@ -45,4 +40,8 @@ public class RoleResAjax{
public RoleResGetResponse get(RoleResGetRequest request) { public RoleResGetResponse get(RoleResGetRequest request) {
return roleResManager.get(request, LocalData.getToken()); return roleResManager.get(request, LocalData.getToken());
} }
public RoleResCheckResponse check(RoleResCheckRequest request) {
return roleResManager.check(request, LocalData.getToken());
}
} }

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

@ -3,16 +3,16 @@ package ${basePackage}.action.ajax.system;
import com.fasterxml.jackson.core.TreeNode; import com.fasterxml.jackson.core.TreeNode;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import ${basePackage}.frame.excel.WSheet;
import ${basePackage}.frame.utils.LogUtil;
import ${basePackage}.frame.auth.LocalData; import ${basePackage}.frame.auth.LocalData;
import ${basePackage}.frame.base.BaseResponse;
import ${basePackage}.frame.base.ErrorType; 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.MapperUtil;
import ${basePackage}.frame.base.BaseResponse;
import ${basePackage}.frame.utils.ResponseUtil; import ${basePackage}.frame.utils.ResponseUtil;
import ${basePackage}.frame.utils.ValidationUtil; import ${basePackage}.frame.utils.ValidationUtil;
import ${basePackage}.frame.excel.exception.ReadErrorException;
import ${basePackage}.frame.excel.exception.TemplateNotMatchException;
import ${basePackage}.module.system.ent.Tokens; import ${basePackage}.module.system.ent.Tokens;
import ${basePackage}.module.system.mgr.TokensManager; import ${basePackage}.module.system.mgr.TokensManager;
import ${basePackage}.module.system.req.TokensCreateRequest; import ${basePackage}.module.system.req.TokensCreateRequest;
@ -31,7 +31,7 @@ import ${basePackage}.module.system.rsp.TokensUpdateResponse;
import java.io.IOException; import java.io.IOException;
import java.util.List; import java.util.List;
public class TokensAjax{ public class TokensAjax {
@Autowired @Autowired
private TokensManager tokensManager; private TokensManager tokensManager;
@ -60,7 +60,7 @@ public class TokensAjax{
return tokensManager.logout(request, LocalData.getToken()); return tokensManager.logout(request, LocalData.getToken());
} }
public Object template(){ public Object template() {
return ResponseUtil.apply(new WSheet<>(Tokens.class)); return ResponseUtil.apply(new WSheet<>(Tokens.class));
} }

@ -44,7 +44,7 @@ import java.util.Date;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
public class UserAjax{ public class UserAjax {
@Value("${r'${web.url.auth.admin}'}") @Value("${r'${web.url.auth.admin}'}")
private String admin; private String admin;
@ -174,7 +174,7 @@ public class UserAjax{
return response; return response;
} }
public Object template(){ public Object template() {
return ResponseUtil.apply(new WSheet<>(User.class)); return ResponseUtil.apply(new WSheet<>(User.class));
} }

@ -14,10 +14,7 @@ import ${basePackage}.module.system.rsp.UserRoleFindResponse;
import ${basePackage}.module.system.rsp.UserRoleGetResponse; import ${basePackage}.module.system.rsp.UserRoleGetResponse;
import ${basePackage}.module.system.rsp.UserRoleUpdateResponse; import ${basePackage}.module.system.rsp.UserRoleUpdateResponse;
import java.io.IOException; public class UserRoleAjax {
import java.util.List;
public class UserRoleAjax{
@Autowired @Autowired
private UserRoleManager userRoleManager; private UserRoleManager userRoleManager;

@ -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,16 +1,18 @@
package ${basePackage}.module.system.mgr; package ${basePackage}.module.system.mgr;
import ${basePackage}.frame.base.Token;
import ${basePackage}.module.system.req.RoleResCheckRequest;
import ${basePackage}.module.system.req.RoleResCreateRequest; import ${basePackage}.module.system.req.RoleResCreateRequest;
import ${basePackage}.module.system.req.RoleResDeleteRequest; import ${basePackage}.module.system.req.RoleResDeleteRequest;
import ${basePackage}.module.system.req.RoleResFindRequest; import ${basePackage}.module.system.req.RoleResFindRequest;
import ${basePackage}.module.system.req.RoleResGetRequest; import ${basePackage}.module.system.req.RoleResGetRequest;
import ${basePackage}.module.system.req.RoleResUpdateRequest; import ${basePackage}.module.system.req.RoleResUpdateRequest;
import ${basePackage}.module.system.rsp.RoleResCheckResponse;
import ${basePackage}.module.system.rsp.RoleResCreateResponse; import ${basePackage}.module.system.rsp.RoleResCreateResponse;
import ${basePackage}.module.system.rsp.RoleResDeleteResponse; import ${basePackage}.module.system.rsp.RoleResDeleteResponse;
import ${basePackage}.module.system.rsp.RoleResFindResponse; import ${basePackage}.module.system.rsp.RoleResFindResponse;
import ${basePackage}.module.system.rsp.RoleResGetResponse; import ${basePackage}.module.system.rsp.RoleResGetResponse;
import ${basePackage}.module.system.rsp.RoleResUpdateResponse; import ${basePackage}.module.system.rsp.RoleResUpdateResponse;
import ${basePackage}.frame.base.Token;
/** /**
* *
@ -65,4 +67,13 @@ public interface RoleResManager {
* @return * @return
*/ */
RoleResGetResponse get(RoleResGetRequest request, Token token); RoleResGetResponse get(RoleResGetRequest request, Token token);
/**
*
*
* @param request
* @param token
* @return
*/
RoleResCheckResponse check(RoleResCheckRequest request, Token token);
} }

@ -1,29 +1,32 @@
package ${basePackage}.module.system.mgr; package ${basePackage}.module.system.mgr;
import ${basePackage}.frame.utils.IDgenerator; import com.github.pagehelper.PageHelper;
import ${basePackage}.frame.utils.Message; 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.ErrorType;
import ${basePackage}.frame.base.Token; import ${basePackage}.frame.base.Token;
import ${basePackage}.frame.utils.IDgenerator;
import ${basePackage}.frame.utils.MapperUtil; import ${basePackage}.frame.utils.MapperUtil;
import ${basePackage}.frame.utils.Message;
import ${basePackage}.frame.utils.ValidationUtil; import ${basePackage}.frame.utils.ValidationUtil;
import ${basePackage}.module.system.ent.RoleRes; import ${basePackage}.module.system.ent.RoleRes;
import ${basePackage}.module.system.mpr.RoleResMapper; import ${basePackage}.module.system.mpr.RoleResMapper;
import ${basePackage}.module.system.req.RoleResCheckRequest;
import ${basePackage}.module.system.req.RoleResCreateRequest; import ${basePackage}.module.system.req.RoleResCreateRequest;
import ${basePackage}.module.system.req.RoleResDeleteRequest; import ${basePackage}.module.system.req.RoleResDeleteRequest;
import ${basePackage}.module.system.req.RoleResFindRequest; import ${basePackage}.module.system.req.RoleResFindRequest;
import ${basePackage}.module.system.req.RoleResGetRequest; import ${basePackage}.module.system.req.RoleResGetRequest;
import ${basePackage}.module.system.req.RoleResUpdateRequest; import ${basePackage}.module.system.req.RoleResUpdateRequest;
import ${basePackage}.module.system.rsp.RoleResCheckResponse;
import ${basePackage}.module.system.rsp.RoleResCreateResponse; import ${basePackage}.module.system.rsp.RoleResCreateResponse;
import ${basePackage}.module.system.rsp.RoleResDeleteResponse; import ${basePackage}.module.system.rsp.RoleResDeleteResponse;
import ${basePackage}.module.system.rsp.RoleResFindResponse; import ${basePackage}.module.system.rsp.RoleResFindResponse;
import ${basePackage}.module.system.rsp.RoleResGetResponse; import ${basePackage}.module.system.rsp.RoleResGetResponse;
import ${basePackage}.module.system.rsp.RoleResUpdateResponse; import ${basePackage}.module.system.rsp.RoleResUpdateResponse;
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;
/** /**
* ROLE_RES - * ROLE_RES -
@ -172,4 +175,53 @@ public class RoleResManagerImpl implements RoleResManager {
return response; return response;
} }
/**
*
*
* @param request
* @param token
* @return
*/
public RoleResCheckResponse check(RoleResCheckRequest request, Token token) {
RoleResCheckResponse response = new RoleResCheckResponse();
ValidationUtil.validate(request, response);
if (response.hasError()) {
return response;
}
RoleResFindRequest roleResFindRequest = new RoleResFindRequest();
roleResFindRequest.setRoleId(request.getRoleId());
roleResFindRequest.setResId(request.getResId());
RoleResFindResponse roleResFindResponse = this.find(roleResFindRequest, token);
if (roleResFindResponse.hasError()) {
response.addErrors(roleResFindResponse.getErrors());
return response;
}
if (request.getChecked() && roleResFindResponse.getResult().size() == 0) {
RoleResCreateRequest roleResCreateRequest = new RoleResCreateRequest();
roleResCreateRequest.setRoleId(request.getRoleId());
roleResCreateRequest.setResId(request.getResId());
RoleResCreateResponse roleResCreateResponse = this.create(roleResCreateRequest, token);
if (roleResCreateResponse.hasError()) {
response.addErrors(roleResCreateResponse.getErrors());
return response;
}
} else if (!request.getChecked() && roleResFindResponse.getResult().size() > 0) {
for (RoleRes roleRes : roleResFindResponse.getResult()) {
RoleResDeleteRequest roleResDeleteRequest = new RoleResDeleteRequest();
roleResDeleteRequest.setId(roleRes.getId());
RoleResDeleteResponse roleResDeleteResponse = this.delete(roleResDeleteRequest, token);
if (roleResDeleteResponse.hasError()) {
response.addErrors(roleResDeleteResponse.getErrors());
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
return response;
}
}
}
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);
}

@ -25,7 +25,8 @@ public class ResCreateRequest extends BaseRequest {
/** /**
* *
*/ */
@Length(min = 0, max = 255, message = "[resName]资源名称长度不合法(0-255)") @NotEmpty(message = "[resName]资源名称不能为空")
@Length(min = 0, max = 50, message = "[resName]资源名称长度不合法(0-50)")
private String resName; private String resName;
/** /**
@ -38,7 +39,7 @@ public class ResCreateRequest extends BaseRequest {
/** /**
* *
*/ */
@Length(min = 0, max = 100, message = "[resValue]资源内容长度不合法(0-100)") @Length(min = 0, max = 255, message = "[resValue]资源内容长度不合法(0-255)")
private String resValue; private String resValue;
/** /**

@ -31,7 +31,8 @@ public class ResUpdateRequest extends BaseUpdateRequest {
/** /**
* *
*/ */
@Length(min = 0, max = 255, message = "[resName]资源名称长度不合法(0-255)") @NotEmpty(message = "[resName]资源名称不能为空")
@Length(min = 0, max = 50, message = "[resName]资源名称长度不合法(0-50)")
private String resName; private String resName;
/** /**
@ -44,22 +45,9 @@ public class ResUpdateRequest extends BaseUpdateRequest {
/** /**
* *
*/ */
@NotEmpty(message = "[resValue]资源内容不能为空") @Length(min = 0, max = 255, message = "[resValue]资源内容长度不合法(0-255)")
@Length(min = 0, max = 100, message = "[resValue]资源内容长度不合法(0-100)")
private String resValue; private String resValue;
/**
*
*/
@Length(min = 0, max = 50, message = "[supCode]上级代码长度不合法(0-50)")
private String supCode;
/**
*
*/
@Length(min = 0, max = 50, message = "[supName]上级名称长度不合法(0-50)")
private String supName;
/** /**
* *
*/ */
@ -106,22 +94,6 @@ public class ResUpdateRequest extends BaseUpdateRequest {
this.resValue = resValue; this.resValue = resValue;
} }
public String getSupCode() {
return this.supCode;
}
public void setSupCode(String supCode) {
this.supCode = supCode;
}
public String getSupName() {
return this.supName;
}
public void setSupName(String supName) {
this.supName = supName;
}
public Boolean getValid() { public Boolean getValid() {
return this.valid; return this.valid;
} }
@ -130,3 +102,4 @@ public class ResUpdateRequest extends BaseUpdateRequest {
this.valid = valid; this.valid = valid;
} }
} }

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

@ -9,7 +9,7 @@ import ${basePackage}.frame.base.BaseResponse;
* @version 0.0.1 * @version 0.0.1
* @since 2017-01-01 * @since 2017-01-01
*/ */
public class RoleResourceCheckResponse extends BaseResponse { public class RoleResCheckResponse extends BaseResponse {
/** /**
* ID * ID

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

@ -48,20 +48,20 @@ PRIMARY KEY (`ID`)
-- Date: : 2020-01-05 -- Date: : 2020-01-05
-- ---------------------------- -- ----------------------------
CREATE TABLE `SYS_RES` ( CREATE TABLE `SYS_RES` (
`ID` BIGINT(20) NOT NULL COMMENT '主键', `ID` BIGINT(20) NOT NULL COMMENT '主键',
`RES_CODE` VARCHAR(50) NOT NULL COMMENT '资源代码', `RES_CODE` VARCHAR(50) NOT NULL COMMENT '资源代码',
`RES_NAME` VARCHAR(250) COMMENT '资源名称', `RES_NAME` VARCHAR(50) NOT NULL COMMENT '资源名称',
`RES_TYPE` VARCHAR(20) NOT NULL COMMENT '资源类型', `RES_TYPE` VARCHAR(20) NOT NULL COMMENT '资源类型',
`RES_VALUE` VARCHAR(100) NOT NULL COMMENT '资源内容', `RES_VALUE` VARCHAR(250) COMMENT '资源内容',
`SUP_CODE` VARCHAR(50) COMMENT '上级代码', `SUP_CODE` VARCHAR(50) COMMENT '上级代码',
`SUP_NAME` VARCHAR(50) COMMENT '上级名称', `SUP_NAME` VARCHAR(50) COMMENT '上级名称',
`VALID` TINYINT(1) NOT NULL COMMENT '是否有效', `VALID` TINYINT(1) NOT NULL COMMENT '是否有效',
`ROW_VERSION` BIGINT(20) NOT NULL DEFAULT 0 COMMENT '行版本', `ROW_VERSION` BIGINT(20) NOT NULL DEFAULT 0 COMMENT '行版本',
`IS_DELETED` TINYINT(1) NOT NULL DEFAULT 0 COMMENT '是否已删除', `IS_DELETED` TINYINT(1) NOT NULL DEFAULT 0 COMMENT '是否已删除',
`CREATE_BY` BIGINT(20) NOT NULL COMMENT '创建用户', `CREATE_BY` BIGINT(20) NOT NULL COMMENT '创建用户',
`CREATE_TIME` DATETIME NOT NULL COMMENT '创建时间', `CREATE_TIME` DATETIME NOT NULL COMMENT '创建时间',
`LAST_UPDATE_BY` BIGINT(20) DEFAULT NULL COMMENT '最后更新用户', `LAST_UPDATE_BY` BIGINT(20) DEFAULT NULL COMMENT '最后更新用户',
`LAST_UPDATE_TIME` DATETIME DEFAULT NULL COMMENT '最后更新时间', `LAST_UPDATE_TIME` DATETIME DEFAULT NULL COMMENT '最后更新时间',
PRIMARY KEY (`ID`) PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='资源'; ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='资源';

@ -7,9 +7,9 @@
CREATE TABLE `SYS_RES` ( CREATE TABLE `SYS_RES` (
`ID` BIGINT(20) NOT NULL COMMENT '主键', `ID` BIGINT(20) NOT NULL COMMENT '主键',
`RES_CODE` VARCHAR(50) NOT NULL COMMENT '资源代码', `RES_CODE` VARCHAR(50) NOT NULL COMMENT '资源代码',
`RES_NAME` VARCHAR(250) COMMENT '资源名称', `RES_NAME` VARCHAR(50) NOT NULL COMMENT '资源名称',
`RES_TYPE` VARCHAR(20) NOT NULL COMMENT '资源类型', `RES_TYPE` VARCHAR(20) NOT NULL COMMENT '资源类型',
`RES_VALUE` VARCHAR(100) NOT NULL COMMENT '资源内容', `RES_VALUE` VARCHAR(250) COMMENT '资源内容',
`SUP_CODE` VARCHAR(50) COMMENT '上级代码', `SUP_CODE` VARCHAR(50) COMMENT '上级代码',
`SUP_NAME` VARCHAR(50) COMMENT '上级名称', `SUP_NAME` VARCHAR(50) COMMENT '上级名称',
`VALID` TINYINT(1) NOT NULL COMMENT '是否有效', `VALID` TINYINT(1) NOT NULL COMMENT '是否有效',

@ -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='资源';

@ -47,9 +47,9 @@
<fields> <fields>
<field IsSystem="true" defaultValue="" fieldComment="主键" fieldLength="0" fieldName="ID" fieldType="Long" isMust="true" isPrimaryKey="true" isQuery="false" isSearch="false"/> <field IsSystem="true" defaultValue="" fieldComment="主键" fieldLength="0" fieldName="ID" fieldType="Long" isMust="true" isPrimaryKey="true" isQuery="false" isSearch="false"/>
<field IsSystem="false" defaultValue="NULL" fieldComment="资源代码" fieldLength="50" fieldName="RES_CODE" fieldType="String_var50" isMust="true" isPrimaryKey="false" isQuery="true" isSearch="false"/> <field IsSystem="false" defaultValue="NULL" fieldComment="资源代码" fieldLength="50" fieldName="RES_CODE" fieldType="String_var50" isMust="true" isPrimaryKey="false" isQuery="true" isSearch="false"/>
<field IsSystem="false" defaultValue="NULL" fieldComment="资源名称" fieldLength="255" fieldName="RES_NAME" fieldType="String_var255" isMust="false" isPrimaryKey="false" isQuery="true" isSearch="false"/> <field IsSystem="false" defaultValue="NULL" fieldComment="资源名称" fieldLength="50" fieldName="RES_NAME" fieldType="String_var50" isMust="true" isPrimaryKey="false" isQuery="true" isSearch="false"/>
<field IsSystem="false" defaultValue="NULL" fieldComment="资源类型" fieldLength="20" fieldName="RES_TYPE" fieldType="Dict" isMust="true" isPrimaryKey="false" isQuery="true" isSearch="false"/> <field IsSystem="false" defaultValue="NULL" fieldComment="资源类型" fieldLength="20" fieldName="RES_TYPE" fieldType="Dict" isMust="true" isPrimaryKey="false" isQuery="true" isSearch="false"/>
<field IsSystem="false" defaultValue="NULL" fieldComment="资源内容" fieldLength="100" fieldName="RES_VALUE" fieldType="String_var100" isMust="true" isPrimaryKey="false" isQuery="true" isSearch="false"/> <field IsSystem="false" defaultValue="NULL" fieldComment="资源内容" fieldLength="255" fieldName="RES_VALUE" fieldType="String_var255" isMust="false" isPrimaryKey="false" isQuery="true" isSearch="false"/>
<field IsSystem="false" defaultValue="NULL" fieldComment="上级代码" fieldLength="50" fieldName="SUP_CODE" fieldType="String_var50" isMust="false" isPrimaryKey="false" isQuery="true" isSearch="false"/> <field IsSystem="false" defaultValue="NULL" fieldComment="上级代码" fieldLength="50" fieldName="SUP_CODE" fieldType="String_var50" isMust="false" isPrimaryKey="false" isQuery="true" isSearch="false"/>
<field IsSystem="false" defaultValue="NULL" fieldComment="上级名称" fieldLength="50" fieldName="SUP_NAME" fieldType="String_var50" isMust="false" isPrimaryKey="false" isQuery="true" isSearch="false"/> <field IsSystem="false" defaultValue="NULL" fieldComment="上级名称" fieldLength="50" fieldName="SUP_NAME" fieldType="String_var50" isMust="false" isPrimaryKey="false" isQuery="true" isSearch="false"/>
<field IsSystem="false" defaultValue="NULL" fieldComment="是否有效" fieldLength="0" fieldName="VALID" fieldType="Boolean" isMust="true" isPrimaryKey="false" isQuery="true" isSearch="false"/> <field IsSystem="false" defaultValue="NULL" fieldComment="是否有效" fieldLength="0" fieldName="VALID" fieldType="Boolean" isMust="true" isPrimaryKey="false" isQuery="true" isSearch="false"/>

@ -276,7 +276,7 @@
], ],
resName: [ resName: [
{required: true, message: '资源名称不能为空', trigger: 'blur'}, {required: true, message: '资源名称不能为空', trigger: 'blur'},
{min: 1, max: 100, message: '资源名称长度在 1 到 100 个字符', trigger: 'blur'} {min: 1, max: 50, message: '资源名称长度在 1 到 50 个字符', trigger: 'blur'}
], ],
resType: [ resType: [
{required: true, message: '资源类型不能为空', trigger: 'blur'}, {required: true, message: '资源类型不能为空', trigger: 'blur'},

@ -9,12 +9,19 @@ import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import ${basePackage}.frame.base.Token; import ${basePackage}.frame.base.Token;
import ${basePackage}.module.system.mgr.DeptManager; import ${basePackage}.module.system.mgr.DeptManager;
import ${basePackage}.module.system.req.*; import ${basePackage}.module.system.req.DeptCreateRequest;
import ${basePackage}.module.system.rsp.*; import ${basePackage}.module.system.req.DeptDeleteRequest;
import ${basePackage}.module.system.req.DeptFindRequest;
import ${basePackage}.module.system.req.DeptGetRequest;
import ${basePackage}.module.system.req.DeptUpdateRequest;
import ${basePackage}.module.system.rsp.DeptCreateResponse;
import ${basePackage}.module.system.rsp.DeptDeleteResponse;
import ${basePackage}.module.system.rsp.DeptFindResponse;
import ${basePackage}.module.system.rsp.DeptGetResponse;
import ${basePackage}.module.system.rsp.DeptUpdateResponse;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
/** /**
* DeptTest - - * DeptTest - -
* *
@ -42,7 +49,7 @@ public class DeptTest {
request.setDeptName("开发部"); request.setDeptName("开发部");
request.setDeptAlias("开发部"); request.setDeptAlias("开发部");
request.setValid(true); request.setValid(true);
DeptCreateResponse response = deptManager.create(request,token); DeptCreateResponse response = deptManager.create(request, token);
assertTrue(!response.hasError()); assertTrue(!response.hasError());
} }
{ {
@ -51,7 +58,7 @@ public class DeptTest {
request.setDeptName("开发部开发一组"); request.setDeptName("开发部开发一组");
request.setDeptAlias("开发一组"); request.setDeptAlias("开发一组");
request.setValid(true); request.setValid(true);
DeptCreateResponse response = deptManager.create(request,token); DeptCreateResponse response = deptManager.create(request, token);
assertTrue(!response.hasError()); assertTrue(!response.hasError());
} }
} }
@ -66,14 +73,14 @@ public class DeptTest {
createRequest.setDeptAlias("开发部"); createRequest.setDeptAlias("开发部");
createRequest.setValid(true); createRequest.setValid(true);
DeptCreateResponse createResponse = deptManager.create(createRequest,token); DeptCreateResponse createResponse = deptManager.create(createRequest, token);
assertTrue(!createResponse.hasError() && createResponse.getId() > 0); assertTrue(!createResponse.hasError() && createResponse.getId() > 0);
//删除数据 //删除数据
DeptDeleteRequest request = new DeptDeleteRequest(); DeptDeleteRequest request = new DeptDeleteRequest();
request.setId(createResponse.getId()); request.setId(createResponse.getId());
DeptDeleteResponse response = deptManager.delete(request,token); DeptDeleteResponse response = deptManager.delete(request, token);
assertTrue(!response.hasError() && response.getResult() == 1L); assertTrue(!response.hasError() && response.getResult() == 1L);
} }
@ -99,7 +106,7 @@ public class DeptTest {
request.setDeptAlias("开发部"); request.setDeptAlias("开发部");
request.setValid(true); request.setValid(true);
DeptUpdateResponse response = deptManager.update(request,token); DeptUpdateResponse response = deptManager.update(request, token);
assertTrue(!response.hasError() && response.getResult() == 1L); assertTrue(!response.hasError() && response.getResult() == 1L);
} }
@ -112,7 +119,7 @@ public class DeptTest {
request.setDeptAlias("开发部"); request.setDeptAlias("开发部");
request.setValid(true); request.setValid(true);
DeptFindResponse response = deptManager.find(request,token); DeptFindResponse response = deptManager.find(request, token);
assertTrue(!response.hasError()); assertTrue(!response.hasError());
} }
@ -134,7 +141,7 @@ public class DeptTest {
DeptGetRequest request = new DeptGetRequest(); DeptGetRequest request = new DeptGetRequest();
request.setId(createResponse.getId()); request.setId(createResponse.getId());
DeptGetResponse response = deptManager.get(request,token); DeptGetResponse response = deptManager.get(request, token);
assertTrue(!response.hasError() && response.getDept() != null); assertTrue(!response.hasError() && response.getDept() != null);
} }

@ -21,7 +21,6 @@ import ${basePackage}.module.system.rsp.DictItemUpdateResponse;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
/** /**
* DictItemTest - - * DictItemTest - -
* *
@ -49,7 +48,7 @@ public class DictItemTest {
request.setSort(1); request.setSort(1);
request.setValid(true); request.setValid(true);
DictItemCreateResponse response = dictItemManager.create(request,token); DictItemCreateResponse response = dictItemManager.create(request, token);
assertTrue(!response.hasError()); assertTrue(!response.hasError());
} }
@ -65,14 +64,14 @@ public class DictItemTest {
createRequest.setSort(1); createRequest.setSort(1);
createRequest.setValid(true); createRequest.setValid(true);
DictItemCreateResponse createResponse = dictItemManager.create(createRequest,token); DictItemCreateResponse createResponse = dictItemManager.create(createRequest, token);
assertTrue(!createResponse.hasError() && createResponse.getId() > 0); assertTrue(!createResponse.hasError() && createResponse.getId() > 0);
//删除数据 //删除数据
DictItemDeleteRequest request = new DictItemDeleteRequest(); DictItemDeleteRequest request = new DictItemDeleteRequest();
request.setId(createResponse.getId()); request.setId(createResponse.getId());
DictItemDeleteResponse response = dictItemManager.delete(request,token); DictItemDeleteResponse response = dictItemManager.delete(request, token);
assertTrue(!response.hasError() && response.getResult() == 1L); assertTrue(!response.hasError() && response.getResult() == 1L);
} }
@ -97,7 +96,7 @@ public class DictItemTest {
request.setSort(1); request.setSort(1);
request.setValid(true); request.setValid(true);
DictItemUpdateResponse response = dictItemManager.update(request,token); DictItemUpdateResponse response = dictItemManager.update(request, token);
assertTrue(!response.hasError() && response.getResult() == 1L); assertTrue(!response.hasError() && response.getResult() == 1L);
} }
@ -111,7 +110,7 @@ public class DictItemTest {
request.setSort(1); request.setSort(1);
request.setValid(true); request.setValid(true);
DictItemFindResponse response = dictItemManager.find(request,token); DictItemFindResponse response = dictItemManager.find(request, token);
assertTrue(!response.hasError()); assertTrue(!response.hasError());
} }
@ -132,7 +131,7 @@ public class DictItemTest {
DictItemGetRequest request = new DictItemGetRequest(); DictItemGetRequest request = new DictItemGetRequest();
request.setId(createResponse.getId()); request.setId(createResponse.getId());
DictItemGetResponse response = dictItemManager.get(request,token); DictItemGetResponse response = dictItemManager.get(request, token);
assertTrue(!response.hasError() && response.getDictItem() != null); assertTrue(!response.hasError() && response.getDictItem() != null);
} }

@ -26,7 +26,6 @@ import ${basePackage}.module.system.rsp.DictUpdateResponse;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
/** /**
* DictTest - - * DictTest - -
* *

@ -19,7 +19,6 @@ import ${basePackage}.module.system.rsp.FileGetResponse;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
/** /**
* FileTest - - * FileTest - -
* *

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

@ -8,12 +8,19 @@ import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import ${basePackage}.frame.base.Token; import ${basePackage}.frame.base.Token;
import ${basePackage}.module.system.mgr.RoleManager; import ${basePackage}.module.system.mgr.RoleManager;
import ${basePackage}.module.system.req.*; import ${basePackage}.module.system.req.RoleCreateRequest;
import ${basePackage}.module.system.rsp.*; import ${basePackage}.module.system.req.RoleDeleteRequest;
import ${basePackage}.module.system.req.RoleFindRequest;
import ${basePackage}.module.system.req.RoleGetRequest;
import ${basePackage}.module.system.req.RoleUpdateRequest;
import ${basePackage}.module.system.rsp.RoleCreateResponse;
import ${basePackage}.module.system.rsp.RoleDeleteResponse;
import ${basePackage}.module.system.rsp.RoleFindResponse;
import ${basePackage}.module.system.rsp.RoleGetResponse;
import ${basePackage}.module.system.rsp.RoleUpdateResponse;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
/** /**
* RoleTest - - * RoleTest - -
* *
@ -39,7 +46,7 @@ public class RoleTest {
request.setName("角色名称"); request.setName("角色名称");
request.setComment("角色描述"); request.setComment("角色描述");
RoleCreateResponse response = roleManager.create(request,token); RoleCreateResponse response = roleManager.create(request, token);
assertTrue(!response.hasError()); assertTrue(!response.hasError());
} }
@ -53,14 +60,14 @@ public class RoleTest {
createRequest.setName("角色名称"); createRequest.setName("角色名称");
createRequest.setComment("角色描述"); createRequest.setComment("角色描述");
RoleCreateResponse createResponse = roleManager.create(createRequest,token); RoleCreateResponse createResponse = roleManager.create(createRequest, token);
assertTrue(!createResponse.hasError() && createResponse.getId() > 0); assertTrue(!createResponse.hasError() && createResponse.getId() > 0);
//删除数据 //删除数据
RoleDeleteRequest request = new RoleDeleteRequest(); RoleDeleteRequest request = new RoleDeleteRequest();
request.setId(createResponse.getId()); request.setId(createResponse.getId());
RoleDeleteResponse response = roleManager.delete(request,token); RoleDeleteResponse response = roleManager.delete(request, token);
assertTrue(!response.hasError() && response.getResult() == 1L); assertTrue(!response.hasError() && response.getResult() == 1L);
} }
@ -84,7 +91,7 @@ public class RoleTest {
request.setName("角色名称"); request.setName("角色名称");
request.setComment("角色描述"); request.setComment("角色描述");
RoleUpdateResponse response = roleManager.update(request,token); RoleUpdateResponse response = roleManager.update(request, token);
assertTrue(!response.hasError() && response.getResult() == 1L); assertTrue(!response.hasError() && response.getResult() == 1L);
} }
@ -96,7 +103,7 @@ public class RoleTest {
request.setName("角色名称"); request.setName("角色名称");
request.setComment("角色描述"); request.setComment("角色描述");
RoleFindResponse response = roleManager.find(request,token); RoleFindResponse response = roleManager.find(request, token);
assertTrue(!response.hasError()); assertTrue(!response.hasError());
} }
@ -117,7 +124,7 @@ public class RoleTest {
RoleGetRequest request = new RoleGetRequest(); RoleGetRequest request = new RoleGetRequest();
request.setId(createResponse.getId()); request.setId(createResponse.getId());
RoleGetResponse response = roleManager.get(request,token); RoleGetResponse response = roleManager.get(request, token);
assertTrue(!response.hasError() && response.getRole() != null); assertTrue(!response.hasError() && response.getRole() != null);
} }

@ -23,7 +23,6 @@ import java.util.Date;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
/** /**
* TokensTest - - * TokensTest - -
* *

@ -8,12 +8,19 @@ import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import ${basePackage}.frame.base.Token; import ${basePackage}.frame.base.Token;
import ${basePackage}.module.system.mgr.UserRoleManager; import ${basePackage}.module.system.mgr.UserRoleManager;
import ${basePackage}.module.system.req.*; import ${basePackage}.module.system.req.UserRoleCreateRequest;
import ${basePackage}.module.system.rsp.*; import ${basePackage}.module.system.req.UserRoleDeleteRequest;
import ${basePackage}.module.system.req.UserRoleFindRequest;
import ${basePackage}.module.system.req.UserRoleGetRequest;
import ${basePackage}.module.system.req.UserRoleUpdateRequest;
import ${basePackage}.module.system.rsp.UserRoleCreateResponse;
import ${basePackage}.module.system.rsp.UserRoleDeleteResponse;
import ${basePackage}.module.system.rsp.UserRoleFindResponse;
import ${basePackage}.module.system.rsp.UserRoleGetResponse;
import ${basePackage}.module.system.rsp.UserRoleUpdateResponse;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
/** /**
* UserRoleTest - - * UserRoleTest - -
* *
@ -38,7 +45,7 @@ public class UserRoleTest {
request.setUserId(1L); request.setUserId(1L);
request.setRoleId(1L); request.setRoleId(1L);
UserRoleCreateResponse response = userRoleManager.create(request,token); UserRoleCreateResponse response = userRoleManager.create(request, token);
assertTrue(!response.hasError()); assertTrue(!response.hasError());
} }
@ -51,14 +58,14 @@ public class UserRoleTest {
createRequest.setUserId(1L); createRequest.setUserId(1L);
createRequest.setRoleId(1L); createRequest.setRoleId(1L);
UserRoleCreateResponse createResponse = userRoleManager.create(createRequest,token); UserRoleCreateResponse createResponse = userRoleManager.create(createRequest, token);
assertTrue(!createResponse.hasError() && createResponse.getId() > 0); assertTrue(!createResponse.hasError() && createResponse.getId() > 0);
//删除数据 //删除数据
UserRoleDeleteRequest request = new UserRoleDeleteRequest(); UserRoleDeleteRequest request = new UserRoleDeleteRequest();
request.setId(createResponse.getId()); request.setId(createResponse.getId());
UserRoleDeleteResponse response = userRoleManager.delete(request,token); UserRoleDeleteResponse response = userRoleManager.delete(request, token);
assertTrue(!response.hasError() && response.getResult() == 1L); assertTrue(!response.hasError() && response.getResult() == 1L);
} }
@ -80,7 +87,7 @@ public class UserRoleTest {
request.setUserId(1L); request.setUserId(1L);
request.setRoleId(1L); request.setRoleId(1L);
UserRoleUpdateResponse response = userRoleManager.update(request,token); UserRoleUpdateResponse response = userRoleManager.update(request, token);
assertTrue(!response.hasError() && response.getResult() == 1L); assertTrue(!response.hasError() && response.getResult() == 1L);
} }
@ -91,7 +98,7 @@ public class UserRoleTest {
request.setUserId(1L); request.setUserId(1L);
request.setRoleId(1L); request.setRoleId(1L);
UserRoleFindResponse response = userRoleManager.find(request,token); UserRoleFindResponse response = userRoleManager.find(request, token);
assertTrue(!response.hasError()); assertTrue(!response.hasError());
} }
@ -111,7 +118,7 @@ public class UserRoleTest {
UserRoleGetRequest request = new UserRoleGetRequest(); UserRoleGetRequest request = new UserRoleGetRequest();
request.setId(createResponse.getId()); request.setId(createResponse.getId());
UserRoleGetResponse response = userRoleManager.get(request,token); UserRoleGetResponse response = userRoleManager.get(request, token);
assertTrue(!response.hasError() && response.getUserRole() != null); assertTrue(!response.hasError() && response.getUserRole() != null);
} }

@ -21,7 +21,6 @@ import ${basePackage}.module.system.rsp.UserUpdateResponse;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
/** /**
* UserTest - - * UserTest - -
* *

@ -2,16 +2,25 @@ package ${basePackage}.${moduleName};
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.context.junit4.SpringRunner;
import static org.junit.Assert.assertTrue;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import ${basePackage}.module.${moduleName}.mgr.${table.getCName()}Manager; <#if table.getImport()?length gt 1>
import ${basePackage}.module.${moduleName}.req.*;
import ${basePackage}.module.${moduleName}.rsp.*;
import ${basePackage}.frame.base.Token;
${table.getImport()} ${table.getImport()}
</#if>
import ${basePackage}.frame.base.Token;
import ${basePackage}.module.${moduleName}.mgr.${table.getCName()}Manager;
import ${basePackage}.module.${moduleName}.req.${table.getCName()}CreateRequest;
import ${basePackage}.module.${moduleName}.req.${table.getCName()}DeleteRequest;
import ${basePackage}.module.${moduleName}.req.${table.getCName()}FindRequest;
import ${basePackage}.module.${moduleName}.req.${table.getCName()}GetRequest;
import ${basePackage}.module.${moduleName}.req.${table.getCName()}UpdateRequest;
import ${basePackage}.module.${moduleName}.rsp.${table.getCName()}CreateResponse;
import ${basePackage}.module.${moduleName}.rsp.${table.getCName()}DeleteResponse;
import ${basePackage}.module.${moduleName}.rsp.${table.getCName()}FindResponse;
import ${basePackage}.module.${moduleName}.rsp.${table.getCName()}GetResponse;
import ${basePackage}.module.${moduleName}.rsp.${table.getCName()}UpdateResponse;
/** /**
* ${table.getCName()}Test - - ${table.tableComment}测试用例 * ${table.getCName()}Test - - ${table.tableComment}测试用例

Loading…
Cancel
Save

Powered by TurnKey Linux.