Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
abd03dd5a5
@ -0,0 +1,66 @@
|
|||||||
|
package com.xdap.self_development.controller;
|
||||||
|
|
||||||
|
|
||||||
|
import com.definesys.mpaas.common.http.Response;
|
||||||
|
import com.xdap.self_development.controller.request.ModelRolesRequest;
|
||||||
|
import com.xdap.self_development.pojo.ModelRolesPojo;
|
||||||
|
import com.xdap.self_development.pojo.dto.PageResultDTO;
|
||||||
|
import com.xdap.self_development.pojo.view.MenuListView;
|
||||||
|
import com.xdap.self_development.service.ModelMenuPermissionService;
|
||||||
|
import com.xdap.self_development.service.ModelRoleService;
|
||||||
|
import org.checkerframework.checker.units.qual.A;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/custom/permission")
|
||||||
|
public class PermissionController {
|
||||||
|
@Autowired
|
||||||
|
ModelRoleService modelRoleService;
|
||||||
|
@Autowired
|
||||||
|
ModelMenuPermissionService modelMenuPermissionService;
|
||||||
|
//添加角色
|
||||||
|
@PostMapping("/addRoles")
|
||||||
|
Response addRoles(ModelRolesRequest request){
|
||||||
|
try {
|
||||||
|
modelRoleService.addRoles(request);
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException("添加失败:" +e.getMessage());
|
||||||
|
}
|
||||||
|
return Response.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
//查看角色
|
||||||
|
@GetMapping("/selectRoles")
|
||||||
|
Response selectRoles(@RequestParam String userID){
|
||||||
|
try {
|
||||||
|
// PageResultDTO<ModelRolesPojo> modelRolesPojoPageResultDTO = modelRoleService.selectRoles(userID);
|
||||||
|
List<ModelRolesPojo> modelRolesPojos = modelRoleService.selectRoles(userID);
|
||||||
|
return Response.ok().data(modelRolesPojos);
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException(e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//为角色添加权限
|
||||||
|
|
||||||
|
//修改角色信息
|
||||||
|
|
||||||
|
//菜单查询
|
||||||
|
@GetMapping("/selectMenus")
|
||||||
|
Response selectMenus(){
|
||||||
|
try {
|
||||||
|
List<MenuListView> modelRolesPojos = modelMenuPermissionService.selectMenus();
|
||||||
|
return Response.ok().data(modelRolesPojos);
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException(e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//参数查询
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,23 @@
|
|||||||
|
package com.xdap.self_development.controller.request;
|
||||||
|
|
||||||
|
import com.definesys.mpaas.query.annotation.RowID;
|
||||||
|
import com.definesys.mpaas.query.annotation.RowIDType;
|
||||||
|
import com.definesys.mpaas.query.annotation.Table;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class ModelRolesRequest {
|
||||||
|
|
||||||
|
/** 角色名称,; */
|
||||||
|
private String roleName ;
|
||||||
|
/** 角色代号,; */
|
||||||
|
private String roleCode ;
|
||||||
|
/** 角色描述,; */
|
||||||
|
private String roleDescription ;
|
||||||
|
/** 登录用户ID,; */
|
||||||
|
private String userId ;
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,32 @@
|
|||||||
|
package com.xdap.self_development.pojo;
|
||||||
|
|
||||||
|
import com.definesys.mpaas.query.annotation.RowID;
|
||||||
|
import com.definesys.mpaas.query.annotation.RowIDType;
|
||||||
|
import com.definesys.mpaas.query.annotation.Table;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = false)
|
||||||
|
@Table("yfsjglpt_model_dep_user_role")
|
||||||
|
public class ModelDepUserRolePojo {
|
||||||
|
/** ID,; */
|
||||||
|
@RowID(sequence = "yfsjglpt_model_dep_user_role_s", type = RowIDType.UUID)
|
||||||
|
private String id ;
|
||||||
|
/** 用户或部门ID,; */
|
||||||
|
private String userOrDep ;
|
||||||
|
/** 角色ID,; */
|
||||||
|
private String roleId ;
|
||||||
|
/** 是否是部门,0:个人;1:部门,; */
|
||||||
|
private int isDep ;
|
||||||
|
/** 创建人,; */
|
||||||
|
private String createdBy ;
|
||||||
|
/** 创建时间,; */
|
||||||
|
private Date creationDate ;
|
||||||
|
/** 最后更新人,; */
|
||||||
|
private String lastUpdatedBy ;
|
||||||
|
/** 最后更新时间,; */
|
||||||
|
private Date lastUpdateDate ;
|
||||||
|
}
|
||||||
@ -0,0 +1,34 @@
|
|||||||
|
package com.xdap.self_development.pojo;
|
||||||
|
|
||||||
|
import com.definesys.mpaas.query.annotation.RowID;
|
||||||
|
import com.definesys.mpaas.query.annotation.RowIDType;
|
||||||
|
import com.definesys.mpaas.query.annotation.Table;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = false)
|
||||||
|
@Table("yfsjglpt_model_menu_parameter")
|
||||||
|
public class ModelMenuParameterPojo {
|
||||||
|
/** ID,; */
|
||||||
|
@RowID(sequence = "yfsjglpt_model_menu_parameter_s", type = RowIDType.UUID)
|
||||||
|
private String id ;
|
||||||
|
/** 菜单ID,; */
|
||||||
|
private String menuId ;
|
||||||
|
/** 子系统,; */
|
||||||
|
private String subsystem ;
|
||||||
|
/** 参数ID,; */
|
||||||
|
private String parameterId ;
|
||||||
|
/** 参数权限,1:查看;2:编辑,; */
|
||||||
|
private int parameterPer ;
|
||||||
|
/** 创建人,; */
|
||||||
|
private String createdBy ;
|
||||||
|
/** 创建时间,; */
|
||||||
|
private Date creationDate ;
|
||||||
|
/** 最后更新人,; */
|
||||||
|
private String lastUpdatedBy ;
|
||||||
|
/** 最后更新时间,; */
|
||||||
|
private Date lastUpdateDate ;
|
||||||
|
}
|
||||||
@ -0,0 +1,36 @@
|
|||||||
|
package com.xdap.self_development.pojo;
|
||||||
|
|
||||||
|
import com.definesys.mpaas.query.annotation.RowID;
|
||||||
|
import com.definesys.mpaas.query.annotation.RowIDType;
|
||||||
|
import com.definesys.mpaas.query.annotation.Table;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = false)
|
||||||
|
@Table("yfsjglpt_model_menu_permission")
|
||||||
|
public class ModelMenuPermissionPojo {
|
||||||
|
|
||||||
|
@RowID(sequence = "yfsjglpt_model_menu_permission_s", type = RowIDType.UUID)
|
||||||
|
private String id ;
|
||||||
|
/** 上级ID,; */
|
||||||
|
private String parentId ;
|
||||||
|
/** 菜单名称,; */
|
||||||
|
private String menuName ;
|
||||||
|
/** 菜单代码,; */
|
||||||
|
private String menuCode ;
|
||||||
|
/** 菜单描述,; */
|
||||||
|
private String menuDesc ;
|
||||||
|
/** 是否可用,; */
|
||||||
|
private int isEnable ;
|
||||||
|
/** 创建人,; */
|
||||||
|
private String createdBy ;
|
||||||
|
/** 创建时间,; */
|
||||||
|
private Date creationDate ;
|
||||||
|
/** 最后更新人,; */
|
||||||
|
private String lastUpdatedBy ;
|
||||||
|
/** 最后更新时间,; */
|
||||||
|
private Date lastUpdateDate ;
|
||||||
|
}
|
||||||
@ -0,0 +1,35 @@
|
|||||||
|
package com.xdap.self_development.pojo;
|
||||||
|
|
||||||
|
import com.definesys.mpaas.query.annotation.RowID;
|
||||||
|
import com.definesys.mpaas.query.annotation.RowIDType;
|
||||||
|
import com.definesys.mpaas.query.annotation.Table;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = false)
|
||||||
|
@Table("yfsjglpt_model_roles")
|
||||||
|
public class ModelRolesPojo {
|
||||||
|
/** ID,; */
|
||||||
|
@RowID(sequence = "yfsjglpt_model_roles_s", type = RowIDType.UUID)
|
||||||
|
private String id ;
|
||||||
|
/** 角色名称,; */
|
||||||
|
private String roleName ;
|
||||||
|
/** 角色代号,; */
|
||||||
|
private String roleCode ;
|
||||||
|
/** 角色描述,; */
|
||||||
|
private String roleDescription ;
|
||||||
|
/** 是否启用,; */
|
||||||
|
private int isEnabled ;
|
||||||
|
/** 创建人,; */
|
||||||
|
private String createdBy ;
|
||||||
|
/** 创建时间,; */
|
||||||
|
private Date creationDate ;
|
||||||
|
/** 最后更新人,; */
|
||||||
|
private String lastUpdatedBy ;
|
||||||
|
/** 最后更新时间,; */
|
||||||
|
private Date lastUpdateDate ;
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,20 @@
|
|||||||
|
package com.xdap.self_development.pojo.view;
|
||||||
|
|
||||||
|
import com.definesys.mpaas.query.annotation.SQL;
|
||||||
|
import com.definesys.mpaas.query.annotation.SQLQuery;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.sql.Timestamp;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class MenuListView {
|
||||||
|
private String id;
|
||||||
|
private String parent_id;
|
||||||
|
private String menu;
|
||||||
|
ArrayList<MenuListView> listViews;
|
||||||
|
}
|
||||||
@ -0,0 +1,12 @@
|
|||||||
|
package com.xdap.self_development.service;
|
||||||
|
|
||||||
|
|
||||||
|
import com.xdap.self_development.pojo.view.MenuListView;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface ModelMenuPermissionService {
|
||||||
|
|
||||||
|
//菜单查询
|
||||||
|
List<MenuListView> selectMenus();
|
||||||
|
}
|
||||||
@ -0,0 +1,22 @@
|
|||||||
|
package com.xdap.self_development.service;
|
||||||
|
|
||||||
|
|
||||||
|
import com.xdap.self_development.controller.request.ModelRolesRequest;
|
||||||
|
import com.xdap.self_development.pojo.ModelMenuPermissionPojo;
|
||||||
|
import com.xdap.self_development.pojo.ModelRolesPojo;
|
||||||
|
import com.xdap.self_development.pojo.dto.PageResultDTO;
|
||||||
|
import com.xdap.self_development.pojo.view.MenuListView;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface ModelRoleService {
|
||||||
|
|
||||||
|
void addRoles(ModelRolesRequest request);
|
||||||
|
|
||||||
|
PageResultDTO<ModelRolesPojo> selectRolesByPage(String userID);
|
||||||
|
List<ModelRolesPojo> selectRoles(String userID);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,61 @@
|
|||||||
|
package com.xdap.self_development.service.impl;
|
||||||
|
|
||||||
|
|
||||||
|
import com.xdap.self_development.config.BusinessDatabase;
|
||||||
|
import com.xdap.self_development.controller.request.ModelRolesRequest;
|
||||||
|
import com.xdap.self_development.pojo.ModelMenuPermissionPojo;
|
||||||
|
import com.xdap.self_development.pojo.ModelRolesPojo;
|
||||||
|
import com.xdap.self_development.pojo.view.MenuListView;
|
||||||
|
import com.xdap.self_development.service.ModelMenuPermissionService;
|
||||||
|
import com.xdap.self_development.service.ModelRoleService;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.lang3.ObjectUtils;
|
||||||
|
import org.springframework.beans.BeanUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@Service
|
||||||
|
public class ModelMenuPermissionServiceImpl implements ModelMenuPermissionService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
BusinessDatabase businessDatabase;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<MenuListView> selectMenus() {
|
||||||
|
List<MenuListView> menuListViews = new ArrayList<MenuListView>();
|
||||||
|
List<ModelMenuPermissionPojo> permissionPojos = businessDatabase.getBusinessDatabase()
|
||||||
|
.doQuery(ModelMenuPermissionPojo.class);
|
||||||
|
for (ModelMenuPermissionPojo pojo : permissionPojos) {
|
||||||
|
MenuListView menuListView = new MenuListView();
|
||||||
|
String id = pojo.getId();
|
||||||
|
menuListView.setId(id);
|
||||||
|
menuListView.setMenu(pojo.getMenuName());
|
||||||
|
List<ModelMenuPermissionPojo> pojos = permissionPojos.stream().filter(x -> x.getParentId().equals(id)).collect(Collectors.toList());
|
||||||
|
|
||||||
|
if (ObjectUtils.isNotEmpty(pojos)) {
|
||||||
|
ArrayList<MenuListView> menuListViews1 = new ArrayList<MenuListView>();
|
||||||
|
|
||||||
|
for (ModelMenuPermissionPojo pojo2 : pojos) {
|
||||||
|
MenuListView menuListView1 = new MenuListView();
|
||||||
|
String id2 = pojo2.getId();
|
||||||
|
menuListView1.setId(id2);
|
||||||
|
menuListView1.setMenu(pojo2.getMenuName());
|
||||||
|
menuListViews1.add(menuListView1);
|
||||||
|
}
|
||||||
|
menuListView.setListViews(menuListViews1);
|
||||||
|
}
|
||||||
|
menuListViews.add(menuListView);
|
||||||
|
}
|
||||||
|
return menuListViews;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,51 @@
|
|||||||
|
package com.xdap.self_development.service.impl;
|
||||||
|
|
||||||
|
|
||||||
|
import com.xdap.self_development.config.BusinessDatabase;
|
||||||
|
import com.xdap.self_development.controller.request.ModelRolesRequest;
|
||||||
|
import com.xdap.self_development.pojo.ModelMenuPermissionPojo;
|
||||||
|
import com.xdap.self_development.pojo.ModelRolesPojo;
|
||||||
|
import com.xdap.self_development.pojo.Parameter;
|
||||||
|
import com.xdap.self_development.pojo.dto.PageResultDTO;
|
||||||
|
import com.xdap.self_development.pojo.view.MenuListView;
|
||||||
|
import com.xdap.self_development.service.ModelRoleService;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.lang3.ObjectUtils;
|
||||||
|
import org.springframework.beans.BeanUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@Service
|
||||||
|
public class ModelRoleServiceImpl implements ModelRoleService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
BusinessDatabase businessDatabase;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addRoles(ModelRolesRequest request) {
|
||||||
|
ModelRolesPojo modelRolesPojo = new ModelRolesPojo();
|
||||||
|
BeanUtils.copyProperties(request, modelRolesPojo);
|
||||||
|
modelRolesPojo.setCreatedBy(request.getUserId());
|
||||||
|
modelRolesPojo.setCreationDate(new Date());
|
||||||
|
businessDatabase.getBusinessDatabase()
|
||||||
|
.doInsert(modelRolesPojo);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PageResultDTO<ModelRolesPojo> selectRolesByPage(String userID) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<ModelRolesPojo> selectRoles(String userID) {
|
||||||
|
List<ModelRolesPojo> modelRolesPojos = businessDatabase.getBusinessDatabase()
|
||||||
|
.doQuery(ModelRolesPojo.class);
|
||||||
|
return modelRolesPojos;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user