liujie
2023-04-06 30cb1d32796a1b482d44bd424fdfe28c26b87be9
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
package com.stylefeng.guns.modular.system.controller;
 
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.stylefeng.guns.core.base.controller.BaseController;
import com.stylefeng.guns.modular.system.utils.tips.SuccessTip;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.beans.factory.annotation.Autowired;
import com.stylefeng.guns.modular.system.model.TWebsite;
import com.stylefeng.guns.modular.system.service.ITWebsiteService;
 
import java.util.Date;
 
/**
 * 控制器
 *
 * @author fengshuonan
 * @Date 2022-12-28 09:33:09
 */
@Controller
@Api(tags = "官网")
@RequestMapping("/api/tWebsite")
public class TWebsiteController extends BaseController {
 
 
    @Autowired
    private ITWebsiteService tWebsiteService;
 
 
 
    /**
     * 获取列表
     */
    @ApiOperation(value = "官网列表",notes="官网列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."),
            @ApiImplicitParam(name = "pageNumber", value = "pageNumber", required = true, dataType = "int",paramType = "query"),
            @ApiImplicitParam(name = "pageSize", value = "pageSize", required = true, dataType = "int",paramType = "query"),
            @ApiImplicitParam(name = "page", value = "位置  1Home  2ABOUT US 3Carriers", required = false, dataType = "Integer"),
    })
    @GetMapping(value = "/list")
    @ResponseBody
    public Object list(Integer page,Integer pageNumber,Integer pageSize) {
        Page<TWebsite> tWebsitePage = new Page<>(pageNumber, pageSize);
        if(page==null || "".equals(page)){
            Page<TWebsite> page1 = tWebsiteService.selectPage(tWebsitePage, new EntityWrapper<TWebsite>().eq("remove",0));
            return new SuccessTip(page1.getRecords());
        }else {
            Page<TWebsite> page1 = tWebsiteService.selectPage(tWebsitePage, new EntityWrapper<TWebsite>().eq("page", page).eq("remove", 0));
            return new SuccessTip(page1.getRecords());
        }
    }
 
    /**
     * 新增
     */
    @ApiOperation(value = "添加官网",notes="添加官网")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."),
    })
    @PostMapping(value = "/add")
    @ResponseBody
    public Object add(TWebsite tWebsite) {
        tWebsite.setCreateTime(new Date());
        tWebsiteService.insert(tWebsite);
        return SUCCESS_TIP;
    }
 
    /**
     * 删除
     */
    @ApiOperation(value = "删除官网",notes="删除官网")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."),
            @ApiImplicitParam(name = "tWebsiteId", value = "官网id", required = true, dataType = "int"),
    })
    @DeleteMapping(value = "/delete")
    @ResponseBody
    public Object delete(@RequestParam int tWebsiteId) {
        TWebsite tWebsite = tWebsiteService.selectById(tWebsiteId);
        tWebsite.setRemove(1);
        tWebsiteService.updateById(tWebsite);
        return SUCCESS_TIP;
    }
 
    /**
     * 修改
     */
    @ApiOperation(value = "修改官网",notes="修改官网")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."),
    })
    @PostMapping(value = "/update")
    @ResponseBody
    public Object update(TWebsite tWebsite) {
        tWebsite.setUpdateTime(new Date());
        tWebsiteService.updateById(tWebsite);
        return SUCCESS_TIP;
    }
 
    /**
     * 详情
     */
    @RequestMapping(value = "/detail/{tWebsiteId}")
    @ResponseBody
    public Object detail(@PathVariable("tWebsiteId") Integer tWebsiteId) {
        return tWebsiteService.selectById(tWebsiteId);
    }
}