|
|
@@ -1,17 +1,20 @@
|
|
|
package shop.alien.gateway.controller;
|
|
|
|
|
|
-import io.swagger.annotations.Api;
|
|
|
-import io.swagger.annotations.ApiOperation;
|
|
|
-import io.swagger.annotations.ApiOperationSupport;
|
|
|
-import io.swagger.annotations.ApiSort;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import io.swagger.annotations.*;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
import shop.alien.entity.result.R;
|
|
|
+import shop.alien.entity.store.LawyerUser;
|
|
|
import shop.alien.entity.store.dto.LawyerUserDto;
|
|
|
import shop.alien.entity.store.vo.LawyerUserVo;
|
|
|
+import shop.alien.gateway.mapper.LawyerUserMapper;
|
|
|
import shop.alien.gateway.service.LawyerUserService;
|
|
|
|
|
|
+import java.util.Objects;
|
|
|
+import java.util.Optional;
|
|
|
+
|
|
|
/**
|
|
|
* 门店用户 前端控制器
|
|
|
*
|
|
|
@@ -28,20 +31,69 @@ import shop.alien.gateway.service.LawyerUserService;
|
|
|
public class LawyerUserLogInController {
|
|
|
|
|
|
private final LawyerUserService lawyerUserService;
|
|
|
+ private final LawyerUserMapper lawyerUserMapper;
|
|
|
|
|
|
- @ApiOperation("律师用户登录")
|
|
|
+ @ApiOperation("律师用户注册")
|
|
|
@ApiOperationSupport(order = 1)
|
|
|
- @PostMapping("/login")
|
|
|
- public R<LawyerUserVo> login(@RequestBody LawyerUserDto lawyerUserDto) {
|
|
|
- log.info("StoreUserController.login?lawyerUserDto={}", lawyerUserDto);
|
|
|
+ @PostMapping("/register")
|
|
|
+ public R<LawyerUserVo> register(@RequestBody LawyerUserDto lawyerUserDto) {
|
|
|
+ log.info("LawyerUserLogInController.login?lawyerUserDto={}", lawyerUserDto);
|
|
|
return lawyerUserService.logIn(lawyerUserDto);
|
|
|
}
|
|
|
|
|
|
@ApiOperation("律师用户验证码校验")
|
|
|
@ApiOperationSupport(order = 2)
|
|
|
@PostMapping("/checkMsgCode")
|
|
|
- public R<LawyerUserVo> checkMsgCode(@RequestBody LawyerUserDto lawyerUserDto) {
|
|
|
- log.info("StoreUserController.login?lawyerUserDto={}", lawyerUserDto);
|
|
|
- return lawyerUserService.logIn(lawyerUserDto);
|
|
|
+ public R checkMsgCode(@RequestBody LawyerUserDto lawyerUserDto) {
|
|
|
+ log.info("LawyerUserLogInController.checkMsgCode?lawyerUserDto={}", lawyerUserDto);
|
|
|
+ return lawyerUserService.checkMsgCode(lawyerUserDto);
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation("律师用户登录")
|
|
|
+ @ApiOperationSupport(order = 3)
|
|
|
+ @GetMapping("/login")
|
|
|
+ public R<LawyerUserVo> login(@RequestBody LawyerUserDto lawyerUserDto) {
|
|
|
+ log.info("LawyerUserLogInController.login?lawyerUserDto={}", lawyerUserDto);
|
|
|
+ LawyerUser lawyerUser = lawyerUserMapper.selectOne(new LambdaQueryWrapper<LawyerUser>()
|
|
|
+ .eq(LawyerUser::getPhone, lawyerUserDto.getPhone()));
|
|
|
+ if (null == lawyerUser) {
|
|
|
+ return R.fail("当前账号不存在,请先去注册账号!");
|
|
|
+ }
|
|
|
+ if (lawyerUser.getStatus() == 0) {
|
|
|
+ return R.fail("账号被禁用");
|
|
|
+ }
|
|
|
+ return Optional.ofNullable(lawyerUser).
|
|
|
+ map(user -> lawyerUserDto.getIsPassword() ? checkPassword(user, lawyerUserDto.getPassWord()) : lawyerUserService.createToKen(user)).
|
|
|
+ orElseGet(() -> R.fail("手机号不存在"));
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation("律师用户修改密码")
|
|
|
+ @ApiOperationSupport(order = 4)
|
|
|
+ @PostMapping("/updatePassWord")
|
|
|
+ public R updatePassWord(@RequestBody LawyerUserDto lawyerUserDto) {
|
|
|
+ log.info("LawyerUserLogInController.updatePassWord?lawyerUserDto={}", lawyerUserDto);
|
|
|
+ try {
|
|
|
+ LawyerUser lawyerUser = lawyerUserMapper.selectOne(new LambdaQueryWrapper<LawyerUser>()
|
|
|
+ .eq(LawyerUser::getPhone, lawyerUserDto.getPhone()));
|
|
|
+ if (null == lawyerUser) {
|
|
|
+ return R.fail("当前账号不存在,请先去注册账号!");
|
|
|
+ }
|
|
|
+ if (lawyerUser.getStatus() == 0) {
|
|
|
+ return R.fail("账号被禁用");
|
|
|
+ }
|
|
|
+ LawyerUser update = new LawyerUser();
|
|
|
+ update.setPassword(lawyerUserDto.getPassWord());
|
|
|
+ update.setId(lawyerUser.getId());
|
|
|
+ lawyerUserMapper.updateById(update);
|
|
|
+ return R.success("修改成功");
|
|
|
+ }catch (Exception e){
|
|
|
+ return R.fail("修改密码失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private R<LawyerUserVo> checkPassword(LawyerUser lawyerUser, String password) {
|
|
|
+ return Objects.equals(password, lawyerUser.getPassword())
|
|
|
+ ? lawyerUserService.createToKen(lawyerUser)
|
|
|
+ : R.fail("密码错误");
|
|
|
}
|
|
|
}
|