From bfcb35400f9cf730e60d746b27fcf131d4e53754 Mon Sep 17 00:00:00 2001 From: RuoYi Date: Sun, 5 Aug 2018 11:05:26 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B2=97=E4=BD=8D=E5=90=8D=E7=A7=B0=E7=BC=96?= =?UTF-8?q?=E7=A0=81=E5=94=AF=E4=B8=80=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 2 +- .../ruoyi/common/constant/UserConstants.java | 10 +++- .../post/controller/PostController.java | 33 ++++++++++++ .../system/post/mapper/PostMapper.java | 16 ++++++ .../system/post/service/IPostService.java | 16 ++++++ .../system/post/service/PostServiceImpl.java | 38 +++++++++++++ src/main/resources/application.yml | 2 +- .../resources/mybatis/system/PostMapper.xml | 10 ++++ src/main/resources/templates/include.html | 4 +- src/main/resources/templates/index.html | 4 +- src/main/resources/templates/login.html | 4 +- src/main/resources/templates/main.html | 32 ++++++++++- .../resources/templates/system/post/add.html | 48 ++++++++++++++--- .../resources/templates/system/post/edit.html | 54 ++++++++++++++++--- 14 files changed, 251 insertions(+), 22 deletions(-) diff --git a/pom.xml b/pom.xml index f8fe87a1..3fbb5d49 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ com.ruoyi RuoYi - 2.2.0 + 2.3.0 jar RuoYi diff --git a/src/main/java/com/ruoyi/common/constant/UserConstants.java b/src/main/java/com/ruoyi/common/constant/UserConstants.java index 51141843..40a551b5 100644 --- a/src/main/java/com/ruoyi/common/constant/UserConstants.java +++ b/src/main/java/com/ruoyi/common/constant/UserConstants.java @@ -48,11 +48,19 @@ public class UserConstants /** 角色名称是否唯一的返回结果码 */ public final static String ROLE_NAME_UNIQUE = "0"; public final static String ROLE_NAME_NOT_UNIQUE = "1"; - + + /** 岗位名称是否唯一的返回结果码 */ + public final static String POST_NAME_UNIQUE = "0"; + public final static String POST_NAME_NOT_UNIQUE = "1"; + /** 角色权限是否唯一的返回结果码 */ public final static String ROLE_KEY_UNIQUE = "0"; public final static String ROLE_KEY_NOT_UNIQUE = "1"; + /** 岗位编码是否唯一的返回结果码 */ + public final static String POST_CODE_UNIQUE = "0"; + public final static String POST_CODE_NOT_UNIQUE = "1"; + /** 菜单名称是否唯一的返回结果码 */ public final static String MENU_NAME_UNIQUE = "0"; public final static String MENU_NAME_NOT_UNIQUE = "1"; diff --git a/src/main/java/com/ruoyi/project/system/post/controller/PostController.java b/src/main/java/com/ruoyi/project/system/post/controller/PostController.java index 71460419..8e4ed328 100644 --- a/src/main/java/com/ruoyi/project/system/post/controller/PostController.java +++ b/src/main/java/com/ruoyi/project/system/post/controller/PostController.java @@ -1,6 +1,7 @@ package com.ruoyi.project.system.post.controller; import java.util.List; + import org.apache.shiro.authz.annotation.RequiresPermissions; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; @@ -10,6 +11,8 @@ import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; + +import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.poi.ExcelUtil; import com.ruoyi.framework.aspectj.lang.annotation.Log; import com.ruoyi.framework.aspectj.lang.constant.BusinessType; @@ -127,4 +130,34 @@ public class PostController extends BaseController return toAjax(postService.updatePost(post)); } + /** + * 校验岗位名称 + */ + @PostMapping("/checkPostNameUnique") + @ResponseBody + public String checkPostNameUnique(Post post) + { + String uniqueFlag = "0"; + if (StringUtils.isNotNull(post)) + { + uniqueFlag = postService.checkPostNameUnique(post); + } + return uniqueFlag; + } + + /** + * 校验岗位编码 + */ + @PostMapping("/checkPostCodeUnique") + @ResponseBody + public String checkPostCodeUnique(Post post) + { + String uniqueFlag = "0"; + if (StringUtils.isNotNull(post)) + { + uniqueFlag = postService.checkPostCodeUnique(post); + } + return uniqueFlag; + } + } diff --git a/src/main/java/com/ruoyi/project/system/post/mapper/PostMapper.java b/src/main/java/com/ruoyi/project/system/post/mapper/PostMapper.java index ffeeb865..7b71d281 100644 --- a/src/main/java/com/ruoyi/project/system/post/mapper/PostMapper.java +++ b/src/main/java/com/ruoyi/project/system/post/mapper/PostMapper.java @@ -66,4 +66,20 @@ public interface PostMapper */ public int insertPost(Post post); + /** + * 校验岗位名称 + * + * @param post 岗位信息 + * @return 结果 + */ + public Post checkPostNameUnique(String postName); + + /** + * 校验岗位编码 + * + * @param post 岗位信息 + * @return 结果 + */ + public Post checkPostCodeUnique(String postCode); + } diff --git a/src/main/java/com/ruoyi/project/system/post/service/IPostService.java b/src/main/java/com/ruoyi/project/system/post/service/IPostService.java index 2c5c84ff..93edd60c 100644 --- a/src/main/java/com/ruoyi/project/system/post/service/IPostService.java +++ b/src/main/java/com/ruoyi/project/system/post/service/IPostService.java @@ -73,4 +73,20 @@ public interface IPostService * @return 结果 */ public int countUserPostById(Long postId); + + /** + * 校验岗位名称 + * + * @param post 岗位信息 + * @return 结果 + */ + public String checkPostNameUnique(Post post); + + /** + * 校验岗位编码 + * + * @param post 岗位信息 + * @return 结果 + */ + public String checkPostCodeUnique(Post post); } diff --git a/src/main/java/com/ruoyi/project/system/post/service/PostServiceImpl.java b/src/main/java/com/ruoyi/project/system/post/service/PostServiceImpl.java index 06af7151..9f1c868d 100644 --- a/src/main/java/com/ruoyi/project/system/post/service/PostServiceImpl.java +++ b/src/main/java/com/ruoyi/project/system/post/service/PostServiceImpl.java @@ -3,7 +3,9 @@ package com.ruoyi.project.system.post.service; import java.util.List; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import com.ruoyi.common.constant.UserConstants; import com.ruoyi.common.support.Convert; +import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.security.ShiroUtils; import com.ruoyi.project.system.post.domain.Post; import com.ruoyi.project.system.post.mapper.PostMapper; @@ -142,4 +144,40 @@ public class PostServiceImpl implements IPostService return userPostMapper.countUserPostById(postId); } + /** + * 校验岗位名称是否唯一 + * + * @param post 岗位信息 + * @return 结果 + */ + @Override + public String checkPostNameUnique(Post post) + { + Long postId = StringUtils.isNull(post.getPostId()) ? -1L : post.getPostId(); + Post info = postMapper.checkPostNameUnique(post.getPostName()); + if (StringUtils.isNotNull(info) && info.getPostId().longValue() != postId.longValue()) + { + return UserConstants.POST_NAME_NOT_UNIQUE; + } + return UserConstants.POST_NAME_UNIQUE; + } + + /** + * 校验岗位编码是否唯一 + * + * @param post 岗位信息 + * @return 结果 + */ + @Override + public String checkPostCodeUnique(Post post) + { + Long postId = StringUtils.isNull(post.getPostId()) ? -1L : post.getPostId(); + Post info = postMapper.checkPostCodeUnique(post.getPostCode()); + if (StringUtils.isNotNull(info) && info.getPostId().longValue() != postId.longValue()) + { + return UserConstants.POST_CODE_NOT_UNIQUE; + } + return UserConstants.POST_CODE_UNIQUE; + } + } diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index a9cd9161..5ca98dfe 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -3,7 +3,7 @@ ruoyi: #名称 name: RuoYi #版本 - version: 2.2.0 + version: 2.3.0 #版权年份 copyrightYear: 2018 #头像上传路径 diff --git a/src/main/resources/mybatis/system/PostMapper.xml b/src/main/resources/mybatis/system/PostMapper.xml index b5d44ff8..7634fddb 100644 --- a/src/main/resources/mybatis/system/PostMapper.xml +++ b/src/main/resources/mybatis/system/PostMapper.xml @@ -53,6 +53,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" where post_id = #{postId} + + + + delete from sys_post where post_id in diff --git a/src/main/resources/templates/include.html b/src/main/resources/templates/include.html index 5f17fae2..a9fb90a6 100644 --- a/src/main/resources/templates/include.html +++ b/src/main/resources/templates/include.html @@ -38,8 +38,8 @@ - - + + diff --git a/src/main/resources/templates/index.html b/src/main/resources/templates/index.html index 6692923f..bfc46acb 100644 --- a/src/main/resources/templates/index.html +++ b/src/main/resources/templates/index.html @@ -15,7 +15,7 @@ - + @@ -136,7 +136,7 @@ - + diff --git a/src/main/resources/templates/login.html b/src/main/resources/templates/login.html index f15e44f5..3856233a 100644 --- a/src/main/resources/templates/login.html +++ b/src/main/resources/templates/login.html @@ -12,7 +12,7 @@ - + @@ -82,7 +82,7 @@ - + diff --git a/src/main/resources/templates/main.html b/src/main/resources/templates/main.html index 5280abfc..fbe1f4c5 100644 --- a/src/main/resources/templates/main.html +++ b/src/main/resources/templates/main.html @@ -94,13 +94,43 @@
+
+
+
+ v2.3.02018.08.06 +
+
+
+
+
    +
  1. 支持表格不分页开关控制
  2. +
  3. 修改字典类型同步修改字典数据
  4. +
  5. 代码生成新增修改后缀处理
  6. +
  7. 代码生成新增实体toString
  8. +
  9. 代码生成非字符串去除!=''
  10. +
  11. 导出数据前加载遮罩层
  12. +
  13. 部门删除校验条件修改
  14. +
  15. 搜索查询下载优化
  16. +
  17. 手机打开弹出层自适应
  18. +
  19. 角色岗位禁用显示置灰
  20. +
  21. 角色禁用不显示菜单
  22. +
  23. 新增导出权限
  24. +
  25. 角色权限唯一校验
  26. +
  27. 岗位名称编码唯一校验
  28. +
  29. TreeTable优化
  30. +
  31. 支持多数据源
  32. +
  33. 其他细节优化
  34. +
+
+
+
v2.2.02018.07.23
-
+
  1. 修复批量生成代码异常问题
  2. diff --git a/src/main/resources/templates/system/post/add.html b/src/main/resources/templates/system/post/add.html index 383a631d..a5d9290f 100644 --- a/src/main/resources/templates/system/post/add.html +++ b/src/main/resources/templates/system/post/add.html @@ -6,15 +6,15 @@
    - +
    - +
    - +
    - +
    @@ -52,17 +52,53 @@ $("#form-post-add").validate({ rules:{ - postCode:{ + postName:{ required:true, + remote: { + url: ctx + "system/post/checkPostNameUnique", + type: "post", + dataType: "json", + data: { + "postName" : function() { + return $.trim($("#postName").val()); + } + }, + dataFilter: function(data, type) { + if (data == "0") return true; + else return false; + } + } }, - postName:{ + postCode:{ required:true, + remote: { + url: ctx + "system/post/checkPostCodeUnique", + type: "post", + dataType: "json", + data: { + "postCode" : function() { + return $.trim($("#postCode").val()); + } + }, + dataFilter: function(data, type) { + if (data == "0") return true; + else return false; + } + } }, postSort:{ required:true, digits:true }, }, + messages: { + "postCode": { + remote: "岗位编码已经存在" + }, + "postName": { + remote: "岗位名称已经存在" + } + }, submitHandler:function(form){ $.operate.save(prefix + "/add", $('#form-post-add').serialize()); } diff --git a/src/main/resources/templates/system/post/edit.html b/src/main/resources/templates/system/post/edit.html index 6e2cf5b5..0498c887 100644 --- a/src/main/resources/templates/system/post/edit.html +++ b/src/main/resources/templates/system/post/edit.html @@ -7,15 +7,15 @@
    - +
    - +
    - +
    - +
    @@ -53,17 +53,59 @@ $("#form-post-edit").validate({ rules:{ - postCode:{ + postName:{ required:true, + remote: { + url: ctx + "system/post/checkPostNameUnique", + type: "post", + dataType: "json", + data: { + "postId": function() { + return $("input[name='postId']").val(); + }, + "postName" : function() { + return $.trim($("#postName").val()); + } + }, + dataFilter: function(data, type) { + if (data == "0") return true; + else return false; + } + } }, - postName:{ + postCode:{ required:true, + remote: { + url: ctx + "system/post/checkPostCodeUnique", + type: "post", + dataType: "json", + data: { + "postId": function() { + return $("input[name='postId']").val(); + }, + "postCode" : function() { + return $.trim($("#postCode").val()); + } + }, + dataFilter: function(data, type) { + if (data == "0") return true; + else return false; + } + } }, postSort:{ required:true, digits:true }, }, + messages: { + "postCode": { + remote: "岗位编码已经存在" + }, + "postName": { + remote: "岗位名称已经存在" + } + }, submitHandler:function(form){ $.operate.save(prefix + "/edit", $('#form-post-edit').serialize()); }