| | |
| | | package com.mindskip.xzs.controller.admin; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.github.pagehelper.PageInfo; |
| | | import com.mindskip.xzs.base.BaseApiController; |
| | | import com.mindskip.xzs.base.RestResponse; |
| | | import com.mindskip.xzs.domain.Tag; |
| | | import com.mindskip.xzs.domain.vo.TagVO; |
| | | import com.mindskip.xzs.service.TagService; |
| | | import lombok.Data; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.apache.commons.lang3.ObjectUtils; |
| | | import org.springframework.util.CollectionUtils; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.List; |
| | |
| | | |
| | | @RestController |
| | | @RequestMapping(value = "/api/admin/tag") |
| | | @Data |
| | | @RequiredArgsConstructor |
| | | public class TagController extends BaseApiController { |
| | | |
| | | private final TagService tagService; |
| | | |
| | | @RequestMapping(value = "/list", method = RequestMethod.GET) |
| | | public RestResponse<List<Tag>> pageList() { |
| | | LambdaQueryWrapper<Tag> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.in(ObjectUtils.isNotEmpty(getAdminDeptIds()), Tag::getDeptId, getAdminDeptIds()); |
| | | List<Tag> list = tagService.list(queryWrapper); |
| | | List<Tag> list = tagService.list(getAdminDeptIds()); |
| | | return RestResponse.ok(list); |
| | | } |
| | | |
| | | @RequestMapping(value = "/page/list", method = RequestMethod.POST) |
| | | public RestResponse<PageInfo<Tag>> pageList(@RequestBody TagVO tag) { |
| | | if (! CollectionUtils.isEmpty(webContext.getAdminDeptIds())) { |
| | | tag.setDeptId(webContext.getAdminDeptIds().get(0)); |
| | | } |
| | | PageInfo<Tag> page = tagService.tagPage(tag); |
| | | return RestResponse.ok(page); |
| | | } |
| | |
| | | |
| | | @RequestMapping(value = "/edit", method = RequestMethod.POST) |
| | | public RestResponse<Tag> update(@RequestBody Tag tag) { |
| | | tag.setDeptId(ObjectUtils.isNotEmpty(getAdminDeptIds()) ? getAdminDeptIds().get(0) : null); |
| | | tagService.saveOrUpdate(tag); |
| | | return RestResponse.ok(tag); |
| | | } |