Commit 5c07b99a 5c07b99a22867fa4b74b81644bdab89ab4da2960 by xianghan

1.完成通过旧密码修改app密码

2.完成通过验证码修改app密码
3.完成app账号信息的修改
1 parent 99a9491d
......@@ -31,6 +31,9 @@ public class MemberSimpleDTO implements Serializable {
/** 是否会员 0:非会员;1:会员 */
private Integer vip;
/** vip过期时间 */
private Timestamp vipExpireTime;
/** 会员等级(对应level表的level字段,非id) */
private Integer level;
......
package com.topdraw.business.module.user.app.domain;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import lombok.Data;
import lombok.experimental.Accessors;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import javax.persistence.*;
import java.io.Serializable;
/**
* @author XiangHan
* @date 2022-06-27
*/
@Entity
@Data
@EntityListeners(AuditingEntityListener.class)
@Accessors(chain = true)
@Table(name="uc_user_app")
public class UserAppSimple implements Serializable {
// ID
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id")
private Long id;
// 会员id
@Column(name = "member_id")
private Long memberId;
// 用户名(一般为手机号)
@Column(name = "username", nullable = false)
private String username;
// 状态 0:禁用;1:生效;-1:注销
@Column(name = "status", nullable = false)
private Integer status;
// 昵称
@Column(name = "nickname")
private String nickname;
// 头像地址
@Column(name = "headimgurl")
private String headimgurl;
// 邮箱
@Column(name = "email")
private String email;
// 手机号
@Column(name = "cellphone")
private String cellphone;
// 性别 0:女;1:男;-1:其他
@Column(name = "gender")
private Integer gender;
// 生日
@Column(name = "birthday")
private String birthday;
// 标签
@Column(name = "tags")
private String tags;
// 描述
@Column(name = "description")
private String description;
public void copy(UserAppSimple source){
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
}
}
......@@ -5,6 +5,7 @@ import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import java.util.Optional;
......@@ -21,4 +22,15 @@ public interface UserAppRepository extends JpaRepository<UserApp, Long>, JpaSpec
@Modifying
@Query(value = "UPDATE `uc_user_app` SET `update_time` = now(), `last_active_time` = now() WHERE `username` = ?1", nativeQuery = true)
Integer updateLastActiveTime(String username);
@Modifying
@Query(value = "UPDATE `uc_user_app` SET `update_time` = now(), `password` = ?2 WHERE `id` = ?1", nativeQuery = true)
Integer updatePasswordById(Long id, String password);
@Modifying
@Query(value = "UPDATE `uc_user_app` SET `update_time` = now(), `nickname` = :#{#resources.nickname}, " +
" `headimgurl` = :#{#resources.headimgurl}, `email` = :#{#resources.email}, `cellphone` = :#{#resources.cellphone}, " +
" `gender` = :#{#resources.gender}, `birthday` = :#{#resources.birthday}, `tags` = :#{#resources.tags}, `description` = :#{#resources.description}" +
" WHERE `id` = :#{#resources.id}", nativeQuery = true)
Integer updateAppInfo(@Param("resources") UserApp resources);
}
......
package com.topdraw.business.module.user.app.repository;
import com.topdraw.business.module.user.app.domain.UserAppSimple;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
/**
* @author XiangHan
* @date 2022-06-27
*/
public interface UserAppSimpleRepository extends JpaRepository<UserAppSimple, Long>, JpaSpecificationExecutor<UserAppSimple> {
}
......@@ -6,9 +6,11 @@ import com.topdraw.business.module.user.app.domain.UserAppBind;
import com.topdraw.business.module.user.app.service.UserAppBindService;
import com.topdraw.business.module.user.app.service.dto.UserAppBindDTO;
import com.topdraw.business.module.user.app.service.dto.UserAppDTO;
import com.topdraw.business.module.user.app.service.dto.UserAppSimpleDTO;
import com.topdraw.common.ResultInfo;
import com.topdraw.annotation.Log;
import com.topdraw.business.module.user.app.service.UserAppService;
import com.topdraw.util.RegexUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -34,6 +36,34 @@ public class UserAppController {
private UserAppBindService userAppBindService;
@Log
@PostMapping(value = "/updatePasswordById")
@ApiOperation("修改app账号密码")
@AnonymousAccess
public ResultInfo updatePasswordById(@Validated @RequestBody UserApp resources) {
log.info("修改app账号密码,参数 ==>> [updatePassword#{}]", resources);
String username = resources.getUsername();
if (StringUtils.isBlank(username)) {
log.error("修改app账号密码,参数错误,app账号不得为空,[updateLastActiveTime#{}]", resources);
return ResultInfo.failure("修改app账号密码失败,参数错误,app账号不得为空");
}
String password = resources.getPassword();
if (StringUtils.isBlank(password)) {
log.error("修改app账号密码失败,参数错误,密码不得为空,[updatePassword#{}]", resources);
return ResultInfo.failure("修改app账号最新登录时间失败,参数错误,app账号不得为空");
}
boolean passwordRegexResult = RegexUtil.appPasswordRegex(password);
if (!passwordRegexResult) {
log.error("修改app账号密码失败,参数错误,密码格式不正确,[updatePassword#{}]", resources);
return ResultInfo.failure("密码必须包含大小写字母和数字的组合,不能使用特殊字符,长度在 8-10 之间");
}
boolean result = this.userAppService.updatePasswordById(resources);
return ResultInfo.success(result);
}
@Log
@PostMapping(value = "/updateLastActiveTime")
@ApiOperation("修改app账号最新登录时间")
@AnonymousAccess
......@@ -72,7 +102,7 @@ public class UserAppController {
@Log
@PostMapping(value = "/updateValidStatusAndUserAppIdAndNickname")
@ApiOperation("修改第三方账号")
@ApiOperation("修改第三方账号绑定状态、绑定的app账号以及第三方账号昵称")
@AnonymousAccess
public ResultInfo updateValidStatusAndUserAppIdAndNickname(@Validated @RequestBody UserAppBind resources) {
log.info("修改第三方账号 ==>> param ==>> [updateThirdAccountStatusAndUserAppId#{}]", resources);
......@@ -89,7 +119,6 @@ public class UserAppController {
return ResultInfo.failure("检查第三方账号是否绑定了第三方账号失败, 参数错误, 第三方账号或者第三方账号类型不得为空");
}
UserAppDTO userAppDTO = this.userAppService.findByUsername(username);
if (Objects.nonNull(userAppDTO.getId())) {
Long id = userAppDTO.getId();
......@@ -104,7 +133,7 @@ public class UserAppController {
}
@Log
@PostMapping(value = "/updateThirdAccountStatusAndUserAppId")
@PostMapping(value = "/updateThirdAccountNickname")
@ApiOperation("修改第三方账号昵称")
@AnonymousAccess
public ResultInfo updateThirdAccountNickname(@Validated @RequestBody UserAppBind resources) {
......
......@@ -3,6 +3,7 @@ package com.topdraw.business.module.user.app.service;
import com.topdraw.business.module.user.app.domain.UserApp;
import com.topdraw.business.module.user.app.domain.UserAppBind;
import com.topdraw.business.module.user.app.service.dto.UserAppDTO;
import com.topdraw.business.module.user.app.service.dto.UserAppSimpleDTO;
/**
* @author XiangHan
......@@ -49,4 +50,18 @@ public interface UserAppService {
* @return
*/
boolean updateLastActiveTime(UserAppBind resources);
/**
*
* @param resources
* @return
*/
boolean updatePasswordById(UserApp resources);
/**
*
* @param resources
* @return
*/
UserAppSimpleDTO updateAppInfo(UserApp resources);
}
......
package com.topdraw.business.module.user.app.service.dto;
import com.topdraw.business.module.member.service.dto.MemberDTO;
import com.topdraw.business.module.member.service.dto.MemberSimpleDTO;
import lombok.Data;
import java.io.Serializable;
import java.sql.Timestamp;
/**
* @author XiangHan
* @date 2022-06-27
*/
@Data
public class UserAppSimpleDTO implements Serializable {
// ID
private Long id;
// 会员id
private Long memberId;
// 用户名(一般为手机号)
private String username;
// 状态 0:禁用;1:生效;-1:注销
private Integer status;
// 昵称
private String nickname;
// 头像地址
private String headimgurl;
// 邮箱
private String email;
// 手机号
private String cellphone;
// 性别 0:女;1:男;-1:其他
private Integer gender;
// 生日
private String birthday;
// 标签
private String tags;
// 描述
private String description;
private MemberSimpleDTO member;
}
package com.topdraw.business.module.user.app.service.impl;
import com.topdraw.business.module.member.service.MemberService;
import com.topdraw.business.module.member.service.dto.MemberDTO;
import com.topdraw.business.module.member.service.dto.MemberSimpleDTO;
import com.topdraw.business.module.user.app.domain.UserApp;
import com.topdraw.business.module.user.app.domain.UserAppBind;
import com.topdraw.business.module.user.app.domain.UserAppSimple;
import com.topdraw.business.module.user.app.repository.UserAppSimpleRepository;
import com.topdraw.business.module.user.app.service.dto.UserAppSimpleDTO;
import com.topdraw.utils.ValidationUtil;
import com.topdraw.business.module.user.app.repository.UserAppRepository;
import com.topdraw.business.module.user.app.service.UserAppService;
import com.topdraw.business.module.user.app.service.dto.UserAppDTO;
import com.topdraw.business.module.user.app.service.mapper.UserAppMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
......@@ -29,7 +36,11 @@ public class UserAppServiceImpl implements UserAppService {
@Autowired
private UserAppRepository userAppRepository;
@Autowired
private UserAppSimpleRepository userAppSimpleRepository;
@Autowired
private UserAppMapper userAppMapper;
@Autowired
private MemberService memberService;
@Override
......@@ -83,5 +94,33 @@ public class UserAppServiceImpl implements UserAppService {
return this.userAppRepository.updateLastActiveTime(resources.getUsername()) > 0;
}
@Override
@Transactional(rollbackFor = Exception.class)
public boolean updatePasswordById(UserApp resources) {
return this.userAppRepository.updatePasswordById(resources.getId(), resources.getPassword()) > 0;
}
@Override
@Transactional(rollbackFor = Exception.class)
public UserAppSimpleDTO updateAppInfo(UserApp resources) {
if (this.userAppRepository.updateAppInfo(resources) > 0) {
UserAppSimple userAppSimple = this.userAppSimpleRepository.findById(resources.getId()).orElseGet(UserAppSimple::new);
if (Objects.nonNull(userAppSimple.getId())) {
MemberDTO memberDTO = this.memberService.findById(userAppSimple.getMemberId());
UserAppSimpleDTO userAppSimpleDTO = new UserAppSimpleDTO();
BeanUtils.copyProperties(userAppSimple, userAppSimpleDTO);
MemberSimpleDTO memberSimpleDTO = new MemberSimpleDTO();
BeanUtils.copyProperties(memberDTO, memberSimpleDTO);
userAppSimpleDTO.setMember(memberSimpleDTO);
return userAppSimpleDTO;
}
}
return null;
}
}
......
package com.topdraw.business.module.user.app.service.mapper;
import com.topdraw.base.BaseMapper;
import com.topdraw.business.module.user.app.domain.UserApp;
import com.topdraw.business.module.user.app.domain.UserAppSimple;
import com.topdraw.business.module.user.app.service.dto.UserAppDTO;
import com.topdraw.business.module.user.app.service.dto.UserAppSimpleDTO;
import org.mapstruct.Mapper;
import org.mapstruct.ReportingPolicy;
/**
* @author XiangHan
* @date 2022-06-27
*/
@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
public interface UserAppSimpleMapper extends BaseMapper<UserAppSimpleDTO, UserAppSimple> {
}
......@@ -12,6 +12,7 @@ import com.topdraw.business.module.member.service.dto.MemberDTO;
import com.topdraw.business.module.user.app.domain.UserApp;
import com.topdraw.business.module.user.app.domain.UserAppBind;
import com.topdraw.business.module.user.app.service.dto.UserAppDTO;
import com.topdraw.business.module.user.app.service.dto.UserAppSimpleDTO;
import com.topdraw.business.module.user.iptv.domain.UserTv;
import com.topdraw.business.module.user.iptv.service.dto.UserTvDTO;
import com.topdraw.business.module.user.weixin.domain.UserWeixin;
......@@ -28,6 +29,7 @@ import com.topdraw.exception.GlobeExceptionMsg;
import com.topdraw.resttemplate.RestTemplateClient;
import com.topdraw.util.Base64Util;
import com.topdraw.util.JSONUtil;
import com.topdraw.util.RegexUtil;
import com.topdraw.utils.RedisUtils;
import com.topdraw.weixin.util.WeChatConstants;
import com.topdraw.weixin.util.WeixinUtil;
......@@ -46,7 +48,7 @@ import java.net.URLDecoder;
import java.sql.Timestamp;
import java.util.*;
@Api("账处理")
@Api("账处理")
@RestController
@RequestMapping(value = "/uce/userOperation")
@Slf4j
......@@ -72,6 +74,23 @@ public class UserOperationController {
/******************************************************* APP ************************************/
@Log
@PostMapping(value = "/updateAppInfo")
@ApiOperation("修改app账号信息")
@AnonymousAccess
public ResultInfo updateAppInfo(@Validated @RequestBody UserApp resources) {
log.info("修改app账号信息,参数 ==>> [updateAppInfo#{}]", resources);
Long id = resources.getId();
if (Objects.isNull(id)) {
log.error("修改app账号密码,参数错误,id不得为空,[updateAppInfo#{}]", resources);
return ResultInfo.failure("修改app账号密码失败,参数错误,id不得为空");
}
UserAppSimpleDTO result = this.userOperationService.updateAppInfo(resources);
return ResultInfo.success(result);
}
@Log
@PostMapping(value = "/appRegister")
@ApiOperation("app注册")
@AnonymousAccess
......@@ -139,17 +158,6 @@ public class UserOperationController {
}
@Log
@PostMapping(value = "/updateUserApp")
@ApiOperation("修改app账号信息")
@AnonymousAccess
public ResultInfo updateUserApp(@Validated @RequestBody UserApp resources) {
log.info("修改app账号信息 ==>> param ==>> [updateUserApp#{}]", resources);
UserAppDTO userAppDTO = this.userOperationService.updateUserApp(resources);
return ResultInfo.success(userAppDTO);
}
@Log
@PostMapping(value = "/cancelUserAppBind")
@ApiOperation("取消关联第三方账号")
@AnonymousAccess
......
......@@ -4,6 +4,7 @@ import com.topdraw.business.module.member.service.dto.MemberDTO;
import com.topdraw.business.module.user.app.domain.UserApp;
import com.topdraw.business.module.user.app.domain.UserAppBind;
import com.topdraw.business.module.user.app.service.dto.UserAppDTO;
import com.topdraw.business.module.user.app.service.dto.UserAppSimpleDTO;
import com.topdraw.business.module.user.iptv.domain.UserTv;
import com.topdraw.business.module.user.iptv.service.dto.UserTvDTO;
import com.topdraw.business.module.user.weixin.domain.UserWeixin;
......@@ -197,5 +198,12 @@ public interface UserOperationService {
* @param resources
* @return
*/
UserAppDTO updateUserApp(UserApp resources);
UserAppSimpleDTO updateAppInfo(UserApp resources);
/**
*
* @param resources
* @return
*/
boolean updatePasswordById(UserApp resources);
}
......
......@@ -17,6 +17,7 @@ import com.topdraw.business.module.user.app.service.UserAppBindService;
import com.topdraw.business.module.user.app.service.UserAppService;
import com.topdraw.business.module.user.app.service.dto.UserAppBindDTO;
import com.topdraw.business.module.user.app.service.dto.UserAppDTO;
import com.topdraw.business.module.user.app.service.dto.UserAppSimpleDTO;
import com.topdraw.business.module.user.iptv.domain.UserConstant;
import com.topdraw.business.module.user.iptv.domain.UserTv;
import com.topdraw.business.module.user.iptv.domain.UserTvBuilder;
......@@ -182,8 +183,13 @@ public class UserOperationServiceImpl implements UserOperationService {
}
@Override
public UserAppDTO updateUserApp(UserApp resources) {
return this.userAppService.update(resources);
public UserAppSimpleDTO updateAppInfo(UserApp resources) {
return this.userAppService.updateAppInfo(resources);
}
@Override
public boolean updatePasswordById(UserApp resources) {
return this.userAppService.updatePasswordById(resources);
}
/**
......
......@@ -23,4 +23,10 @@ public class RegexUtil {
return m.find();
}
public static boolean appPasswordRegex(String password) {
String pattern = "^(?=.*\\d)(?=.*[a-z])(?=.*[A-Z])[a-zA-Z0-9]{8,10}$";
Pattern r = Pattern.compile(pattern);
Matcher m = r.matcher(password);
return m.find();
}
}
......
......@@ -64,7 +64,7 @@
<!--监控sql日志输出 -->
<logger name="jdbc.sqlonly" level="OFF" additivity="false">
<logger name="jdbc.sqlonly" level="INFO" additivity="false">
<appender-ref ref="console" />
<appender-ref ref="info" />
</logger>
......