Pu Zhibing
2025-02-27 f0a9a41697a8568e8b3bd3436c450e68b3298916
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
package com.panzhihua.service_community.api;
 
import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.panzhihua.common.controller.BaseController;
import com.panzhihua.common.model.dtos.community.sanshuo.ComMediateTypeDTO;
import com.panzhihua.common.model.dtos.community.sanshuo.ComSanshuoEventDTO;
import com.panzhihua.common.model.dtos.community.sanshuo.IndexDateDTO;
import com.panzhihua.common.model.vos.R;
import com.panzhihua.common.service.user.UserService;
import com.panzhihua.service_community.entity.ComEvent;
import com.panzhihua.service_community.entity.ComMediateType;
import com.panzhihua.service_community.entity.ComSanshuoEvent;
import com.panzhihua.service_community.service.ComSanShuoEventService;
import com.panzhihua.service_community.service.CommediateTypeService;
import com.panzhihua.service_community.service.IComEventService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
 
import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
 
/**
 * 三说会堂事件类型管理控制器
 * */
@RestController
@RequestMapping("/sanshuo/event")
public class ComSanShuoEventApi extends BaseController {
 
//    @Resource
//    private ComSanShuoEventService comSanShuoEventService;
 
    @Resource
    private CommediateTypeService commediateTypeService;
 
    @Resource
    private IComEventService comEventService;
 
    @Resource
    private UserService userService;
 
    @GetMapping ("/list")
    public R list(@RequestParam(value = "keyWord",required = false)String keyWord,
                  @RequestParam(value = "page",required = false)Integer page,
                  @RequestParam(value = "size",required = false)Integer size){
//        String appId=userService.detailUser(this.getUserId()).getData().getAppId();
        String appId=getAppId();
        return commediateTypeService.listEvent(keyWord,page,size,appId);
    }
 
    @GetMapping("/detail")
    public R detail(@RequestParam("id")Long id){
        return R.ok(commediateTypeService.getById(id));
    }
 
    @GetMapping("/appletsList")
    public R appletList(){
        return R.ok(commediateTypeService.list(new QueryWrapper<ComMediateType>().eq("enabled",1).eq("delete_flag", 0)));
    }
 
 
 
    /**
     * 新增事件类型
     * */
    @PostMapping
    public R add(@RequestBody ComMediateTypeDTO comMediateTypeDTO){
        comMediateTypeDTO.setCreateUser(this.getLoginUserInfo().getUserId());
        return commediateTypeService.addOrUpdate(comMediateTypeDTO);
    }
 
    /**
     * 修改事件类型
     * */
    @PutMapping
    public R update(@RequestBody ComMediateTypeDTO comMediateTypeDTO){
        comMediateTypeDTO.setModifyUser(this.getLoginUserInfo().getUserId());
        return commediateTypeService.addOrUpdate(comMediateTypeDTO);
    }
 
 
    /**
     * 删除事件
     * */
    @DeleteMapping("/remove")
    public R remove(@RequestParam("id")Long id){
        ComMediateType comMediateType = commediateTypeService.getById(id);
        comMediateType.setDeleteFlag(true);
        comMediateType.setEnabled(false);
        comMediateType.setModifyUser(this.getLoginUserInfo().getUserId());
        //该分类是否有未调解完成事件
        List<ComEvent> list = comEventService.list(new QueryWrapper<ComEvent>().lambda().eq(ComEvent::getEventCategory, id).in(ComEvent::getEventProcessStatus, (1), (2), (5)));
        if (list.size() != 0){
            return R.fail("有未处理完成事件,无法删除");
        }
        return R.ok(commediateTypeService.updateById(comMediateType));
    }
 
 
 
}