1.21
parent
3702701c0d
commit
e0fa5bc2e9
|
@ -19,6 +19,17 @@
|
|||
|
||||
<dependencies>
|
||||
|
||||
<!-- websocket -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-websocket</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>fastjson</artifactId>
|
||||
<version>1.2.76</version>
|
||||
</dependency>
|
||||
|
||||
<!-- <!– https://mvnrepository.com/artifact/com.alipay.sdk/alipay-sdk-java –>-->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>com.alipay.sdk</groupId>-->
|
||||
|
|
|
@ -3,8 +3,10 @@ package doctor;
|
|||
import doctor.common.security.annotation.EnableCustomConfig;
|
||||
import doctor.common.security.annotation.EnableRyFeignClients;
|
||||
import doctor.common.swagger.annotation.EnableCustomSwagger2;
|
||||
import doctor.text.WebSocketServer;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
|
||||
@EnableCustomConfig
|
||||
@EnableCustomSwagger2
|
||||
|
@ -13,7 +15,8 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|||
public class DoctorHealthApplication {
|
||||
public static void main(String[] args)
|
||||
{
|
||||
SpringApplication.run(DoctorHealthApplication.class, args);
|
||||
ConfigurableApplicationContext applicationContext = SpringApplication.run(DoctorHealthApplication.class, args);
|
||||
WebSocketServer.setUserService(applicationContext);
|
||||
System.out.println("(♥◠‿◠)ノ゙ 健康服务启动成功 ლ(´ڡ`ლ)゙ \n" +
|
||||
" .-------. ____ __ \n" +
|
||||
" | _ _ \\ \\ \\ / / \n" +
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
package doctor.config;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.socket.server.standard.ServerEndpointExporter;
|
||||
|
||||
// 配置开启WebSocket
|
||||
@Configuration
|
||||
public class WebSocketConfig {
|
||||
|
||||
@Bean
|
||||
public ServerEndpointExporter serverEndpointExporter() {
|
||||
return new ServerEndpointExporter();
|
||||
}
|
||||
|
||||
}
|
|
@ -17,7 +17,9 @@ public class HealthInquiryVerifyController {
|
|||
private InquiryVerifyService inquiryVerifyService;
|
||||
|
||||
@GetMapping("/findInquiryRecordList")
|
||||
public HealthR<List<InquiryRecordVo>> findInquiryRecordList() {
|
||||
public HealthR<List<InquiryRecordVo>> findInquiryRecordList(@RequestParam Integer page,
|
||||
@RequestParam Integer count,
|
||||
@RequestParam Integer recordId) {
|
||||
List<InquiryRecordVo> inquiryRecordList = inquiryVerifyService.findInquiryRecordList();
|
||||
return HealthR.ok(inquiryRecordList);
|
||||
}
|
||||
|
@ -25,8 +27,8 @@ public class HealthInquiryVerifyController {
|
|||
@GetMapping("/findHistoryInquiryRecord")
|
||||
public HealthR<List<HistoryInquiryRecordVo>> findHistoryInquiryRecord(@RequestParam Integer page,
|
||||
@RequestParam Integer count,
|
||||
@RequestHeader Integer doctorId) {
|
||||
List<HistoryInquiryRecordVo> inquiryRecordList = inquiryVerifyService.findHistoryInquiryRecord(page,count,doctorId);
|
||||
@RequestHeader Integer userId) {
|
||||
List<HistoryInquiryRecordVo> inquiryRecordList = inquiryVerifyService.findHistoryInquiryRecord(page,count,userId);
|
||||
return HealthR.ok(inquiryRecordList);
|
||||
}
|
||||
|
||||
|
|
|
@ -39,12 +39,6 @@ public class HealthJobTitleController {
|
|||
HealthR healthR= healthJobTitleService.applyJoin(applyJoinDto);
|
||||
return HealthR.ok(healthR);
|
||||
}
|
||||
|
||||
@GetMapping("/findDoctorById")
|
||||
public HealthR<DoctorVo> findDoctorById(@RequestHeader Integer doctorId,
|
||||
@RequestHeader String sessionId) {
|
||||
return HealthR.ok(healthJobTitleService.findDoctorById(doctorId));
|
||||
}
|
||||
@GetMapping("/findSystemImagePic")
|
||||
public HealthR<List<FindImagePicVo>> findSystemImagePic() {
|
||||
return HealthR.ok(healthJobTitleService.findSystemImagePic());
|
||||
|
|
|
@ -14,21 +14,11 @@ import org.springframework.web.multipart.MultipartFile;
|
|||
* @Description 新增病友圈
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/user/sickCircle/verify/v1/")
|
||||
@RequestMapping("/sickCircle/verify/v1/")
|
||||
public class SickCircleController {
|
||||
@Autowired
|
||||
SickCircleServer sickCircleServer;
|
||||
|
||||
|
||||
/**
|
||||
* 新增病友圈
|
||||
*/
|
||||
@PostMapping("/publishSickCircle")
|
||||
public HealthR<SickCircleEntity> publishSickCircle(@RequestBody SickCircleEntity sickCircleEntity) {
|
||||
|
||||
return sickCircleServer.publishSickCircle(sickCircleEntity);
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传图片
|
||||
*
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
package doctor.controller;
|
||||
|
||||
import doctor.common.core.domain.HealthR;
|
||||
import doctor.domain.entity.SickCircleEntity;
|
||||
import doctor.service.PatientService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/sickCircle/v1")
|
||||
public class SickCircleV1Controller {
|
||||
@Autowired
|
||||
private PatientService patientService;
|
||||
@GetMapping("/findSickCircleList")
|
||||
public HealthR<List<SickCircleEntity>> findSickCircleList(@RequestParam(value = "departmentId",required = false) Integer departmentId,
|
||||
@RequestParam(value = "page") Integer page,
|
||||
@RequestParam(value = "count") Integer count) {
|
||||
HealthR<List<SickCircleEntity>> listHealthR = patientService.sickCircleList(departmentId, page, count);
|
||||
return listHealthR;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
package doctor.domain.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
public class InquiryDetailsRecord {
|
||||
private Integer id;
|
||||
private Integer inquiryId;
|
||||
private Integer userId;
|
||||
private Integer doctorId;
|
||||
private String askContent;
|
||||
private String askImage;
|
||||
private String voiceChat;
|
||||
private Integer direction;
|
||||
private Date askTime;
|
||||
private Date createTime;
|
||||
}
|
|
@ -16,15 +16,13 @@ import java.util.List;
|
|||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class DoctorVo {
|
||||
private Integer doctorId;
|
||||
private String doctorName;
|
||||
private Integer id;
|
||||
private Integer departmentId;
|
||||
private String departmentName;
|
||||
private String goodField;
|
||||
private String imagePic;
|
||||
private String jobTitle;
|
||||
private String inauguralHospital;
|
||||
private double praise;
|
||||
private Integer serverNum;
|
||||
private Integer servicePrice;
|
||||
private Integer praiseNum;
|
||||
private Integer badNum;
|
||||
private Integer commentNum;
|
||||
private String jobTitle;
|
||||
private String name;
|
||||
private String personalProfile;
|
||||
}
|
||||
|
|
|
@ -2,6 +2,8 @@ package doctor.domain.vo;
|
|||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
public class HistoryInquiryRecordVo {
|
||||
private Integer recordId;
|
||||
|
@ -9,6 +11,6 @@ public class HistoryInquiryRecordVo {
|
|||
private String uerHeadPic;
|
||||
private String doctorHeadPic;
|
||||
private String nickName;
|
||||
private long inquiryTime;
|
||||
private Date inquiryTime;
|
||||
private Integer status;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
package doctor.domain.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class TestUserVo {
|
||||
private String nickName;
|
||||
}
|
|
@ -1,11 +1,18 @@
|
|||
package doctor.mapper;
|
||||
|
||||
import doctor.domain.entity.InquiryDetailsRecord;
|
||||
import doctor.domain.entity.UserEntity;
|
||||
import doctor.domain.vo.InquiryRecordVo;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
@Mapper
|
||||
public interface InquiryVerifyServiceMapper {
|
||||
|
||||
|
||||
List<InquiryDetailsRecord> findHistoryInquiryRecord(Integer doctorId);
|
||||
|
||||
List<UserEntity> findUserByIds(@Param("split") String[] split);
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
package doctor.service;
|
||||
|
||||
import doctor.domain.vo.TestUserVo;
|
||||
|
||||
public interface UserService {
|
||||
TestUserVo findById(Long aLong);
|
||||
}
|
|
@ -1,6 +1,8 @@
|
|||
package doctor.service.impl;
|
||||
|
||||
import doctor.common.core.web.controller.BaseController;
|
||||
import doctor.domain.entity.InquiryDetailsRecord;
|
||||
import doctor.domain.entity.UserEntity;
|
||||
import doctor.domain.vo.HistoryInquiryRecordVo;
|
||||
import doctor.domain.vo.InquiryRecordVo;
|
||||
import doctor.mapper.InquiryVerifyServiceMapper;
|
||||
|
@ -8,6 +10,7 @@ import doctor.service.InquiryVerifyService;
|
|||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
|
@ -25,7 +28,30 @@ public class InquiryVerifyServiceImpl extends BaseController implements InquiryV
|
|||
@Override
|
||||
public List<HistoryInquiryRecordVo> findHistoryInquiryRecord(Integer page, Integer count, Integer doctorId) {
|
||||
startPage(page,count);
|
||||
//TODO 待做
|
||||
return null;
|
||||
//查询所有和医生聊天的聊天列表拿到患者id
|
||||
List<InquiryDetailsRecord> inquiryDetailsRecord = inquiryVerifyServiceMapper.findHistoryInquiryRecord(doctorId);
|
||||
//定义一个数组用来接收所有的用户id
|
||||
String userId="";
|
||||
for (InquiryDetailsRecord detailsRecord : inquiryDetailsRecord) {
|
||||
userId+=","+detailsRecord;
|
||||
}
|
||||
String[] split = userId.split(",");
|
||||
//患者所有信息赋值
|
||||
List<UserEntity> userEntities = inquiryVerifyServiceMapper.findUserByIds(split);
|
||||
ArrayList<HistoryInquiryRecordVo> historyInquiryRecordVos = new ArrayList<>();
|
||||
for (UserEntity userEntity : userEntities) {
|
||||
HistoryInquiryRecordVo historyInquiryRecordVo = new HistoryInquiryRecordVo();
|
||||
historyInquiryRecordVo.setUserId(userEntity.getId());
|
||||
historyInquiryRecordVo.setNickName(historyInquiryRecordVo.getNickName());
|
||||
historyInquiryRecordVo.setUerHeadPic(userEntity.getHeadPic());
|
||||
historyInquiryRecordVo.setStatus(3);
|
||||
historyInquiryRecordVos.add(historyInquiryRecordVo);
|
||||
}
|
||||
for (HistoryInquiryRecordVo historyInquiryRecordVo : historyInquiryRecordVos) {
|
||||
for (InquiryDetailsRecord detailsRecord : inquiryDetailsRecord) {
|
||||
historyInquiryRecordVo.setInquiryTime(detailsRecord.getAskTime());
|
||||
}
|
||||
}
|
||||
return historyInquiryRecordVos;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
package doctor.service.impl;
|
||||
|
||||
public class UserServiceImpl {
|
||||
}
|
|
@ -0,0 +1,169 @@
|
|||
//package doctor.text;
|
||||
//
|
||||
//import com.alibaba.fastjson.JSON;
|
||||
//import com.alibaba.fastjson.JSONObject;
|
||||
//import doctor.common.core.utils.StringUtils;
|
||||
//import doctor.domain.vo.TestUserVo;
|
||||
//import doctor.service.UserService;
|
||||
//import doctor.service.impl.UserServiceImpl;
|
||||
//import org.slf4j.Logger;
|
||||
//import org.slf4j.LoggerFactory;
|
||||
//import org.springframework.context.ApplicationContext;
|
||||
//import org.springframework.data.redis.core.RedisTemplate;
|
||||
//import org.springframework.stereotype.Component;
|
||||
//
|
||||
//import javax.websocket.*;
|
||||
//import javax.websocket.server.PathParam;
|
||||
//import javax.websocket.server.ServerEndpoint;
|
||||
//import java.util.LinkedList;
|
||||
//import java.util.List;
|
||||
//import java.util.Map;
|
||||
//import java.util.concurrent.ConcurrentHashMap;
|
||||
//import java.util.concurrent.TimeUnit;
|
||||
//
|
||||
///**
|
||||
// * @author websocket服务
|
||||
// */
|
||||
//@ServerEndpoint(value = "/imserver/{userId}")
|
||||
//@Component
|
||||
//public class WebSocketServer {
|
||||
//
|
||||
//
|
||||
// private static UserService userService;
|
||||
//
|
||||
// private static RedisTemplate redisTemplate;
|
||||
//
|
||||
// public static void setUserService(ApplicationContext context){
|
||||
// userService = context.getBean(UserServiceImpl.class);
|
||||
// redisTemplate = (RedisTemplate) context.getBean("redisTemplate");
|
||||
// }
|
||||
//
|
||||
//
|
||||
// private static final Logger log = LoggerFactory.getLogger(WebSocketServer.class);
|
||||
// /**
|
||||
// * 记录当前在线连接数
|
||||
// */
|
||||
// public static final Map<String, Session> sessionMap = new ConcurrentHashMap<>();
|
||||
// /**
|
||||
// * 连接建立成功调用的方法
|
||||
// */
|
||||
// // 当前用户
|
||||
// private TestUserVo userVo;
|
||||
// // 连接上服务端触发的方法
|
||||
// @OnOpen
|
||||
// public void onOpen(Session session, @PathParam("userId") String userId) {
|
||||
// if (StringUtils.hasText(userId)){
|
||||
// // 加入新用户
|
||||
// if (sessionMap.containsKey(userId)){
|
||||
// sessionMap.remove(userId);
|
||||
// }
|
||||
// sessionMap.put(userId, session);
|
||||
// this.userVo = userService.findById(Long.valueOf(userId));
|
||||
// // 统计所有在线用户
|
||||
// List<TestUserVo> list = new LinkedList<>();
|
||||
// sessionMap.forEach((userId1,session1) -> {
|
||||
// TestUserVo userVo = userService.findById(Long.valueOf(userId1));
|
||||
// list.add(userVo);
|
||||
// });
|
||||
// try {
|
||||
// // 发送给所有在线的用户,更新在线人数
|
||||
// sendAllMessage(JSON.toJSONString(list));
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// log.info("有新用户加入,userId={}, 当前在线人数为:{}", userId, sessionMap.size());
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// /**
|
||||
// * 连接关闭调用的方法
|
||||
// */
|
||||
// @OnClose
|
||||
// public void onClose(Session session, @PathParam("userId") String userId) {
|
||||
// sessionMap.remove(userId);
|
||||
// // 统计所有在线用户
|
||||
// List<TestUserVo> list = new LinkedList<>();
|
||||
// sessionMap.forEach((userId1,session1) -> {
|
||||
// TestUserVo userVo = userService.findById(Long.valueOf(userId1));
|
||||
// list.add(userVo);
|
||||
// });
|
||||
// sendAllMessage(JSON.toJSONString(list));
|
||||
// log.info("有一连接关闭,移除userId={}的用户session, 当前在线人数为:{}", userId, sessionMap.size());
|
||||
// }
|
||||
// /**
|
||||
// * 收到客户端消息后调用的方法
|
||||
// * 后台收到客户端发送过来的消息
|
||||
// * onMessage 是一个消息的中转站
|
||||
// * 接受 浏览器端 socket.send 发送过来的 json数据
|
||||
// * @param message 客户端发送过来的消息
|
||||
// */
|
||||
// @OnMessage
|
||||
// public void onMessage(String message, Session session, @PathParam("userId") String userId) {
|
||||
// userVo = userService.findById(Long.valueOf(userId));
|
||||
// log.info("服务端收到用户username={},id={}的消息:{}", userVo.getNickName(),userId, message);
|
||||
// // 解析消息
|
||||
// JSONObject jsonObject1 = JSON.parseObject(message);
|
||||
// String toUserId = jsonObject1.getString("toUserId");
|
||||
// String text = jsonObject1.getString("text");
|
||||
// // 判断是给指定人发,还是群发
|
||||
// if (StringUtils.hasText(toUserId)){
|
||||
// // {"to": "admin", "text": "聊天文本"}
|
||||
// Session toSession = sessionMap.get(toUserId); // 根据 to用户名来获取 session,再通过session发送消息文本
|
||||
// if (toSession != null) {
|
||||
// // 服务器端 再把消息组装一下,组装后的消息包含发送人和发送的文本内容
|
||||
// // {"from": "zhang", "text": "hello"}
|
||||
// JSONObject jsonObject = new JSONObject();
|
||||
// jsonObject.put("fromUser",userVo);
|
||||
// jsonObject.put("toUser",userService.findById(Long.valueOf(toUserId)));
|
||||
// jsonObject.put("text",text);
|
||||
// this.sendMessage(jsonObject.toJSONString(), toSession);
|
||||
// log.info("发送给用户userId={},消息:{}", toUserId, jsonObject.toJSONString());
|
||||
// } else {
|
||||
// log.info("发送失败,未找到用户username={}的session", toUserId);
|
||||
// }
|
||||
// }else{
|
||||
// JSONObject jsonObject = new JSONObject();
|
||||
// jsonObject.put("fromUser",userVo);
|
||||
// jsonObject.put("text",text);
|
||||
// this.sendAllMessage(jsonObject.toJSONString());
|
||||
// // 将消息存入redis
|
||||
// redisTemplate.opsForList().rightPush("messageList",jsonObject.toJSONString());
|
||||
// redisTemplate.expire("messageList",60*60, TimeUnit.SECONDS); // 过期时间
|
||||
//
|
||||
// log.info("发送给所有用户,消息:{}", toUserId, jsonObject.toJSONString());
|
||||
//
|
||||
// }
|
||||
// }
|
||||
// @OnError
|
||||
// public void onError(Session session, Throwable error) {
|
||||
// log.error("发生错误");
|
||||
// error.printStackTrace();
|
||||
// }
|
||||
// /**
|
||||
// * 服务端发送消息给客户端
|
||||
// */
|
||||
// private void sendMessage(String message, Session toSession) {
|
||||
// try {
|
||||
// log.info("服务端给客户端[{}]发送消息{}", toSession.getId(), message);
|
||||
// toSession.getBasicRemote().sendText(message);
|
||||
// } catch (Exception e) {
|
||||
// log.error("服务端发送消息给客户端失败", e);
|
||||
// }
|
||||
// }
|
||||
// /**
|
||||
// * 服务端发送消息给所有客户端
|
||||
// */
|
||||
// private void sendAllMessage(String message) {
|
||||
// try {
|
||||
// for (Session session : sessionMap.values()) {
|
||||
// log.info("服务端给客户端[{}]发送消息{}", session.getId(), message);
|
||||
// session.getBasicRemote().sendText(message);
|
||||
//
|
||||
// }
|
||||
// } catch (Exception e) {
|
||||
// log.error("服务端发送消息给客户端失败", e);
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
//
|
||||
//
|
|
@ -5,4 +5,14 @@
|
|||
<mapper namespace="doctor.mapper.InquiryVerifyServiceMapper">
|
||||
|
||||
|
||||
<select id="findHistoryInquiryRecord" resultType="doctor.domain.entity.InquiryDetailsRecord">
|
||||
select * from inquiry_details_record where doctor_id = #{doctorId}
|
||||
</select>
|
||||
<select id="findUserByIds" resultType="doctor.domain.entity.UserEntity">
|
||||
select * from user_entity where id in
|
||||
<foreach collection="split" item="id" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
|
Loading…
Reference in New Issue