OemContractController.java 5.1 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 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132
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.*;
import com.boco.nbd.wios.manage.service.impl.OemContractService;
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.util.StringUtils;
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.util.List;

/**
 * 主机厂合同接口
 *
 * @author
 */
@RestController
@RequestMapping("api")
@Api(tags = "主机厂合同接口管理接口")
@ApiIgnore
public class OemContractController {
    @Autowired
    private OemContractService oemContractService;

    /**
     * 添加合同数据
     *
     * @param contractBo
     */
    @PostMapping(value = "oemContract/add")
    @ApiOperation(value = "添加合同数据")
    public BaseResponse<Object> add(OemContractBo contractBo) {
        if (contractBo.getStartTime() == null || contractBo.getEndTime() == null) {
            throw new ServiceException("缺少日期");
        }
        if (StringUtils.isEmpty(contractBo.getOemId())) {
            throw new ServiceException("缺少主机厂id");
        }
        oemContractService.add(contractBo);
        return new BaseResponse<>();
    }

    /**
     * 更新合同数据
     *
     * @param contractBo
     */
    @PostMapping(value = "oemContract/update")
    @ApiOperation(value = "更新合同数据")
    public BaseResponse<Object> update(OemContractBo contractBo) {
        Assert.notNull(contractBo.getId(), "缺少id");
        oemContractService.update(contractBo);
        return new BaseResponse<>();
    }

    /**
     * 查询列表
     *
     * @param oemContract
     * @return
     */
    @GetMapping(value = "oemContract/list")
    @ApiOperation(value = "查询合同列表")
    @ApiImplicitParams({@ApiImplicitParam(name = "page", value = "一页显示数量", dataType = "int", paramType = "query", required = false),
            @ApiImplicitParam(name = "pagecount", value = "页码", dataType = "int", paramType = "query", required = false),})
    public BaseResponse<List<OemContractVo>> list(OemContractBo2 oemContract) {
        return new BaseResponse<>(oemContractService.getList(oemContract));
    }

    /**
     * 查询合同详情
     *
     * @param id
     * @return
     */
    @GetMapping(value = "oemContract/detail")
    @ApiOperation(value = "查询合同详情")
    @ApiImplicitParams({@ApiImplicitParam(name = "id", value = "id", dataType = "int", paramType = "query", required = true)})
    public BaseResponse<OemContractVo> detail(Integer id) {
        Assert.notNull(id, WiosConstant.EMPTY_ID);
        return new BaseResponse<>(oemContractService.getDetail(id));
    }

    /**
     * 根据主机厂id查询合同详情
     *
     * @param oemId
     * @return
     */
    @GetMapping(value = "oemContract/detailByOemId")
    @ApiOperation(value = "根据主机厂id查询合同详情")
    @ApiImplicitParams({@ApiImplicitParam(name = "oemId", value = "主机厂id", dataType = "int", paramType = "query", required = true)})
    public BaseResponse<OemContractVo> detailByOemId(Integer oemId) {
        Assert.notNull(oemId, "oemId不能为空");
        return new BaseResponse<>(oemContractService.getDetailByOemId(oemId));
    }

    @GetMapping(value = "oemContract/getSupplierInstallDevice")
    @ApiOperation(value = "根据主机厂和墙盒类型查询安装设备详情")
    @ApiImplicitParams({@ApiImplicitParam(name = "oemId", value = "主机厂id", dataType = "int", paramType = "query", required = true),
            @ApiImplicitParam(name = "packType", value = "墙盒型号", dataType = "String", paramType = "query", required = true)})
    public BaseResponse<List<OemContractItemVo>> getSupplierInstallDevice(Integer oemId, String packType) {
        Assert.notNull(oemId, "oemId不能为空");
        Assert.notNull(packType, "packType不能为空");
        return new BaseResponse<>(oemContractService.getSupplierInstallDevice(oemId, packType));
    }

    /**
     * 根据主机厂id查询合同
     *
     * @param oemId
     * @return
     */
    @GetMapping(value = "oemContract/simpleByOemId")
    @ApiOperation(value = "根据主机厂id查询合同详情")
    @ApiImplicitParams({@ApiImplicitParam(name = "oemId", value = "主机厂id", dataType = "int", paramType = "query", required = true)})
    public BaseResponse<List<OemContract>> simpleByOemId(Integer oemId) {
        Assert.notNull(oemId, "oemId不能为空");
        return new BaseResponse<>(oemContractService.getSimpleContractByOemId(oemId));
    }
}