liding
3 天以前 7f9e375391e30fd3c367cb5a080a609a6e25e524
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
package com.zbkj.admin.controller;
 
import com.zbkj.common.annotation.Loggable;
import com.zbkj.common.model.system.SystemNotification;
import com.zbkj.common.request.NotificationInfoRequest;
import com.zbkj.common.request.NotificationSearchRequest;
import com.zbkj.common.request.NotificationUpdateRequest;
import com.zbkj.common.response.CommonResult;
import com.zbkj.common.response.NotificationInfoResponse;
import com.zbkj.service.service.SystemNotificationService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
 
import java.util.List;
 
/**
 * 通知设置 前端控制器
 
 */
@Slf4j
@RestController
@RequestMapping("api/admin/system/notification")
@Api(tags = "通知设置-前端控制器") //配合swagger使用
public class SystemNotificationController {
 
    @Autowired
    private SystemNotificationService systemNotificationService;
 
    /**
     * 系统通知列表
     * @param request ExpressSearchRequest 搜索条件
     */
    @Loggable(value = "系统通知列表", trackParams = true)
    @PreAuthorize("hasAuthority('admin:system:notification:list')")
    @ApiOperation(value = "系统通知列表")
    @RequestMapping(value = "/list", method = RequestMethod.GET)
    public CommonResult<List<SystemNotification>> getList(@Validated NotificationSearchRequest request) {
        return CommonResult.success(systemNotificationService.getList(request));
    }
 
    /**
     * 发送短信开关
     */
    @Loggable(value = "发送短信开关", trackParams = true)
    @PreAuthorize("hasAuthority('admin:system:notification:sms:switch')")
    @ApiOperation(value = "发送短信开关")
    @RequestMapping(value = "/sms/switch/{id}", method = RequestMethod.POST)
    public CommonResult<Object> smsSwitch(@PathVariable Integer id) {
        if (systemNotificationService.smsSwitch(id)) {
            return CommonResult.success("更改成功");
        }
        return CommonResult.failed("更改失败");
    }
 
    /**
     * 通知详情
     */
    @Loggable(value = "通知详情", trackParams = true)
    @PreAuthorize("hasAuthority('admin:system:notification:detail')")
    @ApiOperation(value = "通知详情")
    @RequestMapping(value = "/detail", method = RequestMethod.GET)
    public CommonResult<NotificationInfoResponse> info(@Validated NotificationInfoRequest request) {
        return CommonResult.success(systemNotificationService.getDetail(request));
    }
 
    /**
     * 修改通知
     */
    @Loggable(value = "修改通知", trackParams = true)
    @PreAuthorize("hasAuthority('admin:system:notification:update')")
    @ApiOperation(value = "修改通知")
    @RequestMapping(value = "/update", method = RequestMethod.POST)
    public CommonResult<Object> update(@Validated @RequestBody NotificationUpdateRequest request) {
        if (systemNotificationService.modify(request)) {
            return CommonResult.success();
        }
        return CommonResult.failed();
    }
}