Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
F
fgqyxxlr
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
yaru
fgqyxxlr
Commits
92fffea4
Commit
92fffea4
authored
Aug 05, 2018
by
RuoYi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
岗位名称编码唯一校验
parent
32975b3e
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
251 additions
and
22 deletions
+251
-22
pom.xml
+1
-1
src/main/java/com/ruoyi/common/constant/UserConstants.java
+9
-1
src/main/java/com/ruoyi/project/system/post/controller/PostController.java
+33
-0
src/main/java/com/ruoyi/project/system/post/mapper/PostMapper.java
+16
-0
src/main/java/com/ruoyi/project/system/post/service/IPostService.java
+16
-0
src/main/java/com/ruoyi/project/system/post/service/PostServiceImpl.java
+38
-0
src/main/resources/application.yml
+1
-1
src/main/resources/mybatis/system/PostMapper.xml
+10
-0
src/main/resources/templates/include.html
+2
-2
src/main/resources/templates/index.html
+2
-2
src/main/resources/templates/login.html
+2
-2
src/main/resources/templates/main.html
+31
-1
src/main/resources/templates/system/post/add.html
+42
-6
src/main/resources/templates/system/post/edit.html
+48
-6
No files found.
pom.xml
View file @
92fffea4
...
...
@@ -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>
...
...
src/main/java/com/ruoyi/common/constant/UserConstants.java
View file @
92fffea4
...
...
@@ -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"
;
...
...
src/main/java/com/ruoyi/project/system/post/controller/PostController.java
View file @
92fffea4
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
;
}
}
src/main/java/com/ruoyi/project/system/post/mapper/PostMapper.java
View file @
92fffea4
...
...
@@ -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
);
}
src/main/java/com/ruoyi/project/system/post/service/IPostService.java
View file @
92fffea4
...
...
@@ -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
);
}
src/main/java/com/ruoyi/project/system/post/service/PostServiceImpl.java
View file @
92fffea4
...
...
@@ -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
;
}
}
src/main/resources/application.yml
View file @
92fffea4
...
...
@@ -3,7 +3,7 @@ ruoyi:
#名称
name
:
RuoYi
#版本
version
:
2.
2
.0
version
:
2.
3
.0
#版权年份
copyrightYear
:
2018
#头像上传路径
...
...
src/main/resources/mybatis/system/PostMapper.xml
View file @
92fffea4
...
...
@@ -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=
")"
>
...
...
src/main/resources/templates/include.html
View file @
92fffea4
...
...
@@ -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>
src/main/resources/templates/index.html
View file @
92fffea4
...
...
@@ -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>
...
...
src/main/resources/templates/login.html
View file @
92fffea4
...
...
@@ -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>
src/main/resources/templates/main.html
View file @
92fffea4
...
...
@@ -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>
...
...
src/main/resources/templates/system/post/add.html
View file @
92fffea4
...
...
@@ -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=
"post
Code"
id=
"postCode"
/
>
<input
class=
"form-control"
type=
"text"
name=
"post
Name"
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=
"post
Name"
id=
"postName"
>
<input
class=
"form-control"
type=
"text"
name=
"post
Code"
id=
"postCode"
/
>
</div>
</div>
<div
class=
"form-group"
>
...
...
@@ -52,17 +52,53 @@
$
(
"#form-post-add"
).
validate
({
rules
:{
post
Cod
e
:{
post
Nam
e
:{
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
;
}
}
},
post
Nam
e
:{
post
Cod
e
:{
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
());
}
...
...
src/main/resources/templates/system/post/edit.html
View file @
92fffea4
...
...
@@ -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=
"post
Code"
id=
"postCode"
th:field=
"*{postCode}"
/
>
<input
class=
"form-control"
type=
"text"
name=
"post
Name"
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=
"post
Name"
id=
"postName"
th:field=
"*{postName}"
>
<input
class=
"form-control"
type=
"text"
name=
"post
Code"
id=
"postCode"
th:field=
"*{postCode}"
/
>
</div>
</div>
<div
class=
"form-group"
>
...
...
@@ -53,17 +53,59 @@
$
(
"#form-post-edit"
).
validate
({
rules
:{
post
Cod
e
:{
post
Nam
e
:{
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
;
}
}
},
post
Nam
e
:{
post
Cod
e
:{
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
());
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment