dev #1
|
@ -49,7 +49,7 @@ public class AdminController {
|
||||||
@ApiOperation(value = "新增管理用户")
|
@ApiOperation(value = "新增管理用户")
|
||||||
@PostMapping("save")
|
@PostMapping("save")
|
||||||
public Result<Admin> save(@RequestBody Admin admin) {
|
public Result<Admin> save(@RequestBody Admin admin) {
|
||||||
boolean isSuccess = adminService.save(admin);
|
boolean isSuccess = adminService.saveByAdmin(admin);
|
||||||
return isSuccess ? Result.success() : Result.error();
|
return isSuccess ? Result.success() : Result.error();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,21 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
|
||||||
public interface AdminService extends IService<Admin> {
|
public interface AdminService extends IService<Admin> {
|
||||||
|
/**
|
||||||
|
* * 条件分页查询
|
||||||
|
*
|
||||||
|
* @param page 当前页码
|
||||||
|
* @param limit 每页记录数
|
||||||
|
* @param userQueryVo 查询对象
|
||||||
|
* @return 分页结果
|
||||||
|
*/
|
||||||
|
|
||||||
IPage<Admin> selectPage(Long page, Long limit, AdminQueryVo userQueryVo);
|
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 com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.util.DigestUtils;
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class AdminServiceImpl extends ServiceImpl<AdminMapper, Admin> implements AdminService {
|
public class AdminServiceImpl extends ServiceImpl<AdminMapper, Admin> implements AdminService {
|
||||||
|
/**
|
||||||
|
* * 条件分页查询
|
||||||
|
*
|
||||||
|
* @param page 当前页码
|
||||||
|
* @param limit 每页记录数
|
||||||
|
* @param vo 查询对象
|
||||||
|
* @return 分页结果
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public IPage<Admin> selectPage(Long page, Long limit, AdminQueryVo vo) {
|
public IPage<Admin> selectPage(Long page, Long limit, AdminQueryVo vo) {
|
||||||
Page<Admin> pageParam = new Page<Admin>(page, limit);
|
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);
|
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