Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
S
syyl
Project
Project
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
Graph
比较
统计图
议题
0
议题
0
列表
看板
标记
Milestones
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
注册表
注册表
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
svn
syyl
Commits
5d6b182c
提交
5d6b182c
authored
12月 03, 2019
作者:
yucaiwei
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
--no commit message
上级
8dd8a062
隐藏空白字符变更
内嵌
并排
正在显示
10 个修改的文件
包含
619 行增加
和
1 行删除
+619
-1
DiyTypeController.java
...zrqx/sysuser/bg/controller/diytype/DiyTypeController.java
+354
-0
PermissionsController.java
...user/bg/controller/permissions/PermissionsController.java
+1
-1
DiyTypeMapper.java
...ava/com/zrqx/sysuser/bg/mapper/diytype/DiyTypeMapper.java
+26
-0
DiyTypeService.java
...a/com/zrqx/sysuser/bg/service/diytype/DiyTypeService.java
+28
-0
DiyTypeServiceImpl.java
...m/zrqx/sysuser/bg/service/diytype/DiyTypeServiceImpl.java
+47
-0
Redis.java
...r/src/main/java/com/zrqx/sysuser/commons/redis/Redis.java
+9
-0
FgPermissionsController.java
...er/fg/controller/permissions/FgPermissionsController.java
+86
-0
FgUserMapper.java
...in/java/com/zrqx/sysuser/fg/mapper/user/FgUserMapper.java
+16
-0
FgUserService.java
.../java/com/zrqx/sysuser/fg/service/user/FgUserService.java
+14
-0
FgUserServiceImpl.java
...a/com/zrqx/sysuser/fg/service/user/FgUserServiceImpl.java
+38
-0
没有找到文件。
com.zrqx.sysuser/src/main/java/com/zrqx/sysuser/bg/controller/diytype/DiyTypeController.java
0 → 100644
浏览文件 @
5d6b182c
package
com
.
zrqx
.
sysuser
.
bg
.
controller
.
diytype
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Date
;
import
java.util.List
;
import
org.apache.commons.lang.StringUtils
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
tk.mybatis.mapper.entity.Example
;
import
tk.mybatis.mapper.entity.Example.Criteria
;
import
com.github.pagehelper.PageHelper
;
import
com.zrqx.core.constant.resource.ResourceRequestPath
;
import
com.zrqx.core.enums.AllResourceTypeEnum
;
import
com.zrqx.core.enums.ResponseCodeEnum
;
import
com.zrqx.core.enums.resource.diytype.DiyTypeStatusEnum
;
import
com.zrqx.core.exception.BusinessValidateException
;
import
com.zrqx.core.exception.ParameterValidateException
;
import
com.zrqx.core.form.resource.bg.diytype.QueryDiyTypeForm
;
import
com.zrqx.core.model.resource.diytype.DiyType
;
import
com.zrqx.core.model.resource.videolibrary.VideoLibraryDiyTypeRelation
;
import
com.zrqx.core.util.bean.Copy
;
import
com.zrqx.core.util.datatype.ArrayUtils
;
import
com.zrqx.core.util.datatype.UUIDUtil
;
import
com.zrqx.core.util.page.PageInfo
;
import
com.zrqx.core.util.page.PageParam
;
import
com.zrqx.core.util.response.CallBack
;
import
com.zrqx.core.vo.resource.diytype.DiyTypeVO
;
import
com.zrqx.sysuser.bg.service.diytype.DiyTypeService
;
/**
* 自定义分类 Controller
*/
@RestController
@RequestMapping
(
ResourceRequestPath
.
BG
+
ResourceRequestPath
.
DIYTYPE
)
@Api
(
description
=
"网站管理-自定义分类"
)
public
class
DiyTypeController
{
@Autowired
private
DiyTypeService
service
;
/*@Autowired
private EbookDiyTypeService ebookDiyTypeService;
@Autowired
private ArticleLibraryDiyTypeService articleLibraryDiyTypeService;
@Autowired
private AudioLibraryDiyTypeService audioLibraryDiyTypeService;
@Autowired
private AuthorLibraryDiytypeService authorLibraryDiytypeService;
@Autowired
private VideoLibraryDiyTypeService videoLibraryDiyTypeService;
@Autowired
private ImageLibraryDiyTypeRelationService imageLibraryDiyTypeRelationService;*/
@ApiOperation
(
value
=
"新增自定义分类"
,
notes
=
"新增一个"
)
@PostMapping
(
value
=
ResourceRequestPath
.
SAVE
)
public
CallBack
<
Boolean
>
save
(
@RequestBody
DiyType
entity
)
{
Example
example
=
service
.
createExample
();
example
.
createCriteria
().
andEqualTo
(
"typeName"
,
entity
.
getTypeName
()).
andEqualTo
(
"parentId"
,
entity
.
getParentId
());
if
(
service
.
selectOneByExample
(
example
)
!=
null
){
throw
new
BusinessValidateException
(
"同级已存在"
+
entity
.
getTypeName
());
}
if
(
entity
.
getParentId
().
equals
(
0
)
&&
AllResourceTypeEnum
.
getCode
(
entity
.
getTypeName
())
==
null
){
throw
new
BusinessValidateException
(
"分类名称错误"
);
}
//分页排序查询当前子分类最大code值
example
=
service
.
createExample
();
example
.
createCriteria
().
andEqualTo
(
"parentId"
,
entity
.
getParentId
());
PageParam
pageParam
=
new
PageParam
();
pageParam
.
setPageSize
(
1
);
pageParam
.
setOrderBy
(
"code desc"
);
PageInfo
<
DiyType
>
page
=
service
.
queryExample
(
pageParam
,
example
);
if
(
page
.
getList
()
!=
null
&&
page
.
getList
().
size
()
>
0
){
//查询到子分类,获取最大code生成新的code
String
code
=
page
.
getList
().
get
(
0
).
getCode
();
entity
.
setCode
(
UUIDUtil
.
newCode
(
code
));
}
else
{
//没有查询到子分类,获取父类code 拼接 01
if
(
entity
.
getParentId
()!=
0
){
entity
.
setCode
(
service
.
selectByPrimaryKey
(
entity
.
getParentId
()).
getCode
()+
"01"
);
}
else
{
entity
.
setCode
(
"01"
);
}
}
entity
.
setStatus
(
DiyTypeStatusEnum
.
STATUS_1
.
getCode
());
entity
.
setCreateTime
(
new
Date
());
if
(!
service
.
insert
(
entity
)){
throw
new
BusinessValidateException
(
"操作失败"
);
}
return
CallBack
.
success
(
true
);
}
@ApiOperation
(
value
=
"更新自定义分类"
,
notes
=
"根据ID更新,空值默认不更新"
)
@PostMapping
(
value
=
ResourceRequestPath
.
UPDATE
)
public
CallBack
<
Boolean
>
update
(
@RequestBody
DiyType
entity
)
{
Example
example
=
service
.
createExample
();
example
.
createCriteria
().
andEqualTo
(
"typeName"
,
entity
.
getTypeName
()).
andEqualTo
(
"parentId"
,
entity
.
getParentId
()).
andNotEqualTo
(
"id"
,
entity
.
getId
());
if
(
service
.
selectOneByExample
(
example
)
!=
null
){
throw
new
BusinessValidateException
(
"同级已存在"
+
entity
.
getTypeName
());
}
if
(
entity
.
getParentId
()
==
0
&&
AllResourceTypeEnum
.
getCode
(
entity
.
getTypeName
())
==
null
){
throw
new
BusinessValidateException
(
"分类名称错误"
);
}
DiyType
old
=
service
.
selectByPrimaryKey
(
entity
.
getId
());
entity
.
setCreateTime
(
old
.
getCreateTime
());
entity
.
setCode
(
old
.
getCode
());
entity
.
setStatus
(
old
.
getStatus
());
if
(!
service
.
updateByPrimaryKey
(
entity
))
{
throw
new
BusinessValidateException
(
"操作失败"
);
}
return
CallBack
.
success
(
true
);
}
@ApiOperation
(
value
=
"更新排序自定义分类"
,
notes
=
"根据ID更新排序"
)
@PostMapping
(
value
=
ResourceRequestPath
.
UPDATE
+
ResourceRequestPath
.
SORT
)
public
CallBack
<
Boolean
>
updateSort
(
@RequestBody
DiyType
entity
)
{
service
.
updateByPrimaryKeySelective
(
entity
);
return
CallBack
.
success
(
true
);
}
@ApiOperation
(
value
=
"批量更新排序自定义分类"
,
notes
=
"根据ID更新排序"
)
@PostMapping
(
value
=
ResourceRequestPath
.
BATCH_UPDATE
+
ResourceRequestPath
.
SORT
)
public
CallBack
<
Boolean
>
updateSort
(
@RequestBody
List
<
Integer
>
ids
)
{
service
.
updateSortByPrimaryKey
(
ids
);
return
CallBack
.
success
(
true
);
}
@ApiOperation
(
value
=
"批量删除自定义分类"
,
notes
=
"批量删除"
)
@PostMapping
(
value
=
ResourceRequestPath
.
DELETE
)
public
CallBack
<
Boolean
>
delete
(
@RequestBody
List
<
String
>
id
)
{
Example
example
=
service
.
createExample
();
example
.
createCriteria
().
andIn
(
"id"
,
id
);
if
(!
service
.
deleteByExample
(
example
)){
throw
new
BusinessValidateException
(
"操作失败"
);
}
// 将数据内容中已经关联的分类一并删除
this
.
deleteAllResourceDiyType
(
id
);
return
CallBack
.
success
(
true
);
}
@ApiOperation
(
value
=
"查询根据ID自定义分类"
,
notes
=
"根据ID查询"
)
@GetMapping
(
value
=
ResourceRequestPath
.
OID
)
public
CallBack
<
DiyType
>
getById
(
@PathVariable
Integer
oid
)
{
return
CallBack
.
success
(
service
.
selectByPrimaryKey
(
oid
));
}
@ApiOperation
(
value
=
"查询 自定义分类同树 同级名称是否存在接口"
,
notes
=
"查询 自定义分类同树 同级名称是否存在接口"
)
@GetMapping
(
value
=
ResourceRequestPath
.
ISEXIST_TYPE_NAME
)
public
CallBack
<
Boolean
>
isExistTypeNameBoolean
(
QueryDiyTypeForm
form
)
{
Example
example
=
service
.
createExample
();
Criteria
cr
=
example
.
createCriteria
();
cr
.
andEqualTo
(
"typeName"
,
form
.
getTypeName
());
cr
.
andEqualTo
(
"parentId"
,
form
.
getParentId
());
if
(
form
.
getId
()
!=
null
){
cr
.
andNotEqualTo
(
"id"
,
form
.
getId
());
}
return
CallBack
.
success
(
service
.
selectOneByExample
(
example
)
!=
null
);
}
@ApiOperation
(
value
=
"查询检查旧编码名称是否已存在"
,
notes
=
"查询检查旧编码名称是否已存在"
)
@GetMapping
(
value
=
ResourceRequestPath
.
ISEXIST_OLD_CODE
)
public
CallBack
<
Boolean
>
isExistOldCodeBoolean
(
Integer
id
,
String
oldCode
)
{
Example
example
=
service
.
createExample
();
Criteria
cr
=
example
.
createCriteria
();
cr
.
andEqualTo
(
"oldCode"
,
oldCode
);
if
(
id
!=
null
){
cr
.
andNotEqualTo
(
"id"
,
id
);
}
return
CallBack
.
success
(
service
.
selectOneByExample
(
example
)
!=
null
);
}
@ApiOperation
(
value
=
"查询全部自定义分类list"
,
notes
=
"查询列表"
)
@GetMapping
(
value
=
ResourceRequestPath
.
LIST
)
public
CallBack
<
List
<
DiyType
>>
list
()
{
Example
example
=
service
.
createExample
();
example
.
createCriteria
().
andEqualTo
(
"status"
,
DiyTypeStatusEnum
.
STATUS_1
.
getCode
());
PageHelper
.
orderBy
(
"sort"
);
List
<
DiyType
>
list
=
service
.
selectByExample
(
example
);
return
CallBack
.
success
(
list
);
}
@ApiOperation
(
value
=
"查询全部自定义分类tree"
,
notes
=
"查询列表"
)
@GetMapping
(
value
=
ResourceRequestPath
.
TREE
)
public
CallBack
<
List
<
DiyTypeVO
>>
tree
()
{
Example
example
=
service
.
createExample
();
example
.
createCriteria
().
andEqualTo
(
"status"
,
DiyTypeStatusEnum
.
STATUS_1
.
getCode
());
PageHelper
.
orderBy
(
"sort"
);
List
<
DiyType
>
list
=
service
.
selectByExample
(
example
);
List
<
DiyTypeVO
>
voList
=
Copy
.
copyList
(
list
,
DiyTypeVO
.
class
,
obj
->
obj
.
getParentId
().
intValue
()
==
0
);
tree
(
list
,
voList
);
return
CallBack
.
success
(
voList
);
}
@ApiOperation
(
value
=
"根据数据类型(一级分类名)查询自定义分类tree"
,
notes
=
"查询列表"
)
@GetMapping
(
value
=
ResourceRequestPath
.
NAME
+
ResourceRequestPath
.
TREE
)
public
CallBack
<
List
<
DiyTypeVO
>>
tree
(
String
name
)
{
if
(
StringUtils
.
isBlank
(
name
)){
throw
new
ParameterValidateException
(
ResponseCodeEnum
.
MISS_EXCEPTION
.
getCode
(),
"参数不能为空!"
);
}
Example
example
=
service
.
createExample
();
example
.
createCriteria
().
andEqualTo
(
"status"
,
DiyTypeStatusEnum
.
STATUS_1
.
getCode
());
PageHelper
.
orderBy
(
"sort"
);
List
<
DiyType
>
list
=
service
.
selectByExample
(
example
);
// 获取一级分类
List
<
DiyTypeVO
>
voList
=
Copy
.
copyList
(
list
,
DiyTypeVO
.
class
,
obj
->
name
.
equals
(
obj
.
getTypeName
())
&&
obj
.
getParentId
().
intValue
()
==
0
);
tree
(
list
,
voList
);
return
CallBack
.
success
(
voList
);
}
@ApiOperation
(
value
=
"根据数据类型(一级分类名)查询自定义分类list"
,
notes
=
"查询列表"
)
@GetMapping
(
value
=
ResourceRequestPath
.
NAME
+
ResourceRequestPath
.
LIST
)
public
CallBack
<
List
<
DiyType
>>
list
(
String
name
)
{
List
<
DiyType
>
vos
=
new
ArrayList
<
DiyType
>();
if
(
StringUtils
.
isBlank
(
name
)){
throw
new
ParameterValidateException
(
ResponseCodeEnum
.
MISS_EXCEPTION
.
getCode
(),
"参数不能为空!"
);
}
Example
example
=
service
.
createExample
();
example
.
createCriteria
().
andEqualTo
(
"status"
,
DiyTypeStatusEnum
.
STATUS_1
.
getCode
());
PageHelper
.
orderBy
(
"sort"
);
List
<
DiyType
>
list
=
service
.
selectByExample
(
example
);
// 获取一级分类
List
<
DiyTypeVO
>
voList
=
Copy
.
copyList
(
list
,
DiyTypeVO
.
class
,
obj
->
name
.
equals
(
obj
.
getTypeName
())
&&
obj
.
getParentId
().
intValue
()
==
0
);
tree
(
list
,
voList
);
return
CallBack
.
success
(
convertAllToOne
(
voList
,
vos
));
}
public
List
<
DiyTypeVO
>
tree
(
List
<
DiyType
>
list
,
List
<
DiyTypeVO
>
voList
){
voList
.
forEach
(
entity
->{
//第一次设置 一级分类的子类 后续递归设置 子类的子类
entity
.
setList
(
Copy
.
copyList
(
list
,
DiyTypeVO
.
class
,
obj
->
obj
.
getParentId
().
intValue
()
==
entity
.
getId
().
intValue
()));
//当前分类存在子类 开始递归子类
if
(
entity
.
getList
().
size
()
>
0
){
tree
(
list
,
entity
.
getList
());
}
});
return
voList
;
}
public
List
<
DiyType
>
convertAllToOne
(
List
<
DiyTypeVO
>
all
,
List
<
DiyType
>
dest
)
{
for
(
DiyTypeVO
v:
all
)
{
DiyType
obj
=
new
DiyType
();
BeanUtils
.
copyProperties
(
v
,
obj
);
dest
.
add
(
obj
);
if
(
v
.
getList
()!=
null
)
{
convertAllToOne
(
v
.
getList
(),
dest
);
}
}
return
dest
;
}
@ApiOperation
(
value
=
"查询自定义分类当前最大排序号"
,
notes
=
"查询当前最大排序号"
)
@GetMapping
(
value
=
ResourceRequestPath
.
MAXORDERNUM
)
public
CallBack
<
Integer
>
getMaxOrderNum
(
Integer
id
){
return
CallBack
.
success
(
service
.
getMaxOrderNum
(
id
));
}
@ApiOperation
(
value
=
"根据数据类型(一级分类名)以及关键词查询自定义分类tree"
,
notes
=
"查询列表"
)
@GetMapping
(
value
=
ResourceRequestPath
.
TREE
+
ResourceRequestPath
.
GET
)
public
CallBack
<
List
<
DiyTypeVO
>>
updateTree
(
@RequestParam
(
"name"
)
String
name
,
@RequestParam
(
"search"
)
String
search
)
{
if
(
StringUtils
.
isBlank
(
name
)){
throw
new
ParameterValidateException
(
ResponseCodeEnum
.
MISS_EXCEPTION
.
getCode
(),
"参数不能为空!"
);
}
CallBack
<
List
<
DiyType
>>
call
=
this
.
list
(
name
);
List
<
DiyType
>
list
=
call
.
getData
();
List
<
DiyTypeVO
>
newTree
=
new
ArrayList
<
DiyTypeVO
>();
// 获取一级分类
List
<
DiyTypeVO
>
voList
=
Copy
.
copyList
(
list
,
DiyTypeVO
.
class
,
obj
->
search
.
equals
(
obj
.
getTypeName
())
&&
obj
.
getParentId
().
intValue
()
!=
0
);
if
(!
voList
.
isEmpty
()){
Integer
id
=
voList
.
get
(
0
).
getParentId
();
List
<
DiyType
>
diyList
=
new
ArrayList
<
DiyType
>();
do
{
DiyType
diyType
=
service
.
selectByPrimaryKey
(
id
);
id
=
diyType
.
getParentId
();
diyList
.
add
(
diyType
);
}
while
(
id
!=
0
);
List
<
DiyTypeVO
>
fathor
=
getDiyTypeVO
(
diyList
);
List
<
DiyTypeVO
>
child
=
tree
(
list
,
voList
);
newTree
=
connect
(
fathor
,
child
);
}
return
CallBack
.
success
(
newTree
);
}
public
List
<
DiyTypeVO
>
connect
(
List
<
DiyTypeVO
>
list
,
List
<
DiyTypeVO
>
voList
){
DiyTypeVO
vo
=
list
.
get
(
0
);
if
(
ArrayUtils
.
isNotEmpty
(
vo
.
getList
())){
connect
(
vo
.
getList
(),
voList
);
}
else
{
vo
.
setList
(
voList
);
}
return
Arrays
.
asList
(
vo
);
}
public
List
<
DiyTypeVO
>
getDiyTypeVO
(
List
<
DiyType
>
list
){
List
<
DiyTypeVO
>
voList
=
Copy
.
copyList
(
list
,
DiyTypeVO
.
class
,
obj
->
obj
.
getParentId
().
intValue
()
==
0
);
tree
(
list
,
voList
);
return
voList
;
}
@ApiOperation
(
value
=
"根据code查询自定义分类"
,
notes
=
"查询列表"
)
@GetMapping
(
value
=
ResourceRequestPath
.
CODE
+
ResourceRequestPath
.
GET
)
public
CallBack
<
DiyType
>
selectDiyTypeByCode
(
@RequestParam
(
"code"
)
String
code
)
{
Example
example
=
service
.
createExample
();
example
.
createCriteria
().
andEqualTo
(
"status"
,
DiyTypeStatusEnum
.
STATUS_1
.
getCode
()).
andEqualTo
(
"code"
,
code
);
DiyType
list
=
service
.
selectOneByExample
(
example
);
return
CallBack
.
success
(
list
);
}
/**
* 删除分类时需要将资源数据内容中已经关联的分类一并删除
* @param ids
* @return
* @author ycw
* @date: 2019年6月19日 上午11:40:04
*/
private
boolean
deleteAllResourceDiyType
(
List
<
String
>
ids
){
/*// 图书
Example example = new Example(EbookDiyType.class);
example.createCriteria().andIn("dtId", ids);
ebookDiyTypeService.deleteByExample(example);
// 文章
example = new Example(ArticleLibraryDiyType.class);
example.createCriteria().andIn("dtId", ids);
articleLibraryDiyTypeService.deleteByExample(example);
// 音频
example = new Example(AudioLibraryDiyType.class);
example.createCriteria().andIn("dtId", ids);
audioLibraryDiyTypeService.deleteByExample(example);
// 作者
example = new Example(AuthorLibraryDiytype.class);
example.createCriteria().andIn("dtId", ids);
authorLibraryDiytypeService.deleteByExample(example);
// 视频
example = new Example(VideoLibraryDiyTypeRelation.class);
example.createCriteria().andIn("dtId", ids);
videoLibraryDiyTypeService.deleteByExample(example);
// 图片
example = new Example(ImageLibraryDiyType.class);
example.createCriteria().andIn("dtId", ids);
imageLibraryDiyTypeRelationService.deleteByExample(example);*/
return
true
;
}
}
com.zrqx.sysuser/src/main/java/com/zrqx/sysuser/bg/controller/permissions/PermissionsController.java
浏览文件 @
5d6b182c
...
...
@@ -96,7 +96,7 @@ public class PermissionsController {
name, StringUtils.isBlank(errorCount) ? "1" : Integer.parseInt(errorCount)+1+"",60*60*24,TimeUnit.SECONDS);*/
throw
new
BusinessValidateException
(
"账号或密码错误"
);
}
//
stringRedisTemplate.delete(name);//临时关闭错误三次封停账号
stringRedisTemplate
.
delete
(
name
);
//临时关闭错误三次封停账号
user
.
setPassword
(
null
);
user
.
setToken
(
UUIDUtil
.
getUUID
());
stringRedisTemplate
.
opsForValue
().
set
(
user
.
getToken
(),
JsonUtil
.
bean2Json
(
user
),
60
*
60
*
24
*
7
,
TimeUnit
.
SECONDS
);
...
...
com.zrqx.sysuser/src/main/java/com/zrqx/sysuser/bg/mapper/diytype/DiyTypeMapper.java
0 → 100644
浏览文件 @
5d6b182c
package
com
.
zrqx
.
sysuser
.
bg
.
mapper
.
diytype
;
import
org.apache.ibatis.annotations.Param
;
import
org.apache.ibatis.annotations.Select
;
import
org.apache.ibatis.annotations.Update
;
import
com.zrqx.core.mapper.BaseMapper
;
import
com.zrqx.core.model.resource.diytype.DiyType
;
/**
* 自定义分类
*/
public
interface
DiyTypeMapper
extends
BaseMapper
<
DiyType
>
{
/**
* 查询排序号最大值
* @return
*/
@Select
(
"select sort from res_Diy_Type where parentId = #{id} "
)
Integer
getMaxOrderNum
(
Integer
id
);
/**
* 修改排序号
* @return
*/
@Update
(
"update res_Diy_Type set sort = #{sort} where parentId = #{id}"
)
Integer
updateSortByPrimaryKey
(
@Param
(
"sort"
)
Integer
sort
,
@Param
(
"id"
)
Integer
id
);
}
com.zrqx.sysuser/src/main/java/com/zrqx/sysuser/bg/service/diytype/DiyTypeService.java
0 → 100644
浏览文件 @
5d6b182c
package
com
.
zrqx
.
sysuser
.
bg
.
service
.
diytype
;
import
java.util.List
;
import
com.zrqx.core.model.resource.diytype.DiyType
;
import
com.zrqx.core.service.BaseService
;
/**
*
* 自定义分类service
*/
public
interface
DiyTypeService
extends
BaseService
<
DiyType
,
Integer
>{
/**
* 查询当前最大排序号
* @param id
* @return
*/
Integer
getMaxOrderNum
(
Integer
id
);
/**
* 修改排序
* @param ids
*/
void
updateSortByPrimaryKey
(
List
<
Integer
>
ids
);
/**
* 修改排序
* @param ids
*/
void
updateSortByPrimaryKey
(
Integer
sort
,
Integer
id
);
}
com.zrqx.sysuser/src/main/java/com/zrqx/sysuser/bg/service/diytype/DiyTypeServiceImpl.java
0 → 100644
浏览文件 @
5d6b182c
package
com
.
zrqx
.
sysuser
.
bg
.
service
.
diytype
;
import
java.util.List
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
com.github.pagehelper.PageHelper
;
import
com.zrqx.core.mapper.BaseMapper
;
import
com.zrqx.core.model.resource.diytype.DiyType
;
import
com.zrqx.core.service.BaseServiceImpl
;
import
com.zrqx.sysuser.bg.mapper.diytype.DiyTypeMapper
;
/**
* 自定义分类
*/
@Service
public
class
DiyTypeServiceImpl
extends
BaseServiceImpl
<
DiyType
,
Integer
>
implements
DiyTypeService
{
@Autowired
private
DiyTypeMapper
mapper
;
@Override
public
BaseMapper
<
DiyType
>
getMapper
()
{
return
mapper
;
}
@Override
public
Integer
getMaxOrderNum
(
Integer
id
)
{
PageHelper
.
startPage
(
1
,
1
,
"sort desc"
);
Integer
maxOrderNum
=
mapper
.
getMaxOrderNum
(
id
);
return
maxOrderNum
==
null
?
0
:
maxOrderNum
;
}
@Override
public
void
updateSortByPrimaryKey
(
List
<
Integer
>
ids
)
{
for
(
int
i
=
0
;
i
<
ids
.
size
();
i
++)
{
mapper
.
updateSortByPrimaryKey
(
i
,
ids
.
get
(
i
));
}
}
@Override
public
void
updateSortByPrimaryKey
(
Integer
sort
,
Integer
id
)
{
mapper
.
updateSortByPrimaryKey
(
sort
,
id
);
}
}
com.zrqx.sysuser/src/main/java/com/zrqx/sysuser/commons/redis/Redis.java
浏览文件 @
5d6b182c
...
...
@@ -19,6 +19,7 @@ import org.springframework.web.context.request.ServletRequestAttributes;
import
com.alibaba.fastjson.JSON
;
import
com.zrqx.core.enums.ResponseCodeEnum
;
import
com.zrqx.core.exception.BaseException
;
import
com.zrqx.core.form.sysuser.fg.user.LoginUserInfo
;
import
com.zrqx.core.model.sysuser.user.User
;
import
com.zrqx.core.util.JsonUtil.JsonUtil
;
...
...
@@ -53,6 +54,14 @@ public class Redis {
public
User
getUser
()
{
return
getInfoObjectRedis
(
getBgToken
(),
User
.
class
);
}
/**
* 获取前台登录用户信息
*
* @return
*/
public
LoginUserInfo
getMember
()
{
return
getInfoObjectRedis
(
getToken
(
FG_TOKEN
),
LoginUserInfo
.
class
);
}
public
boolean
isExistMember
()
{
try
{
...
...
com.zrqx.sysuser/src/main/java/com/zrqx/sysuser/fg/controller/permissions/FgPermissionsController.java
0 → 100644
浏览文件 @
5d6b182c
package
com
.
zrqx
.
sysuser
.
fg
.
controller
.
permissions
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
java.io.IOException
;
import
java.util.concurrent.TimeUnit
;
import
javax.servlet.http.HttpServletRequest
;
import
org.apache.commons.lang.StringUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.redis.core.StringRedisTemplate
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
com.zrqx.core.constant.sysuser.SysUserRequestPath
;
import
com.zrqx.core.enums.StatusEnum
;
import
com.zrqx.core.exception.BaseException
;
import
com.zrqx.core.form.sysuser.fg.user.LoginForm
;
import
com.zrqx.core.form.sysuser.fg.user.LoginUserInfo
;
import
com.zrqx.core.model.sysuser.user.User
;
import
com.zrqx.core.util.JsonUtil.JsonUtil
;
import
com.zrqx.core.util.bean.BeanUtils
;
import
com.zrqx.core.util.datatype.UUIDUtil
;
import
com.zrqx.core.util.response.CallBack
;
import
com.zrqx.sysuser.commons.redis.Redis
;
import
com.zrqx.sysuser.fg.service.user.FgUserService
;
/**
* 登录Controller
*/
@RestController
@RequestMapping
(
SysUserRequestPath
.
FG
+
SysUserRequestPath
.
PERMISSIONS
)
@Api
(
description
=
"前台登陆"
)
public
class
FgPermissionsController
{
private
final
static
Logger
logger
=
LoggerFactory
.
getLogger
(
FgPermissionsController
.
class
);
@Autowired
private
FgUserService
userService
;
@Autowired
StringRedisTemplate
stringRedisTemplate
;
@Autowired
private
Redis
redis
;
@ApiOperation
(
value
=
"前台用户登录"
,
notes
=
"0:登录成功;1:账号或密码不能为空;4:账号或密码错误;5:该账户已禁用;"
)
@GetMapping
(
value
=
SysUserRequestPath
.
LOGIN
)
public
CallBack
<
LoginUserInfo
>
login
(
@RequestBody
LoginForm
form
,
HttpServletRequest
request
)
throws
BaseException
,
Exception
{
if
(
StringUtils
.
isBlank
(
form
.
getUserName
())
||
StringUtils
.
isBlank
(
form
.
getPassword
()))
{
throw
new
BaseException
(
1
,
"账号或密码不能为空"
);
}
User
user
=
userService
.
login
(
form
.
getUserName
());
if
(
user
==
null
){
throw
new
BaseException
(
4
,
"账号或密码错误"
);
}
if
(
user
.
getStatus
()
==
StatusEnum
.
DISABLE
.
getCode
()){
throw
new
BaseException
(
5
,
"账号已被禁用,请联系网站管理员!"
);
}
if
(
StringUtils
.
isBlank
(
form
.
getPassword
())
||
!
form
.
getPassword
().
toLowerCase
().
equals
(
user
.
getPassword
().
toLowerCase
())){
throw
new
BaseException
(
4
,
"账号或密码错误"
);
}
LoginUserInfo
info
=
new
LoginUserInfo
();
BeanUtils
.
copyProperties
(
user
,
info
);
info
.
setToken
(
UUIDUtil
.
getUUID
());
stringRedisTemplate
.
opsForValue
().
set
(
info
.
getToken
(),
JsonUtil
.
bean2Json
(
info
),
60
*
60
*
24
*
7
,
TimeUnit
.
SECONDS
);
return
CallBack
.
success
(
info
);
}
@ApiOperation
(
value
=
"前台用户登出"
,
notes
=
"前台用户登出"
)
@GetMapping
(
value
=
SysUserRequestPath
.
LOGOUT
)
public
CallBack
<
Boolean
>
logout
()
throws
IOException
{
redis
.
delete
(
Redis
.
getFgToken
());
return
CallBack
.
success
(
true
);
}
}
com.zrqx.sysuser/src/main/java/com/zrqx/sysuser/fg/mapper/user/FgUserMapper.java
0 → 100644
浏览文件 @
5d6b182c
package
com
.
zrqx
.
sysuser
.
fg
.
mapper
.
user
;
import
org.apache.ibatis.annotations.Select
;
import
com.zrqx.core.mapper.BaseMapper
;
import
com.zrqx.core.model.sysuser.user.User
;
public
interface
FgUserMapper
extends
BaseMapper
<
User
>
{
/**
* 登录接口
* @param userName
* @return
*/
@Select
(
"select userId,userName,name,password,phone,email,img,isAdmin,status from sys_user where userName = #{userName}"
)
User
login
(
String
userName
);
}
com.zrqx.sysuser/src/main/java/com/zrqx/sysuser/fg/service/user/FgUserService.java
0 → 100644
浏览文件 @
5d6b182c
package
com
.
zrqx
.
sysuser
.
fg
.
service
.
user
;
import
com.zrqx.core.model.sysuser.user.User
;
import
com.zrqx.core.service.BaseService
;
public
interface
FgUserService
extends
BaseService
<
User
,
String
>
{
/**
* 登录
* @param userName
* @return
*/
User
login
(
String
userName
);
}
com.zrqx.sysuser/src/main/java/com/zrqx/sysuser/fg/service/user/FgUserServiceImpl.java
0 → 100644
浏览文件 @
5d6b182c
package
com
.
zrqx
.
sysuser
.
fg
.
service
.
user
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
com.zrqx.core.mapper.BaseMapper
;
import
com.zrqx.core.model.sysuser.user.User
;
import
com.zrqx.core.service.BaseServiceImpl
;
import
com.zrqx.sysuser.fg.mapper.user.FgUserMapper
;
/**
* 用户
*
*/
@Service
public
class
FgUserServiceImpl
extends
BaseServiceImpl
<
User
,
String
>
implements
FgUserService
{
private
final
static
Logger
logger
=
LoggerFactory
.
getLogger
(
FgUserServiceImpl
.
class
);
@Autowired
private
FgUserMapper
mapper
;
@Override
public
BaseMapper
<
User
>
getMapper
()
{
return
mapper
;
}
/**
* 登录
* @param userName
* @return
*/
@Override
public
User
login
(
String
userName
)
{
return
mapper
.
login
(
userName
);
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论