| | |
| | | if (StringUtils.isEmpty(tableName)) { |
| | | return Result.error(CodeMsg.ERROR_PARAMS_NOT_MATHED); |
| | | } |
| | | List<SysField> fieldList = fieldService.selectList(new EntityWrapper<SysField>().eq("table_name", tableName).orderBy("order_no")); |
| | | |
| | | List<SysField> fieldList = fieldService.getFieldByTable(tableName); |
| | | return Result.success(fieldList); |
| | | } |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | @RequestMapping(value = "/loadFields", method = RequestMethod.POST) |
| | | public Result loadFields(@RequestBody String fieldListStr, HttpServletRequest request) { |
| | | List<SysField> fieldList = JSONObject.parseArray(fieldListStr,SysField.class); |
| | | if (fieldList.size() == 0) { |
| | | return Result.error(CodeMsg.ERROR_PARAMS_NOT_MATHED); |
| | | } |
| | | String tableName = fieldList.get(0).getTableName(); |
| | | if (StringUtils.isEmpty(tableName)) { |
| | | return Result.error(CodeMsg.ERROR_PARAMS_NOT_MATHED); |
| | | } |
| | | String maintainId = null; |
| | | MaintainField maxVersion = maintainFieldService.getMaxVersion(tableName); |
| | | if (maxVersion != null) { |
| | | maintainId = maxVersion.getId(); |
| | | } |
| | | |
| | | MaintainField nowMaintain = null; |
| | | HttpSession session = request.getSession(); |
| | | TUser user = (TUser) session.getAttribute("user"); |
| | | String userId = user.getUserId(); |
| | | |
| | | if (StringUtils.isEmpty(maintainId)) { |
| | | //创建新版本的字段 |
| | | nowMaintain = flowsService.createNowVerion(tableName, maintainId, userId); |
| | | if (nowMaintain == null) { |
| | | return Result.error(CodeMsg.ERROR_PARAMS_NOT_MATHED); |
| | | } |
| | | |
| | | }else { |
| | | Flows flows = flowsService.selectOne(new EntityWrapper<Flows>().eq("business_id", maintainId)); |
| | | if (flows != null){ |
| | | //当前已审批 |
| | | ActivitiStatus status = flows.getStatus(); |
| | | if (status.equals(ActivitiStatus.open) || status.equals(ActivitiStatus.close)) { |
| | | nowMaintain = flowsService.createNowVerion(tableName, maintainId, userId); |
| | | }else { |
| | | return Result.error(new CodeMsg(7002, "当前字段版本正在审批,请待审批通过后再修改")); |
| | | } |
| | | |
| | | }else { |
| | | //delete |
| | | fieldService.delete(new EntityWrapper<SysField>().eq("maintain_field_id",maintainId)); |
| | | nowMaintain = maintainFieldService.selectById(maintainId); |
| | | } |
| | | } |
| | | for (int i = 0; i < fieldList.size(); i++) { |
| | | SysField sysField = fieldList.get(i); |
| | | sysField.setCreateTime(new Date()).setId(DbUtils.getUUID()).setOperate(Operate.create).setMaintainFieldId(nowMaintain.getId()).setOrderNo(i).insert(); |
| | | } |
| | | nowMaintain.insertOrUpdate(); |
| | | return Result.success(null); |
| | | } |
| | | |
| | | @RequestMapping(value = "/change", method = RequestMethod.POST) |
| | | public Result addOrUpdate(@RequestBody SysField sysField, HttpServletRequest request) { |
| | | Operate operate = sysField.getOperate(); |