Commit a4b8b85ca34ea3d7ec3f1acd50055601f029c051
1 parent
e21e813d7e
Exists in
master
环信组
Showing 4 changed files with 52 additions and 32 deletions
talkonlineweb/src/main/java/com/lyms/talkonlineweb/controller/ChatGroupController.java
View file @
a4b8b85
1 | 1 | package com.lyms.talkonlineweb.controller; |
2 | 2 | |
3 | +import com.alibaba.fastjson.JSONObject; | |
3 | 4 | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
4 | 5 | import com.lyms.talkonlineweb.domain.LymsChatgroup; |
5 | 6 | import com.lyms.talkonlineweb.result.BaseResponse; |
6 | 7 | import com.lyms.talkonlineweb.service.LymsChatgroupService; |
7 | 8 | import com.lyms.talkonlineweb.util.HXService; |
9 | +import lombok.extern.log4j.Log4j2; | |
8 | 10 | import org.springframework.beans.BeanUtils; |
9 | 11 | import org.springframework.beans.factory.annotation.Autowired; |
10 | -import org.springframework.web.bind.annotation.GetMapping; | |
12 | +import org.springframework.web.bind.annotation.PostMapping; | |
11 | 13 | import org.springframework.web.bind.annotation.RequestMapping; |
12 | 14 | import org.springframework.web.bind.annotation.RestController; |
13 | 15 | |
... | ... | @@ -15,6 +17,7 @@ |
15 | 17 | |
16 | 18 | @RestController |
17 | 19 | @RequestMapping("chat") |
20 | +@Log4j2 | |
18 | 21 | public class ChatGroupController { |
19 | 22 | @Autowired |
20 | 23 | private LymsChatgroupService lymsChatgroupService; |
21 | 24 | |
22 | 25 | |
23 | 26 | |
... | ... | @@ -26,15 +29,25 @@ |
26 | 29 | * @param group |
27 | 30 | * @return |
28 | 31 | */ |
29 | - @GetMapping("saveChatGroup") | |
32 | + @PostMapping("saveChatGroup") | |
30 | 33 | public BaseResponse saveChatGroup(LymsChatgroup group){ |
31 | 34 | BaseResponse baseResponse=new BaseResponse(); |
32 | 35 | List<LymsChatgroup> gLst=lymsChatgroupService.list(Wrappers.query(group)); |
36 | + if(group.getOwnerk()==null){ | |
37 | + group.setOwnerk("test"); | |
38 | + } | |
33 | 39 | if(gLst.size()>0){ |
34 | 40 | LymsChatgroup group2=gLst.get(0); |
35 | - group.setId(group2.getId()); | |
41 | + group=group2; | |
42 | + }else{ | |
43 | + log.info("创建环信组:{} from:{} target:{}",group.getOwnerk(),group.getFromp(),group.getTarget()); | |
44 | + JSONObject rJson=hxService.addChatGroups(group.getFromp()+","+group.getTarget(),group.getOwnerk(), new String[]{group.getFromp(), group.getTarget()}); | |
45 | + log.info("rJson:"+rJson); | |
46 | + group.setHxgroupid(rJson.getJSONObject("data").getString("groupid")); | |
47 | + group.setDescription(group.getFromp()+","+group.getTarget()); | |
48 | + group.setGroupname(group.getFromp()+","+group.getTarget()); | |
49 | + lymsChatgroupService.saveOrUpdate(group); | |
36 | 50 | } |
37 | - lymsChatgroupService.saveOrUpdate(group); | |
38 | 51 | baseResponse.setObject(group); |
39 | 52 | return baseResponse; |
40 | 53 | } |
talkonlineweb/src/main/java/com/lyms/talkonlineweb/domain/LymsChatgroup.java
View file @
a4b8b85
... | ... | @@ -18,7 +18,7 @@ |
18 | 18 | /** |
19 | 19 | * |
20 | 20 | */ |
21 | - @TableField(value = "id") | |
21 | + @TableId(value = "id", type = IdType.AUTO) | |
22 | 22 | private Integer id; |
23 | 23 | |
24 | 24 | /** |
25 | 25 | |
26 | 26 | |
27 | 27 | |
... | ... | @@ -36,20 +36,26 @@ |
36 | 36 | /** |
37 | 37 | * 客服人员ID |
38 | 38 | */ |
39 | - @TableField(value = "owner") | |
40 | - private Integer owner; | |
39 | + @TableField(value = "ownerk") | |
40 | + private String ownerk; | |
41 | 41 | |
42 | 42 | /** |
43 | 43 | * 患者ID |
44 | 44 | */ |
45 | - @TableField(value = "from") | |
46 | - private Integer from; | |
45 | + @TableField(value = "fromp") | |
46 | + private String fromp; | |
47 | 47 | |
48 | 48 | /** |
49 | + * 环信组ID | |
50 | + */ | |
51 | + @TableField(value = "hxgroupid") | |
52 | + private String hxgroupid; | |
53 | + | |
54 | + /** | |
49 | 55 | * 医生ID |
50 | 56 | */ |
51 | 57 | @TableField(value = "target") |
52 | - private Integer target; | |
58 | + private String target; | |
53 | 59 | |
54 | 60 | /** |
55 | 61 | * 创建时间 |
... | ... | @@ -75,8 +81,9 @@ |
75 | 81 | return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId())) |
76 | 82 | && (this.getGroupname() == null ? other.getGroupname() == null : this.getGroupname().equals(other.getGroupname())) |
77 | 83 | && (this.getDescription() == null ? other.getDescription() == null : this.getDescription().equals(other.getDescription())) |
78 | - && (this.getOwner() == null ? other.getOwner() == null : this.getOwner().equals(other.getOwner())) | |
79 | - && (this.getFrom() == null ? other.getFrom() == null : this.getFrom().equals(other.getFrom())) | |
84 | + && (this.getOwnerk() == null ? other.getOwnerk() == null : this.getOwnerk().equals(other.getOwnerk())) | |
85 | + && (this.getFromp() == null ? other.getFromp() == null : this.getFromp().equals(other.getFromp())) | |
86 | + && (this.getHxgroupid() == null ? other.getHxgroupid() == null : this.getHxgroupid().equals(other.getHxgroupid())) | |
80 | 87 | && (this.getTarget() == null ? other.getTarget() == null : this.getTarget().equals(other.getTarget())) |
81 | 88 | && (this.getCtime() == null ? other.getCtime() == null : this.getCtime().equals(other.getCtime())); |
82 | 89 | } |
... | ... | @@ -88,8 +95,9 @@ |
88 | 95 | result = prime * result + ((getId() == null) ? 0 : getId().hashCode()); |
89 | 96 | result = prime * result + ((getGroupname() == null) ? 0 : getGroupname().hashCode()); |
90 | 97 | result = prime * result + ((getDescription() == null) ? 0 : getDescription().hashCode()); |
91 | - result = prime * result + ((getOwner() == null) ? 0 : getOwner().hashCode()); | |
92 | - result = prime * result + ((getFrom() == null) ? 0 : getFrom().hashCode()); | |
98 | + result = prime * result + ((getOwnerk() == null) ? 0 : getOwnerk().hashCode()); | |
99 | + result = prime * result + ((getFromp() == null) ? 0 : getFromp().hashCode()); | |
100 | + result = prime * result + ((getHxgroupid() == null) ? 0 : getHxgroupid().hashCode()); | |
93 | 101 | result = prime * result + ((getTarget() == null) ? 0 : getTarget().hashCode()); |
94 | 102 | result = prime * result + ((getCtime() == null) ? 0 : getCtime().hashCode()); |
95 | 103 | return result; |
... | ... | @@ -104,8 +112,9 @@ |
104 | 112 | sb.append(", id=").append(id); |
105 | 113 | sb.append(", groupname=").append(groupname); |
106 | 114 | sb.append(", description=").append(description); |
107 | - sb.append(", owner=").append(owner); | |
108 | - sb.append(", from=").append(from); | |
115 | + sb.append(", ownerk=").append(ownerk); | |
116 | + sb.append(", fromp=").append(fromp); | |
117 | + sb.append(", hxgroupid=").append(hxgroupid); | |
109 | 118 | sb.append(", target=").append(target); |
110 | 119 | sb.append(", ctime=").append(ctime); |
111 | 120 | sb.append(", serialVersionUID=").append(serialVersionUID); |
talkonlineweb/src/main/java/com/lyms/talkonlineweb/util/HXService.java
View file @
a4b8b85
... | ... | @@ -19,10 +19,7 @@ |
19 | 19 | |
20 | 20 | import java.io.*; |
21 | 21 | import java.net.URL; |
22 | -import java.util.ArrayList; | |
23 | -import java.util.HashMap; | |
24 | -import java.util.List; | |
25 | -import java.util.Map; | |
22 | +import java.util.*; | |
26 | 23 | import java.util.zip.GZIPInputStream; |
27 | 24 | |
28 | 25 | import static org.apache.commons.io.FilenameUtils.getExtension; |
29 | 26 | |
30 | 27 | |
31 | 28 | |
32 | 29 | |
... | ... | @@ -272,27 +269,27 @@ |
272 | 269 | |
273 | 270 | /** |
274 | 271 | * 创建聊天室 |
275 | - * @param name | |
276 | 272 | * @param description |
277 | 273 | * @param owner |
278 | 274 | * @param members |
279 | 275 | * @return |
280 | 276 | */ |
281 | - public JSONObject addChatRooms(String name,String description,String owner,String[] members){ | |
277 | + public JSONObject addChatGroups(String description,String owner,String[] members){ | |
282 | 278 | JSONObject rs=new JSONObject(); |
283 | 279 | Map<String,Object> param=new HashMap<>(); |
284 | 280 | HttpHeaders headers=new HttpHeaders(); |
285 | 281 | |
286 | 282 | headers.add("Authorization","Bearer "+getToken()); |
287 | 283 | List lParam=new ArrayList(); |
288 | - param.put("name",name); | |
289 | - param.put("description",description); | |
284 | + param.put("groupname", Arrays.toString(members)); | |
285 | + param.put("desc",description); | |
286 | + param.put("public",true); | |
290 | 287 | param.put("owner",owner); |
291 | - param.put("members",members); | |
288 | + param.put("members",Arrays.asList(members)); | |
292 | 289 | |
293 | 290 | lParam.add(param); |
294 | 291 | HttpEntity entity=new HttpEntity(param,headers); |
295 | - resp=restTemplate.postForEntity(getUrl()+"chatrooms",entity,String.class); | |
292 | + resp=restTemplate.postForEntity(getUrl()+"chatgroups",entity,String.class); | |
296 | 293 | if (resp.getStatusCodeValue()==200){ |
297 | 294 | rs= JSON.parseObject(resp.getBody()); |
298 | 295 | } |
talkonlineweb/src/main/resources/mapper/LymsChatgroupMapper.xml
View file @
a4b8b85
... | ... | @@ -5,19 +5,20 @@ |
5 | 5 | <mapper namespace="com.lyms.talkonlineweb.mapper.LymsChatgroupMapper"> |
6 | 6 | |
7 | 7 | <resultMap id="BaseResultMap" type="com.lyms.talkonlineweb.domain.LymsChatgroup"> |
8 | - <result property="id" column="id" jdbcType="INTEGER"/> | |
8 | + <id property="id" column="id" jdbcType="INTEGER"/> | |
9 | 9 | <result property="groupname" column="groupname" jdbcType="VARCHAR"/> |
10 | 10 | <result property="description" column="description" jdbcType="VARCHAR"/> |
11 | - <result property="owner" column="owner" jdbcType="INTEGER"/> | |
12 | - <result property="from" column="from" jdbcType="INTEGER"/> | |
13 | - <result property="target" column="target" jdbcType="INTEGER"/> | |
11 | + <result property="ownerk" column="ownerk" jdbcType="VARCHAR"/> | |
12 | + <result property="fromp" column="fromp" jdbcType="VARCHAR"/> | |
13 | + <result property="hxgroupid" column="hxgroupid" jdbcType="VARCHAR"/> | |
14 | + <result property="target" column="target" jdbcType="VARCHAR"/> | |
14 | 15 | <result property="ctime" column="ctime" jdbcType="TIMESTAMP"/> |
15 | 16 | </resultMap> |
16 | 17 | |
17 | 18 | <sql id="Base_Column_List"> |
18 | 19 | id,groupname,description, |
19 | - owner,from,target, | |
20 | - ctime | |
20 | + ownerk,fromp,hxgroupid, | |
21 | + target,ctime | |
21 | 22 | </sql> |
22 | 23 | </mapper> |