| | |
| | | package com.highdatas.mdm.controller; |
| | | |
| | | |
| | | 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.mapper.TableInfoMapper; |
| | | import com.highdatas.mdm.pojo.Result; |
| | | import com.highdatas.mdm.service.IMaintainFieldService; |
| | | import com.highdatas.mdm.service.IMaintainService; |
| | | 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.stereotype.Controller; |
| | | import org.springframework.web.bind.annotation.RequestMethod; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | @RestController |
| | | @RequestMapping("/maintainField") |
| | | public class MaintainFieldController { |
| | | @Autowired |
| | | IMaintainService maintainService; |
| | | @Autowired |
| | | IMaintainFieldService maintainFieldService; |
| | | @Autowired |
| | | ISysFieldService fieldService; |
| | | @Autowired |
| | | TableInfoMapper tableInfoMapper; |
| | | |
| | | @RequestMapping(value = "/getMaintainList/{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; |
| | | HashMap<String, List<Maintain>> resultMap = new HashMap<>(); |
| | | if (maintainFieldList.size() == 0) { |
| | | List<Maintain> maintainList = maintainService.selectList(new EntityWrapper<Maintain>().orderBy("order_no")); |
| | | resultMap.put(Constant.Default, maintainList); |
| | | return Result.success(resultMap); |
| | | } |
| | | for (MaintainField maintainField : maintainFieldList) { |
| | | String maintainId = maintainField.getMaintainId(); |
| | | if (StringUtils.isEmpty(maintainId)) { |
| | | continue; |
| | | } |
| | | Maintain maintain = maintainService.selectById(maintainId); |
| | | if (maintain == null) { |
| | | continue; |
| | | } |
| | | Integer orderNo = maintain.getOrderNo(); |
| | | List<Maintain> maintainList = maintainService.selectList(new EntityWrapper<Maintain>().ge("order_no", preOrderNo).le("order_no", orderNo)); |
| | | resultMap.put(maintainField.getId(), maintainList); |
| | | preOrderNo = orderNo; |
| | | } |
| | | return Result.success(resultMap); |
| | | } |
| | | |
| | | |
| | | @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; |
| | | } |
| | | } |