package com.product.administration.controller; import com.product.administration.config.CmnConst; import com.product.administration.config.SystemCode; import com.product.administration.service.CommonWordsService; import com.product.administration.service.ide.ICommonWordsService; import com.product.common.lang.StringUtils; import com.product.core.config.CoreConst; import com.product.core.controller.support.AbstractBaseController; import com.product.core.entity.DataTableEntity; 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.module.sys.version.ApiVersion; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; import javax.servlet.http.HttpServletRequest; /** * Copyright LX * @Title: CommonWordsController * @Project: product-server * @date: 2021-05-26 14:14 * @author: ZhouJie * @Description: 协同办公回复常用语 */ @RequestMapping("/api/common") @RestController public class CommonWordsController extends AbstractBaseController { @Autowired public CommonWordsService commonWordsService; /** * @description: 保存协同办公回复常用语 * @author: ZhouJie * @date: 2021-05-26 14:47 */ @RequestMapping(value = "/save-words/{version}", method = RequestMethod.POST) public String saveCommonWords(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) { SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText()); return this.error(SystemCode.SYSTEM_FORM_NODATA.getValue(), SystemCode.SYSTEM_FORM_NODATA.getText()); } //判断表名是否正常 if (!CmnConst.PRODUCT_OA_COOPERATE_COMMON_WORDS.equals(fse.getTableName())) { SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText()); return this.error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText()); } ICommonWordsService service = (ICommonWordsService) getProxyInstance(commonWordsService); String uuid = service.saveCommonWords(fse); if (!StringUtils.isEmpty(uuid)) { return OK_Add(uuid); } SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_COMMON_WORDS_SAVE_FAIL.getValue(), SystemCode.SYSTEM_COMMON_WORDS_SAVE_FAIL.getText()); return error(SystemCode.SYSTEM_COMMON_WORDS_SAVE_FAIL.getValue(), SystemCode.SYSTEM_COMMON_WORDS_SAVE_FAIL.getText()); }catch(BaseException e) { SpringMVCContextHolder.getSystemLogger().error(e); return this.error(e); }catch (Exception e) { SpringMVCContextHolder.getSystemLogger().error(e); return this.error(SystemCode.SYSTEM_COMMON_WORDS_SAVE_FAIL.getValue(), SystemCode.SYSTEM_COMMON_WORDS_SAVE_FAIL.getText()); } } /** * @description: 删除协同办公回复常用语 * @author: ZhouJie * @date: 2021-05-26 15:28 */ @RequestMapping(value = "/delete-words/{version}", method = RequestMethod.POST) @ApiVersion(1) public String deleteCommonWords(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) { SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_FORM_NODATA.getValue(), SystemCode.SYSTEM_FORM_NODATA.getText()); return this.error(SystemCode.SYSTEM_FORM_NODATA.getValue(), SystemCode.SYSTEM_FORM_NODATA.getText()); } //判断表名是否正常 if (!CmnConst.PRODUCT_OA_COOPERATE_COMMON_WORDS.equals(fse.getTableName())) { SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText()); return this.error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText()); } //判断uuid是否为空 if (com.alibaba.druid.util.StringUtils.isEmpty(fse.getString("uuid"))) { SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_FORM_COUNT.getValue(), SystemCode.SYSTEM_FORM_COUNT.getText()); return this.error(SystemCode.SYSTEM_FORM_COUNT.getValue(), SystemCode.SYSTEM_FORM_COUNT.getText()); } ICommonWordsService service = (ICommonWordsService) getProxyInstance(commonWordsService); boolean success=service.deleteCommonWords(fse); if(success) { return OK(); } SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_COMMON_WORDS_DELETE_FAIL.getValue(),SystemCode.SYSTEM_COMMON_WORDS_DELETE_FAIL.getText()); return error(SystemCode.SYSTEM_COMMON_WORDS_DELETE_FAIL.getValue(),SystemCode.SYSTEM_COMMON_WORDS_DELETE_FAIL.getText()); }catch(BaseException e) { SpringMVCContextHolder.getSystemLogger().error(e); return this.error(e); }catch (Exception e) { SpringMVCContextHolder.getSystemLogger().error(e); return this.error(SystemCode.SYSTEM_COMMON_WORDS_DELETE_FAIL.getValue(),SystemCode.SYSTEM_COMMON_WORDS_DELETE_FAIL.getText()); } } /** * @description: 查询协同办公回复常用语列表 * @author: ZhouJie * @date: 2021-05-26 15:50 */ @RequestMapping(value = "/list-words/{version}", method = RequestMethod.POST) public String CommonWordsList(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) { SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText()); return this.error(SystemCode.SYSTEM_FORM_NODATA.getValue(), SystemCode.SYSTEM_FORM_NODATA.getText()); } // 判断表名是否正常 if (!CmnConst.PRODUCT_OA_COOPERATE_COMMON_WORDS.equals(fse.getTableName())) { SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText()); return this.error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText()); } DataTableEntity dt = commonWordsService.CommonWordslist(fse); return OK_List(dt); } catch (BaseException e) { e.printStackTrace(); SpringMVCContextHolder.getSystemLogger().error(e); return this.error(e); } catch (Exception e) { e.printStackTrace(); SpringMVCContextHolder.getSystemLogger().error(e); return this.error(SystemCode.SYSTEM_COMMON_WORDS_LIST_FAIL.getValue(), SystemCode.SYSTEM_COMMON_WORDS_LIST_FAIL.getText()); } } /** * @description: 查询协同办公回复常用语详情 * @author: ZhouJie * @date: 2021-05-26 16:21 */ @RequestMapping(value = "/info-words/{version}", method = RequestMethod.POST) @ApiVersion(1) public String CommonWordsInfo(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) { SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_FORM_NODATA.getValue(), SystemCode.SYSTEM_FORM_NODATA.getText()); return this.error(SystemCode.SYSTEM_FORM_NODATA.getValue(), SystemCode.SYSTEM_FORM_NODATA.getText()); } // 判断表名是否正常 if (!CmnConst.PRODUCT_OA_COOPERATE_COMMON_WORDS.equals(fse.getTableName())) { SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText()); return this.error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText()); } // 判断uuid是否为空 if (com.alibaba.druid.util.StringUtils.isEmpty(fse.getString("uuid"))) { SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText()); return this.error(SystemCode.SYSTEM_FORM_COUNT.getValue(), SystemCode.SYSTEM_FORM_COUNT.getText()); } FieldSetEntity fs = commonWordsService.CommonWordsInfo(fse); return OK_List(fs); } catch (BaseException e) { e.printStackTrace(); SpringMVCContextHolder.getSystemLogger().error(e); return this.error(e); } catch (Exception e) { e.printStackTrace(); SpringMVCContextHolder.getSystemLogger().error(e); return this.error(SystemCode.SYSTEM_COMMON_WORDS_INFO_FAIL.getValue(), SystemCode.SYSTEM_COMMON_WORDS_INFO_FAIL.getText()); } } }