feat(新增): 新增用户加密密码
This commit is contained in:
parent
7d7cbced23
commit
1b22f6dca0
|
@ -49,7 +49,7 @@ public class AdminController {
|
|||
@ApiOperation(value = "新增管理用户")
|
||||
@PostMapping("save")
|
||||
public Result<Admin> save(@RequestBody Admin admin) {
|
||||
boolean isSuccess = adminService.save(admin);
|
||||
boolean isSuccess = adminService.saveByAdmin(admin);
|
||||
return isSuccess ? Result.success() : Result.error();
|
||||
}
|
||||
|
||||
|
|
|
@ -6,6 +6,21 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
|||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
public interface AdminService extends IService<Admin> {
|
||||
/**
|
||||
* * 条件分页查询
|
||||
*
|
||||
* @param page 当前页码
|
||||
* @param limit 每页记录数
|
||||
* @param userQueryVo 查询对象
|
||||
* @return 分页结果
|
||||
*/
|
||||
|
||||
IPage<Admin> selectPage(Long page, Long limit, AdminQueryVo userQueryVo);
|
||||
|
||||
/**
|
||||
* 新增管理用户
|
||||
*
|
||||
* @param admin 用户管理员
|
||||
*/
|
||||
Boolean saveByAdmin(Admin admin);
|
||||
}
|
|
@ -10,11 +10,20 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.DigestUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
public class AdminServiceImpl extends ServiceImpl<AdminMapper, Admin> implements AdminService {
|
||||
/**
|
||||
* * 条件分页查询
|
||||
*
|
||||
* @param page 当前页码
|
||||
* @param limit 每页记录数
|
||||
* @param vo 查询对象
|
||||
* @return 分页结果
|
||||
*/
|
||||
@Override
|
||||
public IPage<Admin> selectPage(Long page, Long limit, AdminQueryVo vo) {
|
||||
Page<Admin> pageParam = new Page<Admin>(page, limit);
|
||||
|
@ -28,4 +37,19 @@ public class AdminServiceImpl extends ServiceImpl<AdminMapper, Admin> implements
|
|||
|
||||
return baseMapper.selectPage(pageParam, wrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增管理用户
|
||||
*
|
||||
* @param admin 用户管理员
|
||||
*/
|
||||
@Override
|
||||
public Boolean saveByAdmin(Admin admin) {
|
||||
// 获取密码并加密
|
||||
String password = admin.getPassword();
|
||||
String encryptPassword = DigestUtils.md5DigestAsHex(password.getBytes());
|
||||
// 设置密码
|
||||
admin.setPassword(encryptPassword);
|
||||
return save(admin);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue