完成管理后台的 admin 相关接口
This commit is contained in:
@@ -2,14 +2,19 @@ package cn.iocoder.mall.managementweb.controller.admin;
|
||||
|
||||
import cn.iocoder.common.framework.util.HttpUtil;
|
||||
import cn.iocoder.common.framework.vo.CommonResult;
|
||||
import cn.iocoder.common.framework.vo.PageResult;
|
||||
import cn.iocoder.mall.managementweb.controller.admin.dto.AdminCreateDTO;
|
||||
import cn.iocoder.mall.managementweb.controller.admin.dto.AdminPageDTO;
|
||||
import cn.iocoder.mall.managementweb.controller.admin.dto.AdminUpdateInfoDTO;
|
||||
import cn.iocoder.mall.managementweb.controller.admin.dto.AdminUpdateStatusDTO;
|
||||
import cn.iocoder.mall.managementweb.controller.admin.vo.AdminPageItemVO;
|
||||
import cn.iocoder.mall.managementweb.manager.admin.AdminManager;
|
||||
import cn.iocoder.mall.security.admin.core.context.AdminSecurityContextHolder;
|
||||
import cn.iocoder.security.annotations.RequiresPermissions;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
@@ -27,45 +32,32 @@ public class AdminController {
|
||||
private AdminManager adminManager;
|
||||
|
||||
// =========== 管理员管理 API ===========
|
||||
// @GetMapping("/page")
|
||||
// @RequiresPermissions("system.admin.page")
|
||||
// @ApiOperation(value = "管理员分页")
|
||||
// public CommonResult<PageResult<AdminVO>> page(AdminPageDTO adminPageDTO) {
|
||||
// PageResult<AdminBO> page = adminService.getAdminPage(adminPageDTO);
|
||||
// PageResult<AdminVO> resultPage = AdminConvert.INSTANCE.convertAdminVOPage(page);
|
||||
// // 拼接结果
|
||||
// if (!resultPage.getList().isEmpty()) {
|
||||
// // 查询角色数组
|
||||
// Map<Integer, Collection<RoleBO>> roleMap = adminService.getAdminRolesMap(CollectionUtil.convertList(resultPage.getList(), AdminBO::getId));
|
||||
// resultPage.getList().forEach(admin -> admin.setRoles(AdminConvert.INSTANCE.convertAdminVORoleList(roleMap.get(admin.getId()))));
|
||||
//
|
||||
// // 查询对应部门
|
||||
// List<DeptmentBO> deptmentBOS = deptmentService.getAllDeptments();
|
||||
// Map<Integer, String> deptNameMap = deptmentBOS.stream().collect(Collectors.toMap(d->d.getId(), d->d.getName()));
|
||||
// //管理员所在部门被删后,变成未分配状态
|
||||
// deptNameMap.put(0, "未分配");
|
||||
// resultPage.getList().forEach(admin->{
|
||||
// admin.setDeptment(new AdminVO.Deptment(admin.getDeptmentId(), deptNameMap.get(admin.getDeptmentId())));
|
||||
// });
|
||||
// }
|
||||
// return success(resultPage);
|
||||
// }
|
||||
|
||||
@ApiOperation(value = "管理员分页")
|
||||
@GetMapping("/page")
|
||||
@RequiresPermissions("system.admin.page")
|
||||
public CommonResult<PageResult<AdminPageItemVO>> page(AdminPageDTO adminPageDTO) {
|
||||
return success(adminManager.pageAdmin(adminPageDTO));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "创建管理员")
|
||||
@PostMapping("/create")
|
||||
@RequiresPermissions("admin:create")
|
||||
public CommonResult<Integer> createAdmin(AdminCreateDTO createDTO, HttpServletRequest request) {
|
||||
return success(adminManager.createAdmin(createDTO, AdminSecurityContextHolder.getAdminId(), HttpUtil.getIp(request)));
|
||||
}
|
||||
|
||||
@PostMapping("/update")
|
||||
@ApiOperation(value = "更新管理员")
|
||||
@RequiresPermissions("admin:update")
|
||||
public CommonResult<Boolean> updateAdmin(AdminUpdateInfoDTO updateInfoDTO) {
|
||||
adminManager.updateAdmin(updateInfoDTO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@PostMapping("/update_status")
|
||||
@PostMapping("/update-status")
|
||||
@ApiOperation(value = "更新管理员状态")
|
||||
@RequiresPermissions("admin:update-status")
|
||||
public CommonResult<Boolean> updateUserStatus(AdminUpdateStatusDTO updateStatusDTO) {
|
||||
adminManager.updateAdminStatus(updateStatusDTO);
|
||||
return success(true);
|
||||
|
||||
@@ -15,10 +15,10 @@ import javax.validation.constraints.Pattern;
|
||||
@Accessors(chain = true)
|
||||
public class AdminCreateDTO {
|
||||
|
||||
@ApiModelProperty(value = "昵称", required = true, example = "小王")
|
||||
@NotEmpty(message = "昵称不能为空")
|
||||
@Length(max = 10, message = "昵称长度最大为 10 位")
|
||||
private String nickname;
|
||||
@ApiModelProperty(value = "真实名字", required = true, example = "小王")
|
||||
@NotEmpty(message = "真实名字不能为空")
|
||||
@Length(max = 10, message = "真实名字长度最大为 10 位")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty(value = "部门编号", required = true, example = "1")
|
||||
@NotNull(message = "部门不能为空")
|
||||
|
||||
@@ -30,10 +30,10 @@ public class AdminUpdateInfoDTO {
|
||||
@Length(min = 4, max = 16, message = "密码长度为 4-16 位")
|
||||
private String password;
|
||||
|
||||
@ApiModelProperty(value = "昵称", required = true, example = "小王")
|
||||
@NotEmpty(message = "昵称不能为空")
|
||||
@Length(max = 10, message = "昵称长度最大为 10 位")
|
||||
private String nickname;
|
||||
@ApiModelProperty(value = "真实名字", required = true, example = "小王")
|
||||
@NotEmpty(message = "真实名字不能为空")
|
||||
@Length(max = 10, message = "真实名字长度最大为 10 位")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty(value = "部门编号", required = true, example = "1")
|
||||
@NotNull(message = "部门不能为空")
|
||||
|
||||
@@ -8,10 +8,10 @@ import lombok.experimental.Accessors;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@ApiModel("管理员 - 管理员模块 - 管理员分页信息 Response")
|
||||
@ApiModel(value = "分页时,管理员的信息 VO")
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class AdminsAdminPageResponse {
|
||||
public class AdminPageItemVO {
|
||||
|
||||
@ApiModel("角色")
|
||||
@Data
|
||||
@@ -39,19 +39,6 @@ public class AdminsAdminPageResponse {
|
||||
|
||||
}
|
||||
|
||||
@ApiModel("账号")
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public static class Account {
|
||||
|
||||
@ApiModelProperty(value = "账号编号", required = true, example = "1")
|
||||
private Integer id;
|
||||
|
||||
@ApiModelProperty(value = "登陆账号", required = true, example = "15601691300")
|
||||
private String username;
|
||||
|
||||
}
|
||||
|
||||
@ApiModelProperty(value = "管理员编号", required = true, example = "1")
|
||||
private Integer id;
|
||||
@ApiModelProperty(value = "真实名字", required = true, example = "小王")
|
||||
@@ -60,17 +47,13 @@ public class AdminsAdminPageResponse {
|
||||
private Date createTime;
|
||||
@ApiModelProperty(value = "在职状态", required = true, example = "1", notes = "见 AdminStatusEnum 枚举")
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 账号
|
||||
*/
|
||||
private Account account;
|
||||
@ApiModelProperty(value = "登陆账号", required = true, example = "15601691300")
|
||||
private String username;
|
||||
|
||||
/**
|
||||
* 角色列表
|
||||
*/
|
||||
private List<Role> roles;
|
||||
|
||||
/**
|
||||
* 所在部门
|
||||
*/
|
||||
Reference in New Issue
Block a user