ActivityThemeController.java
5.41 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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
package cn.fw.dalaran.server.controller.web;
import cn.fw.common.page.AppPage;
import cn.fw.common.web.annotation.ControllerMethod;
import cn.fw.common.web.auth.LoginAuthBean;
import cn.fw.common.web.auth.annotation.CurrentUser;
import cn.fw.dalaran.common.exception.BusinessException;
import cn.fw.dalaran.domain.db.ActivityTheme;
import cn.fw.dalaran.domain.param.ActivityThemePageParams;
import cn.fw.dalaran.domain.param.AddThemeCoverParams;
import cn.fw.dalaran.domain.param.AddThemeTopicParams;
import cn.fw.dalaran.domain.vo.ActivityThemeVo;
import cn.fw.dalaran.service.data.ActivityThemeService;
import cn.fw.data.base.domain.common.Message;
import cn.fw.security.auth.client.annotation.Authorization;
import cn.fw.security.auth.client.annotation.IgnoreAuth;
import cn.fw.security.auth.client.enums.AuthType;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import javax.validation.constraints.NotNull;
import java.util.Date;
import java.util.List;
import static cn.fw.common.web.util.ResultBuilder.success;
/**
* @author wmy3969
* @date 2022-1-12 10:06:48
* @description 活动配置
*/
@Slf4j
@Validated
@RestController
@RequiredArgsConstructor
@Authorization(AuthType.ERP)
@RequestMapping("/theme/setting")
@IgnoreAuth
public class ActivityThemeController {
private final ActivityThemeService activityThemeService;
/**
* 添加活动
*
* @param themeVo 活动主题参数
* @return 操作结果
*/
@PostMapping("/save")
public Message<Boolean> save(@RequestBody @Valid ActivityThemeVo themeVo) {
if (activityThemeService.validThemeDateDuplicate(themeVo))
throw new BusinessException("指定门店在指定时间段内正在参与其他活动, 添加失败");
return success(activityThemeService.save(themeVo));
}
/**
* 增加活动主题话题
*
* @param params 活动主题id
* @return 操作结果
*/
@PostMapping("/addTopic")
public Message<Boolean> addTopic(@RequestBody @Valid AddThemeTopicParams params) {
return success(activityThemeService.addTopic(params));
}
/**
* 增加封面
*
* @param params 增加封面带参
* @return 操作结果
*/
@PostMapping("/addCover")
public Message<Boolean> addCover(@RequestBody @Valid AddThemeCoverParams params) {
return success(activityThemeService.addCover(params));
}
/**
* 删除活动
*
* @param themeId 活动主题id
* @return 操作结果
*/
@PostMapping("/del")
@ControllerMethod("删除活动主题")
public Message<Boolean> del(@NotNull(message = "活动主题id不能为空") Long themeId) {
return success(activityThemeService.getBaseMapper().deleteById(themeId) > 0);
}
/**
* 查询活动列表
*
* @param user 当前登录用户
* @param configGroupId 所属配置组id
* @return 符合条件的活动列表
*/
@GetMapping("/list")
@ControllerMethod("查询活动主题列表")
public Message<List<ActivityThemeVo>> list(@CurrentUser LoginAuthBean user, @NotNull(message = "所属配置组id不能为空") Long configGroupId) {
return success(activityThemeService.list(user.getGroupId(), configGroupId));
}
/**
* 查询活动列表(指定月)
*
* @param user 当前登录用户
* @param timeStamp 指定月之内的时间戳
* @return 符合条件的活动列表
*/
@GetMapping("/listByMonth")
@ControllerMethod("查询指定月活动主题列表")
public Message<List<ActivityThemeVo>> listByMonth(@CurrentUser LoginAuthBean user, Long timeStamp) {
return success(activityThemeService.listByMonth(user, timeStamp));
}
/**
* 查询活动列表(分页)
*
* @param user 当前登录用户
* @param pageParams 分页参数
* @return 符合条件的活动列表
*/
@GetMapping("/pageList")
@ControllerMethod("分页查询活动主题列表")
public Message<AppPage<ActivityThemeVo>> pageList(@CurrentUser LoginAuthBean user, @Validated ActivityThemePageParams pageParams) {
return success(activityThemeService.pageList(user.getGroupId(), pageParams));
}
/**
* 根据活动id查询活动
*
* @param themeId 活动id
* @return 符合条件的活动
*/
@GetMapping("/getById")
@ControllerMethod("获取指定id的活动主题")
public Message<ActivityTheme> getById(@NotNull(message = "请必须指定主题id") Long themeId) {
return success(activityThemeService.getById(themeId));
}
/**
* 校验时间有无重叠
*
* @param startDate1 开始时间1
* @param endDate1 结束时间1
* @param startDate2 开始时间2
* @param endDate2 结束时间2
* @return 两个时间区间是否有重叠
*/
@GetMapping("/valid")
public Message<Boolean> valid(Date startDate1, Date endDate1, Date startDate2, Date endDate2) {
return success(activityThemeService.validDateOverlap(startDate1, endDate1, startDate2, endDate2));
}
@PostMapping("/alert")
@ControllerMethod("修改活动主题")
public Message<Boolean> alert(@RequestBody @Validated final ActivityTheme param) {
return success(activityThemeService.alertTheme(param));
}
}