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

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.newfiber.api.core.annotation.SysLog;
import com.newfiber.api.core.commons.*;
import com.newfiber.api.pc.dto.PeopleSerchDTO;
import com.newfiber.api.pc.model.meet.People;
import com.newfiber.api.pc.service.PeopleSerivce;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

/**
 * @Author:zzh
 * @CreateDate:2020/11/24 13:42
 * @Description:
 */
@RestController
@RequestMapping("/meet/people")
@Api(value = "PeopleController",tags = "应急指挥-人员配备")
public class PeopleController {

    @Autowired
    private PeopleSerivce peopleSerivce;

    @PostMapping("/list")
    @ApiOperation("分页条件查询人员信息")
    @SysLog(actionType = "4",value = "分页条件查询人员信息")
    public ResultObj<PageResultObject<People>> queryPage(@RequestBody PageRequestObject<PeopleSerchDTO> peopleDTO){
        return new ResultObj<PageResultObject<People>>(ResultCode.OK,peopleSerivce.queryPage(peopleDTO));
    }

    @PostMapping("/add")
    @ApiOperation("添加人员")
    @SysLog(actionType = "1",value = "添加人员")
    public ResultObj addPeople(@RequestBody People people){
        peopleSerivce.addPeople(people);
        return  ResultObj.ok();
    }

    @PostMapping("/update")
    @ApiOperation("修改人员")
    @SysLog(actionType = "3",value = "修改人员")
    public ResultObj updatePeople(@RequestBody People people){
        if(StringUtils.isEmpty(people.getPId())){
            throw new CustomException(701,"请选中一条数据");
        }
       /* if(peopleSerivce.isRepeatJob(people.getPeopleNo(),people.getJob())){
            return ResultObj.error();
        }*/
        boolean byId = peopleSerivce.updateById(people);
        if(!byId){
            return new ResultObj(ResultCode.UPDATE_ERROR);
        }
        return ResultObj.ok();
    }

    @PostMapping("/delete")
    @ApiOperation("删除人员")
    @SysLog(actionType = "2",value = "删除人员")
    public ResultObj deletePeople(@RequestParam(value = "pId") Integer pId){
        if(StringUtils.isEmpty(pId)){
            throw new CustomException(ResultCode.PARAM_NULL);
        }
        peopleSerivce.deleteById(pId);
        return ResultObj.ok();
    }

    @PostMapping("/queryPeopleByAreaId")
    @ApiOperation("查询指定区域下所有的人员信息")
    @SysLog(actionType = "4",value = "查询指定区域下所有的人员信息")
    public ResultObj<List<People>> queryPeopleByAreaId(@RequestParam("areaId")String areaId){
        if(StringUtils.isEmpty(areaId)){
            throw new CustomException(ResultCode.PARAM_NULL);
        }
        EntityWrapper<People> wrapper = new EntityWrapper<>();
        wrapper.eq("area_id",areaId);
        return new ResultObj<>(ResultCode.OK,peopleSerivce.selectList(wrapper));
    }



}