package com.product.admin.controller; import com.alibaba.druid.util.StringUtils; import com.product.admin.config.CmnConst; import com.product.admin.config.SystemCode; import com.product.admin.service.idel.ISystemFaceService; import com.product.core.config.CoreConst; import com.product.core.controller.support.AbstractBaseController; 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 com.product.util.BaseUtil; 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; /** * @Author cheng * @Description * @Date 2021/9/6 17:25 * @Version 1.0 */ @RestController @RequestMapping("/api/system/face") public class SystemFaceController extends AbstractBaseController { @Autowired ISystemFaceService systemFaceService; /** * 获取模块功能树 * @return * @throws BaseException */ @PostMapping("/tree/{version}") @ApiVersion(1) public String getModuleFunctionTree(HttpServletRequest request){ try { return BaseUtil.success(systemFaceService.getModuleFunctionTree()); } catch (BaseException e) { SpringMVCContextHolder.getSystemLogger().error(e); e.printStackTrace(); return this.error(e); }catch (Exception e){ SpringMVCContextHolder.getSystemLogger().error(e); e.printStackTrace(); return error(SystemCode.GET_FUNCTION_TREE_FAIL.getValue(),SystemCode.GET_FUNCTION_TREE_FAIL.getText()+e.getMessage()); } } /** * 表单列表 * * @return * @throws BaseException */ @PostMapping("/list/{version}") @ApiVersion(1) public String getFaceList(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 (fse.getTableName() == null || !CmnConst.PRODUCT_SYS_FACE.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()); } // 判断分页参数是否正常 if (StringUtils.isEmpty(fse.getString(CmnConst.PAGESIZE)) || StringUtils.isEmpty(fse.getString(CmnConst.CPAGE))) { 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()); } return OK_List(systemFaceService.getFaceList(fse)); } catch (BaseException e) { SpringMVCContextHolder.getSystemLogger().error(e); e.printStackTrace(); return this.error(e); }catch (Exception e){ SpringMVCContextHolder.getSystemLogger().error(e); e.printStackTrace(); return error(SystemCode.GET_FACE_LIST_FAIL.getValue(),SystemCode.GET_FACE_LIST_FAIL.getText()+e.getMessage()); } } /** * 获取表单详情根据uuid * * @param request * @return * @throws BaseException */ @PostMapping("/find-info/{version}") @ApiVersion(1) public String getFaceInfoByUuid(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 (fse.getTableName() == null || !CmnConst.PRODUCT_SYS_FACE.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()); } // 判断分页参数是否正常 if (StringUtils.isEmpty(fse.getString(CmnConst.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()); } return OK_List(systemFaceService.getFaceInfoByUuid(fse)); } catch (BaseException e) { SpringMVCContextHolder.getSystemLogger().error(e); e.printStackTrace(); return this.error(e); } catch (Exception e) { SpringMVCContextHolder.getSystemLogger().error(e); e.printStackTrace(); return error(SystemCode.GET_FACE_LIST_FAIL.getValue(), SystemCode.GET_FACE_LIST_FAIL.getText() + e.getMessage()); } } /** * 保存表单详情根据uuid * * @param request * @return * @throws BaseException */ @PostMapping("/save/{version}") @ApiVersion(1) public String saveFaceInfo(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 (fse.getTableName() == null || !CmnConst.PRODUCT_SYS_FACE.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()); } ISystemFaceService proxyInstance =(ISystemFaceService) this.getProxyInstance(systemFaceService); return OK_Add(proxyInstance.saveFaceInfo(fse)); } catch (BaseException e) { SpringMVCContextHolder.getSystemLogger().error(e); e.printStackTrace(); return this.error(e); } catch (Exception e) { SpringMVCContextHolder.getSystemLogger().error(e); e.printStackTrace(); return error(SystemCode.GET_FACE_LIST_FAIL.getValue(), SystemCode.GET_FACE_LIST_FAIL.getText() + e.getMessage()); } } /** * 删除表单详情根据uuid * * @param request * @return * @throws BaseException */ @PostMapping("/delete/{version}") @ApiVersion(1) public String delteFaceInfoByUuids(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 (fse.getTableName() == null || !CmnConst.PRODUCT_SYS_FACE.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()); } // 判断分页参数是否正常 if (StringUtils.isEmpty(fse.getString(CmnConst.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()); } ISystemFaceService proxyInstance =(ISystemFaceService) this.getProxyInstance(systemFaceService); return proxyInstance.deleteFaceInfoByUuids(fse.getUUID().split(","))?OK():error(SystemCode.DEL_FACE_INFO_FAIL.getValue(), SystemCode.DEL_FACE_INFO_FAIL.getText()); } catch (BaseException e) { SpringMVCContextHolder.getSystemLogger().error(e); e.printStackTrace(); return this.error(e); } catch (Exception e) { SpringMVCContextHolder.getSystemLogger().error(e); e.printStackTrace(); return error(SystemCode.DEL_FACE_INFO_FAIL.getValue(), SystemCode.DEL_FACE_INFO_FAIL.getText() + e.getMessage()); } } /** * 删除表单详情根据uuid * * @param request * @return * @throws BaseException */ @PostMapping("/get-field-list/{version}") @ApiVersion(1) public String getFaceFieldList(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 (fse.getTableName() == null || !CmnConst.PRODUCT_SYS_FACE.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()); } // 判断分页参数是否正常 if (StringUtils.isEmpty(fse.getString("face_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()); } return BaseUtil.success(systemFaceService.getFaceFieldList(fse.getString("face_uuid"))); } catch (BaseException e) { SpringMVCContextHolder.getSystemLogger().error(e); e.printStackTrace(); return this.error(e); } catch (Exception e) { SpringMVCContextHolder.getSystemLogger().error(e); e.printStackTrace(); return error(SystemCode.GET_LIST_FIELD_FAIL.getValue(), SystemCode.GET_LIST_FIELD_FAIL.getText() + e.getMessage()); } } }