增加查询当前登陆管理员的基本信息的接口

This commit is contained in:
YunaiV 2020-07-09 23:22:06 +08:00
parent 3a23ca72e6
commit 40fe027753
14 changed files with 73 additions and 50 deletions

View File

@ -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);
}

View File

@ -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',

View File

@ -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',
});
}

View File

@ -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<AdminVO> info() {
return success(adminManager.getAdmin(AdminSecurityContextHolder.getAdminId()));
}
}

View File

@ -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 {

View File

@ -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;
}

View File

@ -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;
}

View File

@ -26,4 +26,6 @@ public interface AdminConvert {
PageResult<AdminPageItemVO> convert(PageResult<AdminVO> pageResultData);
cn.iocoder.mall.managementweb.controller.admin.vo.AdminVO convert(AdminVO bean);
}

View File

@ -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<AdminPageItemVO> pageAdmin(AdminPageDTO pageDTO) {
CommonResult<PageResult<AdminVO>> pageResult = adminRpc.pageAdmin(AdminConvert.INSTANCE.convert(pageDTO));
CommonResult<PageResult<cn.iocoder.mall.systemservice.rpc.admin.vo.AdminVO>> pageResult =
adminRpc.pageAdmin(AdminConvert.INSTANCE.convert(pageDTO));
pageResult.checkError();
// 转换结果
PageResult<AdminPageItemVO> adminPageVO = AdminConvert.INSTANCE.convert(pageResult.getData());
@ -59,4 +60,10 @@ public class AdminManager {
updateAdminResult.checkError();
}
public AdminVO getAdmin(Integer adminId) {
CommonResult<cn.iocoder.mall.systemservice.rpc.admin.vo.AdminVO> getAdminResult = adminRpc.getAdmin(adminId);
getAdminResult.checkError();
return AdminConvert.INSTANCE.convert(getAdminResult.getData());
}
}

View File

@ -32,6 +32,7 @@ public enum SystemErrorCodeEnum implements ServiceExceptionUtil.Enumerable<Syste
ADMIN_ADMIN_STATUS_CAN_NOT_UPDATE(1002002005, "管理员的账号状态不允许变更"),
// ADMIN_ASSIGN_ROLE_NOT_EXISTS(1002002006, "分配员工角色时,有角色不存在"),
ADMIN_ADMIN_CAN_NOT_UPDATE(1002002008, "管理员的账号不允许变更"),
ADMIN_USERNAME_NOT_EXISTS(1002002008, "账号不存在"),
// ========== 资源模块 1002003000 ==========
RESOURCE_NAME_DUPLICATE(1002003000, "已经存在该名字的资源"),

View File

@ -21,4 +21,6 @@ public interface AdminRpc {
CommonResult<PageResult<AdminVO>> pageAdmin(AdminPageDTO pageDTO);
CommonResult<AdminVO> getAdmin(Integer adminId);
}

View File

@ -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);
}
}

View File

@ -41,4 +41,9 @@ public class AdminRpcImpl implements AdminRpc {
return success(adminManager.pageAdmin(pageDTO));
}
@Override
public CommonResult<AdminVO> getAdmin(Integer adminId) {
return success(adminManager.getAdmin(adminId));
}
}

View File

@ -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<Integer, Collection<RoleBO>> getAdminRolesMap(Collection<Integer> adminIds) {