ShyActivityController.java
3.58 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
97
98
99
100
101
102
103
104
105
106
107
108
109
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.dto.ShyActivityDTO;
import com.cnlive.shenhe.entity.ShyActivity;
import com.cnlive.shenhe.service.ShyActivityService;
import com.github.pagehelper.PageInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
/**
* @author Administrator
* @author yanzhaowang
* @create 2022-03-08 12:37
*/
@Controller
@RequestMapping("/activity")
public class ShyActivityController extends BaseController {
private static Logger logger = LoggerFactory.getLogger(ShyActivityController.class);
@Autowired
private ShyActivityService shyActivityService;
/**
* 添加活动
*
* @param shyActivity
* @return
*/
@PostMapping("/add")
@ResponseBody
public ResponseBean insterShyActivity(ShyActivity shyActivity) {
try {
Boolean result = shyActivityService.insertShyActivity(shyActivity);
if (result) {
return new ResponseBean(ErrorEnum.SUCCESS.getErrorCode(), "当前活动添加成功");
}
return new ResponseBean(ErrorEnum.ERROR.getErrorCode(), "添加失败,请重试");
} catch (Exception e) {
e.printStackTrace();
return new ResponseBean(ErrorEnum.ERROR.getErrorCode(), "添加失败,请重试");
}
}
/**
* 根据主键id删除活动
*
* @param id
* @return
*/
@PostMapping("/delete")
@ResponseBody
public ResponseBean deleteShyActivity(Integer id) {
Boolean result = shyActivityService.deleteShyActivity(id);
if (result) {
return new ResponseBean(ErrorEnum.SUCCESS.getErrorCode(), "删除当前活动成功");
}
return new ResponseBean(ErrorEnum.ERROR.getErrorCode(), "删除失败,请重试");
}
/**
* 修改对象
*
* @param shyActivity
* @return
*/
@PostMapping("/update")
@ResponseBody
public ResponseBean updateShyActivity(ShyActivity shyActivity) {
try {
Boolean result = shyActivityService.updateShyActivity(shyActivity);
if (result) {
return new ResponseBean(ErrorEnum.SUCCESS.getErrorCode(), "修改当前活动成功");
}
return new ResponseBean(ErrorEnum.ERROR.getErrorCode(), "修改失败,请重试");
} catch (Exception e) {
e.printStackTrace();
return new ResponseBean(ErrorEnum.ERROR.getErrorCode(), "修改失败,请重试");
}
}
/**
* 获取分页 条件查询的列表
*
* @param shyActivityDTO
* @param model
* @return
*/
@GetMapping("/page")
public String getShyActivity(ShyActivityDTO shyActivityDTO, Model model) {
logger.info("列表请求参数:{}", JSON.toJSONString(shyActivityDTO));
PageInfo<ShyActivity> shyActivityPageInfo = shyActivityService.selectByExample(shyActivityDTO);
model.addAttribute("exempt_from_trial", shyActivityDTO.getExempt_from_trial());
model.addAttribute("ShyActivitylist", shyActivityPageInfo);
return "page/activity.html";
}
}