ShyActivityController.java
2.51 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
package com.cnlive.shenhe.controller;
import com.alibaba.fastjson.JSON;
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("/activity")
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("/page")
// public String getShyActivity(Model model, @RequestParam(defaultValue = "1") Integer page, @RequestParam(defaultValue = "1") Integer pageSize,
// Integer id) {
// System.out.println(id);
// PageInfo<ShyActivity> shyActivityPageInfo = shyActivityImpl.selectByExample(page, pageSize);
// List<ShyActivity> list = shyActivityPageInfo.getList();
// model.addAttribute("list", JSON.toJSONString(list));
// return "page/activity.html";
// }
}