diff --git a/src/main/resources/modules/SpringBoot/java/action/ajax/system/ResAjax.java b/src/main/resources/modules/SpringBoot/java/action/ajax/system/ResAjax.java new file mode 100644 index 00000000..07582a45 --- /dev/null +++ b/src/main/resources/modules/SpringBoot/java/action/ajax/system/ResAjax.java @@ -0,0 +1,104 @@ +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.Res; +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; + +import java.io.IOException; +import java.util.List; + +public class ResAjax { + + @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()); + } + + public Object template() { + return ResponseUtil.apply(new WSheet<>(Res.class)); + } + + public Object exports(TreeNode jsonParam) { + ResFindRequest request = MapperUtil.toJava(jsonParam, ResFindRequest.class); + ResFindResponse response = resManager.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 sheet = new WSheet<>(file.getBytes(), Res.class, new WSheet.Validator() { + @Override + public List validate(Res o) { + ResCreateRequest request = MapperUtil.map(o, ResCreateRequest.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; + } +} diff --git a/src/main/resources/modules/SpringBoot/java/action/ajax/system/RoleResAjax.java b/src/main/resources/modules/SpringBoot/java/action/ajax/system/RoleResAjax.java new file mode 100644 index 00000000..215770e8 --- /dev/null +++ b/src/main/resources/modules/SpringBoot/java/action/ajax/system/RoleResAjax.java @@ -0,0 +1,48 @@ +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.excel.WSheet; +import ${basePackage}.frame.utils.LogUtil; +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.req.*; +import ${basePackage}.module.system.rsp.*; + +import java.io.IOException; +import java.util.List; + +public class RoleResAjax{ + + @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()); + } +} diff --git a/src/main/resources/modules/SpringBoot/java/config/FreeMarkerConfig.java b/src/main/resources/modules/SpringBoot/java/config/FreeMarkerConfig.java index 619f89fb..ae09e4b0 100644 --- a/src/main/resources/modules/SpringBoot/java/config/FreeMarkerConfig.java +++ b/src/main/resources/modules/SpringBoot/java/config/FreeMarkerConfig.java @@ -25,8 +25,8 @@ import java.io.File; import java.util.List; import java.util.Locale; -import static xyz.wbsite.config.ActionConfig.CONTROL_PREFIX; -import static xyz.wbsite.config.ActionConfig.SCREEN_PREFIX; +import static ${basePackage}.config.ActionConfig.CONTROL_PREFIX; +import static ${basePackage}.config.ActionConfig.SCREEN_PREFIX; @Configuration public class FreeMarkerConfig { diff --git a/src/main/resources/modules/SpringBoot/java/module/system/ent/Res.java b/src/main/resources/modules/SpringBoot/java/module/system/ent/Res.java new file mode 100644 index 00000000..084c8e2e --- /dev/null +++ b/src/main/resources/modules/SpringBoot/java/module/system/ent/Res.java @@ -0,0 +1,116 @@ +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; + +/** + * RES - 资源 + * + * @author wangbing + * @version 0.0.1 + * @since 2020-01-05 + */ +@SheetName("资源") +public class Res extends BaseEntity { + + /** + * RES_CODE - 资源代码 + */ + @ColumnName("资源代码") + @ColumnDescription("") + private String resCode; + /** + * RES_NAME - 资源名称 + */ + @ColumnName("资源名称") + @ColumnDescription("") + private String resName; + /** + * RES_TYPE - 资源类型 + */ + @ColumnName("资源类型") + @ColumnDescription("") + private String resType; + /** + * RES_VALUE - 资源内容 + */ + @ColumnName("资源内容") + @ColumnDescription("") + private String resValue; + /** + * SUP_CODE - 上级代码 + */ + @ColumnName("上级代码") + @ColumnDescription("") + private String supCode; + /** + * SUP_NAME - 上级名称 + */ + @ColumnName("上级名称") + @ColumnDescription("") + private String supName; + /** + * VALID - 是否有效 + */ + @ColumnName("是否有效") + @ColumnDescription("") + private Boolean valid; + + public String getResCode() { + return this.resCode; + } + + public void setResCode(String resCode) { + this.resCode = resCode; + } + + public String getResName() { + return this.resName; + } + + public void setResName(String resName) { + this.resName = resName; + } + + public String getResType() { + return this.resType; + } + + public void setResType(String resType) { + this.resType = resType; + } + + public String getResValue() { + return this.resValue; + } + + public void setResValue(String 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() { + return this.valid; + } + + public void setValid(Boolean valid) { + this.valid = valid; + } +} \ No newline at end of file diff --git a/src/main/resources/modules/SpringBoot/java/module/system/ent/ResTree.java b/src/main/resources/modules/SpringBoot/java/module/system/ent/ResTree.java new file mode 100644 index 00000000..9cd0d2f8 --- /dev/null +++ b/src/main/resources/modules/SpringBoot/java/module/system/ent/ResTree.java @@ -0,0 +1,49 @@ +package ${basePackage}.module.system.ent; + +import java.util.ArrayList; +import java.util.List; + +/** + * ResTree - 资源树 + * + * @author wangbing + * @version 0.0.1 + * @since 2019-12-24 + */ +public class ResTree extends Res { + + private String label; + + private String value; + + private List children; + + public String getLabel() { + return label; + } + + public void setLabel(String label) { + this.label = label; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + public List getChildren() { + return children; + } + + public void setChildren(List children) { + this.children = children; + } + + public void addChild(ResTree deptTree) { + if (this.children == null) this.children = new ArrayList<>(); + this.children.add(deptTree); + } +} \ No newline at end of file diff --git a/src/main/resources/modules/SpringBoot/java/module/system/ent/RoleRes.java b/src/main/resources/modules/SpringBoot/java/module/system/ent/RoleRes.java new file mode 100644 index 00000000..d22a8fe1 --- /dev/null +++ b/src/main/resources/modules/SpringBoot/java/module/system/ent/RoleRes.java @@ -0,0 +1,62 @@ +package ${basePackage}.module.system.ent; + +import ${basePackage}.frame.base.BaseEntity; + +/** + * ROLE_RES - 角色资源关系 + * + * @author wangbing + * @version 0.0.1 + * @since 2020-01-05 + */ +public class RoleRes extends BaseEntity { + + /** + * ROLE_ID - 角色主键 + */ + private Long roleId; + /** + * ROLE_CODE - 角色代码 + */ + private String roleCode; + /** + * RES_ID - 资源主键 + */ + private Long resId; + /** + * RES_CODE - 资源代码 + */ + private String resCode; + + public Long getRoleId() { + return this.roleId; + } + + public void setRoleId(Long roleId) { + this.roleId = roleId; + } + + public String getRoleCode() { + return this.roleCode; + } + + public void setRoleCode(String roleCode) { + this.roleCode = roleCode; + } + + public Long getResId() { + return this.resId; + } + + public void setResId(Long resId) { + this.resId = resId; + } + + public String getResCode() { + return this.resCode; + } + + public void setResCode(String resCode) { + this.resCode = resCode; + } +} \ No newline at end of file diff --git a/src/main/resources/modules/SpringBoot/java/module/system/mgr/ResManager.java b/src/main/resources/modules/SpringBoot/java/module/system/mgr/ResManager.java new file mode 100644 index 00000000..38183181 --- /dev/null +++ b/src/main/resources/modules/SpringBoot/java/module/system/mgr/ResManager.java @@ -0,0 +1,79 @@ +package ${basePackage}.module.system.mgr; + +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; +import ${basePackage}.frame.base.Token; + +/** + * 资源 + * + * @author wangbing + * @version 0.0.1 + * @since 2020-01-05 + */ +public interface ResManager { + + /** + * 插入 + * + * @param request 请求对象 + * @param token 令牌 + * @return + */ + ResCreateResponse create(ResCreateRequest request, Token token); + + /** + * 逻辑删除 + * + * @param request 请求对象 + * @param token 令牌 + * @return + */ + ResDeleteResponse delete(ResDeleteRequest request, Token token); + + /** + * 更新 + * + * @param request 请求对象 + * @param token 令牌 + * @return + */ + ResUpdateResponse update(ResUpdateRequest request, Token token); + + /** + * 查询 + * + * @param request 请求对象 + * @param token 令牌 + * @return + */ + ResFindResponse find(ResFindRequest request, Token token); + + /** + * 获得对象 + * + * @param request 请求对象 + * @param token 令牌 + * @return + */ + ResGetResponse get(ResGetRequest request, Token token); + + /** + * 获得资源树 + * + * @param request 请求对象 + * @param token 令牌 + * @return + */ + ResTreeResponse tree(ResTreeRequest request, Token token); +} diff --git a/src/main/resources/modules/SpringBoot/java/module/system/mgr/ResManagerImpl.java b/src/main/resources/modules/SpringBoot/java/module/system/mgr/ResManagerImpl.java new file mode 100644 index 00000000..a9dbc139 --- /dev/null +++ b/src/main/resources/modules/SpringBoot/java/module/system/mgr/ResManagerImpl.java @@ -0,0 +1,249 @@ +package ${basePackage}.module.system.mgr; + +import ${basePackage}.frame.base.SortType; +import ${basePackage}.frame.utils.IDgenerator; +import ${basePackage}.frame.utils.Message; +import ${basePackage}.frame.base.ErrorType; +import ${basePackage}.frame.base.Token; +import ${basePackage}.frame.utils.MapperUtil; +import ${basePackage}.frame.utils.ValidationUtil; +import ${basePackage}.module.system.ent.Res; +import ${basePackage}.module.system.ent.ResTree; +import ${basePackage}.module.system.mpr.ResMapper; +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; +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 java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +/** + * RES - 资源 + * + * @author wangbing + * @version 0.0.1 + * @since 2020-01-05 + */ +@Transactional +@Service +public class ResManagerImpl implements ResManager { + + @Autowired + private ResMapper resMapper; + + /** + * 插入 + * + * @param request 请求对象 + * @param token 令牌 + * @return 响应 + */ + public ResCreateResponse create(ResCreateRequest request, Token token) { + ResCreateResponse response = new ResCreateResponse(); + + ValidationUtil.validate(request, response); + if (response.hasError()) { + return response; + } + + long id = IDgenerator.nextId(); + Res entity = MapperUtil.map(request, Res.class); + entity.setId(id); + + long result = resMapper.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 ResDeleteResponse delete(ResDeleteRequest request, Token token) { + ResDeleteResponse response = new ResDeleteResponse(); + + ValidationUtil.validate(request, response); + if (response.hasError()) { + return response; + } + + long result = resMapper.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 ResUpdateResponse update(ResUpdateRequest request, Token token) { + ResUpdateResponse response = new ResUpdateResponse(); + + ValidationUtil.validate(request, response); + if (response.hasError()) { + return response; + } + + long result = resMapper.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 ResFindResponse find(ResFindRequest request, Token token) { + ResFindResponse response = new ResFindResponse(); + + 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 pageInfo = new PageInfo<>(resMapper.find(request, token)); + + response.setResult(pageInfo.getList()); + response.setTotalCount(pageInfo.getTotal()); + + return response; + } + + /** + * 获得对象 + * + * @param request 请求对象 + * @param token 令牌 + * @return 响应 + */ + @Transactional(readOnly = true) + public ResGetResponse get(ResGetRequest request, Token token) { + ResGetResponse response = new ResGetResponse(); + + ValidationUtil.validate(request, response); + if (response.hasError()) { + return response; + } + + Res po = resMapper.get(request, token); + + if (po != null) { + response.setRes(po); + } else { + response.addError(ErrorType.BUSINESS_ERROR, Message.GET_FAILURE); + } + + return response; + } + + @Override + public ResTreeResponse tree(ResTreeRequest request, Token token) { + ResTreeResponse response = new ResTreeResponse(); + + ValidationUtil.validate(request, response); + if (response.hasError()) { + return response; + } + + ResFindRequest resourceFindRequest = new ResFindRequest(); + resourceFindRequest.setPageSize(0); + resourceFindRequest.setValid(true); + resourceFindRequest.setSortType(SortType.ASC); + resourceFindRequest.setSortKey("CODE"); + ResFindResponse resourceFindResponse = this.find(resourceFindRequest, token); + + if (resourceFindResponse.hasError()) { + response.addErrors(resourceFindResponse.getErrors()); + return response; + } + + List data = new ArrayList<>(); + Map allMap = new HashMap<>(); + List result = resourceFindResponse.getResult(); + // 获取最顶级资源 + int level = 1; + while (result.size() > 0) { + Iterator iterator = result.iterator(); + while (iterator.hasNext()) { + Res next = iterator.next(); + ResTree tree = new ResTree(); + tree.setId(next.getId()); + tree.setResCode(next.getResCode()); + tree.setResName(next.getResName()); + tree.setResType(next.getResType()); + tree.setResValue(next.getResValue()); + tree.setValid(next.getValid()); + tree.setRowVersion(next.getRowVersion()); + + if (next.getResCode() != null && next.getResCode().split("_").length == level) { + allMap.put(tree.getResCode(), tree); + iterator.remove(); + //尝试获取上级资源 + String code = next.getResCode(); + ResTree Ptree = null; + while (code.contains("_")) { + code = code.substring(0, code.lastIndexOf("_")); + Ptree = allMap.get(code); + if (Ptree != null) break; + } + if (Ptree != null) { + Ptree.getChildren().add(tree); + } else { + data.add(tree); + } + } + } + level++; + } + + response.setResult(data); + return response; + } +} diff --git a/src/main/resources/modules/SpringBoot/java/module/system/mgr/RoleResManager.java b/src/main/resources/modules/SpringBoot/java/module/system/mgr/RoleResManager.java new file mode 100644 index 00000000..f66fe301 --- /dev/null +++ b/src/main/resources/modules/SpringBoot/java/module/system/mgr/RoleResManager.java @@ -0,0 +1,68 @@ +package ${basePackage}.module.system.mgr; + +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 ${basePackage}.frame.base.Token; + +/** + * 角色资源关系 + * + * @author wangbing + * @version 0.0.1 + * @since 2020-01-05 + */ +public interface RoleResManager { + + /** + * 插入 + * + * @param request 请求对象 + * @param token 令牌 + * @return + */ + RoleResCreateResponse create(RoleResCreateRequest request, Token token); + + /** + * 逻辑删除 + * + * @param request 请求对象 + * @param token 令牌 + * @return + */ + RoleResDeleteResponse delete(RoleResDeleteRequest request, Token token); + + /** + * 更新 + * + * @param request 请求对象 + * @param token 令牌 + * @return + */ + RoleResUpdateResponse update(RoleResUpdateRequest request, Token token); + + /** + * 查询 + * + * @param request 请求对象 + * @param token 令牌 + * @return + */ + RoleResFindResponse find(RoleResFindRequest request, Token token); + + /** + * 获得对象 + * + * @param request 请求对象 + * @param token 令牌 + * @return + */ + RoleResGetResponse get(RoleResGetRequest request, Token token); +} diff --git a/src/main/resources/modules/SpringBoot/java/module/system/mgr/RoleResManagerImpl.java b/src/main/resources/modules/SpringBoot/java/module/system/mgr/RoleResManagerImpl.java new file mode 100644 index 00000000..8bf15e65 --- /dev/null +++ b/src/main/resources/modules/SpringBoot/java/module/system/mgr/RoleResManagerImpl.java @@ -0,0 +1,175 @@ +package ${basePackage}.module.system.mgr; + +import ${basePackage}.frame.utils.IDgenerator; +import ${basePackage}.frame.utils.Message; +import ${basePackage}.frame.base.ErrorType; +import ${basePackage}.frame.base.Token; +import ${basePackage}.frame.utils.MapperUtil; +import ${basePackage}.frame.utils.ValidationUtil; +import ${basePackage}.module.system.ent.RoleRes; +import ${basePackage}.module.system.mpr.RoleResMapper; +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 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 - 角色资源关系 + * + * @author wangbing + * @version 0.0.1 + * @since 2020-01-05 + */ +@Transactional +@Service +public class RoleResManagerImpl implements RoleResManager { + + @Autowired + private RoleResMapper roleResMapper; + + /** + * 插入 + * + * @param request 请求对象 + * @param token 令牌 + * @return 响应 + */ + public RoleResCreateResponse create(RoleResCreateRequest request, Token token) { + RoleResCreateResponse response = new RoleResCreateResponse(); + + ValidationUtil.validate(request, response); + if (response.hasError()) { + return response; + } + + long id = IDgenerator.nextId(); + RoleRes entity = MapperUtil.map(request, RoleRes.class); + entity.setId(id); + + long result = roleResMapper.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 RoleResDeleteResponse delete(RoleResDeleteRequest request, Token token) { + RoleResDeleteResponse response = new RoleResDeleteResponse(); + + ValidationUtil.validate(request, response); + if (response.hasError()) { + return response; + } + + long result = roleResMapper.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 RoleResUpdateResponse update(RoleResUpdateRequest request, Token token) { + RoleResUpdateResponse response = new RoleResUpdateResponse(); + + ValidationUtil.validate(request, response); + if (response.hasError()) { + return response; + } + + long result = roleResMapper.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 RoleResFindResponse find(RoleResFindRequest request, Token token) { + RoleResFindResponse response = new RoleResFindResponse(); + + 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 pageInfo = new PageInfo<>(roleResMapper.find(request, token)); + + response.setResult(pageInfo.getList()); + response.setTotalCount(pageInfo.getTotal()); + + return response; + } + + /** + * 获得对象 + * + * @param request 请求对象 + * @param token 令牌 + * @return 响应 + */ + @Transactional(readOnly = true) + public RoleResGetResponse get(RoleResGetRequest request, Token token) { + RoleResGetResponse response = new RoleResGetResponse(); + + ValidationUtil.validate(request, response); + if (response.hasError()) { + return response; + } + + RoleRes po = roleResMapper.get(request, token); + + if (po != null) { + response.setRoleRes(po); + } else { + response.addError(ErrorType.BUSINESS_ERROR, Message.GET_FAILURE); + } + + return response; + } +} diff --git a/src/main/resources/modules/SpringBoot/java/module/system/mpr/MySQL_ResMapper.xml b/src/main/resources/modules/SpringBoot/java/module/system/mpr/MySQL_ResMapper.xml new file mode 100644 index 00000000..af1a1d87 --- /dev/null +++ b/src/main/resources/modules/SpringBoot/java/module/system/mpr/MySQL_ResMapper.xml @@ -0,0 +1,161 @@ + + + + + `SYS_RES` + + + `ID`,`RES_CODE`,`RES_NAME`,`RES_TYPE`,`RES_VALUE`,`SUP_CODE`,`SUP_NAME`,`VALID`,`ROW_VERSION`,`IS_DELETED`,`CREATE_BY`,`CREATE_TIME`,`LAST_UPDATE_BY`,`LAST_UPDATE_TIME` + + + + + + + + + + + + + + + + + + + + + + + + + INSERT INTO + + ( + + ) + VALUES + ( + ${r'#'}{request.id}, + ${r'#'}{request.resCode,jdbcType=VARCHAR}, + ${r'#'}{request.resName,jdbcType=VARCHAR}, + ${r'#'}{request.resType,jdbcType=VARCHAR}, + ${r'#'}{request.resValue,jdbcType=VARCHAR}, + ${r'#'}{request.supCode,jdbcType=VARCHAR}, + ${r'#'}{request.supName,jdbcType=VARCHAR}, + ${r'#'}{request.valid,jdbcType=BIT}, + 0, + 0, + ${r'#'}{token.userId,jdbcType=NUMERIC}, + sysdate(), + NULL, + NULL + ) + + + + INSERT INTO + + ( + + ) + VALUES + + ( + ${r'#'}{item.id}, + ${r'#'}{item.resCode,jdbcType=VARCHAR}, + ${r'#'}{item.resName,jdbcType=VARCHAR}, + ${r'#'}{item.resType,jdbcType=VARCHAR}, + ${r'#'}{item.resValue,jdbcType=VARCHAR}, + ${r'#'}{item.supCode,jdbcType=VARCHAR}, + ${r'#'}{item.supName,jdbcType=VARCHAR}, + ${r'#'}{item.valid,jdbcType=BIT}, + 0, + 0, + ${r'#'}{token.userId,jdbcType=NUMERIC}, + sysdate(), + NULL, + NULL + ) + + + + + UPDATE + + SET `IS_DELETED` = 1 + WHERE `IS_DELETED` = 0 + AND `ID` = ${r'#'}{request.id} + + + + UPDATE + + SET + `RES_CODE` = ${r'#'}{request.resCode,jdbcType=VARCHAR}, + `RES_NAME` = ${r'#'}{request.resName,jdbcType=VARCHAR}, + `RES_TYPE` = ${r'#'}{request.resType,jdbcType=VARCHAR}, + `RES_VALUE` = ${r'#'}{request.resValue,jdbcType=VARCHAR}, + `SUP_CODE` = ${r'#'}{request.supCode,jdbcType=VARCHAR}, + `SUP_NAME` = ${r'#'}{request.supName,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} + + + + \ No newline at end of file diff --git a/src/main/resources/modules/SpringBoot/java/module/system/mpr/MySQL_RoleResMapper.xml b/src/main/resources/modules/SpringBoot/java/module/system/mpr/MySQL_RoleResMapper.xml new file mode 100644 index 00000000..e6f4043e --- /dev/null +++ b/src/main/resources/modules/SpringBoot/java/module/system/mpr/MySQL_RoleResMapper.xml @@ -0,0 +1,140 @@ + + + + + `SYS_ROLE_RES` + + + `ID`,`ROLE_ID`,`ROLE_CODE`,`RES_ID`,`RES_CODE`,`ROW_VERSION`,`IS_DELETED`,`CREATE_BY`,`CREATE_TIME`,`LAST_UPDATE_BY`,`LAST_UPDATE_TIME` + + + + + + + + + + + + + + + + + + + + + + INSERT INTO + + ( + + ) + VALUES + ( + ${r'#'}{request.id}, + ${r'#'}{request.roleId,jdbcType=BIGINT}, + ${r'#'}{request.roleCode,jdbcType=VARCHAR}, + ${r'#'}{request.resId,jdbcType=BIGINT}, + ${r'#'}{request.resCode,jdbcType=VARCHAR}, + 0, + 0, + ${r'#'}{token.userId,jdbcType=NUMERIC}, + sysdate(), + NULL, + NULL + ) + + + + INSERT INTO + + ( + + ) + VALUES + + ( + ${r'#'}{item.id}, + ${r'#'}{item.roleId,jdbcType=BIGINT}, + ${r'#'}{item.roleCode,jdbcType=VARCHAR}, + ${r'#'}{item.resId,jdbcType=BIGINT}, + ${r'#'}{item.resCode,jdbcType=VARCHAR}, + 0, + 0, + ${r'#'}{token.userId,jdbcType=NUMERIC}, + sysdate(), + NULL, + NULL + ) + + + + + UPDATE + + SET `IS_DELETED` = 1 + WHERE `IS_DELETED` = 0 + AND `ID` = ${r'#'}{request.id} + + + + UPDATE + + SET + `ROLE_ID` = ${r'#'}{request.roleId,jdbcType=BIGINT}, + `ROLE_CODE` = ${r'#'}{request.roleCode,jdbcType=VARCHAR}, + `RES_ID` = ${r'#'}{request.resId,jdbcType=BIGINT}, + `RES_CODE` = ${r'#'}{request.resCode,jdbcType=VARCHAR}, + `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} + + + + \ No newline at end of file diff --git a/src/main/resources/modules/SpringBoot/java/module/system/mpr/ResMapper.java b/src/main/resources/modules/SpringBoot/java/module/system/mpr/ResMapper.java new file mode 100644 index 00000000..17d4c73b --- /dev/null +++ b/src/main/resources/modules/SpringBoot/java/module/system/mpr/ResMapper.java @@ -0,0 +1,78 @@ +package ${basePackage}.module.system.mpr; + +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Mapper; + +import java.util.List; + +import ${basePackage}.module.system.ent.Res; +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}.frame.base.Token; + +/** + * RES - 资源 + * + * @author wangbing + * @date 2020-01-05 + */ +@Mapper +public interface ResMapper { + + /** + * 插入 + * + * @param request 请求对象 + * @param token 令牌 + * @return 返回数量 + */ + long insert(@Param("request") Res request, @Param("token") Token token); + + /** + * 批量插入 + * + * @param request 请求对象 + * @param token 令牌 + * @return 返回数量 + */ + long insertBatch(@Param("list") List request, @Param("token") Token token); + + /** + * 逻辑删除 + * + * @param request 请求对象 + * @param token 令牌 + * @return 返回数量 + */ + long delete(@Param("request") ResDeleteRequest request, @Param("token") Token token); + + /** + * 更新 + * + * @param request 请求对象 + * @param token 令牌 + * @return 返回数量 + */ + long update(@Param("request") ResUpdateRequest request, @Param("token") Token token); + + /** + * 查询 + * + * @param request 请求对象 + * @param token 令牌 + * @return 返回对象 + */ + List find(@Param("request") ResFindRequest request, @Param("token") Token token); + + /** + * 获得对象 + * + * @param request 请求对象 + * @param token 令牌 + * @return 返回对象 + */ + Res get(@Param("request") ResGetRequest request, @Param("token") Token token); +} diff --git a/src/main/resources/modules/SpringBoot/java/module/system/mpr/RoleResMapper.java b/src/main/resources/modules/SpringBoot/java/module/system/mpr/RoleResMapper.java new file mode 100644 index 00000000..f0f07670 --- /dev/null +++ b/src/main/resources/modules/SpringBoot/java/module/system/mpr/RoleResMapper.java @@ -0,0 +1,78 @@ +package ${basePackage}.module.system.mpr; + +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Mapper; + +import java.util.List; + +import ${basePackage}.module.system.ent.RoleRes; +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}.frame.base.Token; + +/** + * ROLE_RES - 角色资源关系 + * + * @author wangbing + * @date 2020-01-05 + */ +@Mapper +public interface RoleResMapper { + + /** + * 插入 + * + * @param request 请求对象 + * @param token 令牌 + * @return 返回数量 + */ + long insert(@Param("request") RoleRes request, @Param("token") Token token); + + /** + * 批量插入 + * + * @param request 请求对象 + * @param token 令牌 + * @return 返回数量 + */ + long insertBatch(@Param("list") List request, @Param("token") Token token); + + /** + * 逻辑删除 + * + * @param request 请求对象 + * @param token 令牌 + * @return 返回数量 + */ + long delete(@Param("request") RoleResDeleteRequest request, @Param("token") Token token); + + /** + * 更新 + * + * @param request 请求对象 + * @param token 令牌 + * @return 返回数量 + */ + long update(@Param("request") RoleResUpdateRequest request, @Param("token") Token token); + + /** + * 查询 + * + * @param request 请求对象 + * @param token 令牌 + * @return 返回对象 + */ + List find(@Param("request") RoleResFindRequest request, @Param("token") Token token); + + /** + * 获得对象 + * + * @param request 请求对象 + * @param token 令牌 + * @return 返回对象 + */ + RoleRes get(@Param("request") RoleResGetRequest request, @Param("token") Token token); +} diff --git a/src/main/resources/modules/SpringBoot/java/module/system/req/DeptTreeRequest.java b/src/main/resources/modules/SpringBoot/java/module/system/req/DeptTreeRequest.java index 3f0ab776..e151e826 100644 --- a/src/main/resources/modules/SpringBoot/java/module/system/req/DeptTreeRequest.java +++ b/src/main/resources/modules/SpringBoot/java/module/system/req/DeptTreeRequest.java @@ -1,6 +1,6 @@ -package xyz.wbsite.module.system.req; +package ${basePackage}.module.system.req; -import xyz.wbsite.frame.base.BaseRequest; +import ${basePackage}.frame.base.BaseRequest; /** * ResourceTreeRequest - 资源获取 diff --git a/src/main/resources/modules/SpringBoot/java/module/system/req/ResCreateRequest.java b/src/main/resources/modules/SpringBoot/java/module/system/req/ResCreateRequest.java new file mode 100644 index 00000000..9c8754e9 --- /dev/null +++ b/src/main/resources/modules/SpringBoot/java/module/system/req/ResCreateRequest.java @@ -0,0 +1,89 @@ +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; + +/** + * ResCreateRequest - 资源新增 + * + * @author wangbing + * @version 0.0.1 + * @since 2020-01-05 + */ +public class ResCreateRequest extends BaseRequest { + + /** + * 资源代码 + */ + @NotEmpty(message = "[resCode]资源代码不能为空") + @Length(min = 0, max = 50, message = "[resCode]资源代码长度不合法(0-50)") + private String resCode; + + /** + * 资源名称 + */ + @Length(min = 0, max = 255, message = "[resName]资源名称长度不合法(0-255)") + private String resName; + + /** + * 资源类型 + */ + @NotNull(message = "[resType]资源类型不能为NULL") + @Dict(name = "RES_TYPE") + private String resType; + + /** + * 资源内容 + */ + @Length(min = 0, max = 100, message = "[resValue]资源内容长度不合法(0-100)") + private String resValue; + + /** + * 是否有效 + */ + @NotNull(message = "[valid]是否有效不能为NULL") + private Boolean valid; + + public String getResCode() { + return this.resCode; + } + + public void setResCode(String resCode) { + this.resCode = resCode; + } + + public String getResName() { + return this.resName; + } + + public void setResName(String resName) { + this.resName = resName; + } + + public String getResType() { + return this.resType; + } + + public void setResType(String resType) { + this.resType = resType; + } + + public String getResValue() { + return this.resValue; + } + + public void setResValue(String resValue) { + this.resValue = resValue; + } + + public Boolean getValid() { + return this.valid; + } + + public void setValid(Boolean valid) { + this.valid = valid; + } +} diff --git a/src/main/resources/modules/SpringBoot/java/module/system/req/ResDeleteRequest.java b/src/main/resources/modules/SpringBoot/java/module/system/req/ResDeleteRequest.java new file mode 100644 index 00000000..b7037eb4 --- /dev/null +++ b/src/main/resources/modules/SpringBoot/java/module/system/req/ResDeleteRequest.java @@ -0,0 +1,28 @@ +package ${basePackage}.module.system.req; + +import ${basePackage}.frame.base.BaseUpdateRequest; +import javax.validation.constraints.NotNull; + +/** + * ResDeleteRequest - 资源删除 + * + * @author wangbing + * @version 0.0.1 + * @since 2020-01-05 + */ +public class ResDeleteRequest extends BaseUpdateRequest { + + /** + * 主键 + */ + @NotNull(message = "[id]主键不能为空") + private long id; + + public long getId() { + return this.id; + } + + public void setId(long id) { + this.id = id; + } +} diff --git a/src/main/resources/modules/SpringBoot/java/module/system/req/ResFindRequest.java b/src/main/resources/modules/SpringBoot/java/module/system/req/ResFindRequest.java new file mode 100644 index 00000000..7cadf2a7 --- /dev/null +++ b/src/main/resources/modules/SpringBoot/java/module/system/req/ResFindRequest.java @@ -0,0 +1,106 @@ +package ${basePackage}.module.system.req; + +import ${basePackage}.frame.base.BaseFindRequest; +import ${basePackage}.frame.validation.Dict; + +/** + * ResRequest - 资源查询 + * + * @author wangbing + * @version 0.0.1 + * @since 2020-01-05 + */ +public class ResFindRequest extends BaseFindRequest { + + /** + * 资源代码 + */ + private String resCode; + + /** + * 资源名称 + */ + private String resName; + + /** + * 资源类型 + */ + @Dict(name = "RES_TYPE") + private String resType; + + /** + * 资源内容 + */ + private String resValue; + + /** + * 上级代码 + */ + private String supCode; + + /** + * 上级名称 + */ + private String supName; + + /** + * 是否有效 + */ + private Boolean valid; + + public String getResCode() { + return this.resCode; + } + + public void setResCode(String resCode) { + this.resCode = resCode; + } + + public String getResName() { + return this.resName; + } + + public void setResName(String resName) { + this.resName = resName; + } + + public String getResType() { + return this.resType; + } + + public void setResType(String resType) { + this.resType = resType; + } + + public String getResValue() { + return this.resValue; + } + + public void setResValue(String 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() { + return this.valid; + } + + public void setValid(Boolean valid) { + this.valid = valid; + } +} diff --git a/src/main/resources/modules/SpringBoot/java/module/system/req/ResGetRequest.java b/src/main/resources/modules/SpringBoot/java/module/system/req/ResGetRequest.java new file mode 100644 index 00000000..e44dd996 --- /dev/null +++ b/src/main/resources/modules/SpringBoot/java/module/system/req/ResGetRequest.java @@ -0,0 +1,28 @@ +package ${basePackage}.module.system.req; + +import ${basePackage}.frame.base.BaseRequest; +import javax.validation.constraints.NotNull; + +/** + * ResGetRequest - 资源获取 + * + * @author wangbing + * @version 0.0.1 + * @since 2020-01-05 + */ +public class ResGetRequest extends BaseRequest { + + /** + * 主键 + */ + @NotNull(message = "[id]主键不能为空") + private long id; + + public long getId() { + return this.id; + } + + public void setId(long id) { + this.id = id; + } +} diff --git a/src/main/resources/modules/SpringBoot/java/module/system/req/ResTreeRequest.java b/src/main/resources/modules/SpringBoot/java/module/system/req/ResTreeRequest.java new file mode 100644 index 00000000..e6724beb --- /dev/null +++ b/src/main/resources/modules/SpringBoot/java/module/system/req/ResTreeRequest.java @@ -0,0 +1,14 @@ +package ${basePackage}.module.system.req; + +import ${basePackage}.frame.base.BaseRequest; + +/** + * ResTreeRequest - 资源获取 + * + * @author wangbing + * @version 0.0.1 + * @since 2019-12-26 + */ +public class ResTreeRequest extends BaseRequest { + +} diff --git a/src/main/resources/modules/SpringBoot/java/module/system/req/ResUpdateRequest.java b/src/main/resources/modules/SpringBoot/java/module/system/req/ResUpdateRequest.java new file mode 100644 index 00000000..977e96c0 --- /dev/null +++ b/src/main/resources/modules/SpringBoot/java/module/system/req/ResUpdateRequest.java @@ -0,0 +1,132 @@ +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; + +/** + * ResUpdateRequest - 资源更新 + * + * @author wangbing + * @version 0.0.1 + * @since 2020-01-05 + */ +public class ResUpdateRequest extends BaseUpdateRequest { + + /** + * 主键 + */ + @NotNull(message = "[id]主键不能为NULL") + private Long id; + + /** + * 资源代码 + */ + @NotEmpty(message = "[resCode]资源代码不能为空") + @Length(min = 0, max = 50, message = "[resCode]资源代码长度不合法(0-50)") + private String resCode; + + /** + * 资源名称 + */ + @Length(min = 0, max = 255, message = "[resName]资源名称长度不合法(0-255)") + private String resName; + + /** + * 资源类型 + */ + @NotNull(message = "[resType]资源类型不能为NULL") + @Dict(name = "RES_TYPE") + private String resType; + + /** + * 资源内容 + */ + @NotEmpty(message = "[resValue]资源内容不能为空") + @Length(min = 0, max = 100, message = "[resValue]资源内容长度不合法(0-100)") + 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; + + /** + * 是否有效 + */ + @NotNull(message = "[valid]是否有效不能为NULL") + private Boolean valid; + + public Long getId() { + return this.id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getResCode() { + return this.resCode; + } + + public void setResCode(String resCode) { + this.resCode = resCode; + } + + public String getResName() { + return this.resName; + } + + public void setResName(String resName) { + this.resName = resName; + } + + public String getResType() { + return this.resType; + } + + public void setResType(String resType) { + this.resType = resType; + } + + public String getResValue() { + return this.resValue; + } + + public void setResValue(String 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() { + return this.valid; + } + + public void setValid(Boolean valid) { + this.valid = valid; + } +} diff --git a/src/main/resources/modules/SpringBoot/java/module/system/req/RoleResCreateRequest.java b/src/main/resources/modules/SpringBoot/java/module/system/req/RoleResCreateRequest.java new file mode 100644 index 00000000..999d4a85 --- /dev/null +++ b/src/main/resources/modules/SpringBoot/java/module/system/req/RoleResCreateRequest.java @@ -0,0 +1,74 @@ +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; + +/** + * RoleResCreateRequest - 角色资源关系新增 + * + * @author wangbing + * @version 0.0.1 + * @since 2020-01-05 + */ +public class RoleResCreateRequest extends BaseRequest { + + /** + * 角色主键 + */ + @NotNull(message = "[roleId]角色主键不能为NULL") + private Long roleId; + + /** + * 角色代码 + */ + @NotEmpty(message = "[roleCode]角色代码不能为空") + @Length(min = 0, max = 50, message = "[roleCode]角色代码长度不合法(0-50)") + private String roleCode; + + /** + * 资源主键 + */ + @NotNull(message = "[resId]资源主键不能为NULL") + private Long resId; + + /** + * 资源代码 + */ + @NotEmpty(message = "[resCode]资源代码不能为空") + @Length(min = 0, max = 50, message = "[resCode]资源代码长度不合法(0-50)") + private String resCode; + + public Long getRoleId() { + return this.roleId; + } + + public void setRoleId(Long roleId) { + this.roleId = roleId; + } + + public String getRoleCode() { + return this.roleCode; + } + + public void setRoleCode(String roleCode) { + this.roleCode = roleCode; + } + + public Long getResId() { + return this.resId; + } + + public void setResId(Long resId) { + this.resId = resId; + } + + public String getResCode() { + return this.resCode; + } + + public void setResCode(String resCode) { + this.resCode = resCode; + } +} diff --git a/src/main/resources/modules/SpringBoot/java/module/system/req/RoleResDeleteRequest.java b/src/main/resources/modules/SpringBoot/java/module/system/req/RoleResDeleteRequest.java new file mode 100644 index 00000000..68e65ca8 --- /dev/null +++ b/src/main/resources/modules/SpringBoot/java/module/system/req/RoleResDeleteRequest.java @@ -0,0 +1,28 @@ +package ${basePackage}.module.system.req; + +import ${basePackage}.frame.base.BaseUpdateRequest; +import javax.validation.constraints.NotNull; + +/** + * RoleResDeleteRequest - 角色资源关系删除 + * + * @author wangbing + * @version 0.0.1 + * @since 2020-01-05 + */ +public class RoleResDeleteRequest extends BaseUpdateRequest { + + /** + * 主键 + */ + @NotNull(message = "[id]主键不能为空") + private long id; + + public long getId() { + return this.id; + } + + public void setId(long id) { + this.id = id; + } +} diff --git a/src/main/resources/modules/SpringBoot/java/module/system/req/RoleResFindRequest.java b/src/main/resources/modules/SpringBoot/java/module/system/req/RoleResFindRequest.java new file mode 100644 index 00000000..2f1a1c56 --- /dev/null +++ b/src/main/resources/modules/SpringBoot/java/module/system/req/RoleResFindRequest.java @@ -0,0 +1,65 @@ +package ${basePackage}.module.system.req; + +import ${basePackage}.frame.base.BaseFindRequest; + +/** + * RoleResRequest - 角色资源关系查询 + * + * @author wangbing + * @version 0.0.1 + * @since 2020-01-05 + */ +public class RoleResFindRequest extends BaseFindRequest { + + /** + * 角色主键 + */ + private Long roleId; + + /** + * 角色代码 + */ + private String roleCode; + + /** + * 资源主键 + */ + private Long resId; + + /** + * 资源代码 + */ + private String resCode; + + public Long getRoleId() { + return this.roleId; + } + + public void setRoleId(Long roleId) { + this.roleId = roleId; + } + + public String getRoleCode() { + return this.roleCode; + } + + public void setRoleCode(String roleCode) { + this.roleCode = roleCode; + } + + public Long getResId() { + return this.resId; + } + + public void setResId(Long resId) { + this.resId = resId; + } + + public String getResCode() { + return this.resCode; + } + + public void setResCode(String resCode) { + this.resCode = resCode; + } +} diff --git a/src/main/resources/modules/SpringBoot/java/module/system/req/RoleResGetRequest.java b/src/main/resources/modules/SpringBoot/java/module/system/req/RoleResGetRequest.java new file mode 100644 index 00000000..aad4dfc5 --- /dev/null +++ b/src/main/resources/modules/SpringBoot/java/module/system/req/RoleResGetRequest.java @@ -0,0 +1,28 @@ +package ${basePackage}.module.system.req; + +import ${basePackage}.frame.base.BaseRequest; +import javax.validation.constraints.NotNull; + +/** + * RoleResGetRequest - 角色资源关系获取 + * + * @author wangbing + * @version 0.0.1 + * @since 2020-01-05 + */ +public class RoleResGetRequest extends BaseRequest { + + /** + * 主键 + */ + @NotNull(message = "[id]主键不能为空") + private long id; + + public long getId() { + return this.id; + } + + public void setId(long id) { + this.id = id; + } +} diff --git a/src/main/resources/modules/SpringBoot/java/module/system/req/RoleResUpdateRequest.java b/src/main/resources/modules/SpringBoot/java/module/system/req/RoleResUpdateRequest.java new file mode 100644 index 00000000..71506004 --- /dev/null +++ b/src/main/resources/modules/SpringBoot/java/module/system/req/RoleResUpdateRequest.java @@ -0,0 +1,88 @@ +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; + +/** + * RoleResUpdateRequest - 角色资源关系更新 + * + * @author wangbing + * @version 0.0.1 + * @since 2020-01-05 + */ +public class RoleResUpdateRequest extends BaseUpdateRequest { + + /** + * 主键 + */ + @NotNull(message = "[id]主键不能为NULL") + private Long id; + + /** + * 角色主键 + */ + @NotNull(message = "[roleId]角色主键不能为NULL") + private Long roleId; + + /** + * 角色代码 + */ + @NotEmpty(message = "[roleCode]角色代码不能为空") + @Length(min = 0, max = 50, message = "[roleCode]角色代码长度不合法(0-50)") + private String roleCode; + + /** + * 资源主键 + */ + @NotNull(message = "[resId]资源主键不能为NULL") + private Long resId; + + /** + * 资源代码 + */ + @NotEmpty(message = "[resCode]资源代码不能为空") + @Length(min = 0, max = 50, message = "[resCode]资源代码长度不合法(0-50)") + private String resCode; + + 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 String getRoleCode() { + return this.roleCode; + } + + public void setRoleCode(String roleCode) { + this.roleCode = roleCode; + } + + public Long getResId() { + return this.resId; + } + + public void setResId(Long resId) { + this.resId = resId; + } + + public String getResCode() { + return this.resCode; + } + + public void setResCode(String resCode) { + this.resCode = resCode; + } +} diff --git a/src/main/resources/modules/SpringBoot/java/module/system/rsp/DeptTreeResponse.java b/src/main/resources/modules/SpringBoot/java/module/system/rsp/DeptTreeResponse.java index be1d65aa..8cad27b1 100644 --- a/src/main/resources/modules/SpringBoot/java/module/system/rsp/DeptTreeResponse.java +++ b/src/main/resources/modules/SpringBoot/java/module/system/rsp/DeptTreeResponse.java @@ -1,7 +1,7 @@ -package xyz.wbsite.module.system.rsp; +package ${basePackage}.module.system.rsp; -import xyz.wbsite.frame.base.BaseFindResponse; -import xyz.wbsite.module.system.ent.DeptTree; +import ${basePackage}.frame.base.BaseFindResponse; +import ${basePackage}.module.system.ent.DeptTree; /** * ResourceTreeResponse - 机构树 diff --git a/src/main/resources/modules/SpringBoot/java/module/system/rsp/ResCreateResponse.java b/src/main/resources/modules/SpringBoot/java/module/system/rsp/ResCreateResponse.java new file mode 100644 index 00000000..30dc2a05 --- /dev/null +++ b/src/main/resources/modules/SpringBoot/java/module/system/rsp/ResCreateResponse.java @@ -0,0 +1,26 @@ +package ${basePackage}.module.system.rsp; + +import ${basePackage}.frame.base.BaseResponse; + +/** + * ResCreateResponse - 资源 + * + * @author wangbing + * @version 0.0.1 + * @since 2020-01-05 + */ +public class ResCreateResponse extends BaseResponse { + + /** + * 主键 + */ + private Long id; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } +} diff --git a/src/main/resources/modules/SpringBoot/java/module/system/rsp/ResDeleteResponse.java b/src/main/resources/modules/SpringBoot/java/module/system/rsp/ResDeleteResponse.java new file mode 100644 index 00000000..aadf7048 --- /dev/null +++ b/src/main/resources/modules/SpringBoot/java/module/system/rsp/ResDeleteResponse.java @@ -0,0 +1,26 @@ +package ${basePackage}.module.system.rsp; + +import ${basePackage}.frame.base.BaseResponse; + +/** + * ResDeleteResponse - 资源 + * + * @author wangbing + * @version 0.0.1 + * @since 2020-01-05 + */ +public class ResDeleteResponse extends BaseResponse { + + /** + * 删除数目 + */ + private Long result; + + public Long getResult() { + return this.result; + } + + public void setResult(Long result) { + this.result = result; + } +} diff --git a/src/main/resources/modules/SpringBoot/java/module/system/rsp/ResFindResponse.java b/src/main/resources/modules/SpringBoot/java/module/system/rsp/ResFindResponse.java new file mode 100644 index 00000000..37e9da9d --- /dev/null +++ b/src/main/resources/modules/SpringBoot/java/module/system/rsp/ResFindResponse.java @@ -0,0 +1,14 @@ +package ${basePackage}.module.system.rsp; + +import ${basePackage}.frame.base.BaseFindResponse; +import ${basePackage}.module.system.ent.Res; + +/** + * ResFindResponse - 资源 + * + * @author wangbing + * @version 0.0.1 + * @since 2020-01-05 + */ +public class ResFindResponse extends BaseFindResponse { +} \ No newline at end of file diff --git a/src/main/resources/modules/SpringBoot/java/module/system/rsp/ResGetResponse.java b/src/main/resources/modules/SpringBoot/java/module/system/rsp/ResGetResponse.java new file mode 100644 index 00000000..a3906ee0 --- /dev/null +++ b/src/main/resources/modules/SpringBoot/java/module/system/rsp/ResGetResponse.java @@ -0,0 +1,27 @@ +package ${basePackage}.module.system.rsp; + +import ${basePackage}.module.system.ent.Res; +import ${basePackage}.frame.base.BaseResponse; + +/** + * ResGetResponse - 资源 + * + * @author wangbing + * @version 0.0.1 + * @since 2020-01-05 + */ +public class ResGetResponse extends BaseResponse { + + /** + * 资源 + */ + private Res res; + + public Res getRes() { + return this.res; + } + + public void setRes(Res res) { + this.res = res; + } +} diff --git a/src/main/resources/modules/SpringBoot/java/module/system/rsp/ResTreeResponse.java b/src/main/resources/modules/SpringBoot/java/module/system/rsp/ResTreeResponse.java new file mode 100644 index 00000000..737a6bff --- /dev/null +++ b/src/main/resources/modules/SpringBoot/java/module/system/rsp/ResTreeResponse.java @@ -0,0 +1,15 @@ +package ${basePackage}.module.system.rsp; + +import ${basePackage}.frame.base.BaseFindResponse; +import ${basePackage}.module.system.ent.ResTree; + +/** + * ResTreeResponse - 资源 + * + * @author author + * @version 0.0.1 + * @since 2017-01-01 + */ +public class ResTreeResponse extends BaseFindResponse { + +} diff --git a/src/main/resources/modules/SpringBoot/java/module/system/rsp/ResUpdateResponse.java b/src/main/resources/modules/SpringBoot/java/module/system/rsp/ResUpdateResponse.java new file mode 100644 index 00000000..8bd556e0 --- /dev/null +++ b/src/main/resources/modules/SpringBoot/java/module/system/rsp/ResUpdateResponse.java @@ -0,0 +1,26 @@ +package ${basePackage}.module.system.rsp; + +import ${basePackage}.frame.base.BaseResponse; + +/** + * ResUpdateResponse - 资源 + * + * @author wangbing + * @version 0.0.1 + * @since 2020-01-05 + */ +public class ResUpdateResponse extends BaseResponse { + + /** + * 更新数目 + */ + private Long result; + + public Long getResult() { + return this.result; + } + + public void setResult(Long result) { + this.result = result; + } +} diff --git a/src/main/resources/modules/SpringBoot/java/module/system/rsp/RoleResCreateResponse.java b/src/main/resources/modules/SpringBoot/java/module/system/rsp/RoleResCreateResponse.java new file mode 100644 index 00000000..cfe276ce --- /dev/null +++ b/src/main/resources/modules/SpringBoot/java/module/system/rsp/RoleResCreateResponse.java @@ -0,0 +1,26 @@ +package ${basePackage}.module.system.rsp; + +import ${basePackage}.frame.base.BaseResponse; + +/** + * RoleResCreateResponse - 角色资源关系 + * + * @author wangbing + * @version 0.0.1 + * @since 2020-01-05 + */ +public class RoleResCreateResponse extends BaseResponse { + + /** + * 主键 + */ + private Long id; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } +} diff --git a/src/main/resources/modules/SpringBoot/java/module/system/rsp/RoleResDeleteResponse.java b/src/main/resources/modules/SpringBoot/java/module/system/rsp/RoleResDeleteResponse.java new file mode 100644 index 00000000..65dd2c60 --- /dev/null +++ b/src/main/resources/modules/SpringBoot/java/module/system/rsp/RoleResDeleteResponse.java @@ -0,0 +1,26 @@ +package ${basePackage}.module.system.rsp; + +import ${basePackage}.frame.base.BaseResponse; + +/** + * RoleResDeleteResponse - 角色资源关系 + * + * @author wangbing + * @version 0.0.1 + * @since 2020-01-05 + */ +public class RoleResDeleteResponse extends BaseResponse { + + /** + * 删除数目 + */ + private Long result; + + public Long getResult() { + return this.result; + } + + public void setResult(Long result) { + this.result = result; + } +} diff --git a/src/main/resources/modules/SpringBoot/java/module/system/rsp/RoleResFindResponse.java b/src/main/resources/modules/SpringBoot/java/module/system/rsp/RoleResFindResponse.java new file mode 100644 index 00000000..00780efd --- /dev/null +++ b/src/main/resources/modules/SpringBoot/java/module/system/rsp/RoleResFindResponse.java @@ -0,0 +1,14 @@ +package ${basePackage}.module.system.rsp; + +import ${basePackage}.frame.base.BaseFindResponse; +import ${basePackage}.module.system.ent.RoleRes; + +/** + * RoleResFindResponse - 角色资源关系 + * + * @author wangbing + * @version 0.0.1 + * @since 2020-01-05 + */ +public class RoleResFindResponse extends BaseFindResponse { +} \ No newline at end of file diff --git a/src/main/resources/modules/SpringBoot/java/module/system/rsp/RoleResGetResponse.java b/src/main/resources/modules/SpringBoot/java/module/system/rsp/RoleResGetResponse.java new file mode 100644 index 00000000..ab98bb2b --- /dev/null +++ b/src/main/resources/modules/SpringBoot/java/module/system/rsp/RoleResGetResponse.java @@ -0,0 +1,27 @@ +package ${basePackage}.module.system.rsp; + +import ${basePackage}.module.system.ent.RoleRes; +import ${basePackage}.frame.base.BaseResponse; + +/** + * RoleResGetResponse - 角色资源关系 + * + * @author wangbing + * @version 0.0.1 + * @since 2020-01-05 + */ +public class RoleResGetResponse extends BaseResponse { + + /** + * 角色资源关系 + */ + private RoleRes roleRes; + + public RoleRes getRoleRes() { + return this.roleRes; + } + + public void setRoleRes(RoleRes roleRes) { + this.roleRes = roleRes; + } +} diff --git a/src/main/resources/modules/SpringBoot/java/module/system/rsp/RoleResUpdateResponse.java b/src/main/resources/modules/SpringBoot/java/module/system/rsp/RoleResUpdateResponse.java new file mode 100644 index 00000000..dc0a6d8f --- /dev/null +++ b/src/main/resources/modules/SpringBoot/java/module/system/rsp/RoleResUpdateResponse.java @@ -0,0 +1,26 @@ +package ${basePackage}.module.system.rsp; + +import ${basePackage}.frame.base.BaseResponse; + +/** + * RoleResUpdateResponse - 角色资源关系 + * + * @author wangbing + * @version 0.0.1 + * @since 2020-01-05 + */ +public class RoleResUpdateResponse extends BaseResponse { + + /** + * 更新数目 + */ + private Long result; + + public Long getResult() { + return this.result; + } + + public void setResult(Long result) { + this.result = result; + } +} diff --git a/src/main/resources/modules/SpringBoot/resources/dbtool/system/MySQL_ALL_TABLE.sql b/src/main/resources/modules/SpringBoot/resources/dbtool/system/MySQL_ALL_TABLE.sql index dcc97cdd..131a3173 100644 --- a/src/main/resources/modules/SpringBoot/resources/dbtool/system/MySQL_ALL_TABLE.sql +++ b/src/main/resources/modules/SpringBoot/resources/dbtool/system/MySQL_ALL_TABLE.sql @@ -42,17 +42,19 @@ PRIMARY KEY (`ID`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='字典项'; -- ---------------------------- --- Table structure for RESOURCE - 资源 +-- Table structure for RES - 资源 -- Target : MySQL -- Author : wangbing --- Date: : 2019-12-27 +-- Date: : 2020-01-05 -- ---------------------------- -CREATE TABLE `SYS_RESOURCE` ( +CREATE TABLE `SYS_RES` ( `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 '资源类型', + `RES_CODE` VARCHAR(50) NOT NULL COMMENT '资源代码', + `RES_NAME` VARCHAR(250) COMMENT '资源名称', + `RES_TYPE` VARCHAR(20) NOT NULL COMMENT '资源类型', + `RES_VALUE` VARCHAR(100) NOT NULL COMMENT '资源内容', + `SUP_CODE` VARCHAR(50) COMMENT '上级代码', + `SUP_NAME` VARCHAR(50) 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 '是否已删除', @@ -63,6 +65,27 @@ CREATE TABLE `SYS_RESOURCE` ( PRIMARY KEY (`ID`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='资源'; +-- ---------------------------- +-- Table structure for ROLE_RES - 角色资源关系 +-- Target : MySQL +-- Author : wangbing +-- Date: : 2020-01-05 +-- ---------------------------- +CREATE TABLE `SYS_ROLE_RES` ( + `ID` BIGINT(20) NOT NULL COMMENT '主键', + `ROLE_ID` BIGINT(20) NOT NULL COMMENT '角色主键', + `ROLE_CODE` VARCHAR(50) NOT NULL COMMENT '角色代码', + `RES_ID` BIGINT(20) NOT NULL COMMENT '资源主键', + `RES_CODE` VARCHAR(50) 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='角色资源关系'; + -- ---------------------------- -- Table structure for USER - 用户 -- Target : MySQL @@ -203,22 +226,3 @@ CREATE TABLE `SYS_USER_ROLE` ( PRIMARY KEY (`ID`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='用户角色授权'; --- ---------------------------- --- Table structure for ROLE_RESOURCE - 角色资源关系 --- Target : MySQL --- Author : wangbing --- Date: : 2019-12-27 --- ---------------------------- -CREATE TABLE `SYS_ROLE_RESOURCE` ( - `ID` BIGINT(20) NOT NULL COMMENT '主键', - `ROLE_ID` BIGINT(20) NOT NULL COMMENT '角色主键', - `RESOURCE_ID` BIGINT(20) 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='角色资源关系'; - diff --git a/src/main/resources/modules/SpringBoot/resources/dbtool/system/MySQL_RES.sql b/src/main/resources/modules/SpringBoot/resources/dbtool/system/MySQL_RES.sql new file mode 100644 index 00000000..0de877ac --- /dev/null +++ b/src/main/resources/modules/SpringBoot/resources/dbtool/system/MySQL_RES.sql @@ -0,0 +1,23 @@ +-- ---------------------------- +-- Table structure for RES - 资源 +-- Target : MySQL +-- Author : wangbing +-- Date: : 2020-01-05 +-- ---------------------------- +CREATE TABLE `SYS_RES` ( + `ID` BIGINT(20) NOT NULL COMMENT '主键', + `RES_CODE` VARCHAR(50) NOT NULL COMMENT '资源代码', + `RES_NAME` VARCHAR(250) COMMENT '资源名称', + `RES_TYPE` VARCHAR(20) NOT NULL COMMENT '资源类型', + `RES_VALUE` VARCHAR(100) NOT NULL COMMENT '资源内容', + `SUP_CODE` VARCHAR(50) COMMENT '上级代码', + `SUP_NAME` VARCHAR(50) 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='资源'; diff --git a/src/main/resources/modules/SpringBoot/resources/dbtool/system/MySQL_ROLE_RES.sql b/src/main/resources/modules/SpringBoot/resources/dbtool/system/MySQL_ROLE_RES.sql new file mode 100644 index 00000000..e2177b6a --- /dev/null +++ b/src/main/resources/modules/SpringBoot/resources/dbtool/system/MySQL_ROLE_RES.sql @@ -0,0 +1,20 @@ +-- ---------------------------- +-- Table structure for ROLE_RES - 角色资源关系 +-- Target : MySQL +-- Author : wangbing +-- Date: : 2020-01-05 +-- ---------------------------- +CREATE TABLE `SYS_ROLE_RES` ( + `ID` BIGINT(20) NOT NULL COMMENT '主键', + `ROLE_ID` BIGINT(20) NOT NULL COMMENT '角色主键', + `ROLE_CODE` VARCHAR(50) NOT NULL COMMENT '角色代码', + `RES_ID` BIGINT(20) NOT NULL COMMENT '资源主键', + `RES_CODE` VARCHAR(50) 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='角色资源关系'; diff --git a/src/main/resources/modules/SpringBoot/resources/dbtool/wadmin.xml b/src/main/resources/modules/SpringBoot/resources/dbtool/wadmin.xml index f5f44b7a..79e049bd 100644 --- a/src/main/resources/modules/SpringBoot/resources/dbtool/wadmin.xml +++ b/src/main/resources/modules/SpringBoot/resources/dbtool/wadmin.xml @@ -1,7 +1,7 @@ wadmin -${basePackage} +xyz.wbsite wangbing false false @@ -43,13 +43,15 @@ - +
- - - - + + + + + + @@ -163,11 +165,13 @@
- +
- + + + diff --git a/src/main/resources/modules/SpringBoot/resources/templates/screen/index.ftl b/src/main/resources/modules/SpringBoot/resources/templates/screen/index.ftl index 56c72f42..f7432347 100644 --- a/src/main/resources/modules/SpringBoot/resources/templates/screen/index.ftl +++ b/src/main/resources/modules/SpringBoot/resources/templates/screen/index.ftl @@ -19,7 +19,7 @@ 字典管理 文件管理 - 资源管理 + 资源管理 用户管理 部门管理 角色管理 diff --git a/src/main/resources/modules/SpringBoot/resources/templates/screen/module/mgr.ftl b/src/main/resources/modules/SpringBoot/resources/templates/screen/module/mgr.ftl index 5c359799..294f88d8 100644 --- a/src/main/resources/modules/SpringBoot/resources/templates/screen/module/mgr.ftl +++ b/src/main/resources/modules/SpringBoot/resources/templates/screen/module/mgr.ftl @@ -165,7 +165,7 @@ - + <#list fields as item> <#if !item.isSystem> diff --git a/src/main/resources/modules/SpringBoot/resources/templates/screen/module/system/resource.ftl b/src/main/resources/modules/SpringBoot/resources/templates/screen/module/system/res.ftl similarity index 84% rename from src/main/resources/modules/SpringBoot/resources/templates/screen/module/system/resource.ftl rename to src/main/resources/modules/SpringBoot/resources/templates/screen/module/system/res.ftl index 8f8272be..6e7ad817 100644 --- a/src/main/resources/modules/SpringBoot/resources/templates/screen/module/system/resource.ftl +++ b/src/main/resources/modules/SpringBoot/resources/templates/screen/module/system/res.ftl @@ -5,18 +5,17 @@ 列表展示 - - + + - - + + - - + + - - + + @@ -104,7 +103,7 @@ - - + - - + + - - - - - + + dict-name="RES_TYPE"> + + + @@ -246,12 +245,12 @@ el: "#app", data: { module: 'system', - target: 'resource', + target: 'res', vm: {//条件及分页参数 - code: "", - value: "", - comment: "", - resourceType: "", + resCode: "", + resName: "", + resType: "", + resValue: "", valid: "", pageNumber: 1, pageSize: 10, @@ -263,28 +262,28 @@ title: "", dialog: false, id: '', - code: "", - value: "", - comment: "", - resourceType: "", + resCode: "", + resName: "", + resType: "", + resValue: "", valid: "", rowVersion: "" }, formRules: { - code: [ + resCode: [ {required: true, message: '资源代码不能为空', trigger: 'blur'}, {min: 1, max: 50, message: '资源代码长度在 1 到 50 个字符', trigger: 'blur'} ], - value: [ - {required: true, message: '资源内容不能为空', trigger: 'blur'}, - {min: 1, max: 100, message: '资源内容长度在 1 到 100 个字符', trigger: 'blur'} + resName: [ + {required: true, message: '资源名称不能为空', trigger: 'blur'}, + {min: 1, max: 100, message: '资源名称长度在 1 到 100 个字符', trigger: 'blur'} ], - comment: [ - {min: 1, max: 255, message: '资源描述长度在 1 到 255 个字符', trigger: 'blur'} - ], - resourceType: [ + resType: [ {required: true, message: '资源类型不能为空', trigger: 'blur'}, ], + resValue: [ + {min: 1, max: 255, message: '资源内容长度在 1 到 255 个字符', trigger: 'blur'} + ], valid: [ {required: true, message: '是否有效不能为空', trigger: 'blur'}, ], @@ -296,31 +295,30 @@ onCreate: function () { this.form.title = "资源新增"; this.form.dialog = true; - this.form.id = ""; - this.form.code = ""; - this.form.value = ""; - this.form.comment = ""; - this.form.resourceType = ""; - this.form.valid = ""; + this.form.resCode = ""; + this.form.resName = ""; + this.form.resType = ""; + this.form.resValue = ""; + this.form.valid = true; }, onTreeCreate: function (pItem) { this.form.title = "资源新增"; this.form.dialog = true; this.form.id = ""; - this.form.code = pItem.code + "_"; - this.form.value = ""; - this.form.comment = ""; - this.form.resourceType = ""; - this.form.valid = ""; + this.form.resCode = pItem.code + "_"; + this.form.resName = ""; + this.form.resType = ""; + this.form.resValue = ""; + this.form.valid = true; }, onTreeEdit: function (pItem) { this.form.title = "资源编辑"; this.form.dialog = true; this.form.id = pItem.id; - this.form.code = pItem.code; - this.form.value = pItem.value; - this.form.comment = pItem.comment; - this.form.resourceType = pItem.resourceType; + this.form.resCode = pItem.resCode; + this.form.resName = pItem.resName; + this.form.resType = pItem.resType; + this.form.resValue = pItem.resValue; this.form.valid = pItem.valid; this.form.rowVersion = pItem.rowVersion; }, @@ -339,10 +337,10 @@ this.form.title = "资源编辑"; this.form.dialog = true; this.form.id = item.id; - this.form.code = item.code; - this.form.value = item.value; - this.form.comment = item.comment; - this.form.resourceType = item.resourceType; + this.form.resCode = item.resCode; + this.form.resName = item.resName; + this.form.resType = item.resType; + this.form.resValue = item.resValue; this.form.valid = item.valid; this.form.rowVersion = item.rowVersion; break; @@ -357,7 +355,7 @@ onLoadTree: function () { new Ajax() .module("system") - .target("resource") + .target("res") .method("tree") .data({}) .post(function (response) { diff --git a/src/main/resources/modules/SpringBoot/test/system/DeptTest.java b/src/main/resources/modules/SpringBoot/test/system/DeptTest.java index 6e6823c8..209c8491 100644 --- a/src/main/resources/modules/SpringBoot/test/system/DeptTest.java +++ b/src/main/resources/modules/SpringBoot/test/system/DeptTest.java @@ -1,4 +1,4 @@ -package xyz.wbsite.system; +package ${basePackage}.system; import org.junit.Test; import org.junit.runner.RunWith; @@ -7,10 +7,10 @@ import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.annotation.Rollback; import org.springframework.test.context.junit4.SpringRunner; import org.springframework.transaction.annotation.Transactional; -import xyz.wbsite.frame.base.Token; -import xyz.wbsite.module.system.mgr.DeptManager; -import xyz.wbsite.module.system.req.*; -import xyz.wbsite.module.system.rsp.*; +import ${basePackage}.frame.base.Token; +import ${basePackage}.module.system.mgr.DeptManager; +import ${basePackage}.module.system.req.*; +import ${basePackage}.module.system.rsp.*; import static org.junit.Assert.assertTrue; diff --git a/src/main/resources/modules/SpringBoot/test/system/ResourceTest.java b/src/main/resources/modules/SpringBoot/test/system/ResourceTest.java deleted file mode 100644 index b93b177a..00000000 --- a/src/main/resources/modules/SpringBoot/test/system/ResourceTest.java +++ /dev/null @@ -1,139 +0,0 @@ -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.req.*; -import ${basePackage}.module.system.rsp.*; - -import static org.junit.Assert.assertTrue; - - -/** - * ResourceTest - - 资源测试用例 - * - * @author author - * @version 0.0.1 - * @since 2017-01-01 - */ -@RunWith(SpringRunner.class) -@SpringBootTest -@Transactional -public class ResourceTest { - - @Autowired - private Token token; - - @Autowired - private ${basePackage}.module.system.mgr.ResourceManager resourceManager; - - @Test - public void testCreate() { - ResourceCreateRequest request = new ResourceCreateRequest(); - request.setValue("资源内容"); - request.setComment("资源描述"); - request.setResourceType("code"); - request.setValid(true); - - ResourceCreateResponse response = resourceManager.create(request,token); - - assertTrue(!response.hasError()); - } - - @Test - public void testDelete() { - - //创建数据 - ResourceCreateRequest createRequest = new ResourceCreateRequest(); - createRequest.setValue("资源内容"); - createRequest.setComment("资源描述"); - createRequest.setResourceType("code"); - createRequest.setValid(true); - - ResourceCreateResponse createResponse = resourceManager.create(createRequest,token); - - assertTrue(!createResponse.hasError() && createResponse.getId() > 0); - //删除数据 - ResourceDeleteRequest request = new ResourceDeleteRequest(); - request.setId(createResponse.getId()); - - ResourceDeleteResponse response = resourceManager.delete(request,token); - - assertTrue(!response.hasError() && response.getResult() == 1L); - } - - @Test - public void testUpdate() { - //创建数据 - ResourceCreateRequest createRequest = new ResourceCreateRequest(); - createRequest.setValue("资源内容"); - createRequest.setComment("资源描述"); - createRequest.setResourceType("code"); - createRequest.setValid(true); - - ResourceCreateResponse createResponse = resourceManager.create(createRequest, token); - - assertTrue(!createResponse.hasError()); - - //更新数据 - ResourceUpdateRequest request = new ResourceUpdateRequest(); - request.setId(createResponse.getId()); - request.setValue("资源内容"); - request.setComment("资源描述"); - request.setResourceType("code"); - request.setValid(true); - - ResourceUpdateResponse response = resourceManager.update(request,token); - - assertTrue(!response.hasError() && response.getResult() == 1L); - } - - @Test - public void testFind() { - ResourceFindRequest request = new ResourceFindRequest(); - request.setValue("资源内容"); - request.setComment("资源描述"); - request.setResourceType("code"); - request.setValid(true); - - ResourceFindResponse response = resourceManager.find(request,token); - - assertTrue(!response.hasError()); - } - - @Test - public void testGet() { - //创建数据 - ResourceCreateRequest createRequest = new ResourceCreateRequest(); - createRequest.setValue("资源内容"); - createRequest.setComment("资源描述"); - createRequest.setResourceType("code"); - createRequest.setValid(true); - - ResourceCreateResponse createResponse = resourceManager.create(createRequest, token); - - assertTrue(!createResponse.hasError()); - - //获得数据 - ResourceGetRequest request = new ResourceGetRequest(); - request.setId(createResponse.getId()); - - ResourceGetResponse response = resourceManager.get(request,token); - - assertTrue(!response.hasError() && response.getResource() != null); - } - - @Test - public void testTree() { - //创建数据 - ResourceTreeRequest request = new ResourceTreeRequest(); - - ResourceTreeResponse response = resourceManager.tree(request, token); - - assertTrue(!response.hasError()); - } -} diff --git a/src/main/resources/modules/SpringBoot/test/system/RoleResourceTest.java b/src/main/resources/modules/SpringBoot/test/system/RoleResourceTest.java deleted file mode 100644 index 0b552af7..00000000 --- a/src/main/resources/modules/SpringBoot/test/system/RoleResourceTest.java +++ /dev/null @@ -1,118 +0,0 @@ -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.RoleResourceManager; -import ${basePackage}.module.system.req.*; -import ${basePackage}.module.system.rsp.*; - -import static org.junit.Assert.assertTrue; - - -/** - * RoleResourceTest - - 角色资源关系测试用例 - * - * @author wangbing - * @version 0.0.1 - * @since 2019-12-27 - */ -@RunWith(SpringRunner.class) -@SpringBootTest -@Transactional -public class RoleResourceTest { - - @Autowired - private Token token; - - @Autowired - private RoleResourceManager roleResourceManager; - - @Test - public void testCreate() { - RoleResourceCreateRequest request = new RoleResourceCreateRequest(); - request.setRoleId(1L); - request.setResourceId(1L); - - RoleResourceCreateResponse response = roleResourceManager.create(request,token); - - assertTrue(!response.hasError()); - } - - @Test - public void testDelete() { - - //创建数据 - RoleResourceCreateRequest createRequest = new RoleResourceCreateRequest(); - createRequest.setRoleId(1L); - createRequest.setResourceId(1L); - - RoleResourceCreateResponse createResponse = roleResourceManager.create(createRequest,token); - - assertTrue(!createResponse.hasError() && createResponse.getId() > 0); - //删除数据 - RoleResourceDeleteRequest request = new RoleResourceDeleteRequest(); - request.setId(createResponse.getId()); - - RoleResourceDeleteResponse response = roleResourceManager.delete(request,token); - - assertTrue(!response.hasError() && response.getResult() == 1L); - } - - @Test - public void testUpdate() { - //创建数据 - RoleResourceCreateRequest createRequest = new RoleResourceCreateRequest(); - createRequest.setRoleId(1L); - createRequest.setResourceId(1L); - - RoleResourceCreateResponse createResponse = roleResourceManager.create(createRequest, token); - - assertTrue(!createResponse.hasError()); - - //更新数据 - RoleResourceUpdateRequest request = new RoleResourceUpdateRequest(); - request.setId(createResponse.getId()); - request.setRoleId(1L); - request.setResourceId(1L); - - RoleResourceUpdateResponse response = roleResourceManager.update(request,token); - - assertTrue(!response.hasError() && response.getResult() == 1L); - } - - @Test - public void testFind() { - RoleResourceFindRequest request = new RoleResourceFindRequest(); - request.setRoleId(1L); - request.setResourceId(1L); - - RoleResourceFindResponse response = roleResourceManager.find(request,token); - - assertTrue(!response.hasError()); - } - - @Test - public void testGet() { - //创建数据 - RoleResourceCreateRequest createRequest = new RoleResourceCreateRequest(); - createRequest.setRoleId(1L); - createRequest.setResourceId(1L); - - RoleResourceCreateResponse createResponse = roleResourceManager.create(createRequest, token); - - assertTrue(!createResponse.hasError()); - - //获得数据 - RoleResourceGetRequest request = new RoleResourceGetRequest(); - request.setId(createResponse.getId()); - - RoleResourceGetResponse response = roleResourceManager.get(request,token); - - assertTrue(!response.hasError() && response.getRoleResource() != null); - } -} diff --git a/src/main/resources/modules/SpringBoot/test/system/UserTest.java b/src/main/resources/modules/SpringBoot/test/system/UserTest.java index 09e82a60..0209e4a2 100644 --- a/src/main/resources/modules/SpringBoot/test/system/UserTest.java +++ b/src/main/resources/modules/SpringBoot/test/system/UserTest.java @@ -6,18 +6,18 @@ 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 xyz.wbsite.frame.base.Token; -import xyz.wbsite.module.system.mgr.UserManager; -import xyz.wbsite.module.system.req.UserCreateRequest; -import xyz.wbsite.module.system.req.UserDeleteRequest; -import xyz.wbsite.module.system.req.UserFindRequest; -import xyz.wbsite.module.system.req.UserGetRequest; -import xyz.wbsite.module.system.req.UserUpdateRequest; -import xyz.wbsite.module.system.rsp.UserCreateResponse; -import xyz.wbsite.module.system.rsp.UserDeleteResponse; -import xyz.wbsite.module.system.rsp.UserFindResponse; -import xyz.wbsite.module.system.rsp.UserGetResponse; -import xyz.wbsite.module.system.rsp.UserUpdateResponse; +import ${basePackage}.frame.base.Token; +import ${basePackage}.module.system.mgr.UserManager; +import ${basePackage}.module.system.req.UserCreateRequest; +import ${basePackage}.module.system.req.UserDeleteRequest; +import ${basePackage}.module.system.req.UserFindRequest; +import ${basePackage}.module.system.req.UserGetRequest; +import ${basePackage}.module.system.req.UserUpdateRequest; +import ${basePackage}.module.system.rsp.UserCreateResponse; +import ${basePackage}.module.system.rsp.UserDeleteResponse; +import ${basePackage}.module.system.rsp.UserFindResponse; +import ${basePackage}.module.system.rsp.UserGetResponse; +import ${basePackage}.module.system.rsp.UserUpdateResponse; import static org.junit.Assert.assertTrue;