| | |
| | | package com.product.face.controller; |
| | | |
| | | import com.drew.metadata.Face; |
| | | import com.product.core.cache.DataPoolCacheImpl; |
| | | import com.product.core.config.CoreConst; |
| | | import com.product.core.entity.DataTableEntity; |
| | | import com.product.core.entity.FieldSetEntity; |
| | | import com.product.core.exception.BaseException; |
| | | import com.product.core.spring.context.SpringMVCContextHolder; |
| | |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * @Author cheng |
| | |
| | | @RequestMapping("/api/face-design") |
| | | public class FaceDesignController extends AbstractBaseController { |
| | | |
| | | @Resource |
| | | private IFaceDesignService faceDesignService; |
| | | @Resource |
| | | private IFaceDesignService faceDesignService; |
| | | |
| | | /** |
| | | * 查询表单设计数据详情 |
| | | * |
| | | * @param request |
| | | * @return |
| | | */ |
| | | @PostMapping("/find-face-config/{version}") |
| | | @ApiVersion(1) |
| | | public String findFaceConfig(HttpServletRequest request) { |
| | | try { |
| | | FieldSetEntity fse = BaseUtil.getFieldSetEntity(request, FaceConst.TABLE_FACE_CONFIG); |
| | | String uuid = fse.getUUID(); |
| | | return faceDesignService.getFaceConfigInfo(uuid); |
| | | } catch (BaseException e) { |
| | | e.printStackTrace(); |
| | | return error(e); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return error(ErrorCode.SAVE_FACE_FAIL, e); |
| | | } |
| | | } |
| | | /** |
| | | * 表单列表左侧树 |
| | | * |
| | | * @return |
| | | */ |
| | | @PostMapping("/tree-face/{version}") |
| | | @ApiVersion(1) |
| | | public String faceListTree() { |
| | | DataTableEntity tableInfoData = DataPoolCacheImpl.getInstance().getCacheData("所有表信息"); |
| | | List<Map<String, Object>> resultList = new ArrayList<>(); |
| | | if (!DataTableEntity.isEmpty(tableInfoData)) { |
| | | for (int i = 0; i < tableInfoData.getRows(); i++) { |
| | | FieldSetEntity fse = tableInfoData.getFieldSetEntity(i); |
| | | Map<String, Object> record = new HashMap<>(); |
| | | String tableName = fse.getString(FaceConst.FIELD_TABLE_NAME); |
| | | String value = fse.getString(FaceConst.UUID); |
| | | String tableType = fse.getString(FaceConst.FIELD_TABLE_TYPE); |
| | | String tableDescription = fse.getString("table_description"); |
| | | record.put("value", value); |
| | | record.put(FaceConst.FIELD_TABLE_NAME, tableName); |
| | | record.put(FaceConst.FIELD_TABLE_TYPE, tableType); |
| | | record.put("table_description", tableDescription); |
| | | resultList.add(record); |
| | | } |
| | | resultList.sort(Comparator.comparing(o -> o.get(FaceConst.FIELD_TABLE_TYPE).toString())); |
| | | } |
| | | return success(resultList); |
| | | } |
| | | |
| | | /** |
| | | * 保存表单设计数据 |
| | | * |
| | | * @param request |
| | | * @return |
| | | */ |
| | | @PostMapping("/save-face/{version}") |
| | | @ApiVersion(1) |
| | | public String saveFaceData(HttpServletRequest request) { |
| | | try { |
| | | FieldSetEntity fse = BaseUtil.getFieldSetEntity(request, FaceConst.TABLE_FACE_CONFIG); |
| | | IFaceDesignService proxy = getProxy(); |
| | | return OK_List(proxy.saveFaceData(fse)); |
| | | } catch (BaseException e) { |
| | | e.printStackTrace(); |
| | | return error(e); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return error(ErrorCode.SAVE_FACE_FAIL, e); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 获取事务代理 |
| | | * |
| | | * @return |
| | | */ |
| | | private IFaceDesignService getProxy() { |
| | | return (IFaceDesignService) getProxyInstance(faceDesignService); |
| | | } |
| | | /** |
| | | * 查询表单设计数据详情 |
| | | * |
| | | * @param request |
| | | * @return |
| | | */ |
| | | @PostMapping("/find-face-config/{version}") |
| | | @ApiVersion(1) |
| | | public String findFaceConfig(HttpServletRequest request) { |
| | | try { |
| | | FieldSetEntity fse = BaseUtil.getFieldSetEntity(request, FaceConst.TABLE_FACE_CONFIG); |
| | | String uuid = fse.getUUID(); |
| | | return faceDesignService.getFaceConfigInfo(uuid); |
| | | } catch (BaseException e) { |
| | | e.printStackTrace(); |
| | | return error(e); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return error(ErrorCode.SAVE_FACE_FAIL, e); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 保存表单设计数据 |
| | | * |
| | | * @param request |
| | | * @return |
| | | */ |
| | | @PostMapping("/save-face/{version}") |
| | | @ApiVersion(1) |
| | | public String saveFaceData(HttpServletRequest request) { |
| | | try { |
| | | FieldSetEntity fse = BaseUtil.getFieldSetEntity(request, FaceConst.TABLE_FACE_CONFIG); |
| | | IFaceDesignService proxy = getProxy(); |
| | | return OK_List(proxy.saveFaceData(fse)); |
| | | } catch (BaseException e) { |
| | | e.printStackTrace(); |
| | | return error(e); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return error(ErrorCode.SAVE_FACE_FAIL, e); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 删除表单设计 |
| | | * |
| | | * @param request |
| | | * @return |
| | | */ |
| | | @PostMapping("/delete-face/{version}") |
| | | @ApiVersion(1) |
| | | public String deleteFace(HttpServletRequest request) { |
| | | try { |
| | | FieldSetEntity fse = BaseUtil.getFieldSetEntity(request, FaceConst.TABLE_FACE_CONFIG); |
| | | IFaceDesignService proxy = getProxy(); |
| | | proxy.deleteFace(fse); |
| | | return OK(); |
| | | } catch (BaseException e) { |
| | | e.printStackTrace(); |
| | | return error(e); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return error(ErrorCode.DELETE_FACE_FAIL, e); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 获取事务代理 |
| | | * |
| | | * @return |
| | | */ |
| | | private IFaceDesignService getProxy() { |
| | | return (IFaceDesignService) getProxyInstance(faceDesignService); |
| | | } |
| | | |
| | | |
| | | } |