Newer
Older
huludao / src / main / java / com / newfiber / api / pc / controller / RoleJurisdictionController.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.dao.Data_Role_JurisdictionDao;
import com.newfiber.api.pc.dto.RoleJurisdictionDto;
import com.newfiber.api.pc.model.entity.Data_Role_Jurisdiction;
import com.newfiber.api.pc.model.entity.SysJurisdiction;
import com.newfiber.api.pc.service.Data_Role_JurisdictionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@Api(value = "RoleJurisdictionController",tags = "SYS-15、角色权限管理", position = 115)
public class RoleJurisdictionController {
	
	@Autowired
	private Data_Role_JurisdictionService RoleJurisdictionService;

	//查询角色权限
	 @PostMapping(value="/RoleJurisdictionList",produces = "application/json;charset=utf-8")
	 @SysLog(actionType="4",value = "查询角色权限")
	 @ApiOperation("角色权限 - 查询角色权限")
	 public RespBodyObj<Page<Data_Role_Jurisdiction>> RoleJurisdictionList(@RequestBody ReqBodyObj<RoleJurisdictionDto> params){
		 int pageSize=params.getSize();
		 int pageNo=(params.getCurrent()-1)*pageSize;
		 try {
			 RoleJurisdictionDto drj = params.getData();
			 Page<Data_Role_Jurisdiction> json= RoleJurisdictionService.RoleJurisdiction(drj.getSort(),drj.getOrder() ,pageNo,pageSize,drj.getRoleNo(),drj.getFuzzyQuery());
			return RespBodyObj.ok(json);
		} catch (Exception e) {
			e.printStackTrace();
			return RespBodyObj.error("查询失败!");
		}
	 }
	 
	 //查询未分配角色权限
	 @PostMapping(value="/RoleJurisdictionListBy",produces = "application/json;charset=utf-8")
	 @SysLog(actionType="4",value = "查询未分配角色权限")
	 @ApiOperation("角色权限-查询未分配角色权限")
	 public RespBodyObj<Page<SysJurisdiction>> RoleJurisdictionListBy(@RequestBody ReqBodyObj<RoleJurisdictionDto> params){
		 int pageSize=params.getSize();
		 int pageNo=(params.getCurrent()-1)*pageSize;
		 try {
			 RoleJurisdictionDto drj = params.getData();
			 Page<SysJurisdiction> json= RoleJurisdictionService.RoleJurisdictionOne(drj.getSort(),drj.getOrder() ,pageNo,pageSize,drj.getRoleNo(),drj.getFuzzyQuery());
			 return RespBodyObj.ok(json);
		 } catch (Exception e) {
			  e.printStackTrace();
			 return RespBodyObj.error("查询失败!");
		 }
	 }
	//添加角色权限
	 @PostMapping(value="/AddRoleJurisdiction",produces = "application/json;charset=utf-8")
	 @SysLog(actionType="1",value = "添加角色权限")
	 @ApiOperation("角色权限管理-添加角色权限")
	 public RespBodyObj AddRoleJurisdiction(@RequestParam("roleNo")String roleNo,@RequestParam("jurisdictionNo")String jurisdictionNo){
	     try {
	    	 RoleJurisdictionService.addRoleJurisdiction(roleNo,  jurisdictionNo);
	    	return RespBodyObj.ok("添加成功!");
		} catch (Exception e) {
			e.printStackTrace();
			return RespBodyObj.error("添加失败!");
		}
	   
	     
			 }
	     //删除角色权限
	   @PostMapping(value="/deleteRoleJurisdiction",produces = "application/json;charset=utf-8")
	   @SysLog(actionType="2",value = "删除角色权限")
	   @ApiOperation("角色权限管理-删除角色权限")
	   public RespBodyObj deleteRoleJurisdiction(@RequestParam("type") String type){
		   try {
			if(type!=null&&type!=""){
				RoleJurisdictionService.deleteRoleJurisdiction(type);
				return RespBodyObj.ok("删除成功!");
			}else{
				
				return RespBodyObj.error("未选中删除项");
			}
			   
		} catch (Exception e) {
			e.printStackTrace();
			return RespBodyObj.error("删除失败!");
			
		}
	   }
	
	
	   
	   
	   
	   
	   
	   
	   
	   
	





}