Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
C
cms
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
iuav
cms
Commits
db7be215
提交
db7be215
authored
1月 12, 2024
作者:
han
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
web端用户注册
上级
e1237fdc
流水线
#7990
已通过 于阶段
in 2 分 23 秒
变更
10
流水线
1
隐藏空白字符变更
内嵌
并排
正在显示
10 个修改的文件
包含
186 行增加
和
8 行删除
+186
-8
WebRegisterVO.java
...c/main/java/com/mmc/iuav/user/model/vo/WebRegisterVO.java
+30
-0
AuthController.java
...ain/java/com/mmc/iuav/user/controller/AuthController.java
+39
-1
UserServiceDao.java
...r/src/main/java/com/mmc/iuav/user/dao/UserServiceDao.java
+14
-0
UserAccountDO.java
...src/main/java/com/mmc/iuav/user/entity/UserAccountDO.java
+3
-2
AuthService.java
.../src/main/java/com/mmc/iuav/user/service/AuthService.java
+8
-0
AuthServiceImpl.java
.../java/com/mmc/iuav/user/service/impl/AuthServiceImpl.java
+38
-0
UserAccountServiceImpl.java
...om/mmc/iuav/user/service/impl/UserAccountServiceImpl.java
+12
-0
SmsUtil.java
...ce-user/src/main/java/com/mmc/iuav/user/util/SmsUtil.java
+1
-1
UserServiceDao.xml
...service-user/src/main/resources/mapper/UserServiceDao.xml
+39
-4
not-check.yml
...service/cms-service-user/src/main/resources/not-check.yml
+2
-0
没有找到文件。
cms-common/cms-common-model/src/main/java/com/mmc/iuav/user/model/vo/WebRegisterVO.java
0 → 100644
浏览文件 @
db7be215
package
com
.
mmc
.
iuav
.
user
.
model
.
vo
;
import
com.mmc.iuav.group.Insert
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.AllArgsConstructor
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
javax.validation.constraints.NotNull
;
import
java.io.Serializable
;
/**
* @author: zj
* @Date: 2023/5/16 13:56
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public
class
WebRegisterVO
implements
Serializable
{
private
static
final
long
serialVersionUID
=
2500957724470423989L
;
@ApiModelProperty
(
value
=
"手机号"
)
@NotNull
(
message
=
"手机号不能为空"
,
groups
=
{
Insert
.
class
})
private
String
phoneNum
;
@ApiModelProperty
(
value
=
"密码"
)
@NotNull
(
message
=
"密码不能为空"
,
groups
=
{
Insert
.
class
})
private
String
password
;
@ApiModelProperty
(
value
=
"请求code"
)
@NotNull
(
message
=
"验证码不能为空"
,
groups
=
{
Insert
.
class
})
private
String
code
;
}
csm-service/cms-service-user/src/main/java/com/mmc/iuav/user/controller/AuthController.java
浏览文件 @
db7be215
package
com
.
mmc
.
iuav
.
user
.
controller
;
package
com
.
mmc
.
iuav
.
user
.
controller
;
import
com.mmc.iuav.general.CodeUtil
;
import
com.mmc.iuav.group.Insert
;
import
com.mmc.iuav.group.Insert
;
import
com.mmc.iuav.response.ResultBody
;
import
com.mmc.iuav.response.ResultBody
;
import
com.mmc.iuav.user.dao.UserServiceDao
;
import
com.mmc.iuav.user.entity.UserAccountDO
;
import
com.mmc.iuav.user.model.dto.LoginSuccessDTO
;
import
com.mmc.iuav.user.model.dto.LoginSuccessDTO
;
import
com.mmc.iuav.user.model.qo.LoginUserQO
;
import
com.mmc.iuav.user.model.qo.LoginUserQO
;
import
com.mmc.iuav.user.model.vo.AppUserSucVO
;
import
com.mmc.iuav.user.model.vo.AppUserSucVO
;
import
com.mmc.iuav.user.model.vo.WebRegisterVO
;
import
com.mmc.iuav.user.model.vo.WxLoginVO
;
import
com.mmc.iuav.user.model.vo.WxLoginVO
;
import
com.mmc.iuav.user.service.AuthService
;
import
com.mmc.iuav.user.service.AuthService
;
import
com.mmc.iuav.user.service.UserAccountService
;
import
com.mmc.iuav.user.service.UserAccountService
;
import
com.mmc.iuav.user.util.SmsUtil
;
import
io.swagger.annotations.*
;
import
io.swagger.annotations.*
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.redis.core.StringRedisTemplate
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.concurrent.TimeUnit
;
/**
/**
* @author: zj
* @author: zj
* @Date: 2023/5/15 15:50
* @Date: 2023/5/15 15:50
...
@@ -26,7 +36,10 @@ public class AuthController {
...
@@ -26,7 +36,10 @@ public class AuthController {
private
AuthService
authService
;
private
AuthService
authService
;
@Autowired
@Autowired
private
UserAccountService
userAccountService
;
private
UserAccountService
userAccountService
;
@Autowired
private
StringRedisTemplate
stringRedisTemplate
;
@Autowired
private
UserServiceDao
userServiceDao
;
@ApiOperation
(
value
=
"小程序登录/注册"
)
@ApiOperation
(
value
=
"小程序登录/注册"
)
@ApiResponses
({
@ApiResponse
(
code
=
200
,
message
=
"OK"
,
response
=
AppUserSucVO
.
class
)})
@ApiResponses
({
@ApiResponse
(
code
=
200
,
message
=
"OK"
,
response
=
AppUserSucVO
.
class
)})
@PostMapping
(
"appletLogin"
)
@PostMapping
(
"appletLogin"
)
...
@@ -56,4 +69,29 @@ public class AuthController {
...
@@ -56,4 +69,29 @@ public class AuthController {
String
unionId
=
userAccountService
.
selectUnionIdByPhone
(
phone
);
String
unionId
=
userAccountService
.
selectUnionIdByPhone
(
phone
);
return
authService
.
testAppletLogin
(
unionId
);
return
authService
.
testAppletLogin
(
unionId
);
}
}
@ApiOperation
(
value
=
"web注册获取手机号验证码"
)
@ApiResponses
({
@ApiResponse
(
code
=
200
,
message
=
"OK"
,
response
=
ResultBody
.
class
)})
@GetMapping
(
"getVerifyCode"
)
public
ResultBody
getVerifyCode
(
@RequestParam
(
value
=
"phoneNum"
)
String
phoneNum
)
{
if
(
phoneNum
==
null
){
return
ResultBody
.
error
(
"手机号不能为空"
);
}
// 根据手机号生成验证码
String
verifyCode
=
CodeUtil
.
getRandomNum
(
6
);
// 发送给用户
SmsUtil
.
verifyCode
(
verifyCode
,
phoneNum
);
Map
<
String
,
String
>
redisData
=
new
HashMap
<>();
redisData
.
put
(
"phoneNum"
,
phoneNum
);
redisData
.
put
(
"verifyCode"
,
verifyCode
);
stringRedisTemplate
.
opsForHash
().
putAll
(
verifyCode
+
phoneNum
,
redisData
);
stringRedisTemplate
.
expire
(
verifyCode
+
phoneNum
,
120
,
TimeUnit
.
SECONDS
);
return
ResultBody
.
success
();
}
@ApiOperation
(
value
=
"web端注册"
)
@ApiResponses
({
@ApiResponse
(
code
=
200
,
message
=
"OK"
,
response
=
AppUserSucVO
.
class
)})
@PostMapping
(
"webRegister"
)
public
ResultBody
webRegister
(
@Validated
(
value
=
{
Insert
.
class
})
@RequestBody
WebRegisterVO
webRegisterVO
)
{
return
authService
.
webRegister
(
webRegisterVO
);
}
}
}
csm-service/cms-service-user/src/main/java/com/mmc/iuav/user/dao/UserServiceDao.java
浏览文件 @
db7be215
...
@@ -51,6 +51,7 @@ public interface UserServiceDao {
...
@@ -51,6 +51,7 @@ public interface UserServiceDao {
*/
*/
void
update
(
UserAccountDO
userAccountDO
);
void
update
(
UserAccountDO
userAccountDO
);
void
updateId
(
@Param
(
"userAccountDO"
)
UserAccountDO
userAccountDO
,
@Param
(
"newId"
)
Integer
newId
);
/**
/**
* 查询是否存在这个用户
* 查询是否存在这个用户
* @param userId 用户id
* @param userId 用户id
...
@@ -239,4 +240,17 @@ public interface UserServiceDao {
...
@@ -239,4 +240,17 @@ public interface UserServiceDao {
* 根据手机号查询unionId
* 根据手机号查询unionId
*/
*/
String
selectUnionIdByPhone
(
String
phone
);
String
selectUnionIdByPhone
(
String
phone
);
/**
* 根据手机号查询用户信息
*
* @param phoneNum
* @return
*/
UserAccountDO
getUserByPhoneNum
(
String
phoneNum
);
/**
* 删除用户信息
*/
void
deleteById
(
Integer
id
);
}
}
csm-service/cms-service-user/src/main/java/com/mmc/iuav/user/entity/UserAccountDO.java
浏览文件 @
db7be215
...
@@ -25,6 +25,7 @@ import java.util.stream.Collectors;
...
@@ -25,6 +25,7 @@ import java.util.stream.Collectors;
public
class
UserAccountDO
implements
Serializable
{
public
class
UserAccountDO
implements
Serializable
{
private
static
final
long
serialVersionUID
=
5007589179946146721L
;
private
static
final
long
serialVersionUID
=
5007589179946146721L
;
private
Integer
id
;
private
Integer
id
;
private
Integer
newId
;
private
String
uid
;
private
String
uid
;
private
String
phoneNum
;
private
String
phoneNum
;
private
String
userName
;
private
String
userName
;
...
@@ -88,8 +89,8 @@ public class UserAccountDO implements Serializable {
...
@@ -88,8 +89,8 @@ public class UserAccountDO implements Serializable {
private
String
coverPicture
;
private
String
coverPicture
;
@ApiModelProperty
(
value
=
"地区id"
)
@ApiModelProperty
(
value
=
"地区id"
)
private
Integer
districtChildId
;
private
Integer
districtChildId
;
//web端登录密码
private
String
password
;
public
UserAccountDO
(
UserAccountVO
userAccountVO
)
{
public
UserAccountDO
(
UserAccountVO
userAccountVO
)
{
this
.
id
=
userAccountVO
.
getId
();
this
.
id
=
userAccountVO
.
getId
();
this
.
phoneNum
=
userAccountVO
.
getPhoneNum
();
this
.
phoneNum
=
userAccountVO
.
getPhoneNum
();
...
...
csm-service/cms-service-user/src/main/java/com/mmc/iuav/user/service/AuthService.java
浏览文件 @
db7be215
package
com
.
mmc
.
iuav
.
user
.
service
;
package
com
.
mmc
.
iuav
.
user
.
service
;
import
com.mmc.iuav.group.Insert
;
import
com.mmc.iuav.response.ResultBody
;
import
com.mmc.iuav.response.ResultBody
;
import
com.mmc.iuav.user.model.dto.LoginSuccessDTO
;
import
com.mmc.iuav.user.model.dto.LoginSuccessDTO
;
import
com.mmc.iuav.user.model.qo.LoginUserQO
;
import
com.mmc.iuav.user.model.qo.LoginUserQO
;
import
com.mmc.iuav.user.model.vo.WebRegisterVO
;
import
com.mmc.iuav.user.model.vo.WxLoginVO
;
import
com.mmc.iuav.user.model.vo.WxLoginVO
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.RequestBody
;
/**
/**
* @author: zj
* @author: zj
...
@@ -51,4 +55,8 @@ public interface AuthService {
...
@@ -51,4 +55,8 @@ public interface AuthService {
* @return
* @return
*/
*/
ResultBody
getLoginInfo
(
String
randomLoginCode
);
ResultBody
getLoginInfo
(
String
randomLoginCode
);
/**
* web端用户注册
*/
ResultBody
webRegister
(
WebRegisterVO
webRegisterVO
);
}
}
csm-service/cms-service-user/src/main/java/com/mmc/iuav/user/service/impl/AuthServiceImpl.java
浏览文件 @
db7be215
...
@@ -36,6 +36,7 @@ import org.springframework.transaction.annotation.Transactional;
...
@@ -36,6 +36,7 @@ import org.springframework.transaction.annotation.Transactional;
import
javax.annotation.Resource
;
import
javax.annotation.Resource
;
import
java.security.NoSuchAlgorithmException
;
import
java.security.NoSuchAlgorithmException
;
import
java.util.Map
;
import
java.util.concurrent.TimeUnit
;
import
java.util.concurrent.TimeUnit
;
/**
/**
...
@@ -262,6 +263,43 @@ public class AuthServiceImpl implements AuthService {
...
@@ -262,6 +263,43 @@ public class AuthServiceImpl implements AuthService {
return
ResultBody
.
success
(
loginSuccessDTO
);
return
ResultBody
.
success
(
loginSuccessDTO
);
}
}
@Override
public
ResultBody
webRegister
(
WebRegisterVO
webRegisterVO
)
{
Map
<
Object
,
Object
>
redisData
=
stringRedisTemplate
.
opsForHash
().
entries
(
webRegisterVO
.
getCode
()
+
webRegisterVO
.
getPhoneNum
());
if
(
redisData
.
isEmpty
())
{
return
ResultBody
.
error
(
"验证码错误,请重新输入"
);
}
String
code
=
redisData
.
get
(
"verifyCode"
).
toString
();
String
phoneNum
=
redisData
.
get
(
"phoneNum"
).
toString
();
// 验证码错误则修改失败,并提醒
if
(!
code
.
equals
(
webRegisterVO
.
getCode
()))
{
return
ResultBody
.
error
(
"验证码错误,请重新输入"
);
}
UserAccountDO
userAccountDO
=
userServiceDao
.
getUserByPhoneNum
(
phoneNum
);
// 小程序未登录过或者未绑定过手机号
if
(
userAccountDO
==
null
){
userAccountDO
=
new
UserAccountDO
();
userAccountDO
.
setPhoneNum
(
webRegisterVO
.
getPhoneNum
());
try
{
userAccountDO
.
setPassword
(
PwdUtil
.
securityPwd
(
webRegisterVO
.
getPassword
()));
}
catch
(
NoSuchAlgorithmException
e
)
{
return
ResultBody
.
error
(
ResultEnum
.
PWD_CREATE_ERROR
);
}
userServiceDao
.
insertUserAccount
(
userAccountDO
);
}
else
if
(
userAccountDO
.
getPassword
()
==
null
){
//小程序登录过且绑定过手机号
try
{
userAccountDO
.
setPassword
(
PwdUtil
.
securityPwd
(
webRegisterVO
.
getPassword
()));
}
catch
(
NoSuchAlgorithmException
e
)
{
return
ResultBody
.
error
(
ResultEnum
.
PWD_CREATE_ERROR
);
}
userServiceDao
.
update
(
userAccountDO
);
}
else
{
return
ResultBody
.
error
(
"已经注册过,请直接登录"
);
}
return
ResultBody
.
success
();
}
private
void
extracted
(
Integer
id
)
{
private
void
extracted
(
Integer
id
)
{
UserPointsVO
userPointsVO
=
new
UserPointsVO
(
id
,
NumberOfUserPoints
.
match
(
0
).
getMessage
());
UserPointsVO
userPointsVO
=
new
UserPointsVO
(
id
,
NumberOfUserPoints
.
match
(
0
).
getMessage
());
...
...
csm-service/cms-service-user/src/main/java/com/mmc/iuav/user/service/impl/UserAccountServiceImpl.java
浏览文件 @
db7be215
...
@@ -252,6 +252,17 @@ public class UserAccountServiceImpl implements UserAccountService {
...
@@ -252,6 +252,17 @@ public class UserAccountServiceImpl implements UserAccountService {
// return ResultBody.error(ResultEnum.AUTH_PHONE_NUMBER_ERROR);
// return ResultBody.error(ResultEnum.AUTH_PHONE_NUMBER_ERROR);
// }
// }
UserAccountDO
userAccount
=
new
UserAccountDO
();
UserAccountDO
userAccount
=
new
UserAccountDO
();
UserAccountDO
user
=
userServiceDao
.
getUserByPhoneNum
(
userPhoneNumber
);
if
(
user
!=
null
){
userAccount
.
setNewId
(
user
.
getId
());
userServiceDao
.
deleteById
(
id
);
if
(
user
.
getPassword
()
!=
null
){
userAccount
.
setPassword
(
user
.
getPassword
());
}
if
(
user
.
getNickName
()
!=
null
){
userAccount
.
setNickName
(
user
.
getNickName
());
}
}
userAccount
.
setId
(
id
);
userAccount
.
setId
(
id
);
userAccount
.
setPhoneNum
(
userPhoneNumber
);
userAccount
.
setPhoneNum
(
userPhoneNumber
);
userServiceDao
.
update
(
userAccount
);
userServiceDao
.
update
(
userAccount
);
...
@@ -575,4 +586,5 @@ public class UserAccountServiceImpl implements UserAccountService {
...
@@ -575,4 +586,5 @@ public class UserAccountServiceImpl implements UserAccountService {
}
}
}
}
csm-service/cms-service-user/src/main/java/com/mmc/iuav/user/util/SmsUtil.java
浏览文件 @
db7be215
...
@@ -30,7 +30,7 @@ public class SmsUtil {
...
@@ -30,7 +30,7 @@ public class SmsUtil {
private
static
String
COOPERATION_TEMPLATE_PASS_CODE_7
=
"SMS_464335035"
;
private
static
String
COOPERATION_TEMPLATE_PASS_CODE_7
=
"SMS_464335035"
;
//短信验证码模板
//短信验证码模板
private
static
String
VERIFYCODE
=
"SMS_2
11825548
"
;
private
static
String
VERIFYCODE
=
"SMS_2
91570267
"
;
/**
/**
* 加盟审核未通过
* 加盟审核未通过
...
...
csm-service/cms-service-user/src/main/resources/mapper/UserServiceDao.xml
浏览文件 @
db7be215
...
@@ -38,10 +38,10 @@
...
@@ -38,10 +38,10 @@
useGeneratedKeys=
"true"
keyProperty=
"id"
>
useGeneratedKeys=
"true"
keyProperty=
"id"
>
insert into user_account(phone_num, user_name, nick_name, user_img, open_id,
insert into user_account(phone_num, user_name, nick_name, user_img, open_id,
union_id, user_sex, email, source, province_code, city_code, district_code, remark,
union_id, user_sex, email, source, province_code, city_code, district_code, remark,
port_type, create_time)
port_type, create_time
,password
)
values (#{phoneNum}, #{userName}, #{nickName}, #{userImg}, #{openId},
values (#{phoneNum}, #{userName}, #{nickName}, #{userImg}, #{openId},
#{unionId}, #{userSex}, #{email}, #{source}, #{provinceCode}, #{cityCode}, #{districtCode}, #{remark},
#{unionId}, #{userSex}, #{email}, #{source}, #{provinceCode}, #{cityCode}, #{districtCode}, #{remark},
#{portType}, NOW())
#{portType}, NOW()
, #{password}
)
</insert>
</insert>
<insert
id=
"insertUserRcd"
parameterType=
"com.mmc.iuav.user.entity.UserRcdDO"
>
<insert
id=
"insertUserRcd"
parameterType=
"com.mmc.iuav.user.entity.UserRcdDO"
>
...
@@ -57,6 +57,9 @@
...
@@ -57,6 +57,9 @@
<update
id=
"update"
parameterType=
"com.mmc.iuav.user.entity.UserAccountDO"
>
<update
id=
"update"
parameterType=
"com.mmc.iuav.user.entity.UserAccountDO"
>
update user_account
update user_account
<set>
<set>
<if
test=
"newId != null"
>
id = #{newId},
</if>
<if
test=
"phoneNum != null"
>
<if
test=
"phoneNum != null"
>
phone_num = #{phoneNum},
phone_num = #{phoneNum},
</if>
</if>
...
@@ -100,20 +103,25 @@
...
@@ -100,20 +103,25 @@
district_child_id=#{districtChildId},
district_child_id=#{districtChildId},
</if>
</if>
<if
test=
"briefIntroduction!='' and briefIntroduction!=null"
>
<if
test=
"briefIntroduction!='' and briefIntroduction!=null"
>
brief_introduction=#{briefIntroduction}
brief_introduction=#{briefIntroduction},
</if>
<if
test=
"password !='' and password != null"
>
password=#{password}
</if>
</if>
</set>
</set>
<where>
<where>
id = #{id}
id = #{id}
</where>
</where>
</update>
</update>
<update
id=
"disableUserAccount"
>
<update
id=
"disableUserAccount"
>
update user_account
update user_account
set disable = 1,
set disable = 1,
union_id = #{removeNO}
union_id = #{removeNO}
where id = #{userAccountId}
where id = #{userAccountId}
</update>
</update>
<delete
id=
"deleteById"
>
delete from user_account where id = #{id}
</delete>
<select
id=
"getUserAccountInfoByUnionId"
resultType=
"com.mmc.iuav.user.entity.UserAccountDO"
>
<select
id=
"getUserAccountInfoByUnionId"
resultType=
"com.mmc.iuav.user.entity.UserAccountDO"
>
select id,
select id,
...
@@ -672,5 +680,32 @@
...
@@ -672,5 +680,32 @@
where phone_num = #{phone} and disable = 0
where phone_num = #{phone} and disable = 0
limit 1
limit 1
</select>
</select>
<select
id=
"isPhoneNums"
resultType=
"java.lang.Integer"
>
select count(*)
from user_account
where phone_num = #{phoneNum} and disable = 0 and password is not null
</select>
<select
id=
"getUserByPhoneNum"
resultType=
"com.mmc.iuav.user.entity.UserAccountDO"
>
select id,
phone_num,
user_name,
nick_name,
user_img,
open_id,
union_id,
user_sex,
email,
source,
account_status,
remark,
port_type,
disable,
create_time,
update_time,
password
from user_account
where phone_num = #{phoneNum} and disable = 0
limit 1
</select>
</mapper>
</mapper>
csm-service/cms-service-user/src/main/resources/not-check.yml
浏览文件 @
db7be215
...
@@ -45,4 +45,6 @@ data-filter:
...
@@ -45,4 +45,6 @@ data-filter:
-
/userapp/user-account/feignGetUserBaseInfo
-
/userapp/user-account/feignGetUserBaseInfo
-
/userapp/back-user/getMessage
-
/userapp/back-user/getMessage
-
/userapp/user-account/feignListAppUserAccount1
-
/userapp/user-account/feignListAppUserAccount1
-
/userapp/auth/getVerifyCode
-
/userapp/auth/webRegister
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论