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 f22a2117
authored
Oct 08, 2023
by
huangjinxin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix:用户密码初始化
feat:用户组织获取
1 parent
7f9608db
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
63 additions
and
5 deletions
project-interface/src/main/java/com/dituhui/pea/pojo/user/OrgInfo.java
project-interface/src/main/java/com/dituhui/pea/user/IUser.java
project-user/src/main/java/com/dituhui/pea/user/controller/UserController.java
project-user/src/main/java/com/dituhui/pea/user/dao/UserOrgDao.java
project-user/src/main/java/com/dituhui/pea/user/service/UserService.java
project-interface/src/main/java/com/dituhui/pea/pojo/user/OrgInfo.java
0 → 100644
View file @
f22a211
package
com
.
dituhui
.
pea
.
pojo
.
user
;
import
lombok.Data
;
import
java.io.Serializable
;
@Data
public
class
OrgInfo
implements
Serializable
{
/**
* 机构id
*/
private
Integer
id
;
/**
* 机构名称
*/
private
String
name
;
}
project-interface/src/main/java/com/dituhui/pea/user/IUser.java
View file @
f22a211
...
@@ -2,6 +2,7 @@ package com.dituhui.pea.user;
...
@@ -2,6 +2,7 @@ package com.dituhui.pea.user;
import
com.dituhui.pea.common.PageResult
;
import
com.dituhui.pea.common.PageResult
;
import
com.dituhui.pea.pojo.*
;
import
com.dituhui.pea.pojo.*
;
import
com.dituhui.pea.pojo.user.OrgInfo
;
import
org.springframework.cloud.openfeign.FeignClient
;
import
org.springframework.cloud.openfeign.FeignClient
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestHeader
;
import
org.springframework.web.bind.annotation.RequestHeader
;
...
@@ -12,6 +13,8 @@ import org.springframework.web.bind.annotation.RequestParam;
...
@@ -12,6 +13,8 @@ import org.springframework.web.bind.annotation.RequestParam;
import
com.dituhui.pea.common.Result
;
import
com.dituhui.pea.common.Result
;
import
com.dituhui.pea.enums.ThirdPartyEnum
;
import
com.dituhui.pea.enums.ThirdPartyEnum
;
import
java.util.List
;
/**
/**
* 用户相关接口
* 用户相关接口
*
*
...
@@ -162,4 +165,14 @@ public interface IUser {
...
@@ -162,4 +165,14 @@ public interface IUser {
@RequestMapping
(
value
=
"/pea-user/ban"
,
method
=
RequestMethod
.
POST
)
@RequestMapping
(
value
=
"/pea-user/ban"
,
method
=
RequestMethod
.
POST
)
Result
<
Boolean
>
ban
(
@RequestBody
UserInfoSearch
search
);
Result
<
Boolean
>
ban
(
@RequestBody
UserInfoSearch
search
);
/**
* 获取用户组织
*
* @param userId 查询条件
* @return
*/
@RequestMapping
(
value
=
"/pea-user/orgs"
,
method
=
RequestMethod
.
GET
)
Result
<
List
<
OrgInfo
>>
orgs
(
String
userId
);
}
}
project-user/src/main/java/com/dituhui/pea/user/controller/UserController.java
View file @
f22a211
...
@@ -3,6 +3,8 @@ package com.dituhui.pea.user.controller;
...
@@ -3,6 +3,8 @@ package com.dituhui.pea.user.controller;
import
com.dituhui.pea.common.PageResult
;
import
com.dituhui.pea.common.PageResult
;
import
com.dituhui.pea.pojo.*
;
import
com.dituhui.pea.pojo.*
;
import
com.dituhui.pea.pojo.user.OrgInfo
;
import
com.dituhui.pea.user.dao.UserOrgDao
;
import
org.apache.commons.lang.StringUtils
;
import
org.apache.commons.lang.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.validation.annotation.Validated
;
...
@@ -16,6 +18,8 @@ import com.dituhui.pea.user.service.UserService;
...
@@ -16,6 +18,8 @@ import com.dituhui.pea.user.service.UserService;
import
cn.hutool.core.util.ObjectUtil
;
import
cn.hutool.core.util.ObjectUtil
;
import
java.util.List
;
/**
/**
* 用户控制层
* 用户控制层
*/
*/
...
@@ -91,9 +95,9 @@ public class UserController implements IUser {
...
@@ -91,9 +95,9 @@ public class UserController implements IUser {
if
(
StringUtils
.
isBlank
(
userInfo
.
getAccount
()))
{
if
(
StringUtils
.
isBlank
(
userInfo
.
getAccount
()))
{
return
Result
.
failed
(
StatusCodeEnum
.
COMMON_PARAM_EMPTY
,
null
);
return
Result
.
failed
(
StatusCodeEnum
.
COMMON_PARAM_EMPTY
,
null
);
}
}
if
(
StringUtils
.
isBlank
(
userInfo
.
getPassword
()))
{
//
if (StringUtils.isBlank(userInfo.getPassword())) {
return
Result
.
failed
(
StatusCodeEnum
.
COMMON_PARAM_EMPTY
,
null
);
//
return Result.failed(StatusCodeEnum.COMMON_PARAM_EMPTY, null);
}
//
}
return
userService
.
saveUser
(
userInfo
);
return
userService
.
saveUser
(
userInfo
);
}
}
...
@@ -156,4 +160,10 @@ public class UserController implements IUser {
...
@@ -156,4 +160,10 @@ public class UserController implements IUser {
return
Result
.
success
(
true
);
return
Result
.
success
(
true
);
}
}
@Override
public
Result
<
List
<
OrgInfo
>>
orgs
(
String
userId
)
{
List
<
OrgInfo
>
orgInfos
=
userService
.
orgs
(
userId
);
return
Result
.
success
(
orgInfos
);
}
}
}
project-user/src/main/java/com/dituhui/pea/user/dao/UserOrgDao.java
View file @
f22a211
...
@@ -5,6 +5,8 @@ import org.springframework.data.jpa.repository.JpaRepository;
...
@@ -5,6 +5,8 @@ import org.springframework.data.jpa.repository.JpaRepository;
import
org.springframework.data.jpa.repository.JpaSpecificationExecutor
;
import
org.springframework.data.jpa.repository.JpaSpecificationExecutor
;
import
org.springframework.data.repository.CrudRepository
;
import
org.springframework.data.repository.CrudRepository
;
import
java.util.List
;
/**
/**
* 用户组织关联表
* 用户组织关联表
*/
*/
...
@@ -17,7 +19,7 @@ public interface UserOrgDao extends JpaRepository<UserOrgEntity, String>, JpaSpe
...
@@ -17,7 +19,7 @@ public interface UserOrgDao extends JpaRepository<UserOrgEntity, String>, JpaSpe
* @param id
* @param id
* @return
* @return
*/
*/
UserOrgEntity
findByUserId
(
String
i
d
);
List
<
UserOrgEntity
>
findByUserId
(
String
userI
d
);
void
deleteByUserId
(
String
userId
);
void
deleteByUserId
(
String
userId
);
}
}
project-user/src/main/java/com/dituhui/pea/user/service/UserService.java
View file @
f22a211
...
@@ -13,6 +13,7 @@ import javax.persistence.criteria.Predicate;
...
@@ -13,6 +13,7 @@ import javax.persistence.criteria.Predicate;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
com.dituhui.pea.common.PageResult
;
import
com.dituhui.pea.common.PageResult
;
import
com.dituhui.pea.pojo.*
;
import
com.dituhui.pea.pojo.*
;
import
com.dituhui.pea.pojo.user.OrgInfo
;
import
com.dituhui.pea.user.dao.*
;
import
com.dituhui.pea.user.dao.*
;
import
com.dituhui.pea.user.entity.*
;
import
com.dituhui.pea.user.entity.*
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
...
@@ -294,7 +295,7 @@ public class UserService {
...
@@ -294,7 +295,7 @@ public class UserService {
}
}
UserEntity
userEntity
=
BeanUtil
.
copyProperties
(
userInfo
,
UserEntity
.
class
);
UserEntity
userEntity
=
BeanUtil
.
copyProperties
(
userInfo
,
UserEntity
.
class
);
// 密码MD5加密
// 密码MD5加密
userEntity
.
setPassword
(
SecureUtil
.
md5
(
user
Info
.
getPassword
(
)));
userEntity
.
setPassword
(
SecureUtil
.
md5
(
user
Entity
.
getPhone
().
substring
(
userEntity
.
getPhone
().
length
()
-
6
)));
// 保存用户信息
// 保存用户信息
userEntity
=
userDao
.
save
(
userEntity
);
userEntity
=
userDao
.
save
(
userEntity
);
userInfo
.
setId
(
userEntity
.
getId
());
userInfo
.
setId
(
userEntity
.
getId
());
...
@@ -772,4 +773,17 @@ public class UserService {
...
@@ -772,4 +773,17 @@ public class UserService {
userDao
.
save
(
byId
);
userDao
.
save
(
byId
);
}
}
}
}
public
List
<
OrgInfo
>
orgs
(
String
userId
)
{
List
<
OrgInfo
>
orgInfos
=
new
ArrayList
<>();
List
<
UserOrgEntity
>
byUserId
=
userOrgDao
.
findByUserId
(
userId
);
if
(
CollectionUtils
.
isEmpty
(
byUserId
))
{
return
orgInfos
;
}
byUserId
.
forEach
(
e
->
{
OrgInfo
orgInfo
=
new
OrgInfo
();
orgInfo
.
setId
(
e
.
getOrgId
());
});
return
orgInfos
;
}
}
}
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