龚焕茏
2024-05-06 24c9d860ced4d058b866a9fb548a8ef1d1412c20
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
58
59
60
package com.mindskip.xzs.controller.admin;
 
import com.github.pagehelper.PageInfo;
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 org.springframework.web.bind.annotation.*;
 
import java.util.List;
 
/**
 * @author gonghl
 * @since 2024/5/6 上午 11:45
 */
 
@RestController
@RequestMapping(value = "/api/admin/tag")
@Data
public class TagController {
 
    private final TagService tagService;
 
    @RequestMapping(value = "/list", method = RequestMethod.GET)
    public RestResponse<List<Tag>> pageList() {
        List<Tag> list = tagService.list();
        return RestResponse.ok(list);
    }
 
    @RequestMapping(value = "/page/list", method = RequestMethod.POST)
    public RestResponse<PageInfo<Tag>> pageList(@RequestBody TagVO tag) {
        PageInfo<Tag> page = tagService.tagPage(tag);
        return RestResponse.ok(page);
    }
 
    @RequestMapping(value = "/select/{id}", method = RequestMethod.POST)
    public RestResponse<Tag> select(@PathVariable Integer id) {
        Tag tag = tagService.getById(id);
        return RestResponse.ok(tag);
    }
 
    @RequestMapping(value = "/selectCount/{id}", method = RequestMethod.POST)
    public RestResponse<List<String>> selectCount(@PathVariable Integer id) {
        return RestResponse.ok(tagService.selectCount(id));
    }
 
    @RequestMapping(value = "/edit", method = RequestMethod.POST)
    public RestResponse<Tag> update(@RequestBody Tag tag) {
        tagService.saveOrUpdate(tag);
        return RestResponse.ok(tag);
    }
 
    @RequestMapping(value = "/delete/{id}", method = RequestMethod.POST)
    public RestResponse<Integer> delete(@PathVariable Integer id) {
        tagService.removeById(id);
        return RestResponse.ok(id);
    }
 
}