Newer
Older
huludao / src / main / java / com / newfiber / api / pc / controller / JurisdictionController.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.model.entity.SysJurisdiction;
import com.newfiber.api.pc.model.request.SysJurisdictionPageRequest;
import com.newfiber.api.pc.model.request.SysJurisdictionSaveRequest;
import com.newfiber.api.pc.model.request.SysJurisdictionUpdateRequest;
import com.newfiber.api.pc.service.SysJurisdictionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;
import java.util.Map;

@Controller
@Api(tags = "SYS-07、权限管理", position = 107)
public class JurisdictionController {
	
	@Autowired
	private SysJurisdictionService sysJurisdictionService;

	@ApiOperation(value = "分页查看所有权限")
	@PostMapping(value="/JurisdictionList", produces = "application/json;charset=utf-8")
	@ResponseBody
	@SysLog(actionType="4",value = "查看所有权限")
	public RespBodyObj<Page<SysJurisdiction>> JurisdictionList(@RequestBody ReqBodyObj<SysJurisdictionPageRequest> params){
		int pageSize=params.getSize();
		int pageNo=(params.getCurrent()-1)*pageSize;
		try {
			SysJurisdictionPageRequest sj = params.getData();
			Page<SysJurisdiction> json=sysJurisdictionService.JurisdictonList(sj.getSort(), sj.getOrder(), pageNo, pageSize, sj.getFuzzyQuery());
			return RespBodyObj.ok(json);
		} catch (Exception e) {
			e.printStackTrace();
			return RespBodyObj.error("查询失败!");
		}
	}
	
	@ApiOperation(value = "添加权限")
	@PostMapping(value="/AddJurisdiction", produces = "application/json;charset=utf-8")
	@ResponseBody
	@SysLog(actionType="1",value = "添加权限")
	public RespBodyObj AddJurisdiction(@RequestBody SysJurisdictionSaveRequest params){
		try {
			sysJurisdictionService.addJurisdictonList(params.getJurisdictionNo(), params.getJurisdictionName(), params.getJurisdictionType(), params.getJurisdictionState(), params.getRemark(), params.getOrderSort());
			return RespBodyObj.ok("添加成功!");
		} catch (Exception e) {
			e.printStackTrace();
			return RespBodyObj.error("添加失败!");
		}
	}


	@ApiOperation(value = "修改权限信息")
	@PostMapping(value="/updateJurisdiction", produces = "application/json;charset=utf-8")
	@ResponseBody
	@SysLog(actionType="3",value = "修改权限信息")
	public RespBodyObj updateJurisdiction(@RequestBody SysJurisdictionUpdateRequest params){
	   try {
		   sysJurisdictionService.updateJurisdictonList( params.getSerial(), params.getJurisdictionNo(), params.getJurisdictionName(), params.getJurisdictionType(), params.getJurisdictionState(), params.getRemark(), params.getOrderSort());
		   return RespBodyObj.ok("修改成功!");
	   } catch (Exception e) {
		e.printStackTrace();
		return RespBodyObj.error("修改失败!");
		}
	}

	@ApiOperation(value = "删除权限")
	@PostMapping(value="/deleteJurisdiction", produces = "application/json;charset=utf-8")
	@ResponseBody
	@SysLog(actionType="2",value = "删除权限")
	public RespBodyObj deleteJurisdiction(@RequestParam(value = "serials") String serials){
		try {
			if(serials!=null){
			sysJurisdictionService.deleteJurisdictonList(serials);
			  return RespBodyObj.ok("删除成功!");
			}else{
				return RespBodyObj.error("未选中删除项");
			}
		} catch (Exception e) {
			e.printStackTrace();
			return RespBodyObj.error("删除失败!");
		}
	}
}