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

import com.newfiber.api.core.annotation.SysLog;
import com.newfiber.api.core.commons.*;
import com.newfiber.api.core.utils.StringUtil;
import com.newfiber.api.pc.dto.SiteSubDTO;
import com.newfiber.api.pc.model.meet.HouseSiteSupplies;
import com.newfiber.api.pc.model.vo.AlertReturnVo;
import com.newfiber.api.pc.service.HouseSiteSuppliesService;
import com.newfiber.api.pc.service.ReturnGoodsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Author:zzh
 * @CreateDate:2020/11/25 13:37
 * @Description:
 */
@RestController
@RequestMapping("/supplies")
@Api(value = "HouseSiteSuppliesController",tags = "物资管理")
public class HouseSiteSuppliesController {

    @Autowired
    private HouseSiteSuppliesService houseSiteSuppliesService;
    @Autowired
    private ReturnGoodsService returnGoodsService;

    @PostMapping("/selectHouse")
    @ApiOperation("根据存放点id查找该底下的所有物资-不分页")
    @SysLog(actionType = "4",value = "根据存放点id查找该底下的所有物资-不分页")
    public ResultObj<List<HouseSiteSupplies>> querySupByHouseSiteId(@RequestParam("hId") Integer hId){
        return new ResultObj<List<HouseSiteSupplies>>(ResultCode.OK,houseSiteSuppliesService.querySupByHouseSiteId(hId));
    }

    @PostMapping("/queryPage")
    @ApiOperation("根据存放点id分页查询物资数据")
    @SysLog(actionType = "4",value = "根据存放点id分页查询物资数据")
    public ResultObj<PageResultObject<HouseSiteSupplies>> queryPage(@RequestBody PageRequestObject<SiteSubDTO> pageRequestObject){
        return new ResultObj(ResultCode.OK,houseSiteSuppliesService.queryPage(pageRequestObject));
    }

    @PostMapping("/add")
    @ApiOperation("根据存放点添加对应的物资")
    @SysLog(actionType = "1",value = "根据存放点添加对应的物资")
    public ResultObj addHouseSiteSup(@RequestBody HouseSiteSupplies houseSiteSupplies){
        if(StringUtils.isEmpty(houseSiteSupplies.getHId())){
            throw new CustomException(ResultCode.PARAM_NULL);
        }
        houseSiteSuppliesService.addHouseSiteSup(houseSiteSupplies);

        return ResultObj.ok();
    }

    @PostMapping("/selectById")
    @ApiOperation("根据物资主键id查找当前物资数据")
    @SysLog(actionType = "4",value = "根据物资主键id查找当前物资数据")
    public ResultObj selectById(@RequestParam("id")Integer id){
        if(StringUtils.isEmpty(id)){
            throw new CustomException(ResultCode.PARAM_NULL);
        }
        return new ResultObj(ResultCode.OK,houseSiteSuppliesService.selectById(id));
    }


    @PostMapping("/update")
    @ApiOperation("修改物资数据")
    @SysLog(actionType = "3",value = "修改物资数据")
    public ResultObj updateHouseSiteSup(@RequestBody HouseSiteSupplies houseSiteSupplies){
        if(StringUtils.isEmpty(houseSiteSupplies.getSupId())){
            throw new CustomException(ResultCode.PARAM_NULL);
        }
        houseSiteSuppliesService.updateHouseSiteSup(houseSiteSupplies);

        return ResultObj.ok();
    }

    @PostMapping("/delete")
    @ApiOperation("删除物资-批量")
    @SysLog(actionType = "2",value = "删除物资-批量")
    public ResultObj deleteHouseSiteSup(@RequestParam("id")Integer id,@RequestParam("hId")Integer hId){
        if(StringUtils.isEmpty(id) ||  StringUtils.isEmpty(hId)){
            throw new CustomException(ResultCode.PARAM_NULL);
        }
        houseSiteSuppliesService.deleteHouseSiteSup(id,hId);
        return ResultObj.ok();
    }


}