重置用户密码功能的实现

场景:公司有一个商家系统,现在要做这个商家系统的后台管理系统。

我负责的项目需求:在用户忘记自己密码的时候,后台管理员手动帮用户修改密码,修改后的密码是随机生成的。

Controller层:

@Controller
@RequestMapping("/user")
public class UserController{
    @Autowired
    private IUserService iUserService;

    @RequestMapping("/resetPassword")
    public String resetPassword(long userId){
        if(userId > 0){
            return iUserService.resetPassword(userId);
        }else{
            throw new ApiException(400,"用户id小于等于0","用户不存在");
        }
    }
}

ApiException是公司自己封装的异常处理类。第一个参数是状态码,第二个参数是给开发人员看的错误信息,第三个参数是给用户看的信息。

Service层:

public interface IUserService{
    String resetPassword(long userId);
}
@Service
public class IUserServiceImpl implements IUserService{
    @Autowired
    private UserMapper userMapper;

    //根据salt值对s
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值