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


import cn.hutool.db.PageResult;
import com.alibaba.fastjson.JSONArray;
import com.newfiber.api.core.annotation.SysLog;
import com.newfiber.api.core.base.BaseController;
import com.newfiber.api.core.base.domain.Accessory;
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.DutyTeam;
import com.newfiber.api.pc.model.entity.PlanNew;
import com.newfiber.api.pc.model.entity.WaterloggingPoint;
import com.newfiber.api.pc.model.request.dutyTeam.DutyTeamPageQueryRequest;
import com.newfiber.api.pc.model.request.dutyTeam.DutyTeamQueryRequest;
import com.newfiber.api.pc.model.request.dutyTeam.DutyTeamSaveRequest;
import com.newfiber.api.pc.model.request.dutyTeam.DutyTeamUpdateRequest;
import com.newfiber.api.pc.service.IDutyTeamService;
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 javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.UnsupportedEncodingException;
import java.util.Date;
import java.util.List;

/**
 * 防汛应急指挥-应急队伍Controller
 * 
 * @author newfiber
 * @date 2024-07-25
 */
@RestController
@RequestMapping("/team")
@Api(value = "防汛应急指挥-应急队伍", tags = "防汛应急指挥-应急队伍")
public class DutyTeamController extends BaseController {

    @Resource
    private IDutyTeamService teamService;

    /**
     * 新增防汛应急指挥-应急队伍
     */
    @PostMapping("add")
    @ApiOperation(value = "新增防汛应急指挥-应急队伍", position = 10)
    @SysLog(actionType = "1",value =  "防汛应急指挥-应急队伍")
    public ResultObj add(@RequestBody DutyTeamSaveRequest 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,teamService.insert(request));
    }

    /**
     * 修改防汛应急指挥-应急队伍
     */
    @PutMapping("edit")
    @ApiOperation(value = "修改防汛应急指挥-应急队伍", position = 20)
    @SysLog(actionType = "2",value = "防汛应急指挥-应急队伍")
    public ResultObj edit(@RequestBody DutyTeamUpdateRequest request) {
        return new ResultObj<>(ResultCode.OK,teamService.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,teamService.delete(ids));
    }

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

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

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

    @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);
        }
        /*PlanNew meetPlan = planNewMapper.selectById(id);
        List<Accessory> accessoryList = JSONArray.parseArray(meetPlan.getPlanFile(), Accessory.class);
        String value = accessoryList.get(0).getUrl();
        planNewService.downloadFile(id,response);*/
    }

}