package com.highdatas.mdm.controller; import com.baomidou.mybatisplus.mapper.EntityWrapper; import com.highdatas.mdm.entity.SysViewLogic; import com.highdatas.mdm.entity.SysViewLogicmap; import com.highdatas.mdm.pojo.CodeMsg; import com.highdatas.mdm.pojo.Result; import com.highdatas.mdm.service.ISysViewLogicService; import com.highdatas.mdm.service.ISysViewLogicmapService; import com.highdatas.mdm.util.Constant; import com.highdatas.mdm.util.DbUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import java.util.List; /** *

* 前端控制器 *

* * @author kimi * @since 2020-04-22 */ @RestController @RequestMapping("/sysView/logic") public class SysViewLogicController { @Autowired ISysViewLogicService logicService; @Autowired ISysViewLogicmapService logicmapService; @RequestMapping(value = "/all", method = RequestMethod.GET) public Result getList() { List aciveLogic = logicService.selectList(new EntityWrapper().eq("active", true)); return Result.success(aciveLogic); } @RequestMapping(value = "/allmap/{parentId}", method = RequestMethod.GET) public Result allmap(@PathVariable String parentId) { List aciveLogic = logicmapService.selectList(new EntityWrapper().eq(Constant.PARENT_ID, parentId)); return Result.success(aciveLogic); } @RequestMapping(value = "/updateMaps/{parentId}", method = RequestMethod.POST) public Result updateMaps(@PathVariable String parentId, @RequestBody List logicmaps) { boolean delete = logicmapService.delete(new EntityWrapper().eq(Constant.PARENT_ID, parentId)); boolean insert = false; for (SysViewLogicmap logicmap : logicmaps) { insert = logicmap.setId(DbUtils.getUUID()).setParentId(parentId).insert(); if (!insert) { return Result.error(CodeMsg.INSERT_ERROR); } } return Result.success(null); } @RequestMapping(value = "/addmap", method = RequestMethod.POST) public Result addmap(@RequestBody SysViewLogicmap logicmap) { boolean insert = logicmap.setId(DbUtils.getUUID()).insert(); if (insert) { return Result.success(insert); } else { return Result.error(CodeMsg.INSERT_ERROR); } } @RequestMapping(value = "/deletemap/{id}", method = RequestMethod.POST) public Result deletemap(@PathVariable String id) { boolean delete = logicmapService.deleteById(id); if (delete) { return Result.success(CodeMsg.DELETE_SUCCESS); } else { return Result.success(CodeMsg.DELETE_ERROR); } } @RequestMapping(value = "/updatemap", method = RequestMethod.POST) public Result updatemap(@RequestBody SysViewLogicmap logicmap) { String id = logicmap.getId(); if (StringUtils.isEmpty(id)) { return Result.error(CodeMsg.ERROR_PARAMS_NOT_MATHED); } boolean insert = logicmap.updateById(); if (insert) { return Result.success(insert); } else { return Result.error(CodeMsg.INSERT_ERROR); } } @RequestMapping(value = "/add", method = RequestMethod.POST) public Result add(@RequestBody SysViewLogic logic) { boolean insert = logic.setId(DbUtils.getUUID()).insert(); if (insert) { return Result.success(insert); } else { return Result.error(CodeMsg.INSERT_ERROR); } } @RequestMapping(value = "/update", method = RequestMethod.POST) public Result update(@RequestBody SysViewLogic logic) { String id = logic.getId(); if (StringUtils.isEmpty(id)) { return Result.error(CodeMsg.ERROR_PARAMS_NOT_MATHED); } boolean b = logic.updateById(); if (b) { return Result.success(logic); } else { return Result.error(CodeMsg.UPDATE_ERROR); } } }