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 f16f8f8f
authored
Jun 27, 2022
by
levphon
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
微信小程序C端账号体系
1 parent
a9c90d1c
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
19 changed files
with
271 additions
and
164 deletions
src/main/java/cn/com/glsx/app/config/BeansConfig.java
src/main/java/cn/com/glsx/app/modules/ThirdLoginController.java
src/main/java/cn/com/glsx/app/modules/entity/User.java
src/main/java/cn/com/glsx/app/modules/entity/UserLocalAuth.java
src/main/java/cn/com/glsx/app/modules/mapper/UserAuthRelMapper.java
src/main/java/cn/com/glsx/app/modules/mapper/UserLocalAccountMapper.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/UserThirdAuthMapper.java
src/main/java/cn/com/glsx/app/modules/model/QQLoginBO.java
src/main/java/cn/com/glsx/app/modules/model/WechatLoginBO.java
src/main/java/cn/com/glsx/app/modules/service/LoginService.java
src/main/java/cn/com/glsx/app/modules/service/UserService.java
src/main/java/cn/com/glsx/app/modules/service/VehicleMonitorService.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/UserThirdAuthMapper.xml
src/main/java/cn/com/glsx/app/config/BeansConfig.java
0 → 100644
View file @
f16f8f8
package
cn
.
com
.
glsx
.
app
.
config
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder
;
@Configuration
public
class
BeansConfig
{
@Bean
public
BCryptPasswordEncoder
encoder
()
{
return
new
BCryptPasswordEncoder
();
}
}
src/main/java/cn/com/glsx/app/modules/ThirdLoginController.java
View file @
f16f8f8
...
@@ -2,11 +2,10 @@ package cn.com.glsx.app.modules;
...
@@ -2,11 +2,10 @@ package cn.com.glsx.app.modules;
import
cn.binarywang.wx.miniapp.api.WxMaService
;
import
cn.binarywang.wx.miniapp.api.WxMaService
;
import
cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult
;
import
cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult
;
import
cn.com.glsx.app.common.enums.LoginType
;
import
cn.com.glsx.app.modules.entity.UserAuthRel
;
import
cn.com.glsx.app.modules.entity.UserAuthRel
;
import
cn.com.glsx.app.modules.model.AppUser
;
import
cn.com.glsx.app.modules.model.AppUser
;
import
cn.com.glsx.app.modules.model.QQLoginBO
;
import
cn.com.glsx.app.modules.model.QQOAuth2AccessToken
;
import
cn.com.glsx.app.modules.model.QQOAuth2AccessToken
;
import
cn.com.glsx.app.modules.model.WechatLoginBO
;
import
cn.com.glsx.app.modules.service.LoginService
;
import
cn.com.glsx.app.modules.service.LoginService
;
import
cn.com.glsx.app.modules.service.UserService
;
import
cn.com.glsx.app.modules.service.UserService
;
import
cn.hutool.json.JSONUtil
;
import
cn.hutool.json.JSONUtil
;
...
@@ -15,7 +14,9 @@ import com.glsx.plat.core.web.R;
...
@@ -15,7 +14,9 @@ import com.glsx.plat.core.web.R;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
me.chanjar.weixin.common.error.WxErrorException
;
import
me.chanjar.weixin.common.error.WxErrorException
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
javax.annotation.Resource
;
import
javax.annotation.Resource
;
import
java.util.HashMap
;
import
java.util.HashMap
;
...
@@ -41,65 +42,45 @@ public class ThirdLoginController {
...
@@ -41,65 +42,45 @@ public class ThirdLoginController {
private
WxMaService
wxMaService
;
private
WxMaService
wxMaService
;
@NoLogin
@NoLogin
@GetMapping
(
value
=
"/wechatAuth"
)
public
R
wechatAuth
(
@RequestParam
String
code
)
throws
WxErrorException
{
//获取openId、unionid、session_key
WxMaJscode2SessionResult
sessionInfo
=
wxMaService
.
getUserService
().
getSessionInfo
(
code
);
log
.
info
(
"微信code[{}]获取的Session信息为{}"
,
code
,
JSONUtil
.
toJsonStr
(
sessionInfo
));
UserAuthRel
authRel
=
loginService
.
wechatAuth
(
sessionInfo
);
Map
<
String
,
Object
>
rtnMap
=
thirdLogin
(
authRel
);
return
R
.
ok
().
data
(
rtnMap
);
}
@NoLogin
@PostMapping
(
value
=
"/wechatLogin"
)
public
R
wechatLogin
(
@RequestBody
WechatLoginBO
loginBO
)
{
log
.
info
(
"微信授权参数 {}"
,
loginBO
.
toString
());
UserAuthRel
wxAuthRel
=
loginService
.
wechatLogin
(
loginBO
);
Map
<
String
,
Object
>
rtnMap
=
thirdLogin
(
wxAuthRel
);
return
R
.
ok
().
data
(
rtnMap
);
}
@NoLogin
@GetMapping
(
value
=
"/qqAuth"
)
@GetMapping
(
value
=
"/qqAuth"
)
public
R
qqAuth
(
@RequestParam
String
code
)
{
public
R
qqAuth
(
@RequestParam
String
code
)
{
//获取openId、unionId等
QQOAuth2AccessToken
accessToken
=
new
QQOAuth2AccessToken
();
QQOAuth2AccessToken
accessToken
=
new
QQOAuth2AccessToken
();
log
.
info
(
"QQ code[{}]获取的Session信息为{}"
,
code
,
JSONUtil
.
toJsonStr
(
accessToken
));
log
.
info
(
"QQ code[{}]获取的Session信息为{}"
,
code
,
JSONUtil
.
toJsonStr
(
accessToken
));
UserAuthRel
authRel
=
loginService
.
qqAuth
(
accessToken
);
UserAuthRel
authRel
=
loginService
.
qqAuth
(
accessToken
);
Map
<
String
,
Object
>
rtnMap
=
thirdLogin
(
authRel
);
Map
<
String
,
Object
>
rtnMap
=
thirdLogin
(
LoginType
.
QQ
,
authRel
);
return
R
.
ok
().
data
(
rtnMap
);
return
R
.
ok
().
data
(
rtnMap
);
}
}
@NoLogin
@NoLogin
@PostMapping
(
value
=
"/qqLogin"
)
@GetMapping
(
value
=
"/wechatAuth"
)
public
R
qqLogin
(
@RequestBody
QQLoginBO
loginBO
)
{
public
R
wechatAuth
(
@RequestParam
String
code
)
throws
WxErrorException
{
log
.
info
(
"QQ授权参数 {}"
,
loginBO
.
toString
());
//获取openId、unionid、session_key
UserAuthRel
qqAuthRel
=
loginService
.
qqLogin
(
loginBO
);
WxMaJscode2SessionResult
sessionInfo
=
wxMaService
.
getUserService
().
getSessionInfo
(
code
);
log
.
info
(
"微信code[{}]获取的Session信息为{}"
,
code
,
JSONUtil
.
toJsonStr
(
sessionInfo
));
UserAuthRel
authRel
=
loginService
.
wechatAuth
(
sessionInfo
);
Map
<
String
,
Object
>
rtnMap
=
thirdLogin
(
qqA
uthRel
);
Map
<
String
,
Object
>
rtnMap
=
thirdLogin
(
LoginType
.
WECHAT
,
a
uthRel
);
return
R
.
ok
().
data
(
rtnMap
);
return
R
.
ok
().
data
(
rtnMap
);
}
}
private
Map
<
String
,
Object
>
thirdLogin
(
UserAuthRel
authRel
)
{
private
Map
<
String
,
Object
>
thirdLogin
(
LoginType
loginType
,
UserAuthRel
authRel
)
{
Map
<
String
,
Object
>
rtnMap
=
new
HashMap
<>();
Map
<
String
,
Object
>
rtnMap
=
new
HashMap
<>();
Optional
<
Long
>
optUserId
=
Optional
.
ofNullable
(
authRel
.
getUserId
());
Optional
<
Long
>
optUserId
=
Optional
.
ofNullable
(
authRel
.
getUserId
());
if
(
optUserId
.
isPresent
())
{
if
(
optUserId
.
isPresent
())
{
//
如果用户id存在,理论上User不为空
//
已绑定本地账号
AppUser
user
=
userService
.
getAppUserByUserId
(
optUserId
.
get
());
AppUser
user
=
userService
.
getAppUserByUserId
(
authRel
.
getUserId
());
String
token
=
userService
.
createToken
(
user
);
String
token
=
userService
.
createToken
(
user
);
rtnMap
.
put
(
"token"
,
token
);
rtnMap
.
put
(
"user"
,
user
);
rtnMap
.
put
(
"user"
,
user
);
rtnMap
.
put
(
"token"
,
token
);
}
else
{
}
else
{
//
没有绑定用户
,跳转登录界面登录,回传此id
//
未绑定本地账号
,跳转登录界面登录,回传此id
rtnMap
.
put
(
"authRelId"
,
authRel
.
getId
());
rtnMap
.
put
(
"authRelId"
,
authRel
.
getId
());
}
}
return
rtnMap
;
return
rtnMap
;
...
...
src/main/java/cn/com/glsx/app/modules/entity/User.java
0 → 100644
View file @
f16f8f8
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
;
@Data
@Table
(
name
=
"t_cust_user"
)
public
class
User
extends
BaseEntity
{
/**
* 登录token
*/
private
String
token
;
/**
* token过期时间
*/
@Column
(
name
=
"expire_in"
)
private
Long
expireIn
;
/**
* 登录失败次数
*/
@Column
(
name
=
"try_times"
)
private
Integer
tryTimes
;
/**
* 用户账号/手机号
*/
private
String
account
;
/**
* 状态:0白名单,临时封禁(blacklist>0,值为封禁天数),永久封禁(del_flag=-1)
*/
private
Integer
blacklist
;
}
\ No newline at end of file
\ No newline at end of file
src/main/java/cn/com/glsx/app/modules/entity/UserLocalAuth.java
View file @
f16f8f8
...
@@ -11,9 +11,15 @@ import javax.persistence.Table;
...
@@ -11,9 +11,15 @@ import javax.persistence.Table;
public
class
UserLocalAuth
extends
BaseEntity
{
public
class
UserLocalAuth
extends
BaseEntity
{
/**
/**
* 用户
id
* 用户
账号
*/
*/
@Column
(
name
=
"user_id"
)
@Column
(
name
=
"account"
)
private
Long
userId
;
private
String
account
;
/**
* 密码
*/
@Column
(
name
=
"account"
)
private
String
password
;
}
}
\ No newline at end of file
\ No newline at end of file
src/main/java/cn/com/glsx/app/modules/mapper/UserAuthRelMapper.java
View file @
f16f8f8
...
@@ -10,16 +10,8 @@ import java.util.List;
...
@@ -10,16 +10,8 @@ import java.util.List;
@Mapper
@Mapper
public
interface
UserAuthRelMapper
extends
CommonBaseMapper
<
UserAuthRel
>
{
public
interface
UserAuthRelMapper
extends
CommonBaseMapper
<
UserAuthRel
>
{
UserAuthRel
selectById
(
@Param
(
"id"
)
Long
id
);
UserAuthRel
selectLocalAuthRelByUserId
(
@Param
(
"userId"
)
Long
userId
);
UserAuthRel
selectByAuthTypeAndAuthId
(
@Param
(
"authType"
)
String
authType
,
@Param
(
"authId"
)
Long
authId
);
UserAuthRel
selectByAuthTypeAndAuthId
(
@Param
(
"authType"
)
String
authType
,
@Param
(
"authId"
)
Long
authId
);
List
<
UserAuthRel
>
selectByAuthTypeAndUserId
(
@Param
(
"authType"
)
String
authType
,
@Param
(
"userId"
)
Long
userId
);
List
<
UserAuthRel
>
selectByAuthTypeAndUserId
(
@Param
(
"authType"
)
String
authType
,
@Param
(
"userId"
)
Long
userId
);
List
<
UserAuthRel
>
selectByUserId
(
@Param
(
"userId"
)
Long
userId
);
int
logicDeleteByUserId
(
@Param
(
"userId"
)
Long
userId
);
}
}
\ No newline at end of file
\ No newline at end of file
src/main/java/cn/com/glsx/app/modules/mapper/UserLocalAccountMapper.java
0 → 100644
View file @
f16f8f8
package
cn
.
com
.
glsx
.
app
.
modules
.
mapper
;
import
cn.com.glsx.app.modules.entity.UserLocalAccount
;
import
cn.com.glsx.app.modules.model.AppUser
;
import
com.glsx.plat.mybatis.mapper.CommonBaseMapper
;
import
org.apache.ibatis.annotations.Mapper
;
import
org.apache.ibatis.annotations.Param
;
@Mapper
public
interface
UserLocalAccountMapper
extends
CommonBaseMapper
<
UserLocalAccount
>
{
UserLocalAccount
selectByAuthId
(
@Param
(
"authId"
)
Long
authId
);
AppUser
selectAppUserByUserId
(
@Param
(
"userId"
)
Long
userId
);
}
\ No newline at end of file
\ No newline at end of file
src/main/java/cn/com/glsx/app/modules/mapper/UserLocalAuthMapper.java
View file @
f16f8f8
...
@@ -8,10 +8,8 @@ import org.apache.ibatis.annotations.Param;
...
@@ -8,10 +8,8 @@ import org.apache.ibatis.annotations.Param;
@Mapper
@Mapper
public
interface
UserLocalAuthMapper
extends
CommonBaseMapper
<
UserLocalAuth
>
{
public
interface
UserLocalAuthMapper
extends
CommonBaseMapper
<
UserLocalAuth
>
{
UserLocalAuth
selectBy
Id
(
@Param
(
"id"
)
Long
i
d
);
UserLocalAuth
selectBy
AuthId
(
@Param
(
"authId"
)
Long
authI
d
);
int
updatePasswordByUserId
(
@Param
(
"userId"
)
Long
userId
,
@Param
(
"password"
)
String
password
);
UserLocalAuth
selectByUserId
(
@Param
(
"userId"
)
Long
userId
);
int
logicDeleteById
(
@Param
(
"id"
)
Long
id
);
}
}
\ No newline at end of file
\ No newline at end of file
src/main/java/cn/com/glsx/app/modules/mapper/UserMapper.java
0 → 100644
View file @
f16f8f8
package
cn
.
com
.
glsx
.
app
.
modules
.
mapper
;
import
cn.com.glsx.app.modules.entity.User
;
import
com.glsx.plat.mybatis.mapper.CommonBaseMapper
;
import
org.apache.ibatis.annotations.Mapper
;
import
org.apache.ibatis.annotations.Param
;
@Mapper
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
\ No newline at end of file
src/main/java/cn/com/glsx/app/modules/mapper/UserThirdAuthMapper.java
View file @
f16f8f8
...
@@ -10,8 +10,6 @@ public interface UserThirdAuthMapper extends CommonBaseMapper<UserThirdAuth> {
...
@@ -10,8 +10,6 @@ public interface UserThirdAuthMapper extends CommonBaseMapper<UserThirdAuth> {
UserThirdAuth
selectByOpenid
(
@Param
(
"openid"
)
String
openid
);
UserThirdAuth
selectByOpenid
(
@Param
(
"openid"
)
String
openid
);
UserThirdAuth
selectByLoginTypeAndUserId
(
@Param
(
"loginType"
)
String
loginType
,
@Param
(
"userId"
)
Long
userId
);
UserThirdAuth
selectByLoginTypeAndAuthId
(
@Param
(
"loginType"
)
String
loginType
,
@Param
(
"authId"
)
Long
authId
);
int
logicDeleteById
(
@Param
(
"id"
)
Long
id
);
}
}
\ No newline at end of file
\ No newline at end of file
src/main/java/cn/com/glsx/app/modules/model/QQLoginBO.java
deleted
100644 → 0
View file @
a9c90d1
package
cn
.
com
.
glsx
.
app
.
modules
.
model
;
import
lombok.Data
;
import
javax.validation.constraints.NotBlank
;
@Data
public
class
QQLoginBO
{
@NotBlank
private
String
openId
;
}
src/main/java/cn/com/glsx/app/modules/model/WechatLoginBO.java
deleted
100644 → 0
View file @
a9c90d1
package
cn
.
com
.
glsx
.
app
.
modules
.
model
;
import
lombok.Data
;
import
javax.validation.constraints.NotBlank
;
@Data
public
class
WechatLoginBO
{
@NotBlank
private
String
openId
;
@NotBlank
private
String
unionId
;
}
src/main/java/cn/com/glsx/app/modules/service/LoginService.java
View file @
f16f8f8
This diff is collapsed.
Click to expand it.
src/main/java/cn/com/glsx/app/modules/service/UserService.java
View file @
f16f8f8
package
cn
.
com
.
glsx
.
app
.
modules
.
service
;
package
cn
.
com
.
glsx
.
app
.
modules
.
service
;
import
cn.com.glsx.app.common.exception.AppServerException
;
import
cn.com.glsx.app.common.enums.AuthType
;
import
cn.com.glsx.app.modules.converter.UserConverter
;
import
cn.com.glsx.app.common.enums.LoginType
;
import
cn.com.glsx.app.modules.entity.UserAuthRel
;
import
cn.com.glsx.app.modules.entity.UserThirdAuth
;
import
cn.com.glsx.app.modules.mapper.UserAuthRelMapper
;
import
cn.com.glsx.app.modules.mapper.UserLocalAccountMapper
;
import
cn.com.glsx.app.modules.mapper.UserThirdAuthMapper
;
import
cn.com.glsx.app.modules.model.AppUser
;
import
cn.com.glsx.app.modules.model.AppUser
;
import
cn.com.glsx.auth.api.AuthFeignClient
;
import
cn.com.glsx.auth.model.SimpleUser
;
import
cn.hutool.core.lang.UUID
;
import
cn.hutool.core.lang.UUID
;
import
com.glsx.plat.common.utils.ObjectUtils
;
import
com.glsx.plat.common.utils.ObjectUtils
;
import
com.glsx.plat.core.web.R
;
import
com.glsx.plat.jwt.base.ComJwtUser
;
import
com.glsx.plat.jwt.base.ComJwtUser
;
import
com.glsx.plat.jwt.util.JwtUtils
;
import
com.glsx.plat.jwt.util.JwtUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.Assert
;
import
org.springframework.util.Assert
;
import
javax.annotation.Resource
;
import
java.util.Map
;
import
java.util.Map
;
@Service
@Service
...
@@ -22,8 +25,14 @@ public class UserService {
...
@@ -22,8 +25,14 @@ public class UserService {
@Autowired
@Autowired
private
JwtUtils
<
ComJwtUser
>
jwtUtils
;
private
JwtUtils
<
ComJwtUser
>
jwtUtils
;
@Autowired
@Resource
private
AuthFeignClient
authFeignClient
;
private
UserAuthRelMapper
userAuthRelMapper
;
@Resource
private
UserThirdAuthMapper
userThirdAuthMapper
;
@Resource
private
UserLocalAccountMapper
userLocalAccountMapper
;
/**
/**
* 生成带用户信息的token
* 生成带用户信息的token
...
@@ -45,12 +54,17 @@ public class UserService {
...
@@ -45,12 +54,17 @@ public class UserService {
}
}
public
AppUser
getAppUserByUserId
(
Long
userId
)
{
public
AppUser
getAppUserByUserId
(
Long
userId
)
{
R
<
SimpleUser
>
userR
=
authFeignClient
.
getSimpleUserById
(
userId
);
//获取用户本地信息
SimpleUser
simpleUser
=
userR
.
getData
(
SimpleUser
.
class
);
return
userLocalAccountMapper
.
selectAppUserByUserId
(
userId
);
if
(!
userR
.
isSuccess
()
||
simpleUser
==
null
)
{
}
throw
new
AppServerException
(
userR
.
getMessage
());
}
public
AppUser
getAppUserByAuthId
(
LoginType
loginType
,
Long
authId
)
{
return
UserConverter
.
INSTANCE
.
su2au
(
simpleUser
);
//获取具体第三方授权
UserThirdAuth
thirdAuth
=
userThirdAuthMapper
.
selectByLoginTypeAndAuthId
(
loginType
.
getType
(),
authId
);
//获取第三方授权关联
UserAuthRel
userAuthRel
=
userAuthRelMapper
.
selectByAuthTypeAndAuthId
(
AuthType
.
THIRD
.
getType
(),
thirdAuth
.
getId
());
//获取用户本地信息
return
this
.
getAppUserByUserId
(
userAuthRel
.
getUserId
());
}
}
}
}
src/main/java/cn/com/glsx/app/modules/service/VehicleMonitorService.java
View file @
f16f8f8
...
@@ -28,7 +28,7 @@ public class VehicleMonitorService {
...
@@ -28,7 +28,7 @@ public class VehicleMonitorService {
}
}
public
List
<
VehicleLocationDTO
>
getVehicleLocations
(
String
sns
)
{
public
List
<
VehicleLocationDTO
>
getVehicleLocations
(
String
sns
)
{
R
<
List
<
DeviceLocationDTO
>>
listR
=
gpsBsFeignService
.
listDeviceMonitorInfo
(
sns
,
null
);
R
<
List
<
DeviceLocationDTO
>>
listR
=
gpsBsFeignService
.
listDeviceMonitorInfo
(
sns
);
List
<
DeviceLocationDTO
>
dataList
=
listR
.
getDataList
(
new
TypeToken
<
List
<
DeviceLocationDTO
>>()
{
List
<
DeviceLocationDTO
>
dataList
=
listR
.
getDataList
(
new
TypeToken
<
List
<
DeviceLocationDTO
>>()
{
}.
getType
());
}.
getType
());
...
...
src/main/resources/mapper/UserAuthRelMapper.xml
View file @
f16f8f8
...
@@ -30,6 +30,7 @@
...
@@ -30,6 +30,7 @@
where auth_type = #{authType}
where auth_type = #{authType}
and auth_id = #{authId}
and auth_id = #{authId}
and del_flag = 0
and del_flag = 0
limit 1
</select>
</select>
<select
id=
"selectByAuthTypeAndUserId"
resultMap=
"BaseResultMap"
>
<select
id=
"selectByAuthTypeAndUserId"
resultMap=
"BaseResultMap"
>
...
@@ -40,36 +41,4 @@
...
@@ -40,36 +41,4 @@
and user_id = #{userId}
and user_id = #{userId}
and del_flag = 0
and del_flag = 0
</select>
</select>
<select
id=
"selectLocalAuthRelByUserId"
resultMap=
"BaseResultMap"
>
select
<include
refid=
"Base_Column_List"
/>
from t_user_auth_rel
where auth_type = 'local'
and user_id = #{userId}
and del_flag = 0
limit 1
</select>
<select
id=
"selectById"
resultMap=
"BaseResultMap"
>
select
<include
refid=
"Base_Column_List"
/>
from t_user_auth_rel
where id = #{id}
and del_flag = 0
</select>
<select
id=
"selectByUserId"
resultMap=
"BaseResultMap"
>
select
<include
refid=
"Base_Column_List"
/>
from t_user_auth_rel
where user_id = #{userId}
and del_flag = 0
</select>
<update
id=
"logicDeleteByUserId"
>
update t_user_auth_rel
set del_flag = -1
where user_id = #{userId}
</update>
</mapper>
</mapper>
\ No newline at end of file
\ No newline at end of file
src/main/resources/mapper/UserLocalAccountMapper.xml
0 → 100644
View file @
f16f8f8
<?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.UserLocalAccountMapper"
>
<resultMap
id=
"BaseResultMap"
type=
"cn.com.glsx.app.modules.entity.UserLocalAccount"
>
<!--
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"
/>
<result
column=
"avatar"
jdbcType=
"VARCHAR"
property=
"avatar"
/>
<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, user_id, auth_id, union_id, username, avatar, del_flag, created_date, created_by,
updated_date, updated_by
</sql>
<select
id=
"selectByAuthId"
resultMap=
"BaseResultMap"
>
select
<include
refid=
"Base_Column_List"
/>
from t_cust_user_local_account
where auth_id = #{authId}
and del_flag = 0
</select>
<select
id=
"selectAppUserByUserId"
resultType=
"cn.com.glsx.app.modules.model.AppUser"
>
select tcula.user_id as id,
tcula.union_id unionId,
tcu.account,
tcula.username,
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 = tcula.user_id
where tcula.del_flag = 0
and tcuar.auth_type = 'local'
and tcula.user_id = #{userId} limit 1
</select>
</mapper>
\ No newline at end of file
\ No newline at end of file
src/main/resources/mapper/UserLocalAuthMapper.xml
View file @
f16f8f8
...
@@ -6,7 +6,8 @@
...
@@ -6,7 +6,8 @@
WARNING - @mbg.generated
WARNING - @mbg.generated
-->
-->
<id
column=
"id"
jdbcType=
"INTEGER"
property=
"id"
/>
<id
column=
"id"
jdbcType=
"INTEGER"
property=
"id"
/>
<result
column=
"user_id"
jdbcType=
"INTEGER"
property=
"userId"
/>
<result
column=
"account"
jdbcType=
"VARCHAR"
property=
"account"
/>
<result
column=
"password"
jdbcType=
"VARCHAR"
property=
"password"
/>
<result
column=
"del_flag"
jdbcType=
"TINYINT"
property=
"delFlag"
/>
<result
column=
"del_flag"
jdbcType=
"TINYINT"
property=
"delFlag"
/>
<result
column=
"created_date"
jdbcType=
"TIMESTAMP"
property=
"createdDate"
/>
<result
column=
"created_date"
jdbcType=
"TIMESTAMP"
property=
"createdDate"
/>
<result
column=
"created_by"
jdbcType=
"INTEGER"
property=
"createdBy"
/>
<result
column=
"created_by"
jdbcType=
"INTEGER"
property=
"createdBy"
/>
...
@@ -17,29 +18,26 @@
...
@@ -17,29 +18,26 @@
<!--
<!--
WARNING - @mbg.generated
WARNING - @mbg.generated
-->
-->
id,
user_id
, del_flag, created_date, created_by,
id,
account, `password`
, del_flag, created_date, created_by,
updated_date, updated_by
updated_date, updated_by
</sql>
</sql>
<select
id=
"selectById"
resultMap=
"BaseResultMap"
>
<select
id=
"selectByAuthId"
resultMap=
"BaseResultMap"
>
select
select tcula.*
<include
refid=
"Base_Column_List"
/>
from t_cust_user_local_auth tcula
from t_user_local_auth
inner join t_cust_user_auth_rel tcuar on tcula.id = tcuar.auth_id
where id = #{id}
where tcuar.del_flag = 0
and del_flag = 0
and tcuar.auth_type = 'local'
and tcuar.auth_id = #{authId} limit 1
</select>
</select>
<update
id=
"updatePasswordByUserId"
>
<select
id=
"selectByUserId"
resultMap=
"BaseResultMap"
>
update t_user_local_auth tcula ,t_user_auth_rel tcuar
select tcula.*
set tcula.password = #{password}
from t_cust_user_local_auth tcula
where tcula.id = tcuar.auth_id
inner join t_cust_user_auth_rel tcuar on tcula.id = tcuar.auth_id
and auth_type = 'local'
inner join t_cust_user_local_account tcula2 on tcula2.auth_id = tcuar.auth_id
and tcuar.user_id = #{userId}
where tcuar.del_flag = 0
</update>
and tcuar.auth_type = 'local'
and tcula2.user_id = #{userId} limit 1
<update
id=
"logicDeleteById"
>
</select>
update t_user_local_auth
set del_flag = -1
where id = #{id}
</update>
</mapper>
</mapper>
\ No newline at end of file
\ No newline at end of file
src/main/resources/mapper/UserMapper.xml
0 → 100644
View file @
f16f8f8
<?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.UserMapper"
>
<resultMap
id=
"BaseResultMap"
type=
"cn.com.glsx.app.modules.entity.User"
>
<!--
WARNING - @mbg.generated
-->
<id
column=
"id"
jdbcType=
"INTEGER"
property=
"id"
/>
<result
column=
"token"
jdbcType=
"VARCHAR"
property=
"token"
/>
<result
column=
"expire_in"
jdbcType=
"INTEGER"
property=
"expireIn"
/>
<result
column=
"try_times"
jdbcType=
"INTEGER"
property=
"tryTimes"
/>
<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"
/>
<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, token, expire_in, try_times, account, blacklist, del_flag, created_date, created_by, updated_date,
updated_by
</sql>
<select
id=
"selectById"
resultMap=
"BaseResultMap"
>
select
<include
refid=
"Base_Column_List"
/>
from t_cust_user
where id = #{id}
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, account, blacklist, del_flag, created_date)
VALUES (#{id}, #{account}, #{blacklist}, 0, sysdate()) ON DUPLICATE KEY
UPDATE updated_date = sysdate()
</insert>
</mapper>
\ No newline at end of file
\ No newline at end of file
src/main/resources/mapper/UserThirdAuthMapper.xml
View file @
f16f8f8
...
@@ -31,21 +31,13 @@
...
@@ -31,21 +31,13 @@
and del_flag = 0
and del_flag = 0
</select>
</select>
<select
id=
"selectByLoginTypeAnd
User
Id"
resultMap=
"BaseResultMap"
>
<select
id=
"selectByLoginTypeAnd
Auth
Id"
resultMap=
"BaseResultMap"
>
select tcuta.*
select tcuta.*
from t_
user_third_auth tcuta,
from t_
cust_user_third_auth tcuta
t_user_auth_rel tcuar
inner join t_cust_user_auth_rel tcuar on tcuta.id = tcuar.auth_id
where tcuta.
id = tcuar.auth_id
where tcuta.
del_flag = 0
and tcuar.auth_type = 'third'
and tcuar.auth_type = 'third'
and tcuta.login_type = #{loginType}
and tcuta.login_type = #{loginType}
and tcuar.user_id = #{userId}
and tcuar.auth_id = #{userId};
and tcuta.del_flag = 0
and tcuar.del_flag = 0
</select>
</select>
<update
id=
"logicDeleteById"
>
update t_user_third_auth
set del_flag = -1
where id = #{id}
</update>
</mapper>
</mapper>
\ No newline at end of file
\ 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