岗位名称编码唯一校验

master
RuoYi 6 years ago committed by Limy
parent 5a0ab9bfac
commit bfcb35400f

@ -5,7 +5,7 @@
<groupId>com.ruoyi</groupId>
<artifactId>RuoYi</artifactId>
<version>2.2.0</version>
<version>2.3.0</version>
<packaging>jar</packaging>
<name>RuoYi</name>

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

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

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

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

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

@ -3,7 +3,7 @@ ruoyi:
#名称
name: RuoYi
#版本
version: 2.2.0
version: 2.3.0
#版权年份
copyrightYear: 2018
#头像上传路径

@ -53,6 +53,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where post_id = #{postId}
</select>
<select id="checkPostNameUnique" parameterType="String" resultMap="PostResult">
<include refid="selectPostVo"/>
where post_name=#{postName}
</select>
<select id="checkPostCodeUnique" parameterType="String" resultMap="PostResult">
<include refid="selectPostVo"/>
where post_code=#{postCode}
</select>
<delete id="deletePostByIds" parameterType="Long">
delete from sys_post where post_id in
<foreach collection="array" item="postId" open="(" separator="," close=")">

@ -38,8 +38,8 @@
<script th:src="@{/ajax/libs/blockUI/jquery.blockUI.js}"></script>
<script th:src="@{/ajax/libs/layer/layer.min.js}"></script>
<script th:src="@{/ajax/libs/layui/layui.js}"></script>
<script th:src="@{/ruoyi/js/common.js?v=2.2.0}"></script>
<script th:src="@{/ruoyi/js/ry-ui.min.js?v=2.2.0}"></script>
<script th:src="@{/ruoyi/js/common.js?v=2.3.0}"></script>
<script th:src="@{/ruoyi/js/ry-ui.min.js?v=2.3.0}"></script>
<script src="http://tajs.qq.com/stats?sId=62048022"></script>
<script th:inline="javascript"> var ctx = [[@{/}]]; </script>
</div>

@ -15,7 +15,7 @@
<link th:href="@{/css/font-awesome.css}" rel="stylesheet"/>
<link th:href="@{/css/animate.css}" rel="stylesheet"/>
<link th:href="@{/css/style.css}" rel="stylesheet"/>
<link th:href="@{/ruoyi/css/ry-ui.min.css?v=2.2.0}" rel="stylesheet"/>
<link th:href="@{/ruoyi/css/ry-ui.min.css?v=2.3.0}" rel="stylesheet"/>
<style type="text/css">
.nav > li:hover .dropdown-menu {display: block;}
</style>
@ -136,7 +136,7 @@
<script th:src="@{/js/plugins/slimscroll/jquery.slimscroll.min.js}"></script>
<script th:src="@{/ajax/libs/blockUI/jquery.blockUI.js}"></script>
<script src="http://tajs.qq.com/stats?sId=62048022"></script>
<script th:src="@{/ruoyi/js/ry-ui.min.js?v=2.2.0}"></script>
<script th:src="@{/ruoyi/js/ry-ui.min.js?v=2.3.0}"></script>
<script th:src="@{/ruoyi/index.js}"></script>
<script th:src="@{/ajax/libs/fullscreen/jquery.fullscreen.js}"></script>
</body>

@ -12,7 +12,7 @@
<link href="../static/css/style.css" th:href="@{css/style.css}" rel="stylesheet"/>
<link href="../static/css/login.min.css" th:href="@{css/login.min.css}" rel="stylesheet"/>
<link href="../static/ajax/libs/iCheck/custom.css" th:href="@{/ajax/libs/iCheck/custom.css}" rel="stylesheet"/>
<link href="../static/ruoyi/css/ry-ui.min.css" th:href="@{/ruoyi/css/ry-ui.min.css?v=2.2.0}" rel="stylesheet"/>
<link href="../static/ruoyi/css/ry-ui.min.css" th:href="@{/ruoyi/css/ry-ui.min.css?v=2.3.0}" rel="stylesheet"/>
<!--[if lt IE 9]>
<meta http-equiv="refresh" content="0;ie.html" />
<![endif]-->
@ -82,7 +82,7 @@
<script src="../static/ajax/libs/iCheck/icheck.min.js" th:src="@{/ajax/libs/iCheck/icheck.min.js}"></script>
<script src="../static/ajax/libs/blockUI/jquery.blockUI.js" th:src="@{/ajax/libs/blockUI/jquery.blockUI.js}"></script>
<script src="http://tajs.qq.com/stats?sId=62048022"></script>
<script src="../static/ruoyi/js/ry-ui.min.js" th:src="@{/ruoyi/js/ry-ui.min.js?v=2.2.0}"></script>
<script src="../static/ruoyi/js/ry-ui.min.js" th:src="@{/ruoyi/js/ry-ui.min.js?v=2.3.0}"></script>
<script src="../static/ruoyi/login.js" th:src="@{/ruoyi/login.js}"></script>
</body>
</html>

@ -94,13 +94,43 @@
<div class="ibox-content no-padding">
<div class="panel-body">
<div class="panel-group" id="version">
<div class="panel panel-default">
<div class="panel-heading">
<h5 class="panel-title">
<a data-toggle="collapse" data-parent="#version" href="#v23">v2.3.0</a><code class="pull-right">2018.08.06</code>
</h5>
</div>
<div id="v23" class="panel-collapse collapse in">
<div class="panel-body">
<ol>
<li>支持表格不分页开关控制</li>
<li>修改字典类型同步修改字典数据</li>
<li>代码生成新增修改后缀处理</li>
<li>代码生成新增实体toString</li>
<li>代码生成非字符串去除!=''</li>
<li>导出数据前加载遮罩层</li>
<li>部门删除校验条件修改</li>
<li>搜索查询下载优化</li>
<li>手机打开弹出层自适应</li>
<li>角色岗位禁用显示置灰</li>
<li>角色禁用不显示菜单</li>
<li>新增导出权限</li>
<li>角色权限唯一校验</li>
<li>岗位名称编码唯一校验</li>
<li>TreeTable优化</li>
<li>支持多数据源</li>
<li>其他细节优化</li>
</ol>
</div>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading">
<h5 class="panel-title">
<a data-toggle="collapse" data-parent="#version" href="#v22">v2.2.0</a><code class="pull-right">2018.07.23</code>
</h5>
</div>
<div id="v22" class="panel-collapse collapse in">
<div id="v22" class="panel-collapse collapse">
<div class="panel-body">
<ol>
<li>修复批量生成代码异常问题</li>

@ -6,15 +6,15 @@
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
<form class="form-horizontal m" id="form-post-add">
<div class="form-group">
<label class="col-sm-3 control-label ">岗位编码</label>
<label class="col-sm-3 control-label">岗位名称</label>
<div class="col-sm-8">
<input class="form-control" type="text" name="postCode" id="postCode"/>
<input class="form-control" type="text" name="postName" id="postName">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">岗位名称</label>
<label class="col-sm-3 control-label ">岗位编码</label>
<div class="col-sm-8">
<input class="form-control" type="text" name="postName" id="postName">
<input class="form-control" type="text" name="postCode" id="postCode"/>
</div>
</div>
<div class="form-group">
@ -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());
}

@ -7,15 +7,15 @@
<form class="form-horizontal m" id="form-post-edit" th:object="${post}">
<input id="postId" name="postId" type="hidden" th:field="*{postId}"/>
<div class="form-group">
<label class="col-sm-3 control-label ">岗位编码</label>
<label class="col-sm-3 control-label">岗位名称</label>
<div class="col-sm-8">
<input class="form-control" type="text" name="postCode" id="postCode" th:field="*{postCode}"/>
<input class="form-control" type="text" name="postName" id="postName" th:field="*{postName}">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">岗位名称</label>
<label class="col-sm-3 control-label ">岗位编码</label>
<div class="col-sm-8">
<input class="form-control" type="text" name="postName" id="postName" th:field="*{postName}">
<input class="form-control" type="text" name="postCode" id="postCode" th:field="*{postCode}"/>
</div>
</div>
<div class="form-group">
@ -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());
}

Loading…
Cancel
Save