From c635d78b479510ebe2556a420948effcd30a0731 Mon Sep 17 00:00:00 2001 From: skyouc Date: 星期六, 21 十二月 2024 18:40:43 +0800 Subject: [PATCH] 新建德森项目分支 --- zy-asrs-common/src/main/java/com/zy/asrs/common/sys/controller/ResourceController.java | 254 +++++++++++++++++++++++++------------------------- 1 files changed, 127 insertions(+), 127 deletions(-) diff --git a/zy-asrs-common/src/main/java/com/zy/asrs/common/sys/controller/ResourceController.java b/zy-asrs-common/src/main/java/com/zy/asrs/common/sys/controller/ResourceController.java index dd9bdba..1e14125 100644 --- a/zy-asrs-common/src/main/java/com/zy/asrs/common/sys/controller/ResourceController.java +++ b/zy-asrs-common/src/main/java/com/zy/asrs/common/sys/controller/ResourceController.java @@ -1,127 +1,127 @@ -package com.zy.asrs.common.sys.controller; - -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import com.zy.asrs.common.sys.entity.Resource; -import com.zy.asrs.common.sys.service.ResourceService; -import com.zy.asrs.common.web.BaseController; -import com.zy.asrs.framework.annotations.ManagerAuth; -import com.zy.asrs.framework.common.Cools; -import com.zy.asrs.framework.common.R; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -@RestController -public class ResourceController extends BaseController { - - @Autowired - private ResourceService resourceService; - - @RequestMapping(value = "/resource/{id}/auth") - @ManagerAuth - public R get(@PathVariable("id") Long id) { - return R.ok(resourceService.getById(String.valueOf(id))); - } - - @RequestMapping(value = "/resource/list/auth") - @ManagerAuth - public R list(@RequestParam(defaultValue = "1")Integer curr, - @RequestParam(defaultValue = "10")Integer limit, - @RequestParam(required = false)String orderByField, - @RequestParam(required = false)String orderByType, - @RequestParam Map<String, Object> param){ - LambdaQueryWrapper<Resource> wrapper = new LambdaQueryWrapper<>(); - return R.ok(resourceService.page(new Page<>(curr, limit), wrapper)); - } - - @RequestMapping(value = "/resource/tree/auth") - @ManagerAuth - public R tree(@RequestParam(defaultValue = "1")Integer curr, - @RequestParam(defaultValue = "10")Integer limit, - @RequestParam(required = false)String orderByField, - @RequestParam(required = false)String orderByType, - @RequestParam Map<String, Object> param){ - LambdaQueryWrapper<Resource> wrapper = new LambdaQueryWrapper<>(); - wrapper.orderByAsc(Resource::getSort); - return R.parse("0-鎿嶄綔鎴愬姛").add(resourceService.list(wrapper)); - } - - @RequestMapping(value = "/resource/edit/auth") - @ManagerAuth(memo = "鑿滃崟缂栬緫") - public R edit(Resource resource) { - if (Cools.isEmpty(resource)){ - return R.error(); - } - if (null == resource.getId()){ - if (resource.getSort() == null){ - resource.setSort(999); - } - resourceService.save(resource); - } else { - resourceService.updateById(resource); - } - return R.ok(); - } - - @RequestMapping(value = "/resource/add/auth") - @ManagerAuth(memo = "鑿滃崟娣诲姞") - public R add(Resource resource) { - resourceService.save(resource); - return R.ok(); - } - - @RequestMapping(value = "/resource/update/auth") - @ManagerAuth(memo = "鑿滃崟淇敼") - public R update(Resource resource){ - if (Cools.isEmpty(resource) || null==resource.getId()){ - return R.error(); - } - resourceService.updateById(resource); - return R.ok(); - } - -// @RequestMapping(value = "/resource/delete/auth") -// @ManagerAuth(memo = "鑿滃崟鍒犻櫎") -// public R delete(Integer[] ids){ -// if (Cools.isEmpty(ids)){ -// return R.error(); -// } -// resourceService.deleteBatchIds(Arrays.asList(ids)); -// return R.ok(); -// } - - @RequestMapping(value = "/resource/delete/auth") - @ManagerAuth - public R delete(@RequestParam(value="ids[]") Long[] ids){ - for (Long id : ids){ - resourceService.removeById(id); - } - return R.ok(); - } - - - @RequestMapping(value = "/resourceQuery/auth") - @ManagerAuth - public R query(String condition) { - LambdaQueryWrapper<Resource> wrapper = new LambdaQueryWrapper<>(); - wrapper.like(Resource::getName, condition); - Page<Resource> page = resourceService.page(new Page<>(0, 10), wrapper); - List<Map<String, Object>> result = new ArrayList<>(); - for (Resource resource : page.getRecords()){ - Map<String, Object> map = new HashMap<>(); - map.put("id", resource.getId()); - map.put("value", resource.getName().concat("(").concat(resource.getLevel$().substring(0, 2).concat(")"))); - result.add(map); - } - return R.ok(result); - } - -} +package com.zy.asrs.common.sys.controller; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.zy.asrs.common.sys.entity.Resource; +import com.zy.asrs.common.sys.service.ResourceService; +import com.zy.asrs.common.web.BaseController; +import com.zy.asrs.framework.annotations.ManagerAuth; +import com.zy.asrs.framework.common.Cools; +import com.zy.asrs.framework.common.R; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +@RestController +public class ResourceController extends BaseController { + + @Autowired + private ResourceService resourceService; + + @RequestMapping(value = "/resource/{id}/auth") + @ManagerAuth + public R get(@PathVariable("id") Long id) { + return R.ok(resourceService.getById(String.valueOf(id))); + } + + @RequestMapping(value = "/resource/list/auth") + @ManagerAuth + public R list(@RequestParam(defaultValue = "1")Integer curr, + @RequestParam(defaultValue = "10")Integer limit, + @RequestParam(required = false)String orderByField, + @RequestParam(required = false)String orderByType, + @RequestParam Map<String, Object> param){ + LambdaQueryWrapper<Resource> wrapper = new LambdaQueryWrapper<>(); + return R.ok(resourceService.page(new Page<>(curr, limit), wrapper)); + } + + @RequestMapping(value = "/resource/tree/auth") + @ManagerAuth + public R tree(@RequestParam(defaultValue = "1")Integer curr, + @RequestParam(defaultValue = "10")Integer limit, + @RequestParam(required = false)String orderByField, + @RequestParam(required = false)String orderByType, + @RequestParam Map<String, Object> param){ + LambdaQueryWrapper<Resource> wrapper = new LambdaQueryWrapper<>(); + wrapper.orderByAsc(Resource::getSort); + return R.parse("0-鎿嶄綔鎴愬姛").add(resourceService.list(wrapper)); + } + + @RequestMapping(value = "/resource/edit/auth") + @ManagerAuth(memo = "鑿滃崟缂栬緫") + public R edit(Resource resource) { + if (Cools.isEmpty(resource)){ + return R.error(); + } + if (null == resource.getId()){ + if (resource.getSort() == null){ + resource.setSort(999); + } + resourceService.save(resource); + } else { + resourceService.updateById(resource); + } + return R.ok(); + } + + @RequestMapping(value = "/resource/add/auth") + @ManagerAuth(memo = "鑿滃崟娣诲姞") + public R add(Resource resource) { + resourceService.save(resource); + return R.ok(); + } + + @RequestMapping(value = "/resource/update/auth") + @ManagerAuth(memo = "鑿滃崟淇敼") + public R update(Resource resource){ + if (Cools.isEmpty(resource) || null==resource.getId()){ + return R.error(); + } + resourceService.updateById(resource); + return R.ok(); + } + +// @RequestMapping(value = "/resource/delete/auth") +// @ManagerAuth(memo = "鑿滃崟鍒犻櫎") +// public R delete(Integer[] ids){ +// if (Cools.isEmpty(ids)){ +// return R.error(); +// } +// resourceService.deleteBatchIds(Arrays.asList(ids)); +// return R.ok(); +// } + + @RequestMapping(value = "/resource/delete/auth") + @ManagerAuth + public R delete(@RequestParam(value="ids[]") Long[] ids){ + for (Long id : ids){ + resourceService.removeById(id); + } + return R.ok(); + } + + + @RequestMapping(value = "/resourceQuery/auth") + @ManagerAuth + public R query(String condition) { + LambdaQueryWrapper<Resource> wrapper = new LambdaQueryWrapper<>(); + wrapper.like(Resource::getName, condition); + Page<Resource> page = resourceService.page(new Page<>(0, 10), wrapper); + List<Map<String, Object>> result = new ArrayList<>(); + for (Resource resource : page.getRecords()){ + Map<String, Object> map = new HashMap<>(); + map.put("id", resource.getId()); + map.put("value", resource.getName().concat("(").concat(resource.getLevel$().substring(0, 2).concat(")"))); + result.add(map); + } + return R.ok(result); + } + +} -- Gitblit v1.9.1