Newer
Older
casic-metering / casic-metering-api / src / main / java / com / casic / missiles / controller / MeterStaffController.java
xiezhuangzhuang on 29 Nov 2022 4 KB 计量人员相关接口开发
package com.casic.missiles.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.casic.missiles.core.page.PageFactory;
import com.casic.missiles.dto.IdDTO;
import com.casic.missiles.dto.ReturnDTO;
import com.casic.missiles.dto.ReturnUtil;
import com.casic.missiles.dto.meter.MeterStaffRequest;
import com.casic.missiles.model.MeterStaff;
import com.casic.missiles.model.UserInfo;
import com.casic.missiles.service.MeterStaffService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;

/**
 * <p>
 * 计量管理-计量人员-计量人员表 前端控制器
 * </p>
 *
 */
@Api(tags = "计量人员表接口")
@RestController
@RequestMapping("/staff")
public class MeterStaffController {

    @Resource
    private MeterStaffService meterStaffService;

    /**
     * 查询计量人员列表
     * @return
     */
    @ApiOperation("计量人员列表")
    @PostMapping("/selectStaffList")
    @ResponseBody
    public ReturnDTO<MeterStaff> listPage(@RequestBody MeterStaffRequest meterStaffRequest) {
        try {
            Page<MeterStaff> page = PageFactory.defaultPage();
            Page<MeterStaff> list = meterStaffService.selectStaffList(page,meterStaffRequest);
            return ReturnUtil.success(list);
        }catch (Exception e){
            e.printStackTrace();
            return ReturnUtil.failed("计量人员列表查询失败");
        }
    }
    /**
     * 计量人员新增
     * @return
     */
    @ApiOperation("计量人员新增")
    @PostMapping("/addStaffInfo")
    @ResponseBody
    public ReturnDTO addStaffInfo(@RequestBody MeterStaff MeterStaff) {
        try {
            meterStaffService.addStaffInfo(MeterStaff);
            return ReturnUtil.success();
        }catch (Exception e){
            e.printStackTrace();
            return ReturnUtil.failed("计量人员新增失败");
        }
    }

    /**
     * 计量人员编辑
     * @return
     */
    @ApiOperation("计量人员编辑")
    @PostMapping("/updateStaffInfo")
    @ResponseBody
    public ReturnDTO updateStaffInfo(@RequestBody MeterStaff MeterStaff) {
        try {
            meterStaffService.updateStaffInfo(MeterStaff);
            return ReturnUtil.success();
        }catch (Exception e){
            e.printStackTrace();
            return ReturnUtil.failed("计量人员编辑失败");
        }
    }

    /**
     * 人员详细信息
     */
    @ApiOperation("人员详细信息")
    @PostMapping("/selectStaffInfo")
    @ResponseBody
    public ReturnDTO<MeterStaff> selectStaffInfo(@RequestBody IdDTO idDto) {
        try {
            MeterStaff result = meterStaffService.selectStaffInfo(idDto);
            return ReturnUtil.success(result);
        }catch (Exception e){
            e.printStackTrace();
            return ReturnUtil.failed("计量人员详细查询失败");
        }
    }

    /**
     * 人员详细信息
     */
    @ApiOperation("计量人员删除")
    @PostMapping("/deleteStaff")
    @ResponseBody
    public ReturnDTO deleteStaff(@RequestBody IdDTO idDto) {
        try {
            meterStaffService.deleteStaff(idDto);
            return ReturnUtil.success();
        }catch (Exception e){
            e.printStackTrace();
            return ReturnUtil.failed("计量人员详细查询失败");
        }
    }

    /**
     * 选择人员列表查询
     */
    @ApiOperation("选择人员列表查询")
    @GetMapping("/getUserList")
    @ResponseBody
    public Object getUserList(String name,String deptId) {
        try {
            Page<UserInfo> page = PageFactory.defaultPage();
            Page<UserInfo> list = meterStaffService.getUserList(name,deptId,page);
            return ReturnUtil.success(list);
        }catch (Exception e){
            e.printStackTrace();
            return ReturnUtil.failed("计量人员详细查询失败");
        }
    }

    /**
     * 计量人员列表导出
     */
    @ApiOperation("计量人员列表导出")
    @PostMapping("/exportStaffList")
    @ResponseBody
    public void exportStaffList(@RequestBody MeterStaffRequest meterStaffRequest, HttpServletResponse response) {
        try {
            meterStaffService.exportStaffList(meterStaffRequest,response);
        }catch (Exception e){
            e.printStackTrace();
        }
    }

}