liujie
2025-12-30 3beaeea9255b73a9da1e32a25af68d8fcf67cfaa
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
package com.ruoyi.web.controller.api;
 
 
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.domain.model.LoginUser;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.framework.web.service.TokenService;
import com.ruoyi.system.model.TGuide;
import com.ruoyi.system.query.TGuideQuery;
import com.ruoyi.system.service.TGuideService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
 
import java.util.Objects;
 
/**
 * <p>
 * 景区攻略信息表 前端控制器
 * </p>
 *
 * @author L
 * @since 2025-12-30
 */
@RestController
@RequestMapping("/t-guide")
@Api(tags = "(青都)景区攻略管理")
public class TGuideController {
 
    private final TGuideService tGuideService;
    private final TokenService tokenService;
 
 
    public TGuideController(TGuideService tGuideService, TokenService tokenService) {
        this.tGuideService = tGuideService;
        this.tokenService = tokenService;
    }
 
 
    @ApiOperation(value = "景区攻略管理分页列表")
    @PostMapping(value = "/pageList")
    public R<Page<TGuide>> pageList(@RequestBody TGuideQuery query) {
        Page<TGuide> page = new Page<>(query.getPageNum(), query.getPageSize());
        LambdaQueryWrapper<TGuide> wrapper = new LambdaQueryWrapper<>();
        wrapper.like(Objects.nonNull(query.getTitle()), TGuide::getTitle, query.getTitle());
        if(query.getCreateTime()!=null && !query.getCreateTime().isEmpty()){
            String createTime = query.getCreateTime();
            String[] split = createTime.split(" - ");
            wrapper.between(TGuide::getCreateTime, split[0] + " 00:00:00", split[1] + " 23:59:59");
        }
        wrapper.orderByDesc(TGuide::getCreateTime);
        Page<TGuide> pageInfo = tGuideService.page(page, wrapper);
        return R.ok(pageInfo);
    }
 
 
    @ApiOperation(value = "景区攻略详情")
    @GetMapping(value = "/detail/{id}")
    public R<TGuide> detail(@PathVariable Integer id ) {
        TGuide Guide = tGuideService.getById(id);
        return R.ok(Guide);
    }
 
 
    @ApiOperation(value = "景区攻略添加")
    @PostMapping(value = "/add")
    @Log(title = "景区攻略-添加", businessType = BusinessType.INSERT)
    public R<String> add(@RequestBody TGuide tGuide) {
        LoginUser loginUser = tokenService.getLoginUser();
        String nickName = loginUser.getUser().getNickName();
        tGuide.setCreateBy(nickName);
        boolean save = tGuideService.save(tGuide);
        return save ? R.ok() : R.fail();
    }
 
 
    @ApiOperation(value = "景区攻略修改")
    @PostMapping(value = "/update")
    @Log(title = "景区攻略-修改", businessType = BusinessType.UPDATE)
    public R<String> update(@RequestBody TGuide tGuide) {
        LoginUser loginUser = tokenService.getLoginUser();
        tGuide.setUpdateBy(loginUser.getUser().getNickName());
        boolean update = tGuideService.updateById(tGuide);
        return update ? R.ok() : R.fail();
    }
 
 
    @ApiOperation(value = "景区攻略删除")
    @DeleteMapping(value = "/delete/{id}")
    @Log(title = "景区攻略-删除", businessType = BusinessType.DELETE)
    public R<String> delete(@PathVariable Integer id ) {
        boolean remove = tGuideService.removeById(id);
        return remove ? R.ok() : R.fail();
    }
 
 
}