Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
eshiled-new
/
ne-shield-miniappserver
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 2ba62d68
authored
Jun 30, 2022
by
levphon
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
微信小程序C端账号体系
1 parent
b16d7f2b
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
159 additions
and
64 deletions
src/main/java/cn/com/glsx/app/modules/entity/User.java
src/main/java/cn/com/glsx/app/modules/entity/UserAuthRel.java
src/main/java/cn/com/glsx/app/modules/entity/UserLocalAccount.java
src/main/java/cn/com/glsx/app/modules/entity/UserLocalAuth.java
src/main/java/cn/com/glsx/app/modules/entity/UserQQAccount.java
src/main/java/cn/com/glsx/app/modules/entity/UserThirdAuth.java
src/main/java/cn/com/glsx/app/modules/entity/UserWechatAccount.java
src/main/java/cn/com/glsx/app/modules/entity/VehicleShared.java
src/main/java/cn/com/glsx/app/modules/mapper/UserLocalAuthMapper.java
src/main/java/cn/com/glsx/app/modules/mapper/UserMapper.java
src/main/java/cn/com/glsx/app/modules/mapper/VehicleSharedMapper.java
src/main/java/cn/com/glsx/app/modules/service/LoginService.java
src/main/resources/mapper/UserAuthRelMapper.xml
src/main/resources/mapper/UserLocalAccountMapper.xml
src/main/resources/mapper/UserLocalAuthMapper.xml
src/main/resources/mapper/UserMapper.xml
src/main/resources/mapper/UserQQAccountMapper.xml
src/main/resources/mapper/UserThirdAuthMapper.xml
src/main/resources/mapper/UserWechatAccountMapper.xml
src/main/resources/mapper/VehicleSharedMapper.xml
src/main/java/cn/com/glsx/app/modules/entity/User.java
View file @
2ba62d6
...
...
@@ -34,11 +34,6 @@ public class User extends BaseEntity {
private
Long
linkerId
;
/**
* 用户账户/手机号
*/
private
String
account
;
/**
* 状态:0白名单,临时封禁(blacklist>0,值为封禁天数),永久封禁(del_flag=-1)
*/
private
Integer
blacklist
;
...
...
src/main/java/cn/com/glsx/app/modules/entity/UserAuthRel.java
View file @
2ba62d6
...
...
@@ -7,7 +7,7 @@ import javax.persistence.Column;
import
javax.persistence.Table
;
@Data
@Table
(
name
=
"t_user_auth_rel"
)
@Table
(
name
=
"t_
cust_
user_auth_rel"
)
public
class
UserAuthRel
extends
BaseEntity
{
/**
...
...
src/main/java/cn/com/glsx/app/modules/entity/UserLocalAccount.java
View file @
2ba62d6
...
...
@@ -7,16 +7,10 @@ import javax.persistence.Column;
import
javax.persistence.Table
;
@Data
@Table
(
name
=
"t_user_local_account"
)
@Table
(
name
=
"t_
cust_
user_local_account"
)
public
class
UserLocalAccount
extends
BaseEntity
{
/**
* 用户id 为了方便,这里冗余用户id
*/
@Column
(
name
=
"user_id"
)
private
Long
userId
;
/**
* 认证id
*/
@Column
(
name
=
"auth_id"
)
...
...
src/main/java/cn/com/glsx/app/modules/entity/UserLocalAuth.java
View file @
2ba62d6
...
...
@@ -7,7 +7,7 @@ import javax.persistence.Column;
import
javax.persistence.Table
;
@Data
@Table
(
name
=
"t_user_local_auth"
)
@Table
(
name
=
"t_
cust_
user_local_auth"
)
public
class
UserLocalAuth
extends
BaseEntity
{
/**
...
...
@@ -19,7 +19,7 @@ public class UserLocalAuth extends BaseEntity {
/**
* 密码
*/
@Column
(
name
=
"
account
"
)
@Column
(
name
=
"
password
"
)
private
String
password
;
}
\ No newline at end of file
src/main/java/cn/com/glsx/app/modules/entity/UserQQAccount.java
View file @
2ba62d6
...
...
@@ -7,7 +7,7 @@ import javax.persistence.Column;
import
javax.persistence.Table
;
@Data
@Table
(
name
=
"t_user_qq_account"
)
@Table
(
name
=
"t_
cust_
user_qq_account"
)
public
class
UserQQAccount
extends
BaseEntity
{
/**
...
...
src/main/java/cn/com/glsx/app/modules/entity/UserThirdAuth.java
View file @
2ba62d6
...
...
@@ -7,7 +7,7 @@ import javax.persistence.Column;
import
javax.persistence.Table
;
@Data
@Table
(
name
=
"t_user_third_auth"
)
@Table
(
name
=
"t_
cust_
user_third_auth"
)
public
class
UserThirdAuth
extends
BaseEntity
{
/**
...
...
src/main/java/cn/com/glsx/app/modules/entity/UserWechatAccount.java
View file @
2ba62d6
...
...
@@ -7,7 +7,7 @@ import javax.persistence.Column;
import
javax.persistence.Table
;
@Data
@Table
(
name
=
"t_user_wechat_account"
)
@Table
(
name
=
"t_
cust_
user_wechat_account"
)
public
class
UserWechatAccount
extends
BaseEntity
{
/**
...
...
src/main/java/cn/com/glsx/app/modules/entity/VehicleShared.java
0 → 100644
View file @
2ba62d6
package
cn
.
com
.
glsx
.
app
.
modules
.
entity
;
import
com.glsx.plat.mybatis.base.BaseEntity
;
import
lombok.Data
;
import
javax.persistence.Column
;
import
javax.persistence.Table
;
import
java.util.Date
;
@Data
@Table
(
name
=
"t_vehicle_shared"
)
public
class
VehicleShared
extends
BaseEntity
{
/**
* 授权人id,对应t_cust_user表id
*/
@Column
(
name
=
"accorder_id"
)
private
Long
accorderId
;
/**
* 获权人id,对应t_cust_user表id
*/
@Column
(
name
=
"receiver_id"
)
private
Long
receiverId
;
/**
* 授权数据id
*/
@Column
(
name
=
"content_id"
)
private
Long
contentId
;
/**
* 内容类型:0车辆
*/
@Column
(
name
=
"content_type"
)
private
Integer
contentType
;
/**
* 权限类型 r=只读 wr=读写
*/
@Column
(
name
=
"permit_type"
)
private
String
permitType
;
/**
* 生效时间
*/
@Column
(
name
=
"effective_date"
)
private
Date
effectiveDate
;
/**
* 失效时间
*/
@Column
(
name
=
"expiration_date"
)
private
Date
expirationDate
;
/**
* 状态:0默认,1有效,2失效
*/
private
Integer
status
;
}
\ No newline at end of file
src/main/java/cn/com/glsx/app/modules/mapper/UserLocalAuthMapper.java
View file @
2ba62d6
...
...
@@ -8,6 +8,8 @@ import org.apache.ibatis.annotations.Param;
@Mapper
public
interface
UserLocalAuthMapper
extends
CommonBaseMapper
<
UserLocalAuth
>
{
UserLocalAuth
selectByAccount
(
@Param
(
"account"
)
String
account
);
UserLocalAuth
selectByAuthId
(
@Param
(
"authId"
)
Long
authId
);
UserLocalAuth
selectByUserId
(
@Param
(
"userId"
)
Long
userId
);
...
...
src/main/java/cn/com/glsx/app/modules/mapper/UserMapper.java
View file @
2ba62d6
...
...
@@ -10,8 +10,6 @@ public interface UserMapper extends CommonBaseMapper<User> {
User
selectById
(
@Param
(
"id"
)
Long
id
);
User
selectByAccount
(
@Param
(
"account"
)
String
account
);
int
saveOrUpdate
(
User
user
);
}
\ No newline at end of file
src/main/java/cn/com/glsx/app/modules/mapper/VehicleSharedMapper.java
0 → 100644
View file @
2ba62d6
package
cn
.
com
.
glsx
.
app
.
modules
.
mapper
;
import
cn.com.glsx.app.modules.entity.VehicleShared
;
import
com.glsx.plat.mybatis.mapper.CommonBaseMapper
;
import
org.apache.ibatis.annotations.Mapper
;
@Mapper
public
interface
VehicleSharedMapper
extends
CommonBaseMapper
<
VehicleShared
>
{
}
\ No newline at end of file
src/main/java/cn/com/glsx/app/modules/service/LoginService.java
View file @
2ba62d6
...
...
@@ -24,7 +24,6 @@ import org.springframework.transaction.annotation.Transactional;
import
javax.annotation.Resource
;
import
java.util.Date
;
import
java.util.Optional
;
@Slf4j
@Service
...
...
@@ -57,7 +56,6 @@ public class LoginService {
@Autowired
private
BCryptPasswordEncoder
bCryptPasswordEncoder
;
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
AppUser
localAuth
(
LoginByAccountBO
loginBO
)
{
//内部登录转成appUser返回前端
if
(
loginBO
.
getLoginType
()
==
1
)
{
...
...
@@ -70,8 +68,10 @@ public class LoginService {
User
user
=
register
(
simpleUser
);
//返给前端的用户信息
AppUser
appUser
=
UserConverter
.
INSTANCE
.
su2au
(
simpleUser
);
appUser
.
setUserType
(
MiniUserType
.
NORMAL
.
getType
());
return
appUser
;
}
else
if
(
loginBO
.
getLoginType
()
==
2
)
{
//验证码校验
//smsService.verifyCode(loginBO.getAccount(), loginBO.getCode());
...
...
@@ -84,36 +84,21 @@ public class LoginService {
*
* @param simpleUser
*/
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
User
register
(
SimpleUser
simpleUser
)
{
User
user
=
Optional
.
ofNullable
(
userMapper
.
selectByAccount
(
simpleUser
.
getAccount
())).
orElse
(
new
User
());
user
.
setLinkerId
(
simpleUser
.
getId
());
user
.
setAccount
(
simpleUser
.
getAccount
());
user
.
setBlacklist
(
simpleUser
.
getBlacklist
());
userMapper
.
saveOrUpdate
(
user
);
UserLocalAuth
localAuth
=
userLocalAuthMapper
.
selectByUserId
(
user
.
getId
());
UserLocalAuth
localAuth
=
userLocalAuthMapper
.
selectByAccount
(
simpleUser
.
getAccount
());
if
(
localAuth
==
null
)
{
localAuth
=
new
UserLocalAuth
();
localAuth
.
setAccount
(
u
ser
.
getAccount
());
String
encryptedPasswd
=
bCryptPasswordEncoder
.
encode
(
u
ser
.
getAccount
());
localAuth
.
setAccount
(
simpleU
ser
.
getAccount
());
String
encryptedPasswd
=
bCryptPasswordEncoder
.
encode
(
simpleU
ser
.
getAccount
());
localAuth
.
setPassword
(
encryptedPasswd
);
userLocalAuthMapper
.
insertUseGeneratedKeys
(
localAuth
);
}
UserAuthRel
userAuthRel
=
userAuthRelMapper
.
selectByAuthTypeAndAuthId
(
AuthType
.
LOCAL
.
getType
(),
localAuth
.
getId
());
if
(
userAuthRel
==
null
)
{
userAuthRel
=
new
UserAuthRel
();
userAuthRel
.
setUserId
(
user
.
getId
());
userAuthRel
.
setAuthId
(
localAuth
.
getId
());
userAuthRel
.
setAuthType
(
AuthType
.
LOCAL
.
getType
());
userAuthRelMapper
.
insertUseGeneratedKeys
(
userAuthRel
);
userLocalAuthMapper
.
insert
(
localAuth
);
}
//生成本地账号
UserLocalAccount
localAccount
=
userLocalAccountMapper
.
selectByAuthId
(
user
.
getId
());
UserLocalAccount
localAccount
=
userLocalAccountMapper
.
selectByAuthId
(
localAuth
.
getId
());
if
(
localAccount
==
null
)
{
localAccount
=
new
UserLocalAccount
();
//localAccount.setUserId(user.getId());
localAccount
.
setAuthId
(
localAuth
.
getId
());
localAccount
.
setUsername
(
simpleUser
.
getUsername
());
//生成平台unionId
...
...
@@ -128,6 +113,29 @@ public class LoginService {
userLocalAccountMapper
.
updateByPrimaryKeySelective
(
localAccount
);
}
}
//自定义用户主体
User
user
=
null
;
UserAuthRel
userAuthRel
=
userAuthRelMapper
.
selectByAuthTypeAndAuthId
(
AuthType
.
LOCAL
.
getType
(),
localAuth
.
getId
());
if
(
userAuthRel
==
null
)
{
user
=
new
User
();
user
.
setLinkerId
(
simpleUser
.
getId
());
user
.
setBlacklist
(
simpleUser
.
getBlacklist
());
userMapper
.
saveOrUpdate
(
user
);
userAuthRel
=
new
UserAuthRel
();
userAuthRel
.
setUserId
(
user
.
getId
());
userAuthRel
.
setAuthId
(
localAuth
.
getId
());
userAuthRel
.
setAuthType
(
AuthType
.
LOCAL
.
getType
());
userAuthRelMapper
.
insertUseGeneratedKeys
(
userAuthRel
);
return
user
;
}
else
{
user
=
userMapper
.
selectById
(
userAuthRel
.
getUserId
());
if
(
user
==
null
)
{
// TODO: 2022/6/30 抛出异常
}
}
return
user
;
}
...
...
src/main/resources/mapper/UserAuthRelMapper.xml
View file @
2ba62d6
...
...
@@ -26,7 +26,7 @@
<select
id=
"selectByAuthTypeAndAuthId"
resultMap=
"BaseResultMap"
>
select
<include
refid=
"Base_Column_List"
/>
from t_user_auth_rel
from t_
cust_
user_auth_rel
where auth_type = #{authType}
and auth_id = #{authId}
and del_flag = 0
...
...
@@ -36,7 +36,7 @@
<select
id=
"selectByAuthTypeAndUserId"
resultMap=
"BaseResultMap"
>
select
<include
refid=
"Base_Column_List"
/>
from t_user_auth_rel
from t_
cust_
user_auth_rel
where auth_type = #{authType}
and user_id = #{userId}
and del_flag = 0
...
...
src/main/resources/mapper/UserLocalAccountMapper.xml
View file @
2ba62d6
...
...
@@ -6,7 +6,6 @@
WARNING - @mbg.generated
-->
<id
column=
"id"
jdbcType=
"INTEGER"
property=
"id"
/>
<result
column=
"user_id"
jdbcType=
"INTEGER"
property=
"userId"
/>
<result
column=
"auth_id"
jdbcType=
"INTEGER"
property=
"authId"
/>
<result
column=
"union_id"
jdbcType=
"VARCHAR"
property=
"unionId"
/>
<result
column=
"username"
jdbcType=
"VARCHAR"
property=
"username"
/>
...
...
@@ -21,7 +20,7 @@
<!--
WARNING - @mbg.generated
-->
id,
user_id,
auth_id, union_id, username, avatar, del_flag, created_date, created_by,
id, auth_id, union_id, username, avatar, del_flag, created_date, created_by,
updated_date, updated_by
</sql>
...
...
@@ -42,9 +41,9 @@
tcu.blacklist
from t_cust_user_local_account tcula
inner join t_cust_user_auth_rel tcuar on tcula.id = tcuar.auth_id
left join t_cust_user tcu on tcu.id = tcu
la
.user_id
left join t_cust_user tcu on tcu.id = tcu
ar
.user_id
where tcula.del_flag = 0
and tcuar.auth_type = 'local'
and tcu
la
.user_id = #{userId} limit 1
and tcu
ar
.user_id = #{userId} limit 1
</select>
</mapper>
\ No newline at end of file
src/main/resources/mapper/UserLocalAuthMapper.xml
View file @
2ba62d6
...
...
@@ -31,6 +31,14 @@
and tcuar.auth_id = #{authId} limit 1
</select>
<select
id=
"selectByAccount"
resultMap=
"BaseResultMap"
>
select
<include
refid=
"Base_Column_List"
/>
from t_cust_user_local_auth
where account = #{account}
and del_flag = 0
</select>
<select
id=
"selectByUserId"
resultMap=
"BaseResultMap"
>
select tcula.*
from t_cust_user_local_auth tcula
...
...
src/main/resources/mapper/UserMapper.xml
View file @
2ba62d6
...
...
@@ -10,7 +10,6 @@
<result
column=
"expire_in"
jdbcType=
"INTEGER"
property=
"expireIn"
/>
<result
column=
"try_times"
jdbcType=
"INTEGER"
property=
"tryTimes"
/>
<result
column=
"linker_id"
jdbcType=
"INTEGER"
property=
"linkerId"
/>
<result
column=
"account"
jdbcType=
"VARCHAR"
property=
"account"
/>
<result
column=
"blacklist"
jdbcType=
"TINYINT"
property=
"blacklist"
/>
<result
column=
"del_flag"
jdbcType=
"TINYINT"
property=
"delFlag"
/>
<result
column=
"created_date"
jdbcType=
"TIMESTAMP"
property=
"createdDate"
/>
...
...
@@ -22,7 +21,7 @@
<!--
WARNING - @mbg.generated
-->
id, token, expire_in, try_times, linker_id,
account,
blacklist, del_flag, created_date, created_by, updated_date,
id, token, expire_in, try_times, linker_id, blacklist, del_flag, created_date, created_by, updated_date,
updated_by
</sql>
...
...
@@ -34,17 +33,9 @@
and del_flag = 0
</select>
<select
id=
"selectByAccount"
resultMap=
"BaseResultMap"
>
select
<include
refid=
"Base_Column_List"
/>
from t_cust_user
where account = #{account}
and del_flag = 0
</select>
<insert
id=
"saveOrUpdate"
useGeneratedKeys=
"true"
keyProperty=
"id"
parameterType=
"cn.com.glsx.app.modules.entity.User"
>
INSERT INTO t_cust_user (id, linker_id,
account,
blacklist, del_flag, created_date)
VALUES (#{id}, #{linkerId}, #{
account}, #{
blacklist}, 0, sysdate()) ON DUPLICATE KEY
INSERT INTO t_cust_user (id, linker_id, blacklist, del_flag, created_date)
VALUES (#{id}, #{linkerId}, #{blacklist}, 0, sysdate()) ON DUPLICATE KEY
UPDATE updated_date = sysdate()
</insert>
</mapper>
\ No newline at end of file
src/main/resources/mapper/UserQQAccountMapper.xml
View file @
2ba62d6
...
...
@@ -27,7 +27,7 @@
<select
id=
"selectByAuthId"
resultMap=
"BaseResultMap"
>
select
<include
refid=
"Base_Column_List"
/>
from t_user_qq_account
from t_
cust_
user_qq_account
where auth_id = #{authId}
and del_flag = 0
</select>
...
...
src/main/resources/mapper/UserThirdAuthMapper.xml
View file @
2ba62d6
...
...
@@ -26,7 +26,7 @@
<select
id=
"selectByOpenid"
resultMap=
"BaseResultMap"
>
select
<include
refid=
"Base_Column_List"
/>
from t_user_third_auth
from t_
cust_
user_third_auth
where openid = #{openid}
and del_flag = 0
</select>
...
...
src/main/resources/mapper/UserWechatAccountMapper.xml
View file @
2ba62d6
...
...
@@ -27,7 +27,7 @@
<select
id=
"selectByAuthId"
resultMap=
"BaseResultMap"
>
select
<include
refid=
"Base_Column_List"
/>
from t_user_wechat_account
from t_
cust_
user_wechat_account
where auth_id = #{authId}
and del_flag = 0
</select>
...
...
src/main/resources/mapper/VehicleSharedMapper.xml
0 → 100644
View file @
2ba62d6
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace=
"cn.com.glsx.app.modules.mapper.VehicleSharedMapper"
>
<resultMap
id=
"BaseResultMap"
type=
"cn.com.glsx.app.modules.entity.VehicleShared"
>
<!--
WARNING - @mbg.generated
-->
<id
column=
"id"
jdbcType=
"INTEGER"
property=
"id"
/>
<result
column=
"accorder_id"
jdbcType=
"INTEGER"
property=
"accorderId"
/>
<result
column=
"receiver_id"
jdbcType=
"INTEGER"
property=
"receiverId"
/>
<result
column=
"content_id"
jdbcType=
"INTEGER"
property=
"contentId"
/>
<result
column=
"content_type"
jdbcType=
"TINYINT"
property=
"contentType"
/>
<result
column=
"permit_type"
jdbcType=
"VARCHAR"
property=
"permitType"
/>
<result
column=
"effective_date"
jdbcType=
"TIMESTAMP"
property=
"effectiveDate"
/>
<result
column=
"expiration_date"
jdbcType=
"TIMESTAMP"
property=
"expirationDate"
/>
<result
column=
"status"
jdbcType=
"TINYINT"
property=
"status"
/>
<result
column=
"del_flag"
jdbcType=
"TINYINT"
property=
"delFlag"
/>
<result
column=
"created_date"
jdbcType=
"TIMESTAMP"
property=
"createdDate"
/>
<result
column=
"created_by"
jdbcType=
"INTEGER"
property=
"createdBy"
/>
<result
column=
"updated_date"
jdbcType=
"TIMESTAMP"
property=
"updatedDate"
/>
<result
column=
"updated_by"
jdbcType=
"INTEGER"
property=
"updatedBy"
/>
</resultMap>
<sql
id=
"Base_Column_List"
>
<!--
WARNING - @mbg.generated
-->
id, accorder_id, receiver_id, content_id, content_type, permit_type, effective_date,
expiration_date, `status`, del_flag, created_date, created_by, updated_date, updated_by
</sql>
</mapper>
\ No newline at end of file
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