Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
spring-microservice-exam
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
汪想
spring-microservice-exam
Commits
58cdf68b
Commit
58cdf68b
authored
Aug 04, 2019
by
tangyi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化
parent
bcd1715b
Show whitespace changes
Inline
Side-by-side
Showing
36 changed files
with
613 additions
and
52 deletions
+613
-52
ApiConstant.java
...a/com/github/tangyi/common/core/constant/ApiConstant.java
+16
-0
PageUtil.java
...in/java/com/github/tangyi/common/core/utils/PageUtil.java
+16
-2
UserVo.java
...rc/main/java/com/github/tangyi/common/core/vo/UserVo.java
+5
-0
SecurityConstant.java
...hub/tangyi/common/security/constant/SecurityConstant.java
+1
-1
CustomUserDetailsService.java
...tangyi/common/security/core/CustomUserDetailsService.java
+3
-1
MobileAuthenticationFilter.java
...yi/common/security/mobile/MobileAuthenticationFilter.java
+26
-0
MobileAuthenticationProvider.java
.../common/security/mobile/MobileAuthenticationProvider.java
+1
-1
MobileAuthenticationToken.java
...gyi/common/security/mobile/MobileAuthenticationToken.java
+10
-0
MobileUser.java
.../com/github/tangyi/common/security/mobile/MobileUser.java
+55
-0
gateway-service.yml
config-service/src/main/resources/config/gateway-service.yml
+9
-0
msc-service.yml
config-service/src/main/resources/config/msc-service.yml
+62
-3
README.md
gateway-service/README.md
+34
-0
RouteController.java
...com/github/tangyi/gateway/controller/RouteController.java
+0
-1
HttpsToHttpFilter.java
.../com/github/tangyi/gateway/filters/HttpsToHttpFilter.java
+59
-0
README.md
modules/auth-service-parent/README.md
+41
-2
CustomUserDetailsServiceImpl.java
...ub/tangyi/auth/security/CustomUserDetailsServiceImpl.java
+27
-4
CustomGlobalExceptionHandler.java
...ithub/tangyi/exam/error/CustomGlobalExceptionHandler.java
+1
-1
SmsConstant.java
.../java/com/github/tangyi/msc/api/constant/SmsConstant.java
+1
-1
SmsResponse.java
...ain/java/com/github/tangyi/msc/api/model/SmsResponse.java
+23
-0
SmsController.java
.../java/com/github/tangyi/msc/controller/SmsController.java
+5
-5
CustomGlobalExceptionHandler.java
...github/tangyi/msc/error/CustomGlobalExceptionHandler.java
+65
-0
SmsProperties.java
.../java/com/github/tangyi/msc/properties/SmsProperties.java
+20
-0
SmsService.java
...c/main/java/com/github/tangyi/msc/service/SmsService.java
+21
-4
UserStudentConstant.java
.../github/tangyi/user/api/constant/UserStudentConstant.java
+40
-0
StudentDto.java
.../main/java/com/github/tangyi/user/api/dto/StudentDto.java
+13
-5
UserDto.java
...src/main/java/com/github/tangyi/user/api/dto/UserDto.java
+6
-0
Student.java
.../main/java/com/github/tangyi/user/api/module/Student.java
+5
-0
User.java
...src/main/java/com/github/tangyi/user/api/module/User.java
+5
-0
StudentController.java
.../com/github/tangyi/user/controller/StudentController.java
+2
-0
CustomGlobalExceptionHandler.java
...ithub/tangyi/user/error/CustomGlobalExceptionHandler.java
+1
-1
MobileService.java
...in/java/com/github/tangyi/user/service/MobileService.java
+9
-11
StudentService.java
...n/java/com/github/tangyi/user/service/StudentService.java
+4
-2
UserService.java
...main/java/com/github/tangyi/user/service/UserService.java
+5
-2
StudentMapper.xml
.../user-service/src/main/resources/mapper/StudentMapper.xml
+11
-4
UserMapper.xml
...ent/user-service/src/main/resources/mapper/UserMapper.xml
+10
-0
pom.xml
pom.xml
+1
-1
No files found.
common/common-core/src/main/java/com/github/tangyi/common/core/constant/ApiConstant.java
0 → 100644
View file @
58cdf68b
package
com
.
github
.
tangyi
.
common
.
core
.
constant
;
/**
* 定义api返回编码和提示内容
*
* @author tangyi
* @date 2019-07-24 20:31
*/
public
class
ApiConstant
{
/**
* 服务不可用
*/
public
static
final
int
SERVICE_NOT_AVAILABLE
=
1
;
}
common/common-core/src/main/java/com/github/tangyi/common/core/utils/PageUtil.java
View file @
58cdf68b
...
...
@@ -67,8 +67,22 @@ public class PageUtil {
* @date 2019/07/03 22:26:18
*/
public
static
void
copyProperties
(
PageInfo
<?>
source
,
PageInfo
<?>
target
)
{
target
.
setTotal
(
source
.
getTotal
());
target
.
setPageSize
(
source
.
getPageSize
());
target
.
setPageNum
(
source
.
getPageNum
());
target
.
setPageSize
(
source
.
getPageSize
());
target
.
setSize
(
source
.
getSize
());
target
.
setStartRow
(
source
.
getStartRow
());
target
.
setEndRow
(
source
.
getEndRow
());
target
.
setPages
(
source
.
getPages
());
target
.
setPrePage
(
source
.
getPrePage
());
target
.
setNextPage
(
source
.
getNextPage
());
target
.
setIsFirstPage
(
source
.
isIsFirstPage
());
target
.
setIsLastPage
(
source
.
isIsLastPage
());
target
.
setHasPreviousPage
(
source
.
isHasPreviousPage
());
target
.
setHasNextPage
(
source
.
isHasNextPage
());
target
.
setNavigatePages
(
source
.
getNavigatePages
());
target
.
setNavigatepageNums
(
source
.
getNavigatepageNums
());
target
.
setNavigateFirstPage
(
source
.
getNavigateFirstPage
());
target
.
setNavigateLastPage
(
source
.
getNavigateLastPage
());
target
.
setTotal
(
source
.
getTotal
());
}
}
common/common-core/src/main/java/com/github/tangyi/common/core/vo/UserVo.java
View file @
58cdf68b
...
...
@@ -125,5 +125,10 @@ public class UserVo extends BaseEntity<UserVo> {
*/
private
String
wechat
;
/**
* 家庭角色,参考UserStudentConstant
*/
private
Integer
familyRole
;
}
common/common-security/src/main/java/com/github/tangyi/common/security/constant/SecurityConstant.java
View file @
58cdf68b
...
...
@@ -24,7 +24,7 @@ public class SecurityConstant {
/**
* 默认短信验证码过期时间
*/
public
static
final
int
DEFAULT_SMS_EXPIRE
=
5
*
60
;
public
static
final
int
DEFAULT_SMS_EXPIRE
=
1
5
*
60
;
/**
* 正常状态
...
...
common/common-security/src/main/java/com/github/tangyi/common/security/core/CustomUserDetailsService.java
View file @
58cdf68b
package
com
.
github
.
tangyi
.
common
.
security
.
core
;
import
com.github.tangyi.common.security.mobile.MobileUser
;
import
com.github.tangyi.common.security.wx.WxUser
;
import
org.springframework.security.core.userdetails.UserDetails
;
import
org.springframework.security.core.userdetails.UsernameNotFoundException
;
...
...
@@ -28,11 +29,12 @@ public interface CustomUserDetailsService {
*
* @param social social
* @param tenantCode tenantCode
* @param mobileUser mobileUser
* @return UserDetails
* @author tangyi
* @date 2019/06/22 21:08
*/
UserDetails
loadUserBySocialAndTenantCode
(
String
social
,
String
tenantCode
)
throws
UsernameNotFoundException
;
UserDetails
loadUserBySocialAndTenantCode
(
String
social
,
String
tenantCode
,
MobileUser
mobileUser
)
throws
UsernameNotFoundException
;
/**
* 根据微信openId和租户标识查询
...
...
common/common-security/src/main/java/com/github/tangyi/common/security/mobile/MobileAuthenticationFilter.java
View file @
58cdf68b
package
com
.
github
.
tangyi
.
common
.
security
.
mobile
;
import
com.github.tangyi.common.security.constant.SecurityConstant
;
import
com.github.tangyi.common.security.utils.GsonHelper
;
import
lombok.Getter
;
import
lombok.Setter
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.io.IOUtils
;
import
org.apache.commons.lang.StringUtils
;
import
org.springframework.http.HttpMethod
;
import
org.springframework.security.authentication.AuthenticationEventPublisher
;
import
org.springframework.security.authentication.AuthenticationServiceException
;
...
...
@@ -18,6 +22,7 @@ import org.springframework.security.web.util.matcher.AntPathRequestMatcher;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.IOException
;
/**
* 手机登录filter
...
...
@@ -25,6 +30,7 @@ import javax.servlet.http.HttpServletResponse;
* @author tangyi
* @date 2019/6/22 21:15
*/
@Slf4j
public
class
MobileAuthenticationFilter
extends
AbstractAuthenticationProcessingFilter
{
private
static
final
String
SPRING_SECURITY_FORM_MOBILE_KEY
=
"mobile"
;
...
...
@@ -61,6 +67,8 @@ public class MobileAuthenticationFilter extends AbstractAuthenticationProcessing
mobile
=
mobile
.
trim
();
// 封装成token
MobileAuthenticationToken
mobileAuthenticationToken
=
new
MobileAuthenticationToken
(
mobile
);
// 封装其它基本信息
setMobileUserDetails
(
request
,
mobileAuthenticationToken
);
setDetails
(
request
,
mobileAuthenticationToken
);
Authentication
authResult
=
null
;
try
{
...
...
@@ -90,4 +98,22 @@ public class MobileAuthenticationFilter extends AbstractAuthenticationProcessing
private
void
setDetails
(
HttpServletRequest
request
,
MobileAuthenticationToken
authRequest
)
{
authRequest
.
setDetails
(
authenticationDetailsSource
.
buildDetails
(
request
));
}
/**
* 设置姓名、性别、头像等信息
*
* @param request request
* @param authRequest authRequest
*/
private
void
setMobileUserDetails
(
HttpServletRequest
request
,
MobileAuthenticationToken
authRequest
)
{
try
{
String
result
=
IOUtils
.
toString
(
request
.
getReader
());
if
(
StringUtils
.
isNotBlank
(
result
))
{
MobileUser
user
=
GsonHelper
.
getInstance
().
fromJson
(
result
,
MobileUser
.
class
);
authRequest
.
setMobileUser
(
user
);
}
}
catch
(
IOException
e
)
{
log
.
error
(
e
.
getMessage
(),
e
);
}
}
}
common/common-security/src/main/java/com/github/tangyi/common/security/mobile/MobileAuthenticationProvider.java
View file @
58cdf68b
...
...
@@ -28,7 +28,7 @@ public class MobileAuthenticationProvider implements AuthenticationProvider {
public
Authentication
authenticate
(
Authentication
authentication
)
throws
AuthenticationException
{
MobileAuthenticationToken
mobileAuthenticationToken
=
(
MobileAuthenticationToken
)
authentication
;
String
principal
=
mobileAuthenticationToken
.
getPrincipal
().
toString
();
UserDetails
userDetails
=
customUserDetailsService
.
loadUserBySocialAndTenantCode
(
principal
,
TenantContextHolder
.
getTenantCode
());
UserDetails
userDetails
=
customUserDetailsService
.
loadUserBySocialAndTenantCode
(
principal
,
TenantContextHolder
.
getTenantCode
()
,
mobileAuthenticationToken
.
getMobileUser
()
);
if
(
userDetails
==
null
)
{
log
.
debug
(
"Authentication failed: no credentials provided"
);
throw
new
BadCredentialsException
(
messages
.
getMessage
(
"AbstractUserDetailsAuthenticationProvider.noopBindAccount"
,
"Noop Bind Account"
));
...
...
common/common-security/src/main/java/com/github/tangyi/common/security/mobile/MobileAuthenticationToken.java
View file @
58cdf68b
...
...
@@ -15,6 +15,8 @@ public class MobileAuthenticationToken extends AbstractAuthenticationToken {
private
final
Object
principal
;
private
MobileUser
mobileUser
;
public
MobileAuthenticationToken
(
String
mobile
)
{
super
(
null
);
this
.
principal
=
mobile
;
...
...
@@ -49,4 +51,12 @@ public class MobileAuthenticationToken extends AbstractAuthenticationToken {
public
void
eraseCredentials
()
{
super
.
eraseCredentials
();
}
public
MobileUser
getMobileUser
()
{
return
mobileUser
;
}
public
void
setMobileUser
(
MobileUser
mobileUser
)
{
this
.
mobileUser
=
mobileUser
;
}
}
common/common-security/src/main/java/com/github/tangyi/common/security/mobile/MobileUser.java
0 → 100644
View file @
58cdf68b
package
com
.
github
.
tangyi
.
common
.
security
.
mobile
;
import
lombok.Data
;
import
java.io.Serializable
;
/**
* @author tangyi
* @date 2019/08/04 13:28
*/
@Data
public
class
MobileUser
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
/**
* 姓名
*/
private
String
name
;
/**
* 性别
*/
private
Integer
sex
;
/**
* 头像地址
*/
private
String
avatarUrl
;
/**
* 详细描述
*/
private
String
userDesc
;
/**
* 国家
*/
private
String
country
;
/**
* 省
*/
private
String
province
;
/**
* 市
*/
private
String
city
;
/**
* 语言
*/
private
String
languang
;
}
config-service/src/main/resources/config/gateway-service.yml
View file @
58cdf68b
server
:
port
:
8000
# HTTPS
# ssl:
# enabled: false
# key-alias: test
# key-password: test
# key-store: classpath:www.it99.club.jks
# key-store-type: JKS
# key-store-provider: SUN
# key-store-password: test
spring
:
datasource
:
url
:
jdbc:mysql://${MYSQL_HOST:localhost}:${MYSQL_PORT:3306}/microservice-gateway?useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=CTT&characterEncoding=UTF-8
...
...
config-service/src/main/resources/config/msc-service.yml
View file @
58cdf68b
...
...
@@ -17,6 +17,60 @@ spring:
password
:
${ADMIN_PASSWORD:11}
instance
:
service-base-url
:
http://${AUTH_SERVICE_HOST:localhost}:${server.port}
# sleuth 配置
sleuth
:
web
:
client
:
enabled
:
true
sampler
:
probability
:
1.0
# 采样比例为: 0.1(即10%),设置的值介于0.0到1.0之间,1.0则表示全部采集。
# zipkin 配置
zipkin
:
base-url
:
http://${ZIPKIN_HOST:localhost}:${ZIPKIN_PORT:9411}
# 指定了Zipkin服务器的地址
security
:
oauth2
:
client
:
client-id
:
web_app
client-secret
:
$2a$10$S84wOzmAw4wqYBzAqNtmPOx1ZRWdDl9omm/W8T1hhW8S9EK2u57xG
access-token-uri
:
http://${AUTH_SERVICE_HOST:localhost}:${AUTH_SERVICE_PORT:8000}/api/auth/oauth/token
user-authorization-uri
:
http://${AUTH_SERVICE_HOST:localhost}:${AUTH_SERVICE_PORT:8000}/api/auth/oauth/authorize
grant-type
:
password
scope
:
read
resource
:
user-info-uri
:
http://${AUTH_SERVICE_HOST:localhost}:${AUTH_SERVICE_PORT:8000}/api/user/v1/user/info
prefer-token-info
:
false
jwt
:
key-uri
:
http://${AUTH_SERVICE_HOST:localhost}:${AUTH_SERVICE_PORT:8000}/api/auth/oauth/token_key
key-value
:
|
-----BEGIN PUBLIC KEY-----
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAjxSawA+NUNmhB2ctiVnt
YH41WCNoD5STW2iPm5AIsKvm6X67lr6A88qOMRwx9oySdZnUnJ+8L3QJ51fkwuDe
ix5w9yA3f/7LUPWZU8M/7Oi+2nda05JMgU999TUlhTGsp9SPiBqq/iwuqMxU8xKu
F8bpTJTOpzrxH4e5BM6J/UJcOwDZLY6/3zP5w+tbhTvxjc995G4NtUyS4owE1MHe
lj8IJepknjePrE6nXD6ecdL401hstMY838UOOFiCnM8NpiBuNI0nY0qCbb9mhQZ+
7gP3jjM+Ft7R+MFTuEHWQ5UN8qHAPIT9UlLcu9IXdk6YwTsqNavwaTLUcP/ih9HB
6wIDAQAB
-----END PUBLIC KEY-----
# feign相关配置
feign
:
httpclient
:
enabled
:
false
okhttp
:
enabled
:
true
hystrix
:
enabled
:
true
# hystrix配置
hystrix
:
shareSecurityContext
:
true
command
:
default
:
execution
:
isolation
:
thread
:
timeoutInMilliseconds
:
60000
management
:
endpoints
:
...
...
@@ -27,11 +81,16 @@ management:
health
:
show-details
:
ALWAYS
# 短信配置
sms
:
appKey
:
test
appSecret
:
tes
t
regionId
:
cn-hangzhou
appKey
:
appKey
appSecret
:
appSecre
t
regionId
:
default
domain
:
dysmsapi.aliyuncs.com
signName
:
在线考试系统演示
templateCode
:
SMS_171192294
version
:
2017-05-25
action
:
SendSms
ignore
:
urls
:
...
...
gateway-service/README.md
0 → 100644
View file @
58cdf68b
# API网关
HTTPS配置,两种方式:
1.
NGINX配置SSL证书
2.
API网关支持HTTPS
目前API网关已支持HTTPS,并且已经做了适配,转发请求时的协议会转为HTTP
配置见
`gateway-service.yml`
的ssl部分内容
# NGINX配置HTTPS
编辑 Nginx 根目录下的 conf/nginx.conf 文件。修改内容如下:
```
server {
listen 443; #SSL 访问端口号为 443
server_name www.domain.com; #填写绑定证书的域名
ssl on; #启用 SSL 功能
ssl_certificate 1_www.domain.com_bundle.crt; #证书文件名称
ssl_certificate_key 2_www.domain.com.key; #私钥文件名称
ssl_session_timeout 5m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; #请按照这个协议配置
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE; #请按照这个套件配置,配置加密套件,写法遵循 openssl 标准。
ssl_prefer_server_ciphers on;
location / {
root /var/www/www.domain.com; #网站主页路径。此路径仅供参考,具体请您按照实际目录操作。
index index.html index.htm;
}
}
```
\ No newline at end of file
gateway-service/src/main/java/com/github/tangyi/gateway/controller/RouteController.java
View file @
58cdf68b
...
...
@@ -30,7 +30,6 @@ public class RouteController extends BaseController {
private
final
RouteService
routeService
;
/**
* 根据id获取路由
*
...
...
gateway-service/src/main/java/com/github/tangyi/gateway/filters/HttpsToHttpFilter.java
0 → 100644
View file @
58cdf68b
package
com
.
github
.
tangyi
.
gateway
.
filters
;
import
org.springframework.cloud.gateway.filter.GatewayFilterChain
;
import
org.springframework.cloud.gateway.filter.GlobalFilter
;
import
org.springframework.core.Ordered
;
import
org.springframework.http.server.reactive.ServerHttpRequest
;
import
org.springframework.stereotype.Component
;
import
org.springframework.web.server.ServerWebExchange
;
import
reactor.core.publisher.Mono
;
import
java.net.URI
;
/**
* 将HTTPS改为HTTP
* 网关进来的协议是HTTPS,其它服务一般部署在内网,没必要走HTTPS
*
* @author tangyi
* @date 2019/08/03 12:03
*/
@Component
public
class
HttpsToHttpFilter
implements
GlobalFilter
,
Ordered
{
private
static
final
int
HTTPS_TO_HTTP_FILTER_ORDER
=
10099
;
@Override
public
Mono
<
Void
>
filter
(
ServerWebExchange
exchange
,
GatewayFilterChain
chain
)
{
URI
originalUri
=
exchange
.
getRequest
().
getURI
();
ServerHttpRequest
request
=
exchange
.
getRequest
();
ServerHttpRequest
.
Builder
mutate
=
request
.
mutate
();
String
forwardedUri
=
request
.
getURI
().
toString
();
if
(
forwardedUri
!=
null
&&
forwardedUri
.
startsWith
(
"https"
))
{
try
{
URI
mutatedUri
=
new
URI
(
"http"
,
originalUri
.
getUserInfo
(),
originalUri
.
getHost
(),
originalUri
.
getPort
(),
originalUri
.
getPath
(),
originalUri
.
getQuery
(),
originalUri
.
getFragment
());
mutate
.
uri
(
mutatedUri
);
}
catch
(
Exception
e
)
{
throw
new
IllegalArgumentException
(
e
.
getMessage
(),
e
);
}
}
ServerHttpRequest
build
=
mutate
.
build
();
return
chain
.
filter
(
exchange
.
mutate
().
request
(
build
).
build
());
}
/**
* LoadBalancerClientFilter的order是10100
* 要在LoadBalancerClientFilter执行之前将HTTPS修改为HTTP,则这里的order设置为10099
*
* @return int
*/
@Override
public
int
getOrder
()
{
return
HTTPS_TO_HTTP_FILTER_ORDER
;
}
}
modules/auth-service-parent/README.md
View file @
58cdf68b
...
...
@@ -63,9 +63,48 @@ export function loginByUsername (identifier, credential, code, randomStr) {
#### 二 手机号+验证码登录
接口URL:
`/api/auth/mobile/token`
发送短信接口:
`/api/user/v1/mobile/sendSms/`
+ ${mobile},其中mobile为手机号
grant_type: mobile
登录接口URL:
`/api/auth/mobile/token`
```
/**
* 根据手机号登录
* @param social 手机号
* @param code 验证码
*/
export function loginBySocial (social, code) {
const grantType = 'mobile'
const scope = 'read'
return request({
url: '/api/auth/mobile/token',
headers: {
'Authorization': basicAuthorization
},
method: 'post',
params: {mobile: social, code, grant_type: grantType, scope},
data: {
name: userInfo.nickName,
sex: userInfo.gender,
avatarUrl: userInfo.avatarUrl
}
})
}
```
响应体:
```
{
"access_token": "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9",
"token_type": "bearer",
"refresh_token": "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9",
"expires_in": 3599,
"scope": "read write",
"loginType": "SMS",
"tenantCode": "gitee",
"jti": "e446adad-df0a-490a-9cde-8ac69c846335"
}
```
#### 三 微信小程序+code登录
...
...
modules/auth-service-parent/auth-service/src/main/java/com/github/tangyi/auth/security/CustomUserDetailsServiceImpl.java
View file @
58cdf68b
...
...
@@ -14,6 +14,7 @@ import com.github.tangyi.common.core.vo.RoleVo;
import
com.github.tangyi.common.core.vo.UserVo
;
import
com.github.tangyi.common.security.core.CustomUserDetailsService
;
import
com.github.tangyi.common.security.core.GrantedAuthorityImpl
;
import
com.github.tangyi.common.security.mobile.MobileUser
;
import
com.github.tangyi.common.security.wx.WxUser
;
import
com.github.tangyi.user.api.constant.MenuConstant
;
import
com.github.tangyi.user.api.dto.UserDto
;
...
...
@@ -75,17 +76,39 @@ public class CustomUserDetailsServiceImpl implements CustomUserDetailsService {
*
* @param social social
* @param tenantCode tenantCode
* @param mobileUser mobileUser
* @return UserDetails
* @author tangyi
* @date 2019/06/22 21:08
*/
@Override
public
UserDetails
loadUserBySocialAndTenantCode
(
String
social
,
String
tenantCode
)
throws
UsernameNotFoundException
{
public
UserDetails
loadUserBySocialAndTenantCode
(
String
social
,
String
tenantCode
,
MobileUser
mobileUser
)
throws
UsernameNotFoundException
{
long
start
=
System
.
currentTimeMillis
();
Tenant
tenant
=
this
.
validateTenantCode
(
tenantCode
);
UserVo
userVo
=
userServiceClient
.
findUserBySocial
(
social
,
tenantCode
);
if
(
userVo
==
null
)
throw
new
UsernameNotFoundException
(
"用户手机号未注册."
);
UserVo
userVo
=
userServiceClient
.
findUserByIdentifier
(
social
,
IdentityType
.
PHONE_NUMBER
.
getValue
(),
tenantCode
);
// 第一次登录
if
(
userVo
==
null
)
{
UserDto
userDto
=
new
UserDto
();
// 用户的基本信息
if
(
mobileUser
!=
null
)
BeanUtils
.
copyProperties
(
mobileUser
,
userDto
);
userDto
.
setIdentifier
(
social
);
userDto
.
setCredential
(
social
);
userDto
.
setIdentityType
(
IdentityType
.
PHONE_NUMBER
.
getValue
());
userDto
.
setLoginTime
(
DateUtils
.
asDate
(
LocalDateTime
.
now
()));
// 注册账号
ResponseBean
<
Boolean
>
response
=
userServiceClient
.
registerUser
(
userDto
);
if
(
response
==
null
||
!
response
.
getData
())
throw
new
CommonException
(
"自动注册用户失败."
);
// 重新获取用户信息
userVo
=
userServiceClient
.
findUserByIdentifier
(
social
,
IdentityType
.
PHONE_NUMBER
.
getValue
(),
tenantCode
);
}
else
{
// TODO 记录登录时间,IP等信息
UserDto
userDto
=
new
UserDto
();
BeanUtils
.
copyProperties
(
userVo
,
userDto
);
userDto
.
setLoginTime
(
DateUtils
.
asDate
(
LocalDateTime
.
now
()));
//userServiceClient.updateUser(userDto);
}
return
new
CustomUserDetails
(
userVo
.
getIdentifier
(),
userVo
.
getCredential
(),
CommonConstant
.
STATUS_NORMAL
.
equals
(
userVo
.
getStatus
()),
getAuthority
(
userVo
),
userVo
.
getTenantCode
(),
start
,
LoginType
.
SMS
);
}
...
...
modules/exam-service-parent/exam-service/src/main/java/com/github/tangyi/exam/error/CustomGlobalExceptionHandler.java
View file @
58cdf68b
...
...
@@ -60,6 +60,6 @@ public class CustomGlobalExceptionHandler extends ResponseEntityExceptionHandler
responseBean
.
setStatus
(
HttpStatus
.
INTERNAL_SERVER_ERROR
.
value
());
responseBean
.
setCode
(
HttpStatus
.
INTERNAL_SERVER_ERROR
.
value
());
responseBean
.
setMsg
(
e
.
getMessage
());
return
new
ResponseEntity
<>(
responseBean
,
HttpStatus
.
INTERNAL_SERVER_ERROR
);
return
new
ResponseEntity
<>(
responseBean
,
HttpStatus
.
OK
);
}
}
modules/msc-service-parent/msc-service-api/src/main/java/com/github/tangyi/msc/api/constant/SmsConstant.java
View file @
58cdf68b
...
...
@@ -9,5 +9,5 @@ public class SmsConstant {
/**
* 短信模板
*/
public
static
final
String
SMS_TEMPLATE
=
"
验证码:%s,本验证码有效时间5分钟,请勿告知其他人。
"
;
public
static
final
String
SMS_TEMPLATE
=
"
{\"code\":\"%s\"}
"
;
}
modules/msc-service-parent/msc-service-api/src/main/java/com/github/tangyi/msc/api/model/SmsResponse.java
0 → 100644
View file @
58cdf68b
package
com
.
github
.
tangyi
.
msc
.
api
.
model
;
import
com.fasterxml.jackson.annotation.JsonProperty
;
import
lombok.Data
;
/**
* 封装短信服务返回的结果
*
* @author tangyi
* @date 2019/08/04 13:51
*/
@Data
public
class
SmsResponse
{
@JsonProperty
(
"Message"
)
private
String
message
;
@JsonProperty
(
"RequestId"
)
private
String
requestId
;
@JsonProperty
(
"Code"
)
private
String
code
;
}
modules/msc-service-parent/msc-service/src/main/java/com/github/tangyi/msc/controller/SmsController.java
View file @
58cdf68b
...
...
@@ -3,6 +3,7 @@ package com.github.tangyi.msc.controller;
import
com.github.tangyi.common.core.model.ResponseBean
;
import
com.github.tangyi.common.core.web.BaseController
;
import
com.github.tangyi.msc.api.dto.SmsDto
;
import
com.github.tangyi.msc.api.model.SmsResponse
;
import
com.github.tangyi.msc.service.SmsService
;
import
io.swagger.annotations.Api
;
import
lombok.AllArgsConstructor
;
...
...
@@ -36,11 +37,10 @@ public class SmsController extends BaseController {
* @date 2019/06/22 13:12
*/
@PostMapping
(
"sendSms"
)
public
ResponseBean
<
Object
>
sendSms
(
@RequestBody
SmsDto
smsDto
)
{
public
ResponseBean
<
SmsResponse
>
sendSms
(
@RequestBody
SmsDto
smsDto
)
{
log
.
info
(
"发送短信给{},发送内容:{}"
,
smsDto
.
getReceiver
(),
smsDto
.
getContent
());
// TODO 发送逻辑
String
result
=
smsService
.
sendSms
(
smsDto
);
log
.
info
(
"发送短信成功,返回内容:{}"
,
result
);
return
new
ResponseBean
<>(
result
);
SmsResponse
smsResponse
=
smsService
.
sendSms
(
smsDto
);
log
.
info
(
"发送短信成功,返回内容:{}"
,
smsResponse
);
return
new
ResponseBean
<>(
smsResponse
);
}
}
modules/msc-service-parent/msc-service/src/main/java/com/github/tangyi/msc/error/CustomGlobalExceptionHandler.java
0 → 100644
View file @
58cdf68b
package
com
.
github
.
tangyi
.
msc
.
error
;
import
com.github.tangyi.common.core.exceptions.CommonException
;
import
com.github.tangyi.common.core.model.ResponseBean
;
import
org.springframework.context.support.DefaultMessageSourceResolvable
;
import
org.springframework.http.HttpHeaders
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.web.bind.MethodArgumentNotValidException
;
import
org.springframework.web.bind.annotation.ControllerAdvice
;
import
org.springframework.web.bind.annotation.ExceptionHandler
;
import
org.springframework.web.context.request.WebRequest
;
import
org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler
;
import
java.util.List
;
import
java.util.stream.Collectors
;
/**
* 全局异常处理
*
* @author tangyi
* @date 2019/05/25 15:36
*/
@ControllerAdvice
public
class
CustomGlobalExceptionHandler
extends
ResponseEntityExceptionHandler
{
/**
* 处理参数校验异常
*
* @param ex ex
* @param headers headers
* @param status status
* @param request request
* @return ResponseEntity
*/
@Override
protected
ResponseEntity
<
Object
>
handleMethodArgumentNotValid
(
MethodArgumentNotValidException
ex
,
HttpHeaders
headers
,
HttpStatus
status
,
WebRequest
request
)
{
// 获取参数校验异常信息
List
<
String
>
errors
=
ex
.
getBindingResult
()
.
getFieldErrors
()
.
stream
()
.
map
(
DefaultMessageSourceResolvable:
:
getDefaultMessage
)
.
collect
(
Collectors
.
toList
());
ResponseBean
<
List
<
String
>>
responseBean
=
new
ResponseBean
<>(
errors
);
responseBean
.
setStatus
(
status
.
value
());
return
new
ResponseEntity
<>(
responseBean
,
headers
,
status
);
}
/**
* 处理CommonException
*
* @param e e
* @return ResponseEntity
*/
@ExceptionHandler
(
CommonException
.
class
)
public
ResponseEntity
<
ResponseBean
<
String
>>
handleCommonException
(
Exception
e
)
{
ResponseBean
<
String
>
responseBean
=
new
ResponseBean
<>();
responseBean
.
setStatus
(
HttpStatus
.
INTERNAL_SERVER_ERROR
.
value
());
responseBean
.
setCode
(
HttpStatus
.
INTERNAL_SERVER_ERROR
.
value
());
responseBean
.
setMsg
(
e
.
getMessage
());
return
new
ResponseEntity
<>(
responseBean
,
HttpStatus
.
OK
);
}
}
modules/msc-service-parent/msc-service/src/main/java/com/github/tangyi/msc/properties/SmsProperties.java
View file @
58cdf68b
...
...
@@ -38,4 +38,24 @@ public class SmsProperties {
* domain
*/
private
String
domain
;
/**
* 签名
*/
private
String
signName
;
/**
* 模板code
*/
private
String
templateCode
;
/**
* 版本
*/
private
String
version
;
/**
* action
*/
private
String
action
;
}
modules/msc-service-parent/msc-service/src/main/java/com/github/tangyi/msc/service/SmsService.java
View file @
58cdf68b
...
...
@@ -6,7 +6,10 @@ import com.aliyuncs.DefaultAcsClient;
import
com.aliyuncs.IAcsClient
;
import
com.aliyuncs.http.MethodType
;
import
com.aliyuncs.profile.DefaultProfile
;
import
com.github.tangyi.common.core.exceptions.CommonException
;
import
com.github.tangyi.common.core.utils.JsonMapper
;
import
com.github.tangyi.msc.api.dto.SmsDto
;
import
com.github.tangyi.msc.api.model.SmsResponse
;
import
com.github.tangyi.msc.properties.SmsProperties
;
import
lombok.AllArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
...
...
@@ -27,11 +30,11 @@ public class SmsService {
* 发送短信
*
* @param smsDto smsDto
* @return S
tring
* @return S
msResponse
* @author tangyi
* @date 2019/06/22 13:28
*/
public
S
tring
sendSms
(
SmsDto
smsDto
)
{
public
S
msResponse
sendSms
(
SmsDto
smsDto
)
{
DefaultProfile
profile
=
DefaultProfile
.
getProfile
(
smsProperties
.
getRegionId
(),
smsProperties
.
getAppKey
(),
smsProperties
.
getAppSecret
());
IAcsClient
client
=
new
DefaultAcsClient
(
profile
);
CommonRequest
request
=
new
CommonRequest
();
...
...
@@ -39,13 +42,27 @@ public class SmsService {
request
.
setDomain
(
smsProperties
.
getDomain
());
request
.
putQueryParameter
(
"RegionId"
,
smsProperties
.
getRegionId
());
request
.
putQueryParameter
(
"PhoneNumbers"
,
smsDto
.
getReceiver
());
request
.
putQueryParameter
(
"SignName"
,
smsProperties
.
getSignName
());
request
.
putQueryParameter
(
"TemplateCode"
,
smsProperties
.
getTemplateCode
());
request
.
putQueryParameter
(
"TemplateParam"
,
smsDto
.
getContent
());
request
.
setVersion
(
smsProperties
.
getVersion
());
request
.
setAction
(
smsProperties
.
getAction
());
try
{
CommonResponse
response
=
client
.
getCommonResponse
(
request
);
log
.
info
(
"发送结果:{}"
,
response
.
getData
());
return
response
.
getData
();
if
(
response
.
getHttpStatus
()
!=
200
)
throw
new
CommonException
(
response
.
getData
());
SmsResponse
smsResponse
=
JsonMapper
.
getInstance
().
fromJson
(
response
.
getData
(),
SmsResponse
.
class
);
if
(
smsResponse
==
null
)
throw
new
CommonException
(
"解析短信返回结果失败"
);
if
(!
"OK"
.
equals
(
smsResponse
.
getCode
()))
throw
new
CommonException
(
smsResponse
.
getMessage
());
return
smsResponse
;
}
catch
(
Exception
e
)
{
log
.
error
(
e
.
getMessage
(),
e
);
throw
new
CommonException
(
"发送短信失败:"
+
e
.
getMessage
());
}
return
null
;
}
}
modules/user-service-parent/user-service-api/src/main/java/com/github/tangyi/user/api/constant/UserStudentConstant.java
0 → 100644
View file @
58cdf68b
package
com
.
github
.
tangyi
.
user
.
api
.
constant
;
/**
* 用户学生常量
*
* @author tangyi
* @date 2019-07-25 13:08
*/
public
class
UserStudentConstant
{
/**
* 爸爸
*/
public
static
final
Integer
RELATIONSHIP_TYPE_FATHER
=
0
;
/**
* 妈妈
*/
public
static
final
Integer
RELATIONSHIP_TYPE_MOTHER
=
1
;
/**
* 爷爷
*/
public
static
final
Integer
RELATIONSHIP_TYPE_GRAND_FATHER
=
2
;
/**
* 奶奶
*/
public
static
final
Integer
RELATIONSHIP_TYPE_GRAND_MOTHER
=
3
;
/**
* 外公
*/
public
static
final
Integer
RELATIONSHIP_TYPE_GRANDPA_FATHER
=
5
;
/**
* 外婆
*/
public
static
final
Integer
RELATIONSHIP_TYPE_GRANDMA_MOTHER
=
6
;
}
modules/user-service-parent/user-service-api/src/main/java/com/github/tangyi/user/api/dto/StudentDto.java
View file @
58cdf68b
...
...
@@ -13,7 +13,7 @@ import java.util.Date;
@Data
public
class
StudentDto
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1
L
;
private
static
final
long
serialVersionUID
=
2602249526687821147
L
;
private
String
id
;
...
...
@@ -74,9 +74,16 @@ public class StudentDto implements Serializable {
/**
* 就读年级
*/
@ApiModelProperty
(
value
=
"就读年级"
)
@ApiModelProperty
(
value
=
"就读年级
ID
"
)
private
String
grade
;
/**
* 就读年级
*/
@ApiModelProperty
(
value
=
"就读年级名称"
)
private
String
gradeName
;
/**
* 就读学校
*/
...
...
@@ -84,14 +91,14 @@ public class StudentDto implements Serializable {
private
String
school
;
/**
*
城市id
*
就读城市
*/
@ApiModelProperty
(
value
=
"就读
学校
"
)
@ApiModelProperty
(
value
=
"就读
城市ID
"
)
private
String
cityId
;
/**
* 县id
*/
@ApiModelProperty
(
value
=
"
县id
"
)
@ApiModelProperty
(
value
=
"
就读区县ID
"
)
private
String
countyId
;
}
\ No newline at end of file
modules/user-service-parent/user-service-api/src/main/java/com/github/tangyi/user/api/dto/UserDto.java
View file @
58cdf68b
...
...
@@ -196,4 +196,10 @@ public class UserDto implements Serializable {
*/
@ApiModelProperty
(
value
=
"微信"
)
private
String
wechat
;
/**
* 家庭角色
*/
@ApiModelProperty
(
value
=
"家庭角色,0:爸爸,1:妈妈,2:爷爷,3:奶奶,5:外公,6:外婆"
,
example
=
"0"
)
private
Integer
familyRole
;
}
modules/user-service-parent/user-service-api/src/main/java/com/github/tangyi/user/api/module/Student.java
View file @
58cdf68b
...
...
@@ -50,6 +50,11 @@ public class Student extends BaseEntity<Student> {
private
String
grade
;
/**
* 就读班级名称
*/
private
String
gradeName
;
/**
* 就读学校
*/
private
String
school
;
...
...
modules/user-service-parent/user-service-api/src/main/java/com/github/tangyi/user/api/module/User.java
View file @
58cdf68b
...
...
@@ -113,4 +113,9 @@ public class User extends BaseEntity<User> {
* 微信
*/
private
String
wechat
;
/**
* 家庭角色,参考UserStudentConstant
*/
private
Integer
familyRole
;
}
modules/user-service-parent/user-service/src/main/java/com/github/tangyi/user/controller/StudentController.java
View file @
58cdf68b
...
...
@@ -120,6 +120,8 @@ public class StudentController extends BaseController {
try
{
Student
student
=
new
Student
();
BeanUtils
.
copyProperties
(
studentDto
,
student
);
student
.
setId
(
studentDto
.
getId
());
student
.
setCommonValue
(
SysUtil
.
getUser
(),
SysUtil
.
getSysCode
(),
SysUtil
.
getTenantCode
());
return
new
ResponseBean
<>(
studentService
.
update
(
student
)
>
0
);
}
catch
(
Exception
e
)
{
log
.
error
(
"更新学生信息失败!"
,
e
);
...
...
modules/user-service-parent/user-service/src/main/java/com/github/tangyi/user/error/CustomGlobalExceptionHandler.java
View file @
58cdf68b
...
...
@@ -60,6 +60,6 @@ public class CustomGlobalExceptionHandler extends ResponseEntityExceptionHandler
responseBean
.
setStatus
(
HttpStatus
.
INTERNAL_SERVER_ERROR
.
value
());
responseBean
.
setCode
(
HttpStatus
.
INTERNAL_SERVER_ERROR
.
value
());
responseBean
.
setMsg
(
e
.
getMessage
());
return
new
ResponseEntity
<>(
responseBean
,
HttpStatus
.
INTERNAL_SERVER_ERROR
);
return
new
ResponseEntity
<>(
responseBean
,
HttpStatus
.
OK
);
}
}
modules/user-service-parent/user-service/src/main/java/com/github/tangyi/user/service/MobileService.java
View file @
58cdf68b
...
...
@@ -43,23 +43,21 @@ public class MobileService {
* @date 2019/07/02 09:36:52
*/
public
ResponseBean
<
Boolean
>
sendSms
(
String
mobile
,
String
tenantCode
)
{
Object
codeObj
=
redisTemplate
.
opsForValue
().
get
(
CommonConstant
.
DEFAULT_CODE_KEY
+
mobile
);
if
(
codeObj
!=
null
)
{
log
.
info
(
"手机号验证码未过期:{},{}"
,
mobile
,
codeObj
);
return
new
ResponseBean
<>(
Boolean
.
FALSE
,
"手机号未注册."
);
}
String
key
=
tenantCode
+
":"
+
CommonConstant
.
DEFAULT_CODE_KEY
+
LoginType
.
SMS
.
getType
()
+
"@"
+
mobile
;
// TODO 校验时间
String
code
=
RandomUtil
.
randomNumbers
(
Integer
.
parseInt
(
CommonConstant
.
CODE_SIZE
));
log
.
debug
(
"手机号生成验证码成功:{},{}"
,
mobile
,
code
);
redisTemplate
.
opsForValue
().
set
(
tenantCode
+
":"
+
CommonConstant
.
DEFAULT_CODE_KEY
+
LoginType
.
SMS
.
getType
()
+
"@"
+
mobile
,
code
,
SecurityConstant
.
DEFAULT_SMS_EXPIRE
,
TimeUnit
.
SECONDS
);
redisTemplate
.
opsForValue
().
set
(
key
,
code
,
SecurityConstant
.
DEFAULT_SMS_EXPIRE
,
TimeUnit
.
SECONDS
);
// 调用消息中心服务,发送短信验证码
SmsDto
smsDto
=
new
SmsDto
();
smsDto
.
setReceiver
(
mobile
);
smsDto
.
setContent
(
String
.
format
(
SmsConstant
.
SMS_TEMPLATE
,
code
));
// ResponseBean<?> result = mscServiceClient.sendSms(smsDto);
// if (result == null)
// throw new CommonException("发送失败.");
// log.info("发送验证码结果:{}", result.getData());
ResponseBean
<?>
result
=
mscServiceClient
.
sendSms
(
smsDto
);
if
(
result
==
null
)
throw
new
CommonException
(
"发送短信失败."
);
if
(
result
.
getCode
()
==
ResponseBean
.
FAIL
)
throw
new
CommonException
(
result
.
getMsg
());
log
.
info
(
"发送验证码结果:{}"
,
result
.
getData
());
return
new
ResponseBean
<>(
Boolean
.
TRUE
,
code
);
}
}
modules/user-service-parent/user-service/src/main/java/com/github/tangyi/user/service/StudentService.java
View file @
58cdf68b
...
...
@@ -4,6 +4,7 @@ import com.github.tangyi.common.core.exceptions.CommonException;
import
com.github.tangyi.common.core.service.CrudService
;
import
com.github.tangyi.common.core.utils.SysUtil
;
import
com.github.tangyi.common.core.vo.UserVo
;
import
com.github.tangyi.user.api.constant.UserStudentConstant
;
import
com.github.tangyi.user.api.dto.StudentDto
;
import
com.github.tangyi.user.api.module.Student
;
import
com.github.tangyi.user.api.module.UserStudent
;
...
...
@@ -54,8 +55,9 @@ public class StudentService extends CrudService<StudentMapper, Student> {
userStudent
.
setCommonValue
(
currentUser
,
SysUtil
.
getSysCode
(),
tenantCode
);
userStudent
.
setUserId
(
userId
);
userStudent
.
setStudentId
(
student
.
getId
());
// TODO
userStudent
.
setRelationshipType
(
0
);
// 默认关系类型是爸爸
if
(
studentDto
.
getRelationshipType
()
==
null
)
userStudent
.
setRelationshipType
(
UserStudentConstant
.
RELATIONSHIP_TYPE_FATHER
);
userStudentService
.
insert
(
userStudent
);
// 保存学生
return
this
.
insert
(
student
);
...
...
modules/user-service-parent/user-service/src/main/java/com/github/tangyi/user/service/UserService.java
View file @
58cdf68b
...
...
@@ -86,6 +86,9 @@ public class UserService extends CrudService<UserMapper, User> {
BeanUtils
.
copyProperties
(
userDto
,
user
);
// 先保存用户基本信息
user
.
setCommonValue
(
SysUtil
.
getUser
(),
SysUtil
.
getSysCode
(),
SysUtil
.
getTenantCode
());
// 保存父子账号关系
UserVo
currentUser
=
this
.
findUserByIdentifier
(
userDto
.
getIdentityType
(),
SysUtil
.
getUser
(),
SysUtil
.
getTenantCode
());
user
.
setParentUid
(
currentUser
.
getId
());
if
((
update
=
this
.
insert
(
user
))
>
0
)
{
// 保存用户授权信息
UserAuths
userAuths
=
new
UserAuths
();
...
...
@@ -608,8 +611,8 @@ public class UserService extends CrudService<UserMapper, User> {
// 返回默认密码
if
(
StringUtils
.
isBlank
(
encoded
))
return
CommonConstant
.
DEFAULT_PASSWORD
;
// 微信注册不需要解密
if
(
IdentityType
.
WE_CHAT
.
getValue
().
equals
(
identityType
))
// 微信
、手机号
注册不需要解密
if
(
IdentityType
.
WE_CHAT
.
getValue
().
equals
(
identityType
)
||
IdentityType
.
PHONE_NUMBER
.
getValue
().
equals
(
identityType
)
)
return
encoded
;
// 解密密码
try
{
...
...
modules/user-service-parent/user-service/src/main/resources/mapper/StudentMapper.xml
View file @
58cdf68b
...
...
@@ -9,10 +9,11 @@
<result
column=
"sex"
property=
"sex"
/>
<result
column=
"address"
property=
"address"
/>
<result
column=
"grade"
property=
"grade"
/>
<result
column=
"grade_name"
property=
"gradeName"
/>
<result
column=
"school"
property=
"school"
/>
<result
column=
"wechat"
property=
"wechat"
/>
<result
column=
"city
Id"
property=
"city_i
d"
/>
<result
column=
"county
Id"
property=
"county_i
d"
/>
<result
column=
"city
_id"
property=
"cityI
d"
/>
<result
column=
"county
_id"
property=
"countyI
d"
/>
<result
column=
"creator"
property=
"creator"
/>
<result
column=
"create_date"
property=
"createDate"
javaType=
"java.util.Date"
jdbcType=
"TIMESTAMP"
/>
<result
column=
"modifier"
property=
"modifier"
/>
...
...
@@ -28,10 +29,11 @@
a.sex,
a.address,
a.grade,
a.grade_name,
a.school,
a.wechat,
a.city
I
d,
a.county
I
d,
a.city
_i
d,
a.county
_i
d,
a.creator,
a.create_date,
a.modifier,
...
...
@@ -72,6 +74,7 @@
sex,
address,
grade,
grade_name,
school,
wechat,
city_id,
...
...
@@ -89,6 +92,7 @@
#{sex},
#{address},
#{grade},
#{gradeName},
#{school},
#{wechat},
#{cityId},
...
...
@@ -121,6 +125,9 @@
<if
test=
"grade != null"
>
grade = #{grade},
</if>
<if
test=
"gradeName != null"
>
grade_name = #{gradeName},
</if>
<if
test=
"school != null"
>
school = #{school},
</if>
...
...
modules/user-service-parent/user-service/src/main/resources/mapper/UserMapper.xml
View file @
58cdf68b
...
...
@@ -20,6 +20,7 @@
<result
column=
"login_time"
property=
"loginTime"
javaType=
"java.util.Date"
jdbcType=
"TIMESTAMP"
/>
<result
column=
"lock_time"
property=
"lockTime"
javaType=
"java.util.Date"
jdbcType=
"TIMESTAMP"
/>
<result
column=
"wechat"
property=
"wechat"
/>
<result
column=
"family_role"
property=
"familyRole"
/>
<result
column=
"creator"
property=
"creator"
/>
<result
column=
"create_date"
property=
"createDate"
javaType=
"java.util.Date"
jdbcType=
"TIMESTAMP"
/>
<result
column=
"modifier"
property=
"modifier"
/>
...
...
@@ -48,6 +49,7 @@
a.login_time,
a.lock_time,
a.wechat,
a.family_role,
a.creator,
a.create_date,
a.modifier,
...
...
@@ -59,6 +61,9 @@
<!-- where 条件 -->
<sql
id=
"whereColumnList"
>
<if
test=
"parentUid != null and parentUid != ''"
>
and a.parent_uid = #{parentUid}
</if>
<if
test=
"name != null and name != ''"
>
and a.name like CONCAT('%', #{name},'%')
</if>
...
...
@@ -130,6 +135,7 @@
login_time,
lock_time,
wechat,
family_role,
creator,
create_date,
modifier,
...
...
@@ -156,6 +162,7 @@
#{loginTime, jdbcType=TIMESTAMP, javaType=java.util.Date},
#{lockTime, jdbcType=TIMESTAMP, javaType=java.util.Date},
#{wechat},
#{familyRole},
#{creator},
#{createDate, jdbcType=TIMESTAMP, javaType=java.util.Date},
#{modifier},
...
...
@@ -220,6 +227,9 @@
<if
test=
"wechat != null"
>
wechat = #{wechat} ,
</if>
<if
test=
"familyRole != null"
>
family_role = #{familyRole} ,
</if>
<if
test=
"creator != null"
>
creator = #{creator} ,
</if>
...
...
pom.xml
View file @
58cdf68b
...
...
@@ -71,7 +71,7 @@
<kaptcha.version>
0.0.9
</kaptcha.version>
<json.version>
20140107
</json.version>
<okhttp.version>
3.8.1
</okhttp.version>
<aliyun.version>
4.
1.0
</aliyun.version>
<aliyun.version>
4.
0.3
</aliyun.version>
<weixin.version>
3.4.0
</weixin.version>
<!-- docker -->
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
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 comment