| | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.doumee.core.constants.ResponseStatus; |
| | | import com.doumee.core.exception.BusinessException; |
| | | import com.doumee.core.model.PageData; |
| | | import com.doumee.core.model.PageWrap; |
| | | import com.doumee.core.utils.xpyun.XpyunPrintService; |
| | | import com.doumee.core.utils.xpyun.XpyunResponse; |
| | | import com.doumee.dao.business.PrinterInfoMapper; |
| | | import com.doumee.dao.business.model.PrinterInfo; |
| | | import com.doumee.service.business.PrinterInfoService; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.CollectionUtils; |
| | |
| | | @Autowired |
| | | private PrinterInfoMapper printerInfoMapper; |
| | | |
| | | @Autowired |
| | | private XpyunPrintService xpyunPrintService; |
| | | |
| | | @Override |
| | | public Integer create(PrinterInfo printerInfo) { |
| | | if (StringUtils.isBlank(printerInfo.getSn())) { |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "打印机SN不能为空"); |
| | | } |
| | | if (StringUtils.isBlank(printerInfo.getName())) { |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "打印机名称不能为空"); |
| | | } |
| | | XpyunResponse response = xpyunPrintService.addPrinter(printerInfo.getSn(), printerInfo.getName()); |
| | | if (response.getCode() != 0) { |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "芯烨云添加打印机失败:" + response.getMsg()); |
| | | } |
| | | printerInfoMapper.insert(printerInfo); |
| | | return printerInfo.getId(); |
| | | } |