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; /** *

* 前端控制器 *

* * @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 fieldList = fieldService.selectList(new EntityWrapper().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); } } }