zxl
5 天以前 2701dca44e1972afe9956ced2f949d2998c1bb4b
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 cn.lili.controller.message;
 
import cn.lili.common.enums.ResultUtil;
import cn.lili.common.security.context.UserContext;
import cn.lili.common.vo.PageVO;
import cn.lili.common.vo.ResultMessage;
import cn.lili.modules.member.entity.dos.MemberNotice;
import cn.lili.modules.member.service.MemberNoticeService;
import cn.lili.mybatis.util.PageUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
 
import java.util.List;
 
/**
 * 管理端,会员站内信管理接口
 *
 * @author Chopper
 * @since 2020/11/17 4:31 下午
 */
@RestController
@Api(tags = "管理端,会员站内信管理API")
@RequestMapping("/manager/message/memberNotice")
public class MemberNoticeManagerController {
    @Autowired
    private MemberNoticeService memberNoticeService;
 
    @ApiOperation(value = "获取详情")
    @GetMapping(value = "/{id}")
    public ResultMessage<MemberNotice> get(@PathVariable String id) {
        MemberNotice memberNotice = memberNoticeService.getById(id);
        return ResultUtil.data(memberNotice);
    }
 
    @ApiOperation(value = "分页获取站内信")
    @GetMapping(value = "/page")
    public ResultMessage<IPage<MemberNotice>> getByPage(
            PageVO page) {
        IPage<MemberNotice> data = memberNoticeService.page(PageUtil.initPage(page));
        return ResultUtil.data(data);
    }
 
    @ApiOperation(value = "阅读消息")
    @PostMapping("/read/{ids}")
    public ResultMessage<Object> read(@PathVariable List ids) {
        UpdateWrapper updateWrapper = new UpdateWrapper();
        updateWrapper.in("id", ids);
        updateWrapper.set("is_read", true);
        memberNoticeService.update(updateWrapper);
        return ResultUtil.success();
    }
 
    @ApiOperation(value = "阅读全部")
    @PostMapping("/read/all")
    public ResultMessage<Object> readAll() {
        UpdateWrapper updateWrapper = new UpdateWrapper();
        updateWrapper.in("member_id", UserContext.getCurrentUser().getId());
        updateWrapper.set("is_read", true);
        memberNoticeService.update(updateWrapper);
        return ResultUtil.success();
    }
 
    @ApiOperation(value = "批量删除")
    @DeleteMapping(value = "/{ids}")
    public ResultMessage<Object> delAllByIds(@PathVariable List ids) {
        memberNoticeService.removeByIds(ids);
        return ResultUtil.success();
    }
 
    @ApiOperation(value = "删除所有")
    @DeleteMapping
    public ResultMessage<Object> deleteAll() {
        QueryWrapper queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("member_id", UserContext.getCurrentUser().getId());
        memberNoticeService.remove(queryWrapper);
        return ResultUtil.success();
    }
 
}