Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
yangxiujun
/
paidan_demo
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 6e37c205
authored
Oct 10, 2023
by
chamberone
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'develop' of
https://zhangguoping@gitlab.dituhui.com/bsh/project/pr…
…oject.git into develop
2 parents
cad67587
b6a36a39
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
25 additions
and
239 deletions
project-interface/src/main/java/com/dituhui/pea/enums/StatusCodeEnum.java
project-interface/src/main/java/com/dituhui/pea/pojo/UserInfo.java
project-interface/src/main/java/com/dituhui/pea/pojo/user/OrgInfo.java
project-interface/src/main/java/com/dituhui/pea/user/IRole2.java
project-user/src/main/java/com/dituhui/pea/user/controller2/RoleController2.java
project-user/src/main/java/com/dituhui/pea/user/dao/RoleDao2.java
project-user/src/main/java/com/dituhui/pea/user/entity/RoleEntity2.java
project-user/src/main/java/com/dituhui/pea/user/entity/UserOrgEntity.java
project-user/src/main/java/com/dituhui/pea/user/service/RoleService2.java
project-user/src/main/java/com/dituhui/pea/user/service/UserService.java
project-interface/src/main/java/com/dituhui/pea/enums/StatusCodeEnum.java
View file @
6e37c20
...
...
@@ -102,6 +102,11 @@ public enum StatusCodeEnum {
*/
RESOURCE_ALREADY_EXISTS_ROLE
(
"017"
,
"角色中已存在该资源,不能重复添加"
,
false
),
/**
* 用户状态异常或已被禁用
*/
USER_ISBAN_OR_ERROR
(
"018"
,
"用户状态异常或已被禁用"
,
false
),
GIS_EXISTS
(
"001"
,
"已存在"
,
false
),
GIS_NOT_EXISTS
(
"002"
,
"不存在"
,
false
),
...
...
project-interface/src/main/java/com/dituhui/pea/pojo/UserInfo.java
View file @
6e37c20
...
...
@@ -86,7 +86,7 @@ public class UserInfo {
/**
* 组织ids
*/
private
List
<
Integer
>
orgIds
;
private
List
<
String
>
orgIds
;
/**
* 组织级别 0:大区 1:分部 2:站点
*/
...
...
project-interface/src/main/java/com/dituhui/pea/pojo/user/OrgInfo.java
View file @
6e37c20
...
...
@@ -10,7 +10,7 @@ public class OrgInfo implements Serializable {
/**
* 机构id
*/
private
Integer
id
;
private
String
id
;
/**
* 机构名称
...
...
project-interface/src/main/java/com/dituhui/pea/user/IRole2.java
deleted
100644 → 0
View file @
cad6758
// package com.dituhui.pea.user;
//
// import com.dituhui.pea.common.Result;
// import com.dituhui.pea.pojo.RoleInfo;
// import org.springframework.cloud.openfeign.FeignClient;
// import org.springframework.web.bind.annotation.RequestBody;
// import org.springframework.web.bind.annotation.RequestMapping;
// import org.springframework.web.bind.annotation.RequestMethod;
//
// /**
// * 角色相关接口
// */
// @FeignClient(value = "project-user", contextId = "role2")
// public interface IRole2 {
//
// /**
// * 添加角色
// *
// * @param roleInfo 角色信息
// * @return
// */
// @RequestMapping(value = "/pea-user/role/add2", method = RequestMethod.POST)
// Result<RoleInfo> addRole(@RequestBody RoleInfo roleInfo);
//
// }
project-user/src/main/java/com/dituhui/pea/user/controller2/RoleController2.java
deleted
100644 → 0
View file @
cad6758
// package com.dituhui.pea.user.controller2;
//
// import com.dituhui.pea.common.PageResult;
// import com.dituhui.pea.common.Result;
// import com.dituhui.pea.enums.StatusCodeEnum;
// import com.dituhui.pea.pojo.PageRequest;
// import com.dituhui.pea.pojo.ResourceInfo;
// import com.dituhui.pea.pojo.RoleInfo;
// import com.dituhui.pea.pojo.WebResult;
// import com.dituhui.pea.user.IRole;
// import com.dituhui.pea.user.IRole2;
// import com.dituhui.pea.user.service.RoleService;
// import com.dituhui.pea.user.service.RoleService2;
// import org.apache.commons.lang.StringUtils;
// import org.springframework.beans.factory.annotation.Autowired;
// import org.springframework.cloud.context.config.annotation.RefreshScope;
// import org.springframework.validation.annotation.Validated;
// import org.springframework.web.bind.annotation.RequestBody;
// import org.springframework.web.bind.annotation.RequestMapping;
// import org.springframework.web.bind.annotation.RequestMethod;
// import org.springframework.web.bind.annotation.RestController;
//
// import java.util.List;
//
// /**
// * 角色控制层
// */
// @RestController
// @RefreshScope
// public class RoleController2 implements IRole2 {
//
//
// @Autowired
// RoleService2 roleService;
//
// /**
// * 添加角色
// *
// * @param roleInfo 角色信息
// * @return
// */
// @RequestMapping(value = "/pea-user/role/add2", method = RequestMethod.POST)
// public Result<RoleInfo> addRole(@RequestBody RoleInfo roleInfo) {
// return roleService.addRole(roleInfo);
// }
//
// }
project-user/src/main/java/com/dituhui/pea/user/dao/RoleDao2.java
deleted
100644 → 0
View file @
cad6758
// package com.dituhui.pea.user.dao;
//
//
// import com.dituhui.pea.user.entity.RoleEntity2;
// import org.springframework.data.jpa.repository.JpaRepository;
// import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
// import org.springframework.data.repository.CrudRepository;
//
// /**
// * 角色表(Role)表数据库访问层
// *
// */
// public interface RoleDao2 extends JpaRepository<RoleEntity2, String>,
// JpaSpecificationExecutor<RoleEntity2>, CrudRepository<RoleEntity2, String> {
//
// }
project-user/src/main/java/com/dituhui/pea/user/entity/RoleEntity2.java
deleted
100644 → 0
View file @
cad6758
// package com.dituhui.pea.user.entity;
//
// import lombok.Data;
// import org.hibernate.annotations.GenericGenerator;
// import org.springframework.data.annotation.CreatedDate;
// import org.springframework.data.annotation.LastModifiedDate;
// import org.springframework.data.jpa.domain.support.AuditingEntityListener;
//
// import javax.persistence.*;
// import javax.validation.constraints.NotBlank;
// import java.io.Serializable;
// import java.util.Date;
//
// /**
// * 角色表(RoleEntity)实体类
// *
// */
// @Data
// @Entity
// @Table(name ="sys_role")
// @EntityListeners(AuditingEntityListener.class)
// public class RoleEntity2 implements Serializable {
// private static final long serialVersionUID = -71423293716769828L;
// /**
// * 主键
// */
// @Id
// @GeneratedValue(generator = "uuid")
// @GenericGenerator(name = "uuid", strategy = "uuid")
// @Column(name = "ID", unique = true, nullable = false, length = 60)
// private String id;
// /**
// * 名称
// */
// @Column(name = "name")
// @NotBlank(message = "角色名称不能为空!")
// private String name;
// /**
// * 角色组id
// */
// @Column(name = "group_id")
// private String groupId;
// /**
// * 角色自定义条件
// */
// @Column(name = "extra")
// @NotBlank(message = "角色自定义条件不能为空!")
// private String extra;
// /**
// * 创建人
// */
// @Column(name = "CREATED_BY")
// private String createdBy;
// /**
// * 创建时间
// */
// @Column(name = "CREATED_TIME")
// @CreatedDate
// private Date createdTime;
// /**
// * 更新人
// */
// @Column(name = "UPDATED_BY")
// private String updatedBy;
// /**
// * 更新时间
// */
// @Column(name = "UPDATED_TIME")
// @LastModifiedDate
// private Date updatedTime;
//
// /**
// * 备注
// */
// @Column(name = "notes")
// private String notes;
//
// }
project-user/src/main/java/com/dituhui/pea/user/entity/UserOrgEntity.java
View file @
6e37c20
...
...
@@ -20,7 +20,7 @@ public class UserOrgEntity {
private
String
userId
;
@Column
(
name
=
"org_id"
,
nullable
=
false
)
private
Integer
orgId
;
private
String
orgId
;
/**
* 组织级别 0:大区 1:分部 2:站点
...
...
project-user/src/main/java/com/dituhui/pea/user/service/RoleService2.java
deleted
100644 → 0
View file @
cad6758
// package com.dituhui.pea.user.service;
//
// import cn.hutool.core.bean.BeanUtil;
// import com.alibaba.fastjson.JSONObject;
// import com.dituhui.pea.common.Result;
// import com.dituhui.pea.pojo.RoleInfo;
// import com.dituhui.pea.pojo.role.RoleResourceInfo;
// import com.dituhui.pea.user.dao.RoleDao;
// import com.dituhui.pea.user.dao.RoleDao2;
// import com.dituhui.pea.user.dao.RoleResourceDao;
// import com.dituhui.pea.user.entity.RoleEntity;
// import com.dituhui.pea.user.entity.RoleEntity2;
// import com.dituhui.pea.user.entity.RoleResourceEntity;
// import lombok.extern.slf4j.Slf4j;
// import org.apache.commons.collections.CollectionUtils;
// import org.springframework.beans.factory.annotation.Autowired;
// import org.springframework.stereotype.Service;
// import org.springframework.transaction.annotation.Transactional;
//
// import java.util.List;
//
// @Service
// @Slf4j
// public class RoleService2 {
//
// @Autowired
// RoleDao2 roleDao;
// @Autowired
// RoleResourceDao roleResourceDao;
//
// @Transactional
// public Result<RoleInfo> addRole(RoleInfo roleInfo) {
// RoleEntity2 roleEntity = BeanUtil.copyProperties(roleInfo, RoleEntity2.class);
// // RoleEntity roleEntity = assembleRole(roleInfo);
// log.info("新增角色入参:" + JSONObject.toJSONString(roleEntity));
// roleEntity = roleDao.save(roleEntity);
// // roleInfo = BeanUtil.copyProperties(roleEntity, RoleInfo.class);
// roleInfo.setId(roleEntity.getId());
// List<RoleResourceInfo> resourceInfos = roleInfo.getResourceInfos();
// if (CollectionUtils.isNotEmpty(resourceInfos)) {
// for (RoleResourceInfo resourceInfo : resourceInfos) {
// RoleResourceEntity roleResourceEntity = assembleRoleResource(roleInfo.getId(), resourceInfo.getResourceId());
// roleResourceDao.save(roleResourceEntity);
// }
// }
// log.info("新增角色信息:" + JSONObject.toJSONString(roleInfo));
// return Result.success(roleInfo);
// }
//
//
// private RoleResourceEntity assembleRoleResource(String roleId, String resourceId) {
// RoleResourceEntity roleResourceEntity = new RoleResourceEntity();
// roleResourceEntity.setRoleId(roleId);
// roleResourceEntity.setResourceId(resourceId);
// return roleResourceEntity;
// }
//
//
// }
project-user/src/main/java/com/dituhui/pea/user/service/UserService.java
View file @
6e37c20
...
...
@@ -102,17 +102,20 @@ public class UserService {
public
Result
<
UserLoginDTO
>
userLogin
(
String
account
,
String
password
)
{
UserEntity
user
=
userDao
.
findByAccountAndPassword
(
account
,
SecureUtil
.
md5
(
password
));
log
.
info
(
"{}/{} login"
,
account
,
password
);
if
(
null
!=
user
)
{
UserLoginDTO
userDTO
=
convertToUserLoginDTO
(
user
);
// 生成token
String
token
=
IdUtil
.
simpleUUID
();
userDTO
.
setToken
(
token
);
long
timestamp
=
System
.
currentTimeMillis
()
+
LIVE_TIME_MILLIS
;
redisService
.
set
(
RedisKeyGroup
.
authToken
+
":"
+
token
,
gson
.
toJson
(
userDTO
),
timestamp
/
1000
);
return
Result
.
success
(
userDTO
);
}
else
{
if
(
null
==
user
)
{
return
Result
.
failure
(
"鉴权失败"
);
}
//判断用户禁用/异常情况
if
(
user
.
getBan
()
==
1
||
user
.
getStatus
()
==
0
)
{
Result
.
failed
(
StatusCodeEnum
.
USER_ISBAN_OR_ERROR
,
null
);
}
UserLoginDTO
userDTO
=
convertToUserLoginDTO
(
user
);
// 生成token
String
token
=
IdUtil
.
simpleUUID
();
userDTO
.
setToken
(
token
);
long
timestamp
=
System
.
currentTimeMillis
()
+
LIVE_TIME_MILLIS
;
redisService
.
set
(
RedisKeyGroup
.
authToken
+
":"
+
token
,
gson
.
toJson
(
userDTO
),
timestamp
/
1000
);
return
Result
.
success
(
userDTO
);
}
private
UserLoginDTO
convertToUserLoginDTO
(
UserEntity
user
)
{
...
...
@@ -157,7 +160,7 @@ public class UserService {
ResourceInfo
res
=
BeanUtil
.
copyProperties
(
r
,
ResourceInfo
.
class
);
splitMenuExtra
(
res
);
return
res
;
}).
sorted
(
Comparator
.
comparing
(
ResourceInfo:
:
getOrder
)).
collect
(
Collectors
.
toList
());
}).
collect
(
Collectors
.
toList
());
resourceInfo
.
setChildren
(
levelTowResourceInfo
);
}
levelOne
=
levelOne
.
stream
().
sorted
(
Comparator
.
comparing
(
ResourceInfo:
:
getOrder
))
...
...
@@ -193,6 +196,9 @@ public class UserService {
}
private
void
splitMenuExtra
(
ResourceInfo
resourceInfo
)
{
if
(
StringUtils
.
isBlank
(
resourceInfo
.
getExtra
()))
{
return
;
}
String
[]
temp
=
resourceInfo
.
getExtra
().
split
(
","
);
resourceInfo
.
setCode
(
temp
[
0
]);
resourceInfo
.
setOrder
(
Integer
.
parseInt
(
temp
[
1
]));
...
...
@@ -482,7 +488,7 @@ public class UserService {
//处理用户机构关联信息
if
(
CollectionUtils
.
isNotEmpty
(
userInfo
.
getOrgIds
())
&&
null
!=
userInfo
.
getOrgIds
())
{
userOrgDao
.
deleteByUserId
(
userInfo
.
getId
());
for
(
Integer
orgId
:
userInfo
.
getOrgIds
())
{
for
(
String
orgId
:
userInfo
.
getOrgIds
())
{
UserOrgEntity
userOrgEntity
=
new
UserOrgEntity
();
userOrgEntity
.
setUserId
(
userInfo
.
getId
());
userOrgEntity
.
setOrgId
(
orgId
);
...
...
Write
Preview
Markdown
is supported
Attach a file
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 post a comment