package com.product.print.controller; import com.product.common.lang.StringUtils; import com.product.core.config.CoreConst; import com.product.core.entity.FieldMetaEntity; import com.product.core.entity.FieldSetEntity; import com.product.core.entity.RequestParameterEntity; import com.product.core.exception.BaseException; import com.product.core.spring.context.SpringMVCContextHolder; import com.product.core.util.JsonUtil; import com.product.module.sys.version.ApiVersion; import com.product.print.config.CmnCode; import com.product.print.config.CmnConst; import com.product.print.service.ide.IPrintConfigService; import com.product.util.BaseUtil; import com.product.util.support.AbstractBaseController; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import javax.servlet.http.HttpServletRequest; /** * @ClassName PrintConfigContorller * @Description 打印配置 控制层 * @Author cheng * @Date 2021/11/30 15:44 */ @RequestMapping("api/print/config") @RestController public class PrintConfigController extends AbstractBaseController { @Autowired IPrintConfigService printConfigService; /** * 打印配置列表 * * @param request * @return */ @PostMapping("/list-print-config/{version}") @ApiVersion(1) public String listPrintConfig(HttpServletRequest request) { try { FieldSetEntity fse = null; Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA); if (bean != null) { RequestParameterEntity reqp = (RequestParameterEntity) bean; fse = reqp.getFormData(); } if (bean == null || fse == null) { return this.error(CmnCode.SYSTEM_FORM_NODATA); } if (!CmnConst.TABLE_PRINT_CONFIG.equals(fse.getTableName())) { return error(CmnCode.SYSTEM_TABLE_NODATA); } if (!BaseUtil.pageParameterVerification(fse)) { return error(CmnCode.SYSTEM_PAGE_NOT_NULL); } return OK_List(this.printConfigService.getPublicService().listTable(fse)); } catch (BaseException e) { return error(e); } catch (Exception e) { return error(CmnCode.GET_PRINT_CONFIG_LIST_FAIL, e); } } /** * 查询打印配置 * * @param request * @return */ @PostMapping("/find-print-config/{version}") @ApiVersion(1) public String findPrintConfig(HttpServletRequest request) { try { FieldSetEntity fse = null; Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA); if (bean != null) { RequestParameterEntity reqp = (RequestParameterEntity) bean; fse = reqp.getFormData(); } if (bean == null || fse == null) { return this.error(CmnCode.SYSTEM_FORM_NODATA); } if (!CmnConst.TABLE_PRINT_CONFIG.equals(fse.getTableName())) { return error(CmnCode.SYSTEM_TABLE_NODATA); } if (StringUtils.isEmpty(fse.getString(CmnConst.UUID))) { return error(CmnCode.SYSTEM_FORM_COUNT); } return OK_List(printConfigService.getPublicService().getFieldSetEntity(fse, false)); } catch (BaseException e) { return error(e); } catch (Exception e) { return error(CmnCode.GET_PRINT_CONFIG_LIST_FAIL, e); } } /** * 保存打印配置 * * @param request * @return */ @PostMapping("/save-print-config/{version}") @ApiVersion(1) public String savePrintConfig(HttpServletRequest request) { try { FieldSetEntity fse = null; Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA); if (bean != null) { RequestParameterEntity reqp = (RequestParameterEntity) bean; fse = reqp.getFormData(); } if (bean == null || fse == null) { return this.error(CmnCode.SYSTEM_FORM_NODATA); } if (!CmnConst.TABLE_PRINT_CONFIG.equals(fse.getTableName())) { return error(CmnCode.SYSTEM_TABLE_NODATA); } printConfigService.getPublicService().saveFieldSetEntity(fse); return OK(); } catch (BaseException e) { return error(e); } catch (Exception e) { return error(CmnCode.GET_PRINT_CONFIG_LIST_FAIL, e); } } /** * 删除打印配置 * * @param request * @return */ @PostMapping("/del-print-config/{version}") @ApiVersion(1) public String delPrintConfig(HttpServletRequest request) { try { FieldSetEntity fse = null; Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA); if (bean != null) { RequestParameterEntity reqp = (RequestParameterEntity) bean; fse = reqp.getFormData(); } if (bean == null || fse == null) { return this.error(CmnCode.SYSTEM_FORM_NODATA); } if (!CmnConst.TABLE_PRINT_CONFIG.equals(fse.getTableName())) { return error(CmnCode.SYSTEM_TABLE_NODATA); } if (StringUtils.isEmpty(fse.getString(CmnConst.UUID))) { return error(CmnCode.SYSTEM_FORM_COUNT); } printConfigService.getPublicService().delete(fse); return OK(); } catch (BaseException e) { return error(e); } catch (Exception e) { return error(CmnCode.GET_PRINT_CONFIG_LIST_FAIL, e); } } }