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

import java.io.*;
import java.net.URLEncoder;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import cn.hutool.db.PageResult;
import com.newfiber.api.core.annotation.SysLog;
import com.newfiber.api.core.base.BaseController;
import com.newfiber.api.core.commons.CustomException;
import com.newfiber.api.core.commons.PageResultObject;
import com.newfiber.api.core.commons.ResultCode;
import com.newfiber.api.core.commons.ResultObj;
import com.newfiber.api.pc.camera.dto.Result;
import com.newfiber.api.pc.model.entity.PlanNew;
import com.newfiber.api.pc.model.entity.PlanTypeNew;
import com.newfiber.api.pc.model.meet.MeetPlan;
import com.newfiber.api.pc.model.meet.MeetPlanFile;
import com.newfiber.api.pc.model.request.planNew.PlanNewPageQueryRequest;
import com.newfiber.api.pc.model.request.planNew.PlanNewQueryRequest;
import com.newfiber.api.pc.model.request.planNew.PlanNewSaveRequest;
import com.newfiber.api.pc.model.request.planNew.PlanNewUpdateRequest;
import com.newfiber.api.pc.service.IPlanNewService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.java.Log;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;


/**
 * 防汛应急指挥-应急预案Controller
 * 
 * @author newfiber
 * @date 2024-07-23
 */
@RestController
@RequestMapping("/planNew")
@Api(value = "防汛应急指挥-应急预案", tags = "防汛应急指挥-应急预案")
public class PlanNewController extends BaseController {

    @Resource
    private IPlanNewService planNewService;

    /**
     * 新增防汛应急指挥-应急预案
     */
    @PostMapping("add")
    @ApiOperation(value = "新增防汛应急指挥-应急预案", position = 10)
    @SysLog(actionType = "1",value = "分页显示预案")
    public ResultObj add(@RequestBody PlanNewSaveRequest request, HttpServletRequest httpServletRequest) {
        String userNo = httpServletRequest.getHeader("userNo");
        if(StringUtils.isEmpty(request)){
            throw new CustomException(ResultCode.PARAM_NULL);
        }
        request.setCreateBy(userNo);
        request.setCreateTime(new Date());
        return new ResultObj<>(ResultCode.OK,planNewService.insert(request));
    }

    /**
     * 修改防汛应急指挥-应急预案
     */
    @PutMapping("edit")
    @ApiOperation(value = "修改防汛应急指挥-应急预案", position = 20)
    @SysLog(actionType = "2",value = "分页显示预案")
    public ResultObj edit(@RequestBody PlanNewUpdateRequest request) {
        return new ResultObj<>(ResultCode.OK,planNewService.update(request));
    }

    /**
     * 删除防汛应急指挥-应急预案
     */
    @DeleteMapping("/{ids}")
    @ApiOperation(value = "删除防汛应急指挥-应急预案", notes = "传入ids(,隔开)", position = 30)
    @SysLog(actionType = "3",value = "分页显示预案")
    public ResultObj remove(@PathVariable String ids) {
        return new ResultObj<>(ResultCode.OK,planNewService.delete(ids));
    }

    /**
     * 详细查询防汛应急指挥-应急预案
     */
    @GetMapping(value = "/{id}")
    @ApiOperation(value = "详细查询防汛应急指挥-应急预案", position = 40)
    public ResultObj detail(@PathVariable("id") Long id) {
        return new ResultObj<>(ResultCode.OK,planNewService.selectDetail(id));
    }

    /**
     * 分页查询防汛应急指挥-应急预案
     */
    @GetMapping("/page")
    @ApiOperation(value = "分页查询防汛应急指挥-应急预案", position = 50)
    public ResultObj<PageResultObject<PlanNew>> page(PlanNewPageQueryRequest request) {
        return new ResultObj<PageResultObject<PlanNew>>(ResultCode.OK,planNewService.selectPage(request));
    }

    /**
     * 列表查询防汛应急指挥-应急预案
     */
    @GetMapping("/list")
    @ApiOperation(value = "列表查询防汛应急指挥-应急预案", position = 60)
    public ResultObj<List<PlanNew>> list(PlanNewQueryRequest request) {
        List<PlanNew> list = planNewService.selectList(request);
        return new ResultObj<>(ResultCode.OK,list);
    }

    /**
     * 列表查询防汛应急指挥-应急预案-预案类型
     */
    @GetMapping("/listPlanType")
    @ApiOperation(value = "列表查询防汛应急指挥-应急预案-预案类型", position = 70)
    public ResultObj<List<PlanTypeNew>> list() {
        return new ResultObj<>(ResultCode.OK,planNewService.selectPlanTypeNewList());
    }

    @PostMapping("/downloadFile")
    @ApiOperation("文件下载")
    @SysLog(actionType = "2",value = "文件下载")
    public void downloadFile(@RequestParam("id")Long id, HttpServletResponse response) throws UnsupportedEncodingException {
        if(StringUtils.isEmpty(id)){
            throw new CustomException(ResultCode.PARAM_NULL);
        }
        planNewService.downloadFile(id,response);
    }

}