kimi
2020-05-27 c007f0ca1785db093d48f4846cda82fe8e955765
src/main/java/com/highdatas/mdm/controller/MasterDataController.java
@@ -6,7 +6,10 @@
import com.highdatas.mdm.entity.Character;
import com.highdatas.mdm.entity.*;
import com.highdatas.mdm.mapper.TableInfoMapper;
import com.highdatas.mdm.pojo.*;
import com.highdatas.mdm.pojo.CodeMsg;
import com.highdatas.mdm.pojo.Operate;
import com.highdatas.mdm.pojo.Result;
import com.highdatas.mdm.pojo.SysAssembleUpdateType;
import com.highdatas.mdm.service.*;
import com.highdatas.mdm.util.Constant;
import com.highdatas.mdm.util.DbUtils;
@@ -58,6 +61,13 @@
    @Autowired
    NoticeClient noticeClient;
    /**
     *
     * @description: 上传后,关联版本信息
     * @param tableName 表名
     * @return 是否关联成功
     *
     */
    @RequestMapping(value = "{tableName}/uploaded",  method = RequestMethod.GET)
    public Result get(@PathVariable String tableName, HttpServletRequest request) {
        String uploadTypeStr = request.getParameter("uploadType");
@@ -69,12 +79,12 @@
        }
        TUser user = DbUtils.getUser(request);
        //上传数据后的操作,关联版本
        Maintain maintain = masterDataService.uploadedData(tableName, uploadType, user.getUserId());
        // 处理关联人
        //masterModifiedService.dealAssemble(maintain.getId(), user.getUserId(), true);
        //添加 std_id 索引
        String recordTableName = tableName + Constant.RECORD;
        masterDataService.createIdx(recordTableName);
        JSONObject object = new JSONObject();
@@ -83,12 +93,26 @@
        return Result.success(object);
    }
    /**
     *
     * @description: 通过表名和id获取具体信息
     * @param tableName 表名
     * @param id 数据id
     * @return 具体数据
     *
     */
    @RequestMapping(value = "{tableName}/get/{id}",  method = RequestMethod.GET)
    public Result get(@PathVariable String tableName, @PathVariable String id) {
        return masterDataService.selectById(tableName,id);
    }
    /**
     *
     * @description: 通过表名分页获取数据
     * @param tableName 表名
     * @param pageNo 页数
     * @return 具体数据
     *
     */
    @RequestMapping(value = "{tableName}/all/{pageNo}",  method = RequestMethod.GET)
    public Result getByPage(@PathVariable String tableName, @PathVariable Integer pageNo, HttpServletRequest request) throws UnsupportedEncodingException {
        String uuid = DbUtils.getUUID();
@@ -156,6 +180,13 @@
        }
    }
    /**
     *
     * @description: 通过表名获取数据
     * @param tableName 表名
     * @return 具体数据
     *
     */
    @RequestMapping(value = "{tableName}/all",  method = RequestMethod.GET)
    public Result<MenuMapping> getAll(@PathVariable String tableName,HttpServletRequest request) {
        TUser user = DbUtils.getUser(request);
@@ -170,6 +201,14 @@
        return masterDataService.selectList(user, tableName,whereSegment, version);
    }
    /**
     *
     * @description: 通过表名和操作类型更新待修改数据
     * @param maintainId  未生效的版本id
     * @param operateStr 操作类型
     * @return 具体数据
     *
     */
    @RequestMapping(value = "{maintainId}/modify/{operateStr}", method = RequestMethod.POST)
    public Result modify(@RequestParam String datas, @PathVariable String maintainId, @PathVariable String operateStr,  @RequestParam String modify, HttpServletRequest request) throws UnsupportedEncodingException {
        Result result = null;
@@ -196,11 +235,9 @@
                jsonObject.remove(Constant.ID);
                datas = jsonObject.toJSONString();
                String updateSegment = masterDataService.getUpdateSegment(maintain.getTableName(), maintain.getTableName() + Constant.RECORD, datas);
                String tempTable = maintain.getTableName() + Constant.RECORD;
                Segment segment = new Segment(MessageFormat.format(Constant.Alias, tempTable, Constant.STD_ID), id);
                tableInfoMapper.update(tempTable, updateSegment, segment.toString());
                result = Result.success(null);
                Integer updateCount = tableInfoMapper.updateRecordByMaintainId(maintain.getTableName() + Constant.RECORD, updateSegment, DbUtils.quotedStr(maintainId));
                result = Result.success(updateCount);
                break;
            case create:
                JSONObject createObject = JSONObject.parseObject(datas);
@@ -232,7 +269,14 @@
        return result;
    }
    /**
     *
     * @description:  修改一条数据, 供在线编辑使用
     * @param tableName 表名
     * @param operateStr 操作类型
     * @return 具体数据
     *
     */
    @RequestMapping(value = "{tableName}/{operateStr}", method = RequestMethod.POST)
    @Transactional(rollbackFor = {RuntimeException.class, Error.class})
    public Result insert(@PathVariable String tableName,@PathVariable String operateStr, @RequestParam String datas, @RequestParam String modify, HttpServletRequest request) {
@@ -348,6 +392,15 @@
        return result;
    }
    /**
     *
     * @description: 直接更新一条数据
     * @param tableName 表名
     * @param id 数据id
     * @return 具体数据
     *
     */
    @RequestMapping(value = "update/{id}", method = RequestMethod.POST)
    public Result updateById(@PathVariable String tableName,@RequestParam String datas, @PathVariable String id, HttpServletRequest request)  {
        String totalStr = request.getParameter(Constant.TOTAL);
@@ -373,14 +426,29 @@
        }
    }
    /**
     *
     * @description: 直接删除一条数据
     * @param tableName 表名
     * @param id 数据id
     * @return 删除结果
     *
     */
    @RequestMapping(value = "delete/{id}", method = RequestMethod.GET)
    public Result deleteById(@PathVariable String tableName, @PathVariable String id) {
       return masterDataService.deleteById(tableName,id);
    }
    /**
     *
     * @description: 通过筛选条件删除数据
     * @param tableName 表名
     * @return 具体数据
     *
     */
    @RequestMapping(value = "delete", method = RequestMethod.GET)
    public Result delete(@PathVariable String tableName, HttpServletRequest request) {
        //whereSegment 筛选条件
        String whereSegment = request.getParameter(Constant.WHERE_SEGMENT);
        if (StringUtils.isEmpty(whereSegment)) {
            return masterDataService.delete(tableName);
@@ -388,7 +456,15 @@
            return masterDataService.delete(tableName, whereSegment);
        }
    }
    /**
     *
     * @description: 通过字段版本获取某个字段的所有的数据
     * @param maintainFieldId 字段版本
     * @param menuId 主题id
     * @param field 字段
     * @return 具体数据
     *
     */
    @RequestMapping(value = "/getValByMaintainFieldId/{maintainFieldId}", method = RequestMethod.GET)
    public Result getValByMaintainFieldId(@PathVariable String maintainFieldId,@RequestParam String menuId, @RequestParam String field, HttpServletRequest request) {
        String tableName = menuMappingService.getTableNameByMenu(menuId);