mitao
2025-02-21 31573d6180d15ef65ed0df9c2732495f40b12663
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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
package com.panzhihua.service_community.api;
 
import cn.hutool.core.bean.BeanUtil;
import com.alibaba.excel.EasyExcel;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.panzhihua.common.controller.BaseController;
import com.panzhihua.common.model.dtos.community.sanshuo.ComSanshuoExpertDTO;
import com.panzhihua.common.model.vos.LoginUserInfoVO;
import com.panzhihua.common.model.vos.R;
import com.panzhihua.common.model.vos.user.AdministratorsUserVO;
import com.panzhihua.common.service.user.UserService;
import com.panzhihua.common.utlis.ExcelUtils;
import com.panzhihua.common.utlis.Snowflake;
import com.panzhihua.service_community.entity.ComEvent;
import com.panzhihua.service_community.entity.ComSanshuoExpert;
import com.panzhihua.service_community.service.ComSanShuoExpertService;
import com.panzhihua.service_community.service.IComEventService;
import com.panzhihua.service_community.util.ExcelListener;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
 
import javax.annotation.Resource;
import javax.xml.crypto.Data;
import java.io.IOException;
import java.util.Date;
import java.util.List;
 
import static java.util.Objects.isNull;
import static java.util.Objects.nonNull;
 
/**
 * 三说会堂调解专家控制器
 * */
@RestController
@RequestMapping("/sanshuo/expert")
public class ComSanShuoExpertApi extends BaseController {
 
    @Resource
    private ComSanShuoExpertService comSanShuoExpertService;
    @Resource
    private UserService userService;
    @Resource
    private IComEventService comEventService;
 
    /**
     * 添加专家
     * */
    @PostMapping
    public R add(@RequestBody ComSanshuoExpertDTO comSanshuoExpertDTO){
        comSanshuoExpertDTO.setCreateBy(this.getLoginUserInfo().getName());
//        comSanshuoExpertDTO.setAppId(userService.detailUser(getLoginUserInfo().getUserId()).getData().getAppId());
        comSanshuoExpertDTO.setAppId(getAppId());
        return comSanShuoExpertService.addOrUpdateExpert(comSanshuoExpertDTO);
    }
 
    @GetMapping("/detail")
    public R detail(@RequestParam Long id){
        return R.ok(comSanShuoExpertService.getById(id));
    }
 
    /**
     * 小程序获取可选择专家
     * */
    @GetMapping("/appletsList")
    public R appList(@RequestParam (value = "type",required = false)Integer type,@RequestParam(value = "id",required = false)Long id){
        return comSanShuoExpertService.selectExpertList(type, id,this.getLoginUserInfo().getCommunityId());
    }
 
    /**
     * 修改专家
     * */
    @PutMapping
    public R update(@RequestBody ComSanshuoExpertDTO comSanshuoExpertDTO){
        return R.ok(comSanShuoExpertService.addOrUpdateExpert(comSanshuoExpertDTO));
    }
 
 
    /**
     * 后台获取列表
     * */
    @GetMapping("/backstageList")
    public R backList(@RequestParam(value = "keyWord",required = false) String keyWord,
                      @RequestParam(value = "page",required = false)Integer page,
                      @RequestParam(value = "size",required = false)Integer size,
                      @RequestParam(value = "level",required = false)Integer level){
        LoginUserInfoVO loginUserInfo = this.getLoginUserInfo();
//        loginUserInfo.setAppId(userService.detailUser(getLoginUserInfo().getUserId()).getData().getAppId());
        loginUserInfo.setAppId(getAppId());
        return comSanShuoExpertService.expertPage(keyWord,page,size,loginUserInfo,level);
    }
 
 
    /**
     * 删除
     * */
    @DeleteMapping("/remove")
    public R remove(@RequestParam("id")Long id){
        List<ComEvent> list = comEventService.list(new QueryWrapper<ComEvent>().lambda().eq(ComEvent::getSpecialistId, id).in(ComEvent::getEventProcessStatus, (1), (2), (5)));
        if (list.size()!=0){
            return R.fail("有未调解完成事件,无法删除!");
        }
        ComSanshuoExpert expert = comSanShuoExpertService.getById(id);
        expert.setStatus(0);
        expert.setDelFlag(0);
        boolean b = comSanShuoExpertService.updateById(expert);
        if (b){
            //删除专家账号的权限
            userService.removeExpertRole(expert.getPhone());
        }
        return R.ok();
    }
 
    /**
     * 重置密码
     * */
    @PostMapping("/resetPassword")
    public R resetPassword(@RequestBody ComSanshuoExpertDTO comSanshuoExpertDTO){
        ComSanshuoExpert expert = comSanShuoExpertService.getById(comSanshuoExpertDTO.getId());
        expert.setPassword(comSanshuoExpertDTO.getPassword());
        userService.sanShuoResetPassword(comSanshuoExpertDTO.getAccount(),comSanshuoExpertDTO.getPassword() );
        return R.ok(comSanShuoExpertService.updateById(expert));
    }
 
    /**
     * 专家风采
     * */
    @GetMapping("/expertShow")
    public R expertShow(){
        return comSanShuoExpertService.expertShow(this.getLoginUserInfo().getAppId());
    }
 
 
    /**
     * 专家范围
     * */
    @GetMapping("/expertRange")
    public R expertRange(){
        LoginUserInfoVO loginUserInfo1=getLoginUserInfo();
        LoginUserInfoVO loginUserInfo = userService.detailUser(loginUserInfo1.getUserId()).getData();
        return comSanShuoExpertService.expertRange(loginUserInfo);
    }
 
    /**
     * 专家风采列表
     * */
    @GetMapping("/expertShowList")
    public R expertShowList(@RequestParam(value = "level",required = false)Integer level,
                            @RequestParam(value = "id",required = false)Long id){
//        return comSanShuoExpertService.expertShowList(level,id,userService.detailUser(this.getUserId()).getData().getAppId());
        return comSanShuoExpertService.expertShowList(level,id,getAppId());
    }
 
    /**
     * 是否为专家登陆小程序
     * */
    @GetMapping("/checkExpert")
    public R checkExpert(@RequestParam("number") String number){
        ComSanshuoExpert expert = comSanShuoExpertService.getOne(new QueryWrapper<ComSanshuoExpert>().lambda().eq(ComSanshuoExpert::getPhone, number));
        if (nonNull(expert)){
            return R.ok();
        }
        return R.fail();
    }
 
    /**
     * 导入专家信息
     * */
    @PostMapping("/importExpert")
    public R importExpert(@RequestBody MultipartFile multipartFile){
        try {
            ExcelListener listener=new ExcelListener(comSanShuoExpertService);
            EasyExcel.read(multipartFile.getInputStream(),ComSanshuoExpert.class,listener).sheet().doRead();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return R.ok();
    }
 
    /**
     * 后台获取专家列表
     * */
    @GetMapping("/backstageList2")
    public R  backstageList(@RequestParam(value = "level",required = false)Integer level,
                            @RequestParam(value = "page",required = false)Integer page,
                            @RequestParam(value = "size",required = false)Integer size,
                            @RequestParam(value = "keyWord",required = false)String  keyWord){
        LoginUserInfoVO loginUserInfo = getLoginUserInfo();
//        loginUserInfo.setAppId(userService.detailUser(getLoginUserInfo().getUserId()).getData().getAppId());
        loginUserInfo.setAppId(getAppId());
        return comSanShuoExpertService.backstageList(level,loginUserInfo,page,size,keyWord);
    }
 
 
 
 
 
}