OrderInstallController.java 4.0 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
package com.boco.nbd.wios.manage.controller;

import cn.hutool.core.lang.Assert;
import com.boco.nbd.cams.core.constant.MessageConstant;
import com.boco.nbd.wios.manage.contants.WiosConstant;
import com.boco.nbd.wios.manage.entity.bo.OrderInstallBo;
import com.boco.nbd.wios.manage.entity.bo.OrderInstallVo;
import com.boco.nbd.wios.manage.service.impl.OrderInstallService;
import com.ihidea.component.api.v2.BaseResponse;
import com.ihidea.core.support.exception.ServiceException;
import com.ihidea.core.util.StringUtilsEx;
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;

/**
 * 安装订单管理接口
 * 
 * @author xgl
 * @version [版本号, 2020年9月25日]
 */
@RestController
@RequestMapping("api")
@Api(tags = "安装订单管理接口")
@ApiIgnore
public class OrderInstallController {
    @Autowired
    private OrderInstallService orderInstallService;
    
    /**
     * 添加安装订单
     *
     * @param orderInstall
     * @return
     */
    @PostMapping(value = "orderInstall/add")
    @ApiOperation(value = "添加安装订单信息")
    @ApiImplicitParams({@ApiImplicitParam(name = "orderId", value = "订单id", dataType = "String", paramType = "query", required = true)})
    public BaseResponse<Object> add(OrderInstallBo orderInstall) {
        Assert.notNull(orderInstall.getOrderId(), "orderId不能为空");
        if (!StringUtils.isEmpty(orderInstall.getPredictOverItem())) {
            orderInstall.setPredictOverItem(StringUtilsEx.unescapeXss(orderInstall.getPredictOverItem()));
        }
        if (!StringUtils.isEmpty(orderInstall.getDebugCheck())) {
            orderInstall.setDebugCheck(StringUtilsEx.unescapeXss(orderInstall.getDebugCheck()));
        }
        orderInstallService.add(orderInstall);
        return new BaseResponse<>();
    }
    
    /**
     * 修改安装订单
     *
     * @param orderInstall
     * @return
     */
    @PostMapping(value = "orderInstall/update")
    @ApiOperation(value = "修改安装订单信息")
    @ApiImplicitParams({@ApiImplicitParam(name = "id", value = "安装订单id", dataType = "int", paramType = "query", required = true)})
    public BaseResponse<Object> update(OrderInstallBo orderInstall) {
        if (orderInstall.getId() == null) {
            throw new ServiceException(MessageConstant.MISSING_PARAM);
        }
        if (!StringUtils.isEmpty(orderInstall.getPredictOverItem())) {
            orderInstall.setPredictOverItem(StringUtilsEx.unescapeXss(orderInstall.getPredictOverItem()));
        }
        if (!StringUtils.isEmpty(orderInstall.getDebugCheck())) {
            orderInstall.setDebugCheck(StringUtilsEx.unescapeXss(orderInstall.getDebugCheck()));
        }
        // 已支付订单不能修改增项信息
        if (orderInstall.getParkingType() != null && orderInstall.getParkingType().intValue() == 1) {
            orderInstall.setPredictOverItem(null);
        }
        orderInstallService.update(orderInstall.getId(), orderInstall);
        return new BaseResponse<>();
    }
    
    /**
     * 查询安装订单详情
     *
     * @param orderId
     * @return
     */
    @GetMapping(value = "orderInstall/detail")
    @ApiOperation(value = "查询安装订单详情")
    @ApiImplicitParam(paramType = "query", name = "orderId", value = "订单id", required = true, dataType = "String")
    public BaseResponse<OrderInstallVo> get(String orderId) {
        Assert.notNull(orderId, "orderId不能为空");
        OrderInstallVo orderInstall = orderInstallService.getByOrderId(orderId);
        return new BaseResponse<>(orderInstall);
    }
}