SupplierContractController.java 4.6 KB
Newer Older
苗卫卫 committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
package com.boco.nbd.wios.manage.controller;

import cn.hutool.core.lang.Assert;
import com.boco.nbd.wios.manage.contants.WiosConstant;
import com.boco.nbd.wios.manage.entity.bo.SupplierContractBo;
import com.boco.nbd.wios.manage.entity.bo.SupplierContractVo;
import com.boco.nbd.wios.manage.service.impl.SupplierContractService;
import com.ihidea.component.api.v2.BaseResponse;
import com.ihidea.core.support.exception.ServiceException;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;

import java.math.BigDecimal;

/**
 * 服务商合约接口
 * 
 * @author
 * @version
 */
@RestController
@RequestMapping("api")
@Api(tags = "服务商合同管理接口")
@ApiIgnore
public class SupplierContractController {
    @Autowired
    private SupplierContractService supplierContractService;
    
    /**
     * 添加合同数据
     *
     * @param contractBo
     */
    @PostMapping(value = "supplierContract/add")
    @ApiOperation(value = "添加合同数据")
    @ApiImplicitParams({@ApiImplicitParam(name = "code", value = "合同编号", dataType = "String", paramType = "query", required = true),
        @ApiImplicitParam(name = "supplierId", value = "服务商id", dataType = "int", paramType = "query", required = true),
        @ApiImplicitParam(name = "taxRate", value = "税率", dataType = "double", paramType = "query", required = true),
    
    })
    public BaseResponse<Object> add(SupplierContractBo contractBo) {
        if (contractBo.getStartTime() == null || contractBo.getEndTime() == null) {
            throw new ServiceException("缺少日期");
        }
        supplierContractService.add(contractBo);
        return new BaseResponse<>();
    }
    
    /**
     * 更新合同数据
     *
     * @param contractBo
     */
    @PostMapping(value = "supplierContract/update")
    @ApiOperation(value = "更新合同数据")
    @ApiImplicitParams({@ApiImplicitParam(name = "id", value = "合同id", dataType = "int", paramType = "query", required = true),
    
    })
    public BaseResponse<Object> update(SupplierContractBo contractBo) {
        Assert.notNull(contractBo.getId(), "缺少id");
        supplierContractService.update(contractBo);
        return new BaseResponse<>();
    }
    
    /**
     * 查询列表
     * @param code
     * @param supplierName
     * @param taxRate
     * @param status
     * @return
     */
    @GetMapping(value = "supplierContract/list")
    @ApiOperation(value = "查询合同列表")
    @ApiImplicitParams({@ApiImplicitParam(name = "page", value = "一页显示数量", dataType = "int", paramType = "query", required = false),
        @ApiImplicitParam(name = "pagecount", value = "页码", dataType = "int", paramType = "query", required = false),
        @ApiImplicitParam(name = "code", value = "合同编号", dataType = "int", paramType = "query", required = false),
        @ApiImplicitParam(name = "supplierName", value = "服务商名称", dataType = "String", paramType = "query", required = false),
        @ApiImplicitParam(name = "taxRate", value = "税率", dataType = "double", paramType = "query", required = false),
        @ApiImplicitParam(name = "status", value = "状态", dataType = "int", paramType = "query", required = false),})
    public BaseResponse<Object> list(String code, String supplierName, BigDecimal taxRate, Integer status) {
        SupplierContractBo supplierContract = new SupplierContractBo();
        supplierContract.setCode(code);
        supplierContract.setSupplierName(supplierName);
        supplierContract.setTaxRate(taxRate);
        supplierContract.setStatus(status);
        return new BaseResponse<>(supplierContractService.getList(supplierContract));
    }
    
    /**
     * 查询合同详情
     *
     * @param id
     * @return
     */
    @GetMapping(value = "supplierContract/detail")
    @ApiOperation(value = "查询合同详情")
    @ApiImplicitParams({@ApiImplicitParam(name = "id", value = "id", dataType = "int", paramType = "query", required = true)})
    public BaseResponse<SupplierContractVo> detail(Integer id) {
        Assert.notNull(id, WiosConstant.EMPTY_ID);
        return new BaseResponse<>(supplierContractService.getDetail(id));
    }
}