Newer
Older
huludao / src / main / java / com / newfiber / api / pc / controller / RoleOrgController.java
package com.newfiber.api.pc.controller;

import com.baomidou.mybatisplus.plugins.Page;
import com.newfiber.api.core.annotation.SysLog;
import com.newfiber.api.core.bean.ReqBodyObj;
import com.newfiber.api.core.bean.RespBodyObj;
import com.newfiber.api.pc.dto.RoleJurisdictionDto;
import com.newfiber.api.pc.model.entity.SysOrganization;
import com.newfiber.api.pc.service.Data_Role_OrgService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@Api(value = "RoleOrgController",tags = "SYS-09、角色机构管理", position = 109)
public class RoleOrgController {
     @Autowired
     private Data_Role_OrgService roleOrgS;


   		@PostMapping(value="/RoleOrgByList",produces = "application/json;charset=utf-8")
   		@SysLog(actionType="4",value = "查询已分配的角色机构")
		@ApiOperation("角色机构管理-查询已分配的角色机构")
   		public RespBodyObj<List<SysOrganization>> UserOrgByList(@RequestBody ReqBodyObj<RoleJurisdictionDto> params){
   			try {
				RoleJurisdictionDto so = params.getData();

   				return RespBodyObj.ok(roleOrgS.roleOrgByList(so.getRoleNo()));
   			} catch (Exception e) {
   				e.printStackTrace();
   				return RespBodyObj.error("查询失败!");
   			}
   		}
   		//未分配角色机构
   		@PostMapping(value="/RoleOrgByListOne",produces = "application/json;charset=utf-8")
   		@SysLog(actionType="4",value = "未分配角色机构")
		@ApiOperation("角色机构管理-未分配角色机构")
   		public RespBodyObj<Page<SysOrganization>> UserOrgByListOne(@RequestBody ReqBodyObj<RoleJurisdictionDto> params){
			int pageSize=params.getSize();
			int pageNo=(params.getCurrent()-1)*pageSize;
   			try {
				RoleJurisdictionDto so = params.getData();
				Page<SysOrganization> json=roleOrgS.RoleOrgByListOne(so.getSort(), so.getOrder(), pageNo, pageSize, so.getRoleNo());
   			    return RespBodyObj.ok(json);
   			} catch (Exception e) {
   				e.printStackTrace();
   				return RespBodyObj.error("查询失败!");
   			}
   		}
   		//添加角色机构信息
   		@PostMapping(value="AddRoleOrg",produces = "application/json;charset=utf-8")
   		@SysLog(actionType="1",value = "添加角色机构信息")
		@ApiOperation("角色机构管理-添加角色机构信息")
		@ApiImplicitParams({
				@ApiImplicitParam(name = "roleNo",value = "角色编号", paramType = "form"),
				@ApiImplicitParam(name = "orgNo",value = "机构编号", paramType = "form")
		})
   		public RespBodyObj AddUserRole(@RequestParam("roleNo")String roleNo,@RequestParam("orgNo")String orgNo){
   			try {
   				roleOrgS.addRoleOrg(roleNo, orgNo);
   				return  RespBodyObj.ok("添加成功!");
   			} catch (Exception e) {
   				return  RespBodyObj.error("添加失败!");
   			}
   		}
   		//删除角色机构信息
   		@PostMapping(value="/deleteRoleOrg",produces = "application/json;charset=utf-8")
   		@SysLog(actionType="2",value = "删除角色机构信息")
		@ApiOperation("角色机构管理-删除角色机构信息")
		@ApiImplicitParams({
				@ApiImplicitParam(name = "roleNo",value = "角色编号", paramType = "form"),
				@ApiImplicitParam(name = "orgNo",value = "机构编号", paramType = "form")
		})
   		public RespBodyObj deleteUserOrg(@RequestParam("roleNo")String roleNo,@RequestParam("orgNo")String orgNo){
   			try {
   				if(orgNo!=null&&orgNo!=""){
   					roleOrgS.deleteRoleOrg(orgNo,roleNo);
   				return   RespBodyObj.ok("删除成功!");
   				}else{
   					
   				return  RespBodyObj.error("未选中删除项");
   					
   				}
   			} catch (Exception e) {
   				e.printStackTrace();
   				return RespBodyObj.error("删除失败!");
   			}
   		}
}