| | |
| | | package com.highdatas.mdm.controller; |
| | | |
| | | |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.highdatas.mdm.entity.Maintain; |
| | | import com.highdatas.mdm.entity.MaintainField; |
| | | import com.highdatas.mdm.entity.SysField; |
| | | import com.highdatas.mdm.entity.MenuMapping; |
| | | import com.highdatas.mdm.mapper.TableInfoMapper; |
| | | import com.highdatas.mdm.pojo.CodeMsg; |
| | | import com.highdatas.mdm.pojo.Result; |
| | | import com.highdatas.mdm.service.IMaintainFieldService; |
| | | import com.highdatas.mdm.service.IMaintainService; |
| | | import com.highdatas.mdm.service.IMenuMappingService; |
| | | import com.highdatas.mdm.service.ISysFieldService; |
| | | import com.highdatas.mdm.util.Constant; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.PathVariable; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RequestMethod; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.text.MessageFormat; |
| | | import java.util.Comparator; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Set; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | ISysFieldService fieldService; |
| | | @Autowired |
| | | TableInfoMapper tableInfoMapper; |
| | | @Autowired |
| | | IMenuMappingService menuMappingService; |
| | | |
| | | @RequestMapping(value = "/getMaintainList/{tableName}", method = RequestMethod.GET) |
| | | @RequestMapping(value = "/getMaintainListByMenu/{menuId}", method = RequestMethod.GET) |
| | | public Result getMaintainListByTable(@PathVariable String menuId) { |
| | | MenuMapping menuMapping = menuMappingService.selectOne(new EntityWrapper<MenuMapping>().eq("menu_id", menuId).orderBy("create_time")); |
| | | if (menuMapping == null){ |
| | | return Result.error(CodeMsg.ERROR_PARAMS_NOT_MATHED); |
| | | } |
| | | String tableName = menuMapping.getTableName(); |
| | | |
| | | JSONArray array = maintainFieldService.getMaintainListByTable(tableName); |
| | | return Result.success(array); |
| | | } |
| | | |
| | | @RequestMapping(value = "/getMaintainListByMaintainField/{id}", method = RequestMethod.GET) |
| | | public Result getMaintainListByMaintainField(@PathVariable String id, @RequestParam String tableName) { |
| | | List<Maintain> maintainList = maintainFieldService.getMaintainListByMaintainField(id, tableName); |
| | | return Result.success(maintainList); |
| | | } |
| | | |
| | | @RequestMapping(value = "/getMaintainListByTable/{tableName}", method = RequestMethod.GET) |
| | | public Result deleteModel(@PathVariable String tableName) { |
| | | List<MaintainField> maintainFieldList = maintainFieldService.selectList(new EntityWrapper<MaintainField>().eq("table_name", tableName).orderBy("order_no")); |
| | | int preOrderNo = -1; |
| | |
| | | resultMap.put(maintainField.getId(), maintainList); |
| | | preOrderNo = orderNo; |
| | | } |
| | | return Result.success(resultMap); |
| | | Set<String> keySet = resultMap.keySet(); |
| | | JSONArray array = new JSONArray(); |
| | | for (String s : keySet) { |
| | | List<Maintain> maintainList = resultMap.get(s); |
| | | Maintain max = maintainList.stream().max(new Comparator<Maintain>() { |
| | | @Override |
| | | public int compare(Maintain o1, Maintain o2) { |
| | | return o1.getOrderNo() - o2.getOrderNo(); |
| | | } |
| | | }).get(); |
| | | Maintain min = maintainList.stream().min(new Comparator<Maintain>() { |
| | | @Override |
| | | public int compare(Maintain o1, Maintain o2) { |
| | | return o1.getOrderNo() - o2.getOrderNo(); |
| | | } |
| | | }).get(); |
| | | JSONObject object = new JSONObject(); |
| | | object.fluentPut("maintainFieldId", s); |
| | | object.fluentPut("version", MessageFormat.format(Constant.extent, min.getVersion(), max.getVersion())); |
| | | |
| | | array.add(object); |
| | | } |
| | | return Result.success(array); |
| | | } |
| | | |
| | | |
| | | @RequestMapping(value = "/getFieldByMaintainFieldId/{id}", method = RequestMethod.GET) |
| | | public Result getFieldByMaintainFieldId(@PathVariable String id) { |
| | | List<SysField> result; |
| | | if (Constant.Default.equalsIgnoreCase(id)) { |
| | | result = fieldService.getFieldByMaintainField(null); |
| | | } |
| | | if (Constant.All.equalsIgnoreCase(id)) { |
| | | |
| | | } |
| | | result = fieldService.getFieldByMaintainField(id); |
| | | return null; |
| | | } |
| | | |
| | | |
| | | } |