|
@@ -0,0 +1,53 @@
|
|
|
|
|
+package com.etotem.cfc.controller.admin;
|
|
|
|
|
+
|
|
|
|
|
+import com.etotem.cfc.common.Result;
|
|
|
|
|
+import com.etotem.cfc.dto.TaskReminderConfigDTO;
|
|
|
|
|
+import com.etotem.cfc.service.TaskReminderConfigService;
|
|
|
|
|
+import org.springframework.web.bind.annotation.PostMapping;
|
|
|
|
|
+import org.springframework.web.bind.annotation.RequestBody;
|
|
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
|
+import org.springframework.web.bind.annotation.RequestParam;
|
|
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
+
|
|
|
|
|
+import javax.annotation.Resource;
|
|
|
|
|
+
|
|
|
|
|
+@RestController
|
|
|
|
|
+@RequestMapping("/api/admin/task/reminder-config")
|
|
|
|
|
+public class AdminTaskReminderConfigController {
|
|
|
|
|
+
|
|
|
|
|
+ @Resource
|
|
|
|
|
+ private TaskReminderConfigService taskReminderConfigService;
|
|
|
|
|
+
|
|
|
|
|
+ @PostMapping("/get")
|
|
|
|
|
+ public Result<TaskReminderConfigDTO> getConfig(@RequestParam("userId") Long userId) {
|
|
|
|
|
+ if (userId == null) {
|
|
|
|
|
+ return Result.error("缺少 userId");
|
|
|
|
|
+ }
|
|
|
|
|
+ return Result.success(taskReminderConfigService.getConfig(userId));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @PostMapping("/save")
|
|
|
|
|
+ public Result<Void> saveConfig(@RequestBody AdminTaskReminderConfigSaveDTO dto) {
|
|
|
|
|
+ if (dto == null || dto.getUserId() == null) {
|
|
|
|
|
+ return Result.error("缺少 userId");
|
|
|
|
|
+ }
|
|
|
|
|
+ try {
|
|
|
|
|
+ taskReminderConfigService.saveConfig(dto.getUserId(), dto);
|
|
|
|
|
+ return Result.success(null);
|
|
|
|
|
+ } catch (IllegalArgumentException e) {
|
|
|
|
|
+ return Result.error(e.getMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public static class AdminTaskReminderConfigSaveDTO extends TaskReminderConfigDTO {
|
|
|
|
|
+ private Long userId;
|
|
|
|
|
+
|
|
|
|
|
+ public Long getUserId() {
|
|
|
|
|
+ return userId;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public void setUserId(Long userId) {
|
|
|
|
|
+ this.userId = userId;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+}
|