Newer
Older
huludao / src / main / java / com / newfiber / api / pc / controller / UserOrgController.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_User_JurisdictionDao;
import com.newfiber.api.pc.dto.OrgDto;
import com.newfiber.api.pc.model.entity.Data_User_Info;
import com.newfiber.api.pc.service.Data_User_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.web.bind.annotation.*;

@RestController
@Api(value = "UserOrgController",tags = "SYS-08、用户机构管理", position = 108)
public class UserOrgController {
	
	@Autowired
	private Data_User_OrgService uorgService;

	
		
		//查询分配的机构用户
		@PostMapping(value="/UserOrgByList",produces = "application/json;charset=utf-8")
		@SysLog(actionType="4",value = "查询分配的机构用户")
		@ApiOperation("用户机构管理 - 查询该机构下已经分配的用户信息")
		public RespBodyObj<Page<Data_User_Info>> UserOrgByList(@RequestBody ReqBodyObj<OrgDto> params){
			int pageSize=params.getSize();
			int pageNo=(params.getCurrent()-1)*pageSize;
			try {
				OrgDto ui = params.getData();
				Page<Data_User_Info> json=uorgService.userOrgByList(ui.getSort(), ui.getOrder(), pageNo, pageSize, ui.getOrgNo());
				return RespBodyObj.ok(json);
			} catch (Exception e) {
				e.printStackTrace();
				return RespBodyObj.error("查询失败!");
			}
			
			
		}

		@PostMapping(value="/UserOrgByListOne",produces = "application/json;charset=utf-8")
		@SysLog(actionType="4",value = "查询未分配机构用户")
		@ApiOperation("用户机构管理 - 查询未分配机构用户")
		public RespBodyObj<Page<Data_User_Info>> UserOrgByListOne(@RequestBody ReqBodyObj<OrgDto> params){
			int pageSize=params.getSize();
			int pageNo=(params.getCurrent()-1)*pageSize;
			try {
				OrgDto ui = params.getData();
				Page<Data_User_Info> json=uorgService.userOrgByListOne(ui.getSort(), ui.getOrder(), pageNo, pageSize, ui.getOrgNo());
				return RespBodyObj.ok(json);
			} catch (Exception e) {
				e.printStackTrace();
				return RespBodyObj.error("查询失败!");
			}
		}
		//添加用户机构信息
		@PostMapping(value="AddUserOrg",produces = "application/json;charset=utf-8")
		@SysLog(actionType="4",value = "添加用户机构信息")
		@ApiOperation("用户机构管理 - 添加用户机构信息")
		public RespBodyObj AddUserRole(@RequestParam("userNo")String userNo,@RequestParam("orgNo")String orgNo){
			try {
				uorgService.addUserOrg(userNo, orgNo);
				return RespBodyObj.ok("添加成功!");
			} catch (Exception e) {
				return RespBodyObj.error("添加失败!");
			}
			
		
		}
		//删除机构信息
		@PostMapping(value="/deleteUserOrg",produces = "application/json;charset=utf-8")
		@SysLog(actionType="2",value = "删除机构信息")
		@ApiOperation("用户机构管理 - 删除机构信息")
		@ApiImplicitParams({
				@ApiImplicitParam(name = "userNo",value = "用户编号"),
				@ApiImplicitParam(name = "orgNo",value = "机构编号")
		})
		public RespBodyObj deleteUserOrg(@RequestParam("userNo")String userNo,@RequestParam("orgNo")String orgNo){
			try {
				
				
				if(userNo!=null&&userNo!=""){
					uorgService.deleteUserOrg(userNo,orgNo);
				return  RespBodyObj.ok("删除成功!");
				}else{
					return RespBodyObj.error("未选中删除项");
				}
				
			} catch (Exception e) {
				e.printStackTrace();
				return RespBodyObj.error("删除失败!");
			}
		}

		
}