diff --git a/admin-web/src/models/admin/roleList.js b/admin-web/src/models/admin/roleList.js index e85ae91b3..7efc7cad3 100644 --- a/admin-web/src/models/admin/roleList.js +++ b/admin-web/src/models/admin/roleList.js @@ -7,7 +7,7 @@ import { } from '../../services/system'; import { rolePage, - roleAdd, + roleCreate, roleUpdate, roleDelete, } from '../../services/system'; @@ -30,7 +30,7 @@ export default { effects: { *add({ payload }, { call, put }) { const { callback, body, queryParams } = payload; - const response = yield call(roleAdd, body); + const response = yield call(roleCreate, body); if (callback) { callback(response); } diff --git a/admin-web/src/services/admin.js b/admin-web/src/services/admin.js index 31901f12a..7bac2a5c0 100644 --- a/admin-web/src/services/admin.js +++ b/admin-web/src/services/admin.js @@ -3,12 +3,6 @@ import request from '@/utils/request'; // admin -export async function queryAdmin(params) { - return request(`/admin-api/admins/admin/page?${stringify(params)}`, { - method: 'GET', - }); -} - export async function addAdmin(params) { return request(`/admin-api/admins/admin/add?${stringify(params)}`, { method: 'POST', diff --git a/admin-web/src/services/system.js b/admin-web/src/services/system.js index a34751fce..b0b5ae026 100644 --- a/admin-web/src/services/system.js +++ b/admin-web/src/services/system.js @@ -66,25 +66,25 @@ export async function resourceTreeAdminMenu() { // ========== Role 模块 ========== export async function rolePage(params) { - return request(`/system-api/admins/role/page?${stringify(params)}`); + return request(`/management-api/role/page?${stringify(params)}`); } export async function roleDelete(params) { - return request(`/system-api/admins/role/delete?${stringify(params)}`, { + return request(`/management-api/role/delete?${stringify(params)}`, { method: 'POST', body: {}, }); } -export async function roleAdd(params) { - return request(`/system-api/admins/role/add?${stringify(params)}`, { +export async function roleCreate(params) { + return request(`/management-api/role/create?${stringify(params)}`, { method: 'POST', body: {}, }); } export async function roleUpdate(params) { - return request(`/system-api/admins/role/update?${stringify(params)}`, { + return request(`/management-api/role/update?${stringify(params)}`, { method: 'POST', body: {}, }); @@ -93,7 +93,7 @@ export async function roleUpdate(params) { // ========== Admin 模块 ========== export async function adminPage(params) { - return request(`/system-api/admins/admin/page?${stringify(params)}`, { + return request(`/management-api/admin/page?${stringify(params)}`, { method: 'GET', }); } diff --git a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/admin/AdminController.java b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/admin/AdminController.java index 5df1d158c..e65d7d461 100644 --- a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/admin/AdminController.java +++ b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/admin/AdminController.java @@ -8,6 +8,7 @@ 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.controller.admin.vo.AdminVO; import cn.iocoder.mall.managementweb.manager.admin.AdminManager; import cn.iocoder.mall.security.admin.core.context.AdminSecurityContextHolder; import cn.iocoder.security.annotations.RequiresPermissions; @@ -63,4 +64,12 @@ public class AdminController { return success(true); } + // =========== 当前管理员 API =========== + + @GetMapping("/info") + @ApiOperation(value = "更新管理员状态") + public CommonResult info() { + return success(adminManager.getAdmin(AdminSecurityContextHolder.getAdminId())); + } + } diff --git a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/admin/vo/AdminPageItemVO.java b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/admin/vo/AdminPageItemVO.java index d8de770b4..5c128d3c6 100644 --- a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/admin/vo/AdminPageItemVO.java +++ b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/admin/vo/AdminPageItemVO.java @@ -8,7 +8,7 @@ import lombok.experimental.Accessors; import java.util.Date; import java.util.List; -@ApiModel(value = "分页时,管理员的信息 VO") +@ApiModel(value = "分页时,管理员的信息 VO") @Data @Accessors(chain = true) public class AdminPageItemVO { diff --git a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/admin/vo/AdminVO.java b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/admin/vo/AdminVO.java new file mode 100644 index 000000000..960359e62 --- /dev/null +++ b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/admin/vo/AdminVO.java @@ -0,0 +1,26 @@ +package cn.iocoder.mall.managementweb.controller.admin.vo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +import java.util.Date; + +@ApiModel(value = "管理员 VO") +@Data +@Accessors(chain = true) +public class AdminVO { + + @ApiModelProperty(value = "管理员编号", required = true, example = "1") + private Integer id; + @ApiModelProperty(value = "真实名字", required = true, example = "小王") + private String name; + @ApiModelProperty(value = "创建时间", required = true, example = "时间戳格式") + private Date createTime; + @ApiModelProperty(value = "在职状态", required = true, example = "1", notes = "见 AdminStatusEnum 枚举") + private Integer status; + @ApiModelProperty(value = "登陆账号", required = true, example = "15601691300") + private String username; + +} diff --git a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/admin/vo/AdminsUserPageResponse.java b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/admin/vo/AdminsUserPageResponse.java deleted file mode 100644 index 9aba8643b..000000000 --- a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/admin/vo/AdminsUserPageResponse.java +++ /dev/null @@ -1,32 +0,0 @@ -package cn.iocoder.mall.managementweb.controller.admin.vo; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; -import lombok.experimental.Accessors; - -/** - * @Author: jiangweifan - * @Date: 2020/5/12 - * @Description: 管理员 - 用户信息 - 用户分页列表Response - */ -@ApiModel("用户分页信息 Response") -@Data -@Accessors(chain = true) -public class AdminsUserPageResponse { - - @ApiModelProperty(value = "用户编号", required = true, example = "1") - private Integer id; - - @ApiModelProperty(value = "昵称", required = false, example = "1") - private String nickname; - - @ApiModelProperty(value = "手机号", required = true, example = "13631780241") - private String mobile; - - @ApiModelProperty(value = "头像", required = false, example = "http://www.iocoder.cn/xxx.jpg") - private String avatar; - - @ApiModelProperty(value = "用户状态 1 - 开启;2 - 禁用", required = true, example = "1") - private Integer status; -} diff --git a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/convert/admin/AdminConvert.java b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/convert/admin/AdminConvert.java index daf5c6a5c..d37c849a2 100644 --- a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/convert/admin/AdminConvert.java +++ b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/convert/admin/AdminConvert.java @@ -26,4 +26,6 @@ public interface AdminConvert { PageResult convert(PageResult pageResultData); + cn.iocoder.mall.managementweb.controller.admin.vo.AdminVO convert(AdminVO bean); + } diff --git a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/manager/admin/AdminManager.java b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/manager/admin/AdminManager.java index a599620ba..f5bccdaee 100644 --- a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/manager/admin/AdminManager.java +++ b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/manager/admin/AdminManager.java @@ -7,9 +7,9 @@ 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.controller.admin.vo.AdminVO; import cn.iocoder.mall.managementweb.convert.admin.AdminConvert; import cn.iocoder.mall.systemservice.rpc.admin.AdminRpc; -import cn.iocoder.mall.systemservice.rpc.admin.vo.AdminVO; import org.apache.dubbo.config.annotation.Reference; import org.springframework.stereotype.Service; @@ -20,7 +20,8 @@ public class AdminManager { private AdminRpc adminRpc; public PageResult pageAdmin(AdminPageDTO pageDTO) { - CommonResult> pageResult = adminRpc.pageAdmin(AdminConvert.INSTANCE.convert(pageDTO)); + CommonResult> pageResult = + adminRpc.pageAdmin(AdminConvert.INSTANCE.convert(pageDTO)); pageResult.checkError(); // 转换结果 PageResult adminPageVO = AdminConvert.INSTANCE.convert(pageResult.getData()); @@ -59,4 +60,10 @@ public class AdminManager { updateAdminResult.checkError(); } + public AdminVO getAdmin(Integer adminId) { + CommonResult getAdminResult = adminRpc.getAdmin(adminId); + getAdminResult.checkError(); + return AdminConvert.INSTANCE.convert(getAdminResult.getData()); + } + } diff --git a/system-service-project/system-service-api/src/main/java/cn/iocoder/mall/systemservice/enums/SystemErrorCodeEnum.java b/system-service-project/system-service-api/src/main/java/cn/iocoder/mall/systemservice/enums/SystemErrorCodeEnum.java index bcf233cd9..9a6578055 100644 --- a/system-service-project/system-service-api/src/main/java/cn/iocoder/mall/systemservice/enums/SystemErrorCodeEnum.java +++ b/system-service-project/system-service-api/src/main/java/cn/iocoder/mall/systemservice/enums/SystemErrorCodeEnum.java @@ -32,6 +32,7 @@ public enum SystemErrorCodeEnum implements ServiceExceptionUtil.Enumerable> pageAdmin(AdminPageDTO pageDTO); + CommonResult getAdmin(Integer adminId); + } diff --git a/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/manager/admin/AdminManager.java b/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/manager/admin/AdminManager.java index 484c20290..a5d63d888 100644 --- a/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/manager/admin/AdminManager.java +++ b/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/manager/admin/AdminManager.java @@ -52,4 +52,8 @@ public class AdminManager { return AdminConvert.INSTANCE.convert(adminPage); } + public AdminVO getAdmin(Integer adminId) { + AdminBO adminBO = adminService.getAdmin(adminId); + return AdminConvert.INSTANCE.convert(adminBO); + } } diff --git a/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/rpc/admin/AdminRpcImpl.java b/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/rpc/admin/AdminRpcImpl.java index 24f7be311..4e25829b8 100644 --- a/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/rpc/admin/AdminRpcImpl.java +++ b/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/rpc/admin/AdminRpcImpl.java @@ -41,4 +41,9 @@ public class AdminRpcImpl implements AdminRpc { return success(adminManager.pageAdmin(pageDTO)); } + @Override + public CommonResult getAdmin(Integer adminId) { + return success(adminManager.getAdmin(adminId)); + } + } diff --git a/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/service/admin/AdminService.java b/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/service/admin/AdminService.java index 26529b8d1..9899618b1 100644 --- a/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/service/admin/AdminService.java +++ b/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/service/admin/AdminService.java @@ -36,7 +36,7 @@ public class AdminService { public AdminBO verifyPassword(String username, String password, String ip) { AdminDO adminDO = adminMapper.selectByUsername(username); if (adminDO == null) { - throw ServiceExceptionUtil.exception(ADMIN_NOT_FOUND); + throw ServiceExceptionUtil.exception(ADMIN_USERNAME_NOT_EXISTS); } // 校验密码是否正确 String encodedPassword = DigestUtils.bcrypt(password, adminDO.getPasswordSalt()); @@ -114,6 +114,11 @@ public class AdminService { adminMapper.updateById(updateAdmin); } + public AdminBO getAdmin(Integer adminId) { + AdminDO adminDO = adminMapper.selectById(adminId); + return AdminConvert.INSTANCE.convert(adminDO); + } + // // @Override // public Map> getAdminRolesMap(Collection adminIds) {