kimi
2020-05-27 c007f0ca1785db093d48f4846cda82fe8e955765
src/main/java/com/highdatas/mdm/controller/SysFieldController.java
@@ -5,6 +5,7 @@
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.highdatas.mdm.entity.Character;
import com.highdatas.mdm.entity.*;
import com.highdatas.mdm.mapper.SysFieldMapper;
import com.highdatas.mdm.pojo.ActivitiStatus;
@@ -12,6 +13,7 @@
import com.highdatas.mdm.pojo.Operate;
import com.highdatas.mdm.pojo.Result;
import com.highdatas.mdm.service.*;
import com.highdatas.mdm.util.AntianaphylaxisClient;
import com.highdatas.mdm.util.Constant;
import com.highdatas.mdm.util.DbUtils;
import com.highdatas.mdm.util.WorkflowUtils;
@@ -30,6 +32,7 @@
 *  前端控制器
 * </p>
 *
 * @description 字段接口
 * @author kimi
 * @since 2019-12-16
 */
@@ -53,16 +56,35 @@
    IFlowsService flowsService;
    @Autowired
    IMasterAuthorService masterAuthorService;
    @Autowired
    AntianaphylaxisClient antianaphylaxisClient;
    /**
     *
     * @description:  通过表名获取字段列表
     * @param tableName 表名
     * @return: 字段列表
     *
     */
    @RequestMapping(value = "/{tableName}", method = RequestMethod.GET)
    public Result getFields(@PathVariable String tableName, HttpServletRequest request){
        TUser user = DbUtils.getUser(request);
        //请求头获取使用者包装类
        Character character = DbUtils.getCharacter(request);
        String maintainId = request.getParameter("maintainId");
        if (StringUtils.isEmpty(maintainId)) {
            //通过表名获取字段列表
            List<SysField> fieldList = fieldService.getFieldByTable(tableName);
            String isDataIO = request.getParameter("isDataIO");
            if (StringUtils.isEmpty(isDataIO) && !Boolean.valueOf(isDataIO)) {
                return Result.success(fieldList);
            }
            //给上传下载使用 组合好待脱敏的数据返回
            antianaphylaxisClient.getHelpfulFieldBySysField(fieldList, tableName);
            return Result.success(fieldList);
        }else {
            List<SysField> field = masterAuthorService.getField(user.getUserId(), maintainId);
            //BY 版本获取字段
            List<SysField> field = masterAuthorService.getField(character, maintainId);
            //List<SysField> fieldList = fieldService.getFieldByMaintain(maintainId);
            return Result.success(field);
@@ -70,8 +92,17 @@
    }
    /**
     *
     * @description:  通过表名分页获取字段列表
     * @param tableName 表名
     * @param pageNo 页数
     * @return: 字段列表
     *
     */
    @RequestMapping(value = "total/{tableName}/{pageNo}", method = RequestMethod.GET)
    public Result getTotalFields(@PathVariable String tableName,@PathVariable Integer pageNo, HttpServletRequest request){
        //isTotal 是否走权限, pageSize 每页数据数
        String totalStr = request.getParameter("isTotal");
        String pageSize = request.getParameter("pageSize");
@@ -81,8 +112,9 @@
            if (StringUtils.isEmpty(maintainId)){
                return Result.error(CodeMsg.ERROR_PARAMS_NOT_MATHED);
            }
            //获取用户
            TUser user = DbUtils.getUser(request);
            List<SysField> field = masterAuthorService.getField(user.getUserId(), maintainId);
            List<SysField> field = masterAuthorService.getField(user, maintainId);
            Integer size;
            if(StringUtils.isEmpty(pageSize)){
                size = 15;
@@ -93,15 +125,20 @@
            return fieldService.getPagedDataByList(field, pageNo, size);
        }
        //获取字段列表
        if(StringUtils.isEmpty(pageSize)){
            return fieldService.getTotalFields(tableName, pageNo, 15);
        }else  {
            return fieldService.getTotalFields(tableName, pageNo, Integer.valueOf(pageSize));
        }
    }
    /**
     *
     * @description:  通过表名获取当前系统中各种状态的字段列表
     * @param tableName 表名
     * @return: 字段列表
     *
     */
    @RequestMapping(value = "fix/{tableName}", method = RequestMethod.GET)
    public Result fix(@PathVariable String tableName, HttpServletRequest request){
        Result totalFields = fieldService.getTotalFields(tableName);
@@ -110,13 +147,20 @@
        return totalFields;
    }
    /**
     *
     * @description:  通过主题获取字段里输入表
     * @param id 主题id
     * @return: 字段列表
     *
     */
    @RequestMapping(value = "/menu/{id}", method = RequestMethod.GET)
    public Result getFieldByMenu(@PathVariable String id){
        MenuMapping menuMapping = menuMappingService.selectOne(new EntityWrapper<MenuMapping>().eq("menu_id", id));
        if (menuMapping == null) {
            return Result.error(CodeMsg.ERROR_PARAMS_NOT_MATHED);
        }
        //通过主题获获取表名
        String tableName = menuMapping.getTableName();
        if (StringUtils.isEmpty(tableName)) {
            return Result.error(CodeMsg.ERROR_PARAMS_NOT_MATHED);
@@ -124,7 +168,12 @@
        List<SysField> fieldList = fieldService.getFieldByTable(tableName);
        return Result.success(fieldList);
    }
    /**
     *
     * @description:  更新字段数据
     * @return: 更新是否成功
     *
     */
    @RequestMapping(value = "/update", method = RequestMethod.GET)
    public Result update(@RequestParam String json)  {
        try {
@@ -140,7 +189,13 @@
        }
    }
    /**
     *
     * @description:  更新基础参数
     * @param id sys_field 数据id
     * @return: 是否更新完成
     *
     */
    @RequestMapping(value = "/updateCommon/{id}", method = RequestMethod.GET)
    public Result addOrUpdate(@PathVariable String id, HttpServletRequest request)  {
        //更新基础参数不需要关联版本
@@ -148,6 +203,7 @@
        if (sysField == null) {
            return Result.error(CodeMsg.ERROR_PARAMS_NOT_MATHED);
        }
        //可直接更新的参数
        String width = request.getParameter("width");
        String align = request.getParameter("align");
        String orderNoStr = request.getParameter("orderNo");
@@ -193,6 +249,12 @@
        }
    }
    /**
     *
     * @description:  上传后生成的字段保存入库
     * @return: 是否保存成功
     *
     */
    @RequestMapping(value = "/loadFields", method = RequestMethod.POST)
    public Result loadFields(@RequestBody String fieldListStr, HttpServletRequest request)  {
        log.info(fieldListStr);
@@ -265,7 +327,12 @@
        return Result.success(null);
    }
    /**
     *
     * @description:  修改字段
     * @return: 修改后的字段
     *
     */
    @RequestMapping(value = "/change", method = RequestMethod.POST)
    public Result addOrUpdate(@RequestBody SysField sysField, HttpServletRequest request)  {