ShyActivityController.java
3.84 KB
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
package com.cnlive.shenhe.controller;
//
// _ooOoo_
// o8888888o
// 88" . "88
// (| -_- |)
// O\ = /O
// ____/`---'\____
// . ' \\| |// `.
// / \\||| : |||// \
// / _||||| -:- |||||- \
// | | \\\ - /// | |
// | \_| ''\---/'' | |
// \ .-\__ `-` ___/-. /
// ___`. .' /--.--\ `. . __
// ."" '< `.___\_<|>_/___.' >'"".
// | | : `- \`.;`\ _ /`;.`/ - ` : | |
// \ \ `-. \_ __\ /__ _/ .-` / /
// ======`-.____`-.___\_____/___.-`____.-'======
// `=---='
//
// .............................................
// 佛祖镇楼 BUG辟易
// 佛曰:
// 写字楼里写字间,写字间里程序员;
// 程序人员写程序,又拿程序换酒钱。
// 酒醒只在网上坐,酒醉还来网下眠;
// 酒醉酒醒日复日,网上网下年复年。
// 但愿老死电脑间,不愿鞠躬老板前;
// 奔驰宝马贵者趣,公交自行程序员。
// 别人笑我忒疯癫,我笑自己命太贱;
//
import com.cnlive.shenhe.bean.ErrorEnum;
import com.cnlive.shenhe.bean.ResponseBean;
import com.cnlive.shenhe.entity.ShyActivity;
import com.cnlive.shenhe.serviceImpl.ShyActivityImpl;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* @author Administrator
* @author yanzhaowang
* @create 2022-03-08 12:37
*/
@Controller
@RequestMapping("/page")
public class ShyActivityController {
@Autowired
private ShyActivityImpl shyActivityImpl;
@PostMapping("/add")
@ResponseBody
public ResponseBean insterShyActivity(ShyActivity shyActivity, Model model){
int i = shyActivityImpl.insertShyActivity(shyActivity);
if (i>0) {
return new ResponseBean(ErrorEnum.SUCCESS.getErrorCode(), "当前用户添加成功");
}
return new ResponseBean(ErrorEnum.ERROR.getErrorCode(), "添加失败,请重试");
}
@DeleteMapping("/delete/{id}")
@ResponseBody
public ResponseBean deleteShyActivity(@PathVariable(value = "id") Integer id,Model model){
int i = shyActivityImpl.deleteShyActivity(id);
if (i>0) {
return new ResponseBean(ErrorEnum.SUCCESS.getErrorCode(), "删除当前用户添加成功");
}
return new ResponseBean(ErrorEnum.ERROR.getErrorCode(), "删除失败,请重试");
}
@PutMapping("/update")
@ResponseBody
public ResponseBean updateShyActivity(ShyActivity shyActivity,Model model){
int i = shyActivityImpl.updateShyActivity(shyActivity);
if (i>0) {
return new ResponseBean(ErrorEnum.SUCCESS.getErrorCode(), "修改当前用户添加成功");
}
return new ResponseBean(ErrorEnum.ERROR.getErrorCode(), "修改失败,请重试");
}
@GetMapping("/get/{page}/{Pagesize}")
public String getShyActivity(Integer id,@PathVariable(name = "page",value = "1") Integer page,@PathVariable(name = "Pagesize",value = "10") Integer Pagesize,Model model){
PageInfo<ShyActivity> shyActivityPageInfo = shyActivityImpl.selectByExample(page, Pagesize, id);
List<ShyActivity> list = shyActivityPageInfo.getList();
model.addAttribute("list", list);
return "page/activity.html";
}
}