//package shop.alien.gateway.controller;
//
//import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
//import io.swagger.annotations.Api;
//import io.swagger.annotations.ApiOperation;
//import io.swagger.annotations.ApiOperationSupport;
//import io.swagger.annotations.ApiSort;
//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 java.util.Objects;
//import java.util.Optional;
//
///**
// * 门店用户 前端控制器
// *
// * @author ssk
// * @since 2024-12-11
// */
//@Slf4j
//@Api(tags = {"律师用户"})
//@ApiSort(8)
//@CrossOrigin
//@RestController
//@RequestMapping("/lawyer/user")
//@RequiredArgsConstructor
//public class LawyerUserLogInController {
//
//    private final LawyerUserLogInService lawyerUserService;
//    private final LawyerUserMapper lawyerUserMapper;
//
//    @ApiOperation("律师用户注册")
//    @ApiOperationSupport(order = 1)
//    @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 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("密码错误");
//    }
//}
