kimi
2020-02-14 18097001d683a155257d7d38ebedbfe58269449b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package com.highdatas.mdm.controller;
 
 
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.highdatas.mdm.entity.SysField;
import com.highdatas.mdm.pojo.CodeMsg;
import com.highdatas.mdm.pojo.Result;
import com.highdatas.mdm.service.ISysFieldService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
 
import java.util.Date;
import java.util.List;
 
/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author kimi
 * @since 2019-12-16
 */
@RestController
@RequestMapping("/field")
public class SysFieldController {
    @Autowired
    ISysFieldService fieldService;
 
    @RequestMapping(value = "/{tableName}", method = RequestMethod.GET)
    public Result todoTask(@PathVariable String tableName){
        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"));
 
        return Result.success(fieldList);
    }
 
    @RequestMapping(value = "/update", method = RequestMethod.GET)
    public Result update(@RequestParam String json)  {
        try {
            ObjectMapper objectMapper = new ObjectMapper();
            objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
            SysField sysField = objectMapper.readValue(json, SysField.class);
            sysField.setUpdateTime(new Date());
            sysField.updateById();
            return Result.success(null);
        }catch (Exception e) {
            e.printStackTrace();
            return Result.error(CodeMsg.UPDATE_ERROR);
        }
    }
 
}