master
commit
769ae2c425
@ -0,0 +1,51 @@
|
||||
package com.zh.project0512.controller.wxApp;
|
||||
|
||||
import com.zh.project0512.model.dto.OperationRoleJurisdictionDTO;
|
||||
import com.zh.project0512.model.dto.UserJurisdictionFBIDTO;
|
||||
import com.zh.project0512.service.IUserJurisdictionService;
|
||||
import com.zh.project0512.utils.result.Result;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
|
||||
/**
|
||||
* 用户权限
|
||||
*/
|
||||
@Tag(name = "用户权限")
|
||||
@RestController
|
||||
@RequestMapping("/wxApp/userJurisdiction")
|
||||
public class UserJurisdictionController {
|
||||
@Resource
|
||||
IUserJurisdictionService userJurisdictionService;
|
||||
|
||||
/**
|
||||
* 操作角色权限
|
||||
* @param operationRoleJurisdictionDTO 操作用户权限DTO
|
||||
* @return 操作结果
|
||||
*/
|
||||
@PostMapping("/operationRoleJurisdiction")
|
||||
public Result<String> operationRoleJurisdiction(@Validated @RequestBody OperationRoleJurisdictionDTO operationRoleJurisdictionDTO){
|
||||
if (userJurisdictionService.operationRoleJurisdiction(operationRoleJurisdictionDTO)){
|
||||
return Result.success("操作角色权限","操作成功");
|
||||
}else {
|
||||
throw new RuntimeException("操作失败");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据角色主键id查询角色权限信息//TODO 有问题
|
||||
* @param userJurisdictionFBIDTO 角色权限 FBI DTO
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/findByRoleId")
|
||||
public Result<String> findByRoleId(@Validated @RequestBody UserJurisdictionFBIDTO userJurisdictionFBIDTO){
|
||||
// return Result.success(userJurisdictionService.findByRoleId(userJurisdictionFBIDTO));
|
||||
return null;
|
||||
}
|
||||
}
|
@ -0,0 +1,71 @@
|
||||
package com.zh.project0512.controller.wxApp;
|
||||
|
||||
import com.zh.project0512.model.dto.OperationRoleJurisdictionDTO;
|
||||
import com.zh.project0512.model.dto.UserRoleInsertDTO;
|
||||
import com.zh.project0512.model.dto.UserRoleListDTO;
|
||||
import com.zh.project0512.model.dto.UserRoleUpdateDTO;
|
||||
import com.zh.project0512.model.vo.UserRoleListVo;
|
||||
import com.zh.project0512.service.IUserRoleService;
|
||||
import com.zh.project0512.utils.result.Result;
|
||||
import com.zh.project0512.utils.result.ResultPageInfo;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* 用户角色
|
||||
*/
|
||||
@Tag(name = "用户角色")
|
||||
@RestController
|
||||
@RequestMapping("/wxApp/userRole")
|
||||
public class UserRoleController {
|
||||
@Resource
|
||||
IUserRoleService userRoleService;
|
||||
|
||||
|
||||
/**
|
||||
* 查询用户角色
|
||||
* @param userRoleListDTO 用户角色 list DTO
|
||||
* @return 用户角色
|
||||
*/
|
||||
@PostMapping("/list")
|
||||
public ResultPageInfo<UserRoleListVo> list(@Validated @RequestBody UserRoleListDTO userRoleListDTO){
|
||||
return ResultPageInfo.success(userRoleService.list(userRoleListDTO));
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加用户角色
|
||||
* @param userRoleInsertDTO 用户角色添加
|
||||
* @return 操作信息
|
||||
*/
|
||||
@PostMapping("/insert")
|
||||
public Result<String> insert(@Validated @RequestBody UserRoleInsertDTO userRoleInsertDTO){
|
||||
if (userRoleService.insert(userRoleInsertDTO)){
|
||||
return Result.success("添加用户角色","操作成功");
|
||||
}else {
|
||||
throw new RuntimeException("添加失败");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改用户角色
|
||||
* @param userRoleUpdateDTO 用户角色 update DTO
|
||||
* @return 操作信息
|
||||
*/
|
||||
@PostMapping("/update")
|
||||
public Result<String> update(@Validated @RequestBody UserRoleUpdateDTO userRoleUpdateDTO){
|
||||
if (userRoleService.update(userRoleUpdateDTO)){
|
||||
return Result.success("修改用户角色","操作成功");
|
||||
}else {
|
||||
throw new RuntimeException("修改失败");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
package com.zh.project0512.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.zh.project0512.model.UserJurisdiction;
|
||||
|
||||
public interface UserJurisdictionMapper extends BaseMapper<UserJurisdiction> {
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
package com.zh.project0512.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.zh.project0512.model.UserRoleJurisdiction;
|
||||
|
||||
public interface UserRoleJurisdictionMapper extends BaseMapper<UserRoleJurisdiction> {
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
package com.zh.project0512.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.zh.project0512.model.UserRole;
|
||||
|
||||
public interface UserRoleMapper extends BaseMapper<UserRole> {
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
package com.zh.project0512.model;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 用户权限
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@TableName("userJurisdiction")
|
||||
public class UserJurisdiction implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
/**
|
||||
* 主键id
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
@TableField("id")
|
||||
private Integer id;
|
||||
/**
|
||||
* 菜单主键id
|
||||
*/
|
||||
@TableField("menusId")
|
||||
private String menusId;
|
||||
/**
|
||||
* 操作主键id
|
||||
*/
|
||||
@TableField("operationId")
|
||||
private String operationId;
|
||||
/**
|
||||
* 权限备注
|
||||
*/
|
||||
@TableField("remake")
|
||||
private String remake;
|
||||
|
||||
}
|
@ -0,0 +1,63 @@
|
||||
package com.zh.project0512.model;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 用户菜单
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class UserMenus implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 主键id
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
@TableField("id")
|
||||
private Integer id;
|
||||
/**
|
||||
* 菜单名称
|
||||
*/
|
||||
@TableField("name")
|
||||
private String name;
|
||||
/**
|
||||
* 父类主键id
|
||||
*/
|
||||
@TableField("parentId")
|
||||
private String parentId;
|
||||
/**
|
||||
* 父类id全路径
|
||||
*/
|
||||
@TableField("parentIdPath")
|
||||
private String parentIdPath;
|
||||
/**
|
||||
* 权限编码
|
||||
*/
|
||||
@TableField("code")
|
||||
private String code;
|
||||
/**
|
||||
* 路由
|
||||
*/
|
||||
@TableField("routing")
|
||||
private String routing;
|
||||
/**
|
||||
* icon照片路径
|
||||
*/
|
||||
@TableField("iconImgPath")
|
||||
private String iconImgPath;
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@TableField("createAt")
|
||||
private String createAt;
|
||||
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
package com.zh.project0512.model;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 用户操作
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class UserOperation implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 主键id
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
@TableField("id")
|
||||
private Integer id;
|
||||
/**
|
||||
* 操作名称
|
||||
*/
|
||||
@TableField("name")
|
||||
private String name;
|
||||
/**
|
||||
* 权限编码
|
||||
*/
|
||||
@TableField("code")
|
||||
private String code;
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
package com.zh.project0512.model;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 用户角色
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@TableName("userRole")
|
||||
public class UserRole implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 主键id
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
@TableField("id")
|
||||
private Integer id;
|
||||
/**
|
||||
* 角色名称
|
||||
*/
|
||||
@TableField("name")
|
||||
private String name;
|
||||
/**
|
||||
* 角色编码
|
||||
*/
|
||||
@TableField("code")
|
||||
private String code;
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@TableField("createAt")
|
||||
private Date createAt;
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
@TableField("modifyAt")
|
||||
private Date modifyAt;
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
package com.zh.project0512.model;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 用户角色-权限 关联表
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@TableName("userRoleJurisdiction")
|
||||
public class UserRoleJurisdiction implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 主键id
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
@TableField("id")
|
||||
private Integer id;
|
||||
/**
|
||||
* 角色id
|
||||
*/
|
||||
@TableField("roleId")
|
||||
private Integer roleId;
|
||||
/**
|
||||
* 权限id
|
||||
*/
|
||||
@TableField("jurisdictionId")
|
||||
private Integer jurisdictionId;
|
||||
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
package com.zh.project0512.model.dto;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 操作用户权限DTO
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class OperationRoleJurisdictionDTO implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 角色主键id
|
||||
*/
|
||||
@Schema(title = "角色主键id")
|
||||
@NotNull(message = "角色主键id不能为空")
|
||||
private Integer roleId;
|
||||
/**
|
||||
* 权限主键id数组
|
||||
*/
|
||||
private int[] jurisdictionIds;
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
package com.zh.project0512.model.dto;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 角色权限 FBI DTO
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class UserJurisdictionFBIDTO implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 角色主键id
|
||||
*/
|
||||
@Schema(title = "角色主键id")
|
||||
@NotNull(message = "角色主键id不能为空")
|
||||
private Integer roleId;
|
||||
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
package com.zh.project0512.model.dto;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 用户角色添加 DTO
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Schema(title = "用户角色添加")
|
||||
public class UserRoleInsertDTO implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 角色名称
|
||||
*/
|
||||
@Schema(title = "角色名称")
|
||||
@NotBlank(message = "角色名称不能为Null")
|
||||
private String name;
|
||||
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
package com.zh.project0512.model.dto;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 用户角色 list DTO
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Schema
|
||||
public class UserRoleListDTO implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 当前页数
|
||||
*/
|
||||
@Schema(title = "当前页数")
|
||||
@NotNull(message = "当前页数不能为空")
|
||||
private int pageNum;
|
||||
/**
|
||||
* 每页记录数
|
||||
*/
|
||||
@Schema(title = "每页记录数")
|
||||
@NotNull(message = "每页记录数不能为空")
|
||||
private int pageSize;
|
||||
/**
|
||||
* 角色名
|
||||
*/
|
||||
private String name;
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
package com.zh.project0512.model.dto;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 用户角色 update DTO
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class UserRoleUpdateDTO implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 用户角色主键id
|
||||
*/
|
||||
@Schema(title = "用户角色主键id")
|
||||
private Integer id;
|
||||
/**
|
||||
* 用户角色名称
|
||||
*/
|
||||
@Schema(title = "用户角色名称")
|
||||
private String name;
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
package com.zh.project0512.model.vo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 角色权限 FBI Vo
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class UserJurisdictionFBIVo implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Integer id;
|
||||
private String name;
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
package com.zh.project0512.model.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class UserRoleListVo implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 主键id
|
||||
*/
|
||||
@Schema(title = "主键id")
|
||||
private Integer id;
|
||||
/**
|
||||
* 角色名
|
||||
*/
|
||||
@Schema(title = "角色名")
|
||||
private String name;
|
||||
/**
|
||||
* 添加时间
|
||||
*/
|
||||
@Schema(title = "添加时间")
|
||||
private Date createAt;
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@Schema(title = "更新时间")
|
||||
private Date modifyAt;
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
package com.zh.project0512.service;
|
||||
|
||||
import com.zh.project0512.model.dto.OperationRoleJurisdictionDTO;
|
||||
|
||||
public interface IUserJurisdictionService {
|
||||
/**
|
||||
* 操作角色权限
|
||||
* @param operationRoleJurisdictionDTO 操作用户权限DTO
|
||||
* @return 操作结果
|
||||
*/
|
||||
boolean operationRoleJurisdiction(OperationRoleJurisdictionDTO operationRoleJurisdictionDTO);
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
package com.zh.project0512.service;
|
||||
|
||||
import com.zh.project0512.model.dto.UserRoleInsertDTO;
|
||||
import com.zh.project0512.model.dto.UserRoleListDTO;
|
||||
import com.zh.project0512.model.dto.UserRoleUpdateDTO;
|
||||
import com.zh.project0512.model.vo.UserRoleListVo;
|
||||
import com.zh.project0512.utils.page.PageInfo;
|
||||
|
||||
public interface IUserRoleService {
|
||||
/**
|
||||
* 查询用户角色
|
||||
* @param userRoleListDTO 用户角色 list DTO
|
||||
* @return 用户角色
|
||||
*/
|
||||
PageInfo<UserRoleListVo> list(UserRoleListDTO userRoleListDTO);
|
||||
|
||||
/**
|
||||
* 添加用户角色
|
||||
* @param userRoleInsertDTO 用户角色添加 DTO
|
||||
* @return 操作结果
|
||||
*/
|
||||
boolean insert(UserRoleInsertDTO userRoleInsertDTO);
|
||||
|
||||
/**
|
||||
* 修改用户角色
|
||||
* @param userRoleUpdateDTO 用户角色 update DTO
|
||||
* @return 操作结果
|
||||
*/
|
||||
boolean update(UserRoleUpdateDTO userRoleUpdateDTO);
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
package com.zh.project0512.serviceImpl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.zh.project0512.mapper.UserRoleJurisdictionMapper;
|
||||
import com.zh.project0512.model.UserRoleJurisdiction;
|
||||
import com.zh.project0512.model.dto.OperationRoleJurisdictionDTO;
|
||||
import com.zh.project0512.service.IUserJurisdictionService;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
@Service
|
||||
public class UserJurisdictionServiceImpl implements IUserJurisdictionService {
|
||||
@Resource
|
||||
UserRoleJurisdictionMapper userRoleJurisdictionMapper;
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public boolean operationRoleJurisdiction(OperationRoleJurisdictionDTO operationRoleJurisdictionDTO) {
|
||||
//先删除角色-权限关联表
|
||||
QueryWrapper<UserRoleJurisdiction> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("roleId",operationRoleJurisdictionDTO.getRoleId());
|
||||
userRoleJurisdictionMapper.delete(queryWrapper);
|
||||
|
||||
//后添加角色-权限关联表
|
||||
int[] jurisdictionIds = operationRoleJurisdictionDTO.getJurisdictionIds();
|
||||
if (jurisdictionIds.length > 0){
|
||||
for (int jurisdictionId : jurisdictionIds) {
|
||||
UserRoleJurisdiction userRoleJurisdiction = new UserRoleJurisdiction();
|
||||
userRoleJurisdiction.setRoleId(operationRoleJurisdictionDTO.getRoleId());
|
||||
userRoleJurisdiction.setJurisdictionId(jurisdictionId);
|
||||
userRoleJurisdictionMapper.insert(userRoleJurisdiction);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
@ -0,0 +1,71 @@
|
||||
package com.zh.project0512.serviceImpl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.zh.project0512.mapper.UserRoleMapper;
|
||||
import com.zh.project0512.model.UserPointsRecords;
|
||||
import com.zh.project0512.model.UserRole;
|
||||
import com.zh.project0512.model.dto.UserRoleInsertDTO;
|
||||
import com.zh.project0512.model.dto.UserRoleListDTO;
|
||||
import com.zh.project0512.model.dto.UserRoleUpdateDTO;
|
||||
import com.zh.project0512.model.vo.UserPointsRecordListVo;
|
||||
import com.zh.project0512.model.vo.UserRoleListVo;
|
||||
import com.zh.project0512.service.IUserRoleService;
|
||||
import com.zh.project0512.utils.PropertyUtils;
|
||||
import com.zh.project0512.utils.page.PageInfo;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
@Service
|
||||
public class UserRoleServiceImpl implements IUserRoleService {
|
||||
@Resource
|
||||
UserRoleMapper userRoleMapper;
|
||||
|
||||
@Override
|
||||
public PageInfo<UserRoleListVo> list(UserRoleListDTO userRoleListDTO) {
|
||||
ArrayList<UserRoleListVo> userRoleListVoList = new ArrayList<>();
|
||||
QueryWrapper<UserRole> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq(StringUtils.isNotBlank(userRoleListDTO.getName()),"name",userRoleListDTO.getName());
|
||||
|
||||
Page<UserRole> page = new Page<>(userRoleListDTO.getPageNum(), userRoleListDTO.getPageSize());
|
||||
IPage<UserRole> userRoleIPage = userRoleMapper.selectPage(page, queryWrapper);
|
||||
List<UserRole> records = userRoleIPage.getRecords();
|
||||
if (records != null && records.size()>0){
|
||||
for (UserRole record : records) {
|
||||
UserRoleListVo userRoleListVo = new UserRoleListVo();
|
||||
PropertyUtils.copyProperties(record,userRoleListVo);
|
||||
userRoleListVoList.add(userRoleListVo);
|
||||
}
|
||||
}
|
||||
return new PageInfo<>(userRoleIPage.getPages(), userRoleListVoList, userRoleIPage.getTotal());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean insert(UserRoleInsertDTO userRoleInsertDTO) {
|
||||
UserRole userRole = new UserRole();
|
||||
userRole.setName(userRoleInsertDTO.getName());
|
||||
userRole.setCode(UUID.randomUUID().toString().replace("-",""));
|
||||
userRole.setCreateAt(new Date());
|
||||
int insert = userRoleMapper.insert(userRole);
|
||||
return insert > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean update(UserRoleUpdateDTO userRoleUpdateDTO) {
|
||||
UserRole userRole = userRoleMapper.selectById(userRoleUpdateDTO.getId());
|
||||
if (userRole == null){
|
||||
throw new RuntimeException("记录不存在");
|
||||
}
|
||||
|
||||
userRole.setName(userRoleUpdateDTO.getName());
|
||||
int update = userRoleMapper.updateById(userRole);
|
||||
return update > 0;
|
||||
}
|
||||
}
|
Loading…
Reference in new issue