parent
e4d3254869
commit
6bddebafff
@ -0,0 +1,31 @@
|
||||
package cn.iocoder.mall.managementweb.controller.permission.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ApiModel(value = "管理员拥有的菜单树", description = "一般用于首页菜单")
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class AdminMenuTreeNodeVO {
|
||||
|
||||
@ApiModelProperty(value = "菜单编号", required = true, example = "1")
|
||||
private Integer id;
|
||||
@ApiModelProperty(value = "菜单名", required = true, example = "商品管理")
|
||||
private String name;
|
||||
@ApiModelProperty(value = "前端路由", required = true, example = "/order/list")
|
||||
private String route;
|
||||
@ApiModelProperty(value = "菜单图标", required = true, example = "user")
|
||||
private String icon;
|
||||
@ApiModelProperty(value = "父级资源编号", required = true, example = "1", notes = "如果无父资源,则值为 0")
|
||||
private Integer pid;
|
||||
|
||||
/**
|
||||
* 子节点数组
|
||||
*/
|
||||
private List<AdminMenuTreeNodeVO> children;
|
||||
|
||||
}
|
||||
@ -1,22 +0,0 @@
|
||||
package cn.iocoder.mall.system.biz.dto.authorization;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* 授权模块 - 获得账号所拥有的资源树 DTO
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class AuthorizationGetResourceTreeByAccountIdDTO {
|
||||
|
||||
@NotNull(message = "账号编号不能为空")
|
||||
private Integer accountId;
|
||||
/**
|
||||
* 资源类型
|
||||
*/
|
||||
private Integer type;
|
||||
|
||||
}
|
||||
@ -1,39 +0,0 @@
|
||||
package cn.iocoder.mall.system.biz.service.authorization;
|
||||
|
||||
import cn.iocoder.common.framework.vo.PageResult;
|
||||
import cn.iocoder.mall.system.biz.bo.authorization.RoleBO;
|
||||
import cn.iocoder.mall.system.biz.dto.authorization.RoleAddDTO;
|
||||
import cn.iocoder.mall.system.biz.dto.authorization.RoleDeleteDTO;
|
||||
import cn.iocoder.mall.system.biz.dto.authorization.RolePageDTO;
|
||||
import cn.iocoder.mall.system.biz.dto.authorization.RoleUpdateDTO;
|
||||
import cn.iocoder.mall.system.biz.dto.authorization.RoleGetListDTO;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 角色模块 - Service 接口
|
||||
*/
|
||||
public interface RoleService {
|
||||
|
||||
RoleBO getRole(Integer id);
|
||||
|
||||
List<RoleBO> getRoleList(RoleGetListDTO getListDTO);
|
||||
|
||||
PageResult<RoleBO> getRolePage(RolePageDTO pageDTO);
|
||||
|
||||
/**
|
||||
* 判断指定角色是否包含超级管理员角色
|
||||
*
|
||||
* @param ids 角色编号数组
|
||||
* @return 是否有超级管理员角色
|
||||
*/
|
||||
boolean hasSuperAdmin(Collection<Integer> ids);
|
||||
|
||||
Integer addRole(RoleAddDTO roleAddDTO);
|
||||
|
||||
void updateRole(RoleUpdateDTO roleUpdateDTO);
|
||||
|
||||
void deleteRole(RoleDeleteDTO roleDeleteDTO);
|
||||
|
||||
}
|
||||
@ -1,50 +0,0 @@
|
||||
package cn.iocoder.mall.system.biz.service.authorization;
|
||||
|
||||
import cn.iocoder.common.framework.util.ServiceExceptionUtil;
|
||||
import cn.iocoder.common.framework.util.StringUtils;
|
||||
import cn.iocoder.common.framework.vo.PageResult;
|
||||
import cn.iocoder.mall.mybatis.enums.DeletedStatusEnum;
|
||||
import cn.iocoder.mall.system.biz.bo.authorization.RoleBO;
|
||||
import cn.iocoder.mall.system.biz.convert.authorization.RoleConvert;
|
||||
import cn.iocoder.mall.system.biz.dao.authorization.RoleMapper;
|
||||
import cn.iocoder.mall.system.biz.dataobject.authorization.RoleDO;
|
||||
import cn.iocoder.mall.system.biz.dto.authorization.*;
|
||||
import cn.iocoder.mall.system.biz.enums.SystemErrorCodeEnum;
|
||||
import cn.iocoder.mall.system.biz.enums.authorization.RoleCodeEnum;
|
||||
import cn.iocoder.mall.system.biz.enums.authorization.RoleTypeEnum;
|
||||
import cn.iocoder.mall.system.biz.event.authorization.ResourceDeleteEvent;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationEventPublisher;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class RoleServiceImpl implements RoleService {
|
||||
|
||||
@Autowired
|
||||
private ApplicationEventPublisher eventPublisher;
|
||||
|
||||
@Autowired
|
||||
private RoleMapper roleMapper;
|
||||
|
||||
@Override
|
||||
public PageResult<RoleBO> getRolePage(RolePageDTO pageDTO) {
|
||||
return RoleConvert.INSTANCE.convertPage(roleMapper.selectPage(pageDTO));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasSuperAdmin(Collection<Integer> ids) {
|
||||
List<RoleDO> roleDOs = roleMapper.selectBatchIds(ids);
|
||||
for (RoleDO roleDO : roleDOs) {
|
||||
if (RoleCodeEnum.SUPER_ADMIN.getCode().equals(roleDO.getCode())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,75 +0,0 @@
|
||||
package cn.iocoder.mall.system.rest.controller.authorization;
|
||||
|
||||
import cn.iocoder.common.framework.enums.MallConstants;
|
||||
import cn.iocoder.common.framework.vo.CommonResult;
|
||||
import cn.iocoder.common.framework.vo.PageResult;
|
||||
import cn.iocoder.mall.security.core.annotation.RequiresPermissions;
|
||||
import cn.iocoder.mall.security.core.context.AdminSecurityContextHolder;
|
||||
import cn.iocoder.mall.system.biz.bo.authorization.RoleBO;
|
||||
import cn.iocoder.mall.system.biz.dto.authorization.RoleAddDTO;
|
||||
import cn.iocoder.mall.system.biz.dto.authorization.RoleDeleteDTO;
|
||||
import cn.iocoder.mall.system.biz.dto.authorization.RolePageDTO;
|
||||
import cn.iocoder.mall.system.biz.dto.authorization.RoleUpdateDTO;
|
||||
import cn.iocoder.mall.system.biz.service.authorization.RoleService;
|
||||
import cn.iocoder.mall.system.rest.convert.authorization.AdminsRoleConvert;
|
||||
import cn.iocoder.mall.system.rest.request.authorization.AdminsRoleAddRequest;
|
||||
import cn.iocoder.mall.system.rest.request.authorization.AdminsRolePageRequest;
|
||||
import cn.iocoder.mall.system.rest.request.authorization.AdminsRoleUpdateRequest;
|
||||
import cn.iocoder.mall.system.rest.response.authorization.AdminsRolePageResponse;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@RestController
|
||||
@RequestMapping(MallConstants.ROOT_PATH_ADMIN + "/role")
|
||||
@Api(tags = "管理员 - 角色 API")
|
||||
public class AdminsRoleController {
|
||||
|
||||
@Autowired
|
||||
private RoleService roleService;
|
||||
|
||||
@GetMapping("/page")
|
||||
@ApiOperation(value = "角色分页")
|
||||
@RequiresPermissions("system:role:page")
|
||||
public CommonResult<PageResult<AdminsRolePageResponse>> page(AdminsRolePageRequest request) {
|
||||
RolePageDTO pageDTO = AdminsRoleConvert.INSTANCE.convert(request);
|
||||
PageResult<RoleBO> pageResult = roleService.getRolePage(pageDTO);
|
||||
return CommonResult.success(AdminsRoleConvert.INSTANCE.convertPage(pageResult));
|
||||
}
|
||||
|
||||
@PostMapping("/add")
|
||||
@ApiOperation(value = "创建角色")
|
||||
@RequiresPermissions("system:role:add")
|
||||
public CommonResult<Integer> add(AdminsRoleAddRequest request) {
|
||||
RoleAddDTO addDTO = AdminsRoleConvert.INSTANCE.convert(request)
|
||||
.setAdminId(AdminSecurityContextHolder.getAdminId());
|
||||
return CommonResult.success(roleService.addRole(addDTO));
|
||||
}
|
||||
|
||||
@PostMapping("/update")
|
||||
@ApiOperation(value = "更新角色")
|
||||
@RequiresPermissions("system:role:update")
|
||||
public CommonResult<Boolean> update(AdminsRoleUpdateRequest request) {
|
||||
RoleUpdateDTO updateDTO = AdminsRoleConvert.INSTANCE.convert(request)
|
||||
.setAdminId(AdminSecurityContextHolder.getAdminId());
|
||||
roleService.updateRole(updateDTO);
|
||||
return CommonResult.success(true);
|
||||
}
|
||||
|
||||
@PostMapping("/delete")
|
||||
@ApiOperation(value = "删除角色")
|
||||
@RequiresPermissions("system:role:delete")
|
||||
@ApiImplicitParam(name = "id", value = "角色编号", required = true, example = "1")
|
||||
public CommonResult<Boolean> delete(@RequestParam("id") Integer id) {
|
||||
RoleDeleteDTO deleteDTO = new RoleDeleteDTO().setId(id)
|
||||
.setAdminId(AdminSecurityContextHolder.getAdminId());
|
||||
roleService.deleteRole(deleteDTO);
|
||||
return CommonResult.success(true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -1,26 +0,0 @@
|
||||
package cn.iocoder.mall.system.rest.response.authorization;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@ApiModel("管理员 - 角色模块 - 分页列表 Response")
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class AdminsRolePageResponse {
|
||||
|
||||
@ApiModelProperty(value = "角色编号", required = true, example = "1")
|
||||
private Integer id;
|
||||
@ApiModelProperty(value = "角色名字", required = true, example = "管理员")
|
||||
private String name;
|
||||
@ApiModelProperty(value = "角色编码", example = "SUPER_ADMIN")
|
||||
private String code;
|
||||
@ApiModelProperty(value = "角色类型", required = true, example = "1-系统角色; 2-内置角色")
|
||||
private Integer type;
|
||||
@ApiModelProperty(value = "创建时间", required = true)
|
||||
private Date createTime;
|
||||
|
||||
}
|
||||
@ -1,50 +0,0 @@
|
||||
package cn.iocoder.mall.system.rest.response.user;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@ApiModel("用户 - OAuth2 模块 - 认证响应")
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class UsersOAuth2AuthenticateResponse {
|
||||
|
||||
@Data
|
||||
public static class Token {
|
||||
|
||||
@ApiModelProperty(value = "access token", required = true, example = "001e8f49b20e47f7b3a2de774497cd50")
|
||||
private String accessToken;
|
||||
|
||||
@ApiModelProperty(value = "refresh token", required = true, example = "001e8f49b20e47f7b3a2de774497cd50")
|
||||
private String refreshToken;
|
||||
|
||||
@ApiModelProperty(value = "过期时间", required = true)
|
||||
private Date expiresTime;
|
||||
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class User {
|
||||
|
||||
@ApiModelProperty(value = "管理员编号", required = true, example = "1")
|
||||
private Integer id;
|
||||
|
||||
@ApiModelProperty(value = "昵称", required = true, example = "小王")
|
||||
private String nickname;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO 晚点测试下 swagger 的表现
|
||||
*/
|
||||
private User user;
|
||||
|
||||
/**
|
||||
* TODO 晚点测试下 swagger 的表现
|
||||
*/
|
||||
private Token token;
|
||||
|
||||
}
|
||||
Loading…
Reference in new issue