Commit 615f7b7a by giaogiao

消息修改为已接收状态;

离线消息列表;
parent df551751
package io.geekidea.springbootplus.test; package io.geekidea.springbootplus.test;
import com.wecloud.im.entity.ImConversation;
import com.wecloud.im.mapper.ImConversationMapper; import com.wecloud.im.mapper.ImConversationMapper;
import com.wecloud.im.vo.MyConversationListVo; import com.wecloud.im.vo.MyConversationListVo;
import org.junit.Test; import org.junit.Test;
...@@ -22,6 +23,9 @@ public class ImConversationTest { ...@@ -22,6 +23,9 @@ public class ImConversationTest {
@Test @Test
public void listConversation() { public void listConversation() {
List<MyConversationListVo> myImConversationList = imConversationMapper.getMyImConversationList(1394579719625773056L); List<MyConversationListVo> myImConversationList = imConversationMapper.getMyImConversationListAndMsgCount(1394579719625773056L);
List<ImConversation> myImConversationList1 = imConversationMapper.getMyImConversationList(1394579719625773056L);
} }
} }
...@@ -96,11 +96,11 @@ public class LoginTest { ...@@ -96,11 +96,11 @@ public class LoginTest {
@Test @Test
public void test() throws Exception { public void test() throws Exception {
// 时间戳 // 时间戳
String timestemp = "1620456403794"; String timestamp = "1620456403794";
String clientId = "hahah_30"; String clientId = "hahah_30";
String appKey = "elLwpel1gWCHDqZy"; String appKey = "elLwpel1gWCHDqZy";
String sign = "9db5c1383829d346adba48182fd8f503"; String sign = "9db5c1383829d346adba48182fd8f503";
String token = getToken(timestemp, clientId, appKey, sign); String token = getToken(timestamp, clientId, appKey, sign);
System.out.println("token:" + token); System.out.println("token:" + token);
} }
} }
...@@ -17,16 +17,16 @@ public class SignTest { ...@@ -17,16 +17,16 @@ public class SignTest {
/** /**
* 获取sign,客户端sdk得到sign之后就可以进行登录,websocket连接初始化需要带上sign,验证通过才能连接成功 * 获取sign,客户端sdk得到sign之后就可以进行登录,websocket连接初始化需要带上sign,验证通过才能连接成功
* <p> * <p>
* sign = MD5{timestemp + clientId + appKey + appSecret} * sign = MD5{timestamp + clientId + appKey + appSecret}
* *
* @param appKey * @param appKey
* @param appSecret * @param appSecret
*/ */
private static void getSign(String timestemp, String clientId, String appKey, String appSecret) { private static void getSign(String timestamp, String clientId, String appKey, String appSecret) {
String sign = new MD5().digestHex(timestemp + clientId + appKey + appSecret); String sign = new MD5().digestHex(timestamp + clientId + appKey + appSecret);
System.out.println("timestemp:" + timestemp); System.out.println("timestamp:" + timestamp);
System.out.println("sign:" + sign); System.out.println("sign:" + sign);
} }
...@@ -35,8 +35,8 @@ public class SignTest { ...@@ -35,8 +35,8 @@ public class SignTest {
String clientId = "client_333"; String clientId = "client_333";
String appKey = "elLwpel1gWCHDqZy"; String appKey = "elLwpel1gWCHDqZy";
String appSecret = "68809bb5a9077a83631aeb0b17b5965d6b2302faf2ab3737"; String appSecret = "68809bb5a9077a83631aeb0b17b5965d6b2302faf2ab3737";
String timestemp = String.valueOf(new Date().getTime()); String timestamp = String.valueOf(new Date().getTime());
getSign(timestemp, clientId, appKey, appSecret); getSign(timestamp, clientId, appKey, appSecret);
} }
private static void jsonTest() throws JsonProcessingException { private static void jsonTest() throws JsonProcessingException {
......
package com.wecloud.im.controller; //package com.wecloud.im.controller;
//
import io.geekidea.springbootplus.framework.common.api.ApiResult; //import io.geekidea.springbootplus.framework.common.api.ApiResult;
import io.geekidea.springbootplus.framework.log.annotation.OperationLog; //import io.geekidea.springbootplus.framework.log.annotation.OperationLog;
import io.swagger.annotations.Api; //import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; //import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j; //import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.authz.annotation.RequiresRoles; //import org.apache.shiro.authz.annotation.RequiresRoles;
import org.springframework.web.bind.annotation.GetMapping; //import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping; //import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; //import org.springframework.web.bind.annotation.RestController;
//
import java.io.IOException; //import java.io.IOException;
//
/** ///**
* Hello World Controller // * Hello World Controller
**/ // **/
@Slf4j //@Slf4j
@Api(value = "权限测试", tags = {"APP Hello World2"}) //@Api(value = "权限测试", tags = {"APP Hello World2"})
@RestController //@RestController
@RequestMapping("/app") //@RequestMapping("/app")
public class AppHelloWorldController { //public class AppHelloWorldController {
//
/** // /**
* Hello World // * Hello World
* // *
* @return // * @return
* @throws IOException // * @throws IOException
*/ // */
@GetMapping(value = "/world") // @GetMapping(value = "/world")
@OperationLog(name = "helloWorld") // @OperationLog(name = "helloWorld")
@ApiOperation(value = "helloWorld", response = String.class) // @ApiOperation(value = "helloWorld", response = String.class)
public ApiResult<String> helloWorld() throws IOException { // public ApiResult<String> helloWorld() throws IOException {
log.debug("Hello World...app"); // log.debug("Hello World...app");
return ApiResult.ok("Hello World app"); // return ApiResult.ok("Hello World app");
} // }
//
//
@GetMapping(value = "/needRole") // @GetMapping(value = "/needRole")
@OperationLog(name = "needRole") // @OperationLog(name = "needRole")
@ApiOperation(value = "needRole", response = String.class) // @ApiOperation(value = "needRole", response = String.class)
public ApiResult<String> needRole() throws IOException { // public ApiResult<String> needRole() throws IOException {
log.debug("Hello World...app"); // log.debug("Hello World...app");
return ApiResult.ok("Hello World app"); // return ApiResult.ok("Hello World app");
} // }
//
@GetMapping(value = "/needRoleAdmin") // @GetMapping(value = "/needRoleAdmin")
@OperationLog(name = "needRoleAdmin") // @OperationLog(name = "needRoleAdmin")
@ApiOperation(value = "needRoleAdmin", response = String.class) // @ApiOperation(value = "needRoleAdmin", response = String.class)
@RequiresRoles("app:admin") // @RequiresRoles("app:admin")
public ApiResult<String> needRoleAdmin() throws IOException { // public ApiResult<String> needRoleAdmin() throws IOException {
log.debug("Hello World...app"); // log.debug("Hello World...app");
return ApiResult.ok("Hello World needRoleAdmin"); // return ApiResult.ok("Hello World needRoleAdmin");
} // }
//
@GetMapping(value = "/needRoleAll") // @GetMapping(value = "/needRoleAll")
@OperationLog(name = "needRoleAll") // @OperationLog(name = "needRoleAll")
@ApiOperation(value = "needRoleAll", response = String.class) // @ApiOperation(value = "needRoleAll", response = String.class)
@RequiresRoles("app:all") // @RequiresRoles("app:all")
public ApiResult<String> needRoleAll() throws IOException { // public ApiResult<String> needRoleAll() throws IOException {
log.debug("Hello World...app"); // log.debug("Hello World...app");
return ApiResult.ok("Hello World needRoleAll"); // return ApiResult.ok("Hello World needRoleAll");
} // }
//
@GetMapping(value = "/noRole") // @GetMapping(value = "/noRole")
@OperationLog(name = "noRole") // @OperationLog(name = "noRole")
@ApiOperation(value = "noRole", response = String.class) // @ApiOperation(value = "noRole", response = String.class)
public ApiResult<String> noRole() throws IOException { // public ApiResult<String> noRole() throws IOException {
log.info("Hello World...app"); // log.info("Hello World...app");
return ApiResult.ok("Hello World app noRole"); // return ApiResult.ok("Hello World app noRole");
} // }
//
} //}
package com.wecloud.im.controller; //package com.wecloud.im.controller;
//
import com.wecloud.im.entity.ImApplication; //import com.wecloud.im.entity.ImApplication;
import com.wecloud.im.param.ImApplicationPageParam; //import com.wecloud.im.param.ImApplicationPageParam;
import com.wecloud.im.param.ImApplicationQueryVo; //import com.wecloud.im.param.ImApplicationQueryVo;
import com.wecloud.im.service.ImApplicationService; //import com.wecloud.im.service.ImApplicationService;
import io.geekidea.springbootplus.framework.common.api.ApiResult; //import io.geekidea.springbootplus.framework.common.api.ApiResult;
import io.geekidea.springbootplus.framework.common.controller.BaseController; //import io.geekidea.springbootplus.framework.common.controller.BaseController;
import io.geekidea.springbootplus.framework.core.pagination.Paging; //import io.geekidea.springbootplus.framework.core.pagination.Paging;
import io.geekidea.springbootplus.framework.core.validator.groups.Add; //import io.geekidea.springbootplus.framework.core.validator.groups.Add;
import io.geekidea.springbootplus.framework.core.validator.groups.Update; //import io.geekidea.springbootplus.framework.core.validator.groups.Update;
import io.geekidea.springbootplus.framework.log.annotation.OperationLog; //import io.geekidea.springbootplus.framework.log.annotation.OperationLog;
import io.geekidea.springbootplus.framework.log.enums.OperationLogType; //import io.geekidea.springbootplus.framework.log.enums.OperationLogType;
import io.swagger.annotations.Api; //import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; //import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j; //import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; //import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated; //import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping; //import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable; //import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping; //import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody; //import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; //import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; //import org.springframework.web.bind.annotation.RestController;
//
/** ///**
* 第三方应用表 控制器 // * 第三方应用表 控制器
* // *
* @author wei // * @author wei
* @since 2021-04-27 // * @since 2021-04-27
*/ // */
@Slf4j //@Slf4j
@RestController //@RestController
@RequestMapping("/imApplication") //@RequestMapping("/imApplication")
@Api(value = "第三方应用表API", tags = {"第三方应用表"}) //@Api(value = "第三方应用表API", tags = {"第三方应用表"})
public class ImApplicationController extends BaseController { //public class ImApplicationController extends BaseController {
//
@Autowired // @Autowired
private ImApplicationService imApplicationService; // private ImApplicationService imApplicationService;
//
/** // /**
* 添加第三方应用表 // * 添加第三方应用表
*/ // */
@PostMapping("/add") // @PostMapping("/add")
@OperationLog(name = "添加第三方应用表", type = OperationLogType.ADD) // @OperationLog(name = "添加第三方应用表", type = OperationLogType.ADD)
@ApiOperation(value = "添加第三方应用表") // @ApiOperation(value = "添加第三方应用表")
public ApiResult<Boolean> addImApplication(@Validated(Add.class) @RequestBody ImApplication imApplication) throws Exception { // public ApiResult<Boolean> addImApplication(@Validated(Add.class) @RequestBody ImApplication imApplication) throws Exception {
boolean flag = imApplicationService.saveImApplication(imApplication); // boolean flag = imApplicationService.saveImApplication(imApplication);
return ApiResult.result(flag); // return ApiResult.result(flag);
} // }
//
/** // /**
* 修改第三方应用表 // * 修改第三方应用表
*/ // */
@PostMapping("/update") // @PostMapping("/update")
@OperationLog(name = "修改第三方应用表", type = OperationLogType.UPDATE) // @OperationLog(name = "修改第三方应用表", type = OperationLogType.UPDATE)
@ApiOperation(value = "修改第三方应用表") // @ApiOperation(value = "修改第三方应用表")
public ApiResult<Boolean> updateImApplication(@Validated(Update.class) @RequestBody ImApplication imApplication) throws Exception { // public ApiResult<Boolean> updateImApplication(@Validated(Update.class) @RequestBody ImApplication imApplication) throws Exception {
boolean flag = imApplicationService.updateImApplication(imApplication); // boolean flag = imApplicationService.updateImApplication(imApplication);
return ApiResult.result(flag); // return ApiResult.result(flag);
} // }
//
/** // /**
* 删除第三方应用表 // * 删除第三方应用表
*/ // */
@PostMapping("/delete/{id}") // @PostMapping("/delete/{id}")
@OperationLog(name = "删除第三方应用表", type = OperationLogType.DELETE) // @OperationLog(name = "删除第三方应用表", type = OperationLogType.DELETE)
@ApiOperation(value = "删除第三方应用表") // @ApiOperation(value = "删除第三方应用表")
public ApiResult<Boolean> deleteImApplication(@PathVariable("id") Long id) throws Exception { // public ApiResult<Boolean> deleteImApplication(@PathVariable("id") Long id) throws Exception {
boolean flag = imApplicationService.deleteImApplication(id); // boolean flag = imApplicationService.deleteImApplication(id);
return ApiResult.result(flag); // return ApiResult.result(flag);
} // }
//
/** // /**
* 获取第三方应用表详情 // * 获取第三方应用表详情
*/ // */
@GetMapping("/info/{id}") // @GetMapping("/info/{id}")
@OperationLog(name = "第三方应用表详情", type = OperationLogType.INFO) // @OperationLog(name = "第三方应用表详情", type = OperationLogType.INFO)
@ApiOperation(value = "第三方应用表详情") // @ApiOperation(value = "第三方应用表详情")
public ApiResult<ImApplicationQueryVo> getImApplication(@PathVariable("id") Long id) throws Exception { // public ApiResult<ImApplicationQueryVo> getImApplication(@PathVariable("id") Long id) throws Exception {
ImApplicationQueryVo imApplicationQueryVo = imApplicationService.getImApplicationById(id); // ImApplicationQueryVo imApplicationQueryVo = imApplicationService.getImApplicationById(id);
return ApiResult.ok(imApplicationQueryVo); // return ApiResult.ok(imApplicationQueryVo);
} // }
//
/** // /**
* 第三方应用表分页列表 // * 第三方应用表分页列表
*/ // */
@PostMapping("/getPageList") // @PostMapping("/getPageList")
@OperationLog(name = "第三方应用表分页列表", type = OperationLogType.PAGE) // @OperationLog(name = "第三方应用表分页列表", type = OperationLogType.PAGE)
@ApiOperation(value = "第三方应用表分页列表") // @ApiOperation(value = "第三方应用表分页列表")
public ApiResult<Paging<ImApplicationQueryVo>> getImApplicationPageList(@Validated @RequestBody ImApplicationPageParam imApplicationPageParam) throws Exception { // public ApiResult<Paging<ImApplicationQueryVo>> getImApplicationPageList(@Validated @RequestBody ImApplicationPageParam imApplicationPageParam) throws Exception {
Paging<ImApplicationQueryVo> paging = imApplicationService.getImApplicationPageList(imApplicationPageParam); // Paging<ImApplicationQueryVo> paging = imApplicationService.getImApplicationPageList(imApplicationPageParam);
return ApiResult.ok(paging); // return ApiResult.ok(paging);
} // }
//
} //}
//
package com.wecloud.im.controller; package com.wecloud.im.controller;
import com.wecloud.im.entity.ImClient;
import com.wecloud.im.param.ImClientPageParam;
import com.wecloud.im.param.ImClientQueryVo;
import com.wecloud.im.service.ImClientService; import com.wecloud.im.service.ImClientService;
import io.geekidea.springbootplus.framework.common.api.ApiResult;
import io.geekidea.springbootplus.framework.common.controller.BaseController; import io.geekidea.springbootplus.framework.common.controller.BaseController;
import io.geekidea.springbootplus.framework.core.pagination.Paging;
import io.geekidea.springbootplus.framework.core.validator.groups.Add;
import io.geekidea.springbootplus.framework.core.validator.groups.Update;
import io.geekidea.springbootplus.framework.log.annotation.OperationLog;
import io.geekidea.springbootplus.framework.log.enums.OperationLogType;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
...@@ -37,61 +22,61 @@ public class ImClientController extends BaseController { ...@@ -37,61 +22,61 @@ public class ImClientController extends BaseController {
@Autowired @Autowired
private ImClientService imClientService; private ImClientService imClientService;
//
/** // /**
* 添加终端表 // * 添加终端表
*/ // */
@PostMapping("/add") // @PostMapping("/add")
@OperationLog(name = "添加终端表", type = OperationLogType.ADD) // @OperationLog(name = "添加终端表", type = OperationLogType.ADD)
@ApiOperation(value = "添加终端表") // @ApiOperation(value = "添加终端表")
public ApiResult<Boolean> addImClient(@Validated(Add.class) @RequestBody ImClient imClient) throws Exception { // public ApiResult<Boolean> addImClient(@Validated(Add.class) @RequestBody ImClient imClient) throws Exception {
boolean flag = imClientService.saveImClient(imClient); // boolean flag = imClientService.saveImClient(imClient);
return ApiResult.result(flag); // return ApiResult.result(flag);
} // }
//
/** // /**
* 修改终端表 // * 修改终端表
*/ // */
@PostMapping("/update") // @PostMapping("/update")
@OperationLog(name = "修改终端表", type = OperationLogType.UPDATE) // @OperationLog(name = "修改终端表", type = OperationLogType.UPDATE)
@ApiOperation(value = "修改终端表") // @ApiOperation(value = "修改终端表")
public ApiResult<Boolean> updateImClient(@Validated(Update.class) @RequestBody ImClient imClient) throws Exception { // public ApiResult<Boolean> updateImClient(@Validated(Update.class) @RequestBody ImClient imClient) throws Exception {
boolean flag = imClientService.updateImClient(imClient); // boolean flag = imClientService.updateImClient(imClient);
return ApiResult.result(flag); // return ApiResult.result(flag);
} // }
//
/** // /**
* 删除终端表 // * 删除终端表
*/ // */
@PostMapping("/delete/{id}") // @PostMapping("/delete/{id}")
@OperationLog(name = "删除终端表", type = OperationLogType.DELETE) // @OperationLog(name = "删除终端表", type = OperationLogType.DELETE)
@ApiOperation(value = "删除终端表") // @ApiOperation(value = "删除终端表")
public ApiResult<Boolean> deleteImClient(@PathVariable("id") Long id) throws Exception { // public ApiResult<Boolean> deleteImClient(@PathVariable("id") Long id) throws Exception {
boolean flag = imClientService.deleteImClient(id); // boolean flag = imClientService.deleteImClient(id);
return ApiResult.result(flag); // return ApiResult.result(flag);
} // }
//
/** // /**
* 获取终端表详情 // * 获取终端表详情
*/ // */
@GetMapping("/info/{id}") // @GetMapping("/info/{id}")
@OperationLog(name = "终端表详情", type = OperationLogType.INFO) // @OperationLog(name = "终端表详情", type = OperationLogType.INFO)
@ApiOperation(value = "终端表详情") // @ApiOperation(value = "终端表详情")
public ApiResult<ImClientQueryVo> getImClient(@PathVariable("id") Long id) throws Exception { // public ApiResult<ImClientQueryVo> getImClient(@PathVariable("id") Long id) throws Exception {
ImClientQueryVo imClientQueryVo = imClientService.getImClientById(id); // ImClientQueryVo imClientQueryVo = imClientService.getImClientById(id);
return ApiResult.ok(imClientQueryVo); // return ApiResult.ok(imClientQueryVo);
} // }
//
/** // /**
* 终端表分页列表 // * 终端表分页列表
*/ // */
@PostMapping("/getPageList") // @PostMapping("/getPageList")
@OperationLog(name = "终端表分页列表", type = OperationLogType.PAGE) // @OperationLog(name = "终端表分页列表", type = OperationLogType.PAGE)
@ApiOperation(value = "终端表分页列表") // @ApiOperation(value = "终端表分页列表")
public ApiResult<Paging<ImClientQueryVo>> getImClientPageList(@Validated @RequestBody ImClientPageParam imClientPageParam) throws Exception { // public ApiResult<Paging<ImClientQueryVo>> getImClientPageList(@Validated @RequestBody ImClientPageParam imClientPageParam) throws Exception {
Paging<ImClientQueryVo> paging = imClientService.getImClientPageList(imClientPageParam); // Paging<ImClientQueryVo> paging = imClientService.getImClientPageList(imClientPageParam);
return ApiResult.ok(paging); // return ApiResult.ok(paging);
} // }
} }
...@@ -49,9 +49,9 @@ public class ImConversationController extends BaseController { ...@@ -49,9 +49,9 @@ public class ImConversationController extends BaseController {
* 查询用户加入的所有会话 与每个会话的未读条数 成员 * 查询用户加入的所有会话 与每个会话的未读条数 成员
*/ */
@PostMapping("/getList") @PostMapping("/getList")
@ApiOperation(value = "查询用户加入的所有会话 与每个会话的未读条数 成员") @ApiOperation(value = "查询加入的会话列表", notes = "查询用户加入的会话列表 与每个会话的未读条数 成员")
public ApiResult<List<MyConversationListVo>> getImConversationPageList() throws Exception { public ApiResult<List<MyConversationListVo>> getMyImConversationListAndMsgCount() throws Exception {
List<MyConversationListVo> conversationList = imConversationService.getMyImConversationList(); List<MyConversationListVo> conversationList = imConversationService.getMyImConversationListAndMsgCount();
return ApiResult.ok(conversationList); return ApiResult.ok(conversationList);
} }
......
package com.wecloud.im.controller; package com.wecloud.im.controller;
import com.wecloud.im.entity.ImInbox; import com.wecloud.im.param.ImMsgReceivedUpdate;
import com.wecloud.im.param.ImInboxPageParam;
import com.wecloud.im.param.ImInboxQueryVo;
import com.wecloud.im.service.ImInboxService; import com.wecloud.im.service.ImInboxService;
import io.geekidea.springbootplus.framework.common.api.ApiResult; import io.geekidea.springbootplus.framework.common.api.ApiResult;
import io.geekidea.springbootplus.framework.common.controller.BaseController; import io.geekidea.springbootplus.framework.common.controller.BaseController;
import io.geekidea.springbootplus.framework.core.pagination.Paging;
import io.geekidea.springbootplus.framework.core.validator.groups.Add;
import io.geekidea.springbootplus.framework.core.validator.groups.Update;
import io.geekidea.springbootplus.framework.log.annotation.OperationLog;
import io.geekidea.springbootplus.framework.log.enums.OperationLogType;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
...@@ -38,60 +28,72 @@ public class ImInboxController extends BaseController { ...@@ -38,60 +28,72 @@ public class ImInboxController extends BaseController {
@Autowired @Autowired
private ImInboxService imInboxService; private ImInboxService imInboxService;
/**
* 添加消息收件箱表
*/
@PostMapping("/add")
@OperationLog(name = "添加消息收件箱表", type = OperationLogType.ADD)
@ApiOperation(value = "添加消息收件箱表")
public ApiResult<Boolean> addImInbox(@Validated(Add.class) @RequestBody ImInbox imInbox) throws Exception {
boolean flag = imInboxService.saveImInbox(imInbox);
return ApiResult.result(flag);
}
/**
* 修改消息收件箱表
*/
@PostMapping("/update")
@OperationLog(name = "修改消息收件箱表", type = OperationLogType.UPDATE)
@ApiOperation(value = "修改消息收件箱表")
public ApiResult<Boolean> updateImInbox(@Validated(Update.class) @RequestBody ImInbox imInbox) throws Exception {
boolean flag = imInboxService.updateImInbox(imInbox);
return ApiResult.result(flag);
}
/** /**
* 删除消息收件箱表 * 消息修改为已接收状态
*/ */
@PostMapping("/delete/{id}") @PostMapping("/msgReceivedUpdate")
@OperationLog(name = "删除消息收件箱表", type = OperationLogType.DELETE) @ApiOperation(value = "消息修改为已接收状态")
@ApiOperation(value = "删除消息收件箱表") public ApiResult<Boolean> updateImMsgReceived(@RequestBody ImMsgReceivedUpdate imMsgReceivedUpdate) throws Exception {
public ApiResult<Boolean> deleteImInbox(@PathVariable("id") Long id) throws Exception { imInboxService.updateImMsgReceived(imMsgReceivedUpdate);
boolean flag = imInboxService.deleteImInbox(id); return ApiResult.ok();
return ApiResult.result(flag);
} }
/** //
* 获取消息收件箱表详情 // /**
*/ // * 添加消息收件箱表
@GetMapping("/info/{id}") // */
@OperationLog(name = "消息收件箱表详情", type = OperationLogType.INFO) // @PostMapping("/add")
@ApiOperation(value = "消息收件箱表详情") // @OperationLog(name = "添加消息收件箱表", type = OperationLogType.ADD)
public ApiResult<ImInboxQueryVo> getImInbox(@PathVariable("id") Long id) throws Exception { // @ApiOperation(value = "添加消息收件箱表")
ImInboxQueryVo imInboxQueryVo = imInboxService.getImInboxById(id); // public ApiResult<Boolean> addImInbox(@Validated(Add.class) @RequestBody ImInbox imInbox) throws Exception {
return ApiResult.ok(imInboxQueryVo); // boolean flag = imInboxService.saveImInbox(imInbox);
} // return ApiResult.result(flag);
// }
/** //
* 消息收件箱表分页列表 // /**
*/ // * 修改消息收件箱表
@PostMapping("/getPageList") // */
@OperationLog(name = "消息收件箱表分页列表", type = OperationLogType.PAGE) // @PostMapping("/update")
@ApiOperation(value = "消息收件箱表分页列表") // @OperationLog(name = "修改消息收件箱表", type = OperationLogType.UPDATE)
public ApiResult<Paging<ImInboxQueryVo>> getImInboxPageList(@Validated @RequestBody ImInboxPageParam imInboxPageParam) throws Exception { // @ApiOperation(value = "修改消息收件箱表")
Paging<ImInboxQueryVo> paging = imInboxService.getImInboxPageList(imInboxPageParam); // public ApiResult<Boolean> updateImInbox(@Validated(Update.class) @RequestBody ImInbox imInbox) throws Exception {
return ApiResult.ok(paging); // boolean flag = imInboxService.updateImInbox(imInbox);
} // return ApiResult.result(flag);
// }
//
// /**
// * 删除消息收件箱表
// */
// @PostMapping("/delete/{id}")
// @OperationLog(name = "删除消息收件箱表", type = OperationLogType.DELETE)
// @ApiOperation(value = "删除消息收件箱表")
// public ApiResult<Boolean> deleteImInbox(@PathVariable("id") Long id) throws Exception {
// boolean flag = imInboxService.deleteImInbox(id);
// return ApiResult.result(flag);
// }
//
// /**
// * 获取消息收件箱表详情
// */
// @GetMapping("/info/{id}")
// @OperationLog(name = "消息收件箱表详情", type = OperationLogType.INFO)
// @ApiOperation(value = "消息收件箱表详情")
// public ApiResult<ImInboxQueryVo> getImInbox(@PathVariable("id") Long id) throws Exception {
// ImInboxQueryVo imInboxQueryVo = imInboxService.getImInboxById(id);
// return ApiResult.ok(imInboxQueryVo);
// }
//
// /**
// * 消息收件箱表分页列表
// */
// @PostMapping("/getPageList")
// @OperationLog(name = "消息收件箱表分页列表", type = OperationLogType.PAGE)
// @ApiOperation(value = "消息收件箱表分页列表")
// public ApiResult<Paging<ImInboxQueryVo>> getImInboxPageList(@Validated @RequestBody ImInboxPageParam imInboxPageParam) throws Exception {
// Paging<ImInboxQueryVo> paging = imInboxService.getImInboxPageList(imInboxPageParam);
// return ApiResult.ok(paging);
// }
} }
package com.wecloud.im.controller; package com.wecloud.im.controller;
import com.wecloud.im.entity.ImMessage;
import com.wecloud.im.param.ImMessagePageParam;
import com.wecloud.im.param.ImMessageQueryVo;
import com.wecloud.im.service.ImMessageService; import com.wecloud.im.service.ImMessageService;
import com.wecloud.im.vo.ImMessageOfflineListVo;
import io.geekidea.springbootplus.framework.common.api.ApiResult; import io.geekidea.springbootplus.framework.common.api.ApiResult;
import io.geekidea.springbootplus.framework.common.controller.BaseController; import io.geekidea.springbootplus.framework.common.controller.BaseController;
import io.geekidea.springbootplus.framework.core.pagination.Paging;
import io.geekidea.springbootplus.framework.core.validator.groups.Add;
import io.geekidea.springbootplus.framework.core.validator.groups.Update;
import io.geekidea.springbootplus.framework.log.annotation.OperationLog;
import io.geekidea.springbootplus.framework.log.enums.OperationLogType;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/** /**
* 消息存储表 控制器 * 消息存储表 控制器
* *
...@@ -38,60 +29,73 @@ public class ImMessageController extends BaseController { ...@@ -38,60 +29,73 @@ public class ImMessageController extends BaseController {
@Autowired @Autowired
private ImMessageService imMessageService; private ImMessageService imMessageService;
/**
* 添加消息存储表
*/
@PostMapping("/add")
@OperationLog(name = "添加消息存储表", type = OperationLogType.ADD)
@ApiOperation(value = "添加消息存储表")
public ApiResult<Boolean> addImMessage(@Validated(Add.class) @RequestBody ImMessage imMessage) throws Exception {
boolean flag = imMessageService.saveImMessage(imMessage);
return ApiResult.result(flag);
}
/**
* 修改消息存储表
*/
@PostMapping("/update")
@OperationLog(name = "修改消息存储表", type = OperationLogType.UPDATE)
@ApiOperation(value = "修改消息存储表")
public ApiResult<Boolean> updateImMessage(@Validated(Update.class) @RequestBody ImMessage imMessage) throws Exception {
boolean flag = imMessageService.updateImMessage(imMessage);
return ApiResult.result(flag);
}
/** /**
* 删除消息存储 * 离线消息列
*/ */
@PostMapping("/delete/{id}") @PostMapping("/offlineList")
@OperationLog(name = "删除消息存储表", type = OperationLogType.DELETE) @ApiOperation(value = "离线消息列表")
@ApiOperation(value = "删除消息存储表") public ApiResult<List<ImMessageOfflineListVo>> getOfflineList() throws Exception {
public ApiResult<Boolean> deleteImMessage(@PathVariable("id") Long id) throws Exception { List<ImMessageOfflineListVo> offlineList = imMessageService.getOfflineList();
boolean flag = imMessageService.deleteImMessage(id); return ApiResult.ok(offlineList);
return ApiResult.result(flag);
} }
/**
* 获取消息存储表详情
*/
@GetMapping("/info/{id}")
@OperationLog(name = "消息存储表详情", type = OperationLogType.INFO)
@ApiOperation(value = "消息存储表详情")
public ApiResult<ImMessageQueryVo> getImMessage(@PathVariable("id") Long id) throws Exception {
ImMessageQueryVo imMessageQueryVo = imMessageService.getImMessageById(id);
return ApiResult.ok(imMessageQueryVo);
}
/** //
* 消息存储表分页列表 // /**
*/ // * 添加消息存储表
@PostMapping("/getPageList") // */
@OperationLog(name = "消息存储表分页列表", type = OperationLogType.PAGE) // @PostMapping("/add")
@ApiOperation(value = "消息存储表分页列表") // @OperationLog(name = "添加消息存储表", type = OperationLogType.ADD)
public ApiResult<Paging<ImMessageQueryVo>> getImMessagePageList(@Validated @RequestBody ImMessagePageParam imMessagePageParam) throws Exception { // @ApiOperation(value = "添加消息存储表")
Paging<ImMessageQueryVo> paging = imMessageService.getImMessagePageList(imMessagePageParam); // public ApiResult<Boolean> addImMessage(@Validated(Add.class) @RequestBody ImMessage imMessage) throws Exception {
return ApiResult.ok(paging); // boolean flag = imMessageService.saveImMessage(imMessage);
} // return ApiResult.result(flag);
// }
//
// /**
// * 修改消息存储表
// */
// @PostMapping("/update")
// @OperationLog(name = "修改消息存储表", type = OperationLogType.UPDATE)
// @ApiOperation(value = "修改消息存储表")
// public ApiResult<Boolean> updateImMessage(@Validated(Update.class) @RequestBody ImMessage imMessage) throws Exception {
// boolean flag = imMessageService.updateImMessage(imMessage);
// return ApiResult.result(flag);
// }
//
// /**
// * 删除消息存储表
// */
// @PostMapping("/delete/{id}")
// @OperationLog(name = "删除消息存储表", type = OperationLogType.DELETE)
// @ApiOperation(value = "删除消息存储表")
// public ApiResult<Boolean> deleteImMessage(@PathVariable("id") Long id) throws Exception {
// boolean flag = imMessageService.deleteImMessage(id);
// return ApiResult.result(flag);
// }
//
// /**
// * 获取消息存储表详情
// */
// @GetMapping("/info/{id}")
// @OperationLog(name = "消息存储表详情", type = OperationLogType.INFO)
// @ApiOperation(value = "消息存储表详情")
// public ApiResult<ImMessageQueryVo> getImMessage(@PathVariable("id") Long id) throws Exception {
// ImMessageQueryVo imMessageQueryVo = imMessageService.getImMessageById(id);
// return ApiResult.ok(imMessageQueryVo);
// }
//
// /**
// * 消息存储表分页列表
// */
// @PostMapping("/getPageList")
// @OperationLog(name = "消息存储表分页列表", type = OperationLogType.PAGE)
// @ApiOperation(value = "消息存储表分页列表")
// public ApiResult<Paging<ImMessageQueryVo>> getImMessagePageList(@Validated @RequestBody ImMessagePageParam imMessagePageParam) throws Exception {
// Paging<ImMessageQueryVo> paging = imMessageService.getImMessagePageList(imMessagePageParam);
// return ApiResult.ok(paging);
// }
} }
...@@ -46,5 +46,15 @@ public interface ImConversationMapper extends BaseMapper<ImConversation> { ...@@ -46,5 +46,15 @@ public interface ImConversationMapper extends BaseMapper<ImConversation> {
* @param clientId * @param clientId
* @return * @return
*/ */
List<MyConversationListVo> getMyImConversationList(@Param("clientId") Long clientId); List<MyConversationListVo> getMyImConversationListAndMsgCount(@Param("clientId") Long clientId);
/**
* 查询用户加入的所有会话
*
* @param clientId
* @return
*/
List<ImConversation> getMyImConversationList(@Param("clientId") Long clientId);
} }
...@@ -10,6 +10,7 @@ import org.apache.ibatis.annotations.Param; ...@@ -10,6 +10,7 @@ import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import java.io.Serializable; import java.io.Serializable;
import java.util.List;
/** /**
* 消息收件箱表 Mapper 接口 * 消息收件箱表 Mapper 接口
...@@ -37,4 +38,6 @@ public interface ImInboxMapper extends BaseMapper<ImInbox> { ...@@ -37,4 +38,6 @@ public interface ImInboxMapper extends BaseMapper<ImInbox> {
*/ */
IPage<ImInboxQueryVo> getImInboxPageList(@Param("page") Page page, @Param("param") ImInboxPageParam imInboxPageParam); IPage<ImInboxQueryVo> getImInboxPageList(@Param("page") Page page, @Param("param") ImInboxPageParam imInboxPageParam);
Long updateImMsgReceivedByIds(@Param("clientId") Long clientId, @Param("msgIds") List<Long> msgIds);
} }
package com.wecloud.im.mapper; package com.wecloud.im.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wecloud.im.entity.ImMessage; import com.wecloud.im.entity.ImMessage;
import com.wecloud.im.param.ImMessagePageParam; import com.wecloud.im.param.ImMessagePageParam;
import com.wecloud.im.param.ImMessageQueryVo; import com.wecloud.im.param.ImMessageQueryVo;
import com.wecloud.im.vo.OfflineMsgDto;
import org.springframework.stereotype.Repository;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import java.io.Serializable; import java.io.Serializable;
import java.util.List;
/** /**
* 消息存储表 Mapper 接口 * 消息存储表 Mapper 接口
...@@ -37,6 +37,15 @@ public interface ImMessageMapper extends BaseMapper<ImMessage> { ...@@ -37,6 +37,15 @@ public interface ImMessageMapper extends BaseMapper<ImMessage> {
* @param imMessagePageParam * @param imMessagePageParam
* @return * @return
*/ */
IPage<ImMessageQueryVo> getImMessagePageList(@Param("page") Page page,@Param("param") ImMessagePageParam imMessagePageParam); IPage<ImMessageQueryVo> getImMessagePageList(@Param("page") Page page, @Param("param") ImMessagePageParam imMessagePageParam);
} /**
* 根据客户端id与会话id 查询离线消息
*
* @param clientId
* @param conversationId
* @return
*/
List<OfflineMsgDto> getOfflineListByClientAndConversation(@Param("clientId") Long clientId, @Param("conversationId") Long conversationId);
}
...@@ -58,16 +58,6 @@ public class ImMessageQueryVo implements Serializable { ...@@ -58,16 +58,6 @@ public class ImMessageQueryVo implements Serializable {
@ApiModelProperty("发送状态, 0AVIMMessageStatusNone(未知) 1AVIMMessageStatusSending(发送中) 2AVIMMessageStatusSent(发送成功) 3AVIMMessageStatusReceipt(被接收) 4AVIMMessageStatusFailed(失败)") @ApiModelProperty("发送状态, 0AVIMMessageStatusNone(未知) 1AVIMMessageStatusSending(发送中) 2AVIMMessageStatusSent(发送成功) 3AVIMMessageStatusReceipt(被接收) 4AVIMMessageStatusFailed(失败)")
private Integer sendStatus; private Integer sendStatus;
@ApiModelProperty("类型" +
"类型 文本消息-1" +
"图像消息-2" +
"音频消息-3" +
"视频消息-4" +
"位置消息-5" +
"文件消息-6" +
"以上类型均使用负数,所有正数留给自定义扩展类型使用,0 作为「没有类型」被保留起来。")
private Integer type;
@ApiModelProperty("会话id") @ApiModelProperty("会话id")
private Long fkConversationId; private Long fkConversationId;
} }
\ No newline at end of file
package com.wecloud.im.param;
import io.geekidea.springbootplus.framework.common.entity.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import java.util.List;
/**
* ImMsgReadUpdate
*
* @author wei
* @since 2021-05-07
*/
@Data
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = true)
@ApiModel(value = "ImMsgReceivedUpdate")
public class ImMsgReceivedUpdate extends BaseEntity {
private static final long serialVersionUID = 1L;
@ApiModelProperty("可选 邀请加入会话的客户端,如创建单聊,则填入对方的clientId")
private List<Long> msgIds;
}
...@@ -16,7 +16,7 @@ public class ImTokenVerify { ...@@ -16,7 +16,7 @@ public class ImTokenVerify {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@ApiModelProperty("时间戳") @ApiModelProperty("时间戳")
private String timestemp; private String timestamp;
@ApiModelProperty("client客户端id") @ApiModelProperty("client客户端id")
private String clientId; private String clientId;
......
...@@ -74,6 +74,9 @@ public interface ImConversationService extends BaseService<ImConversation> { ...@@ -74,6 +74,9 @@ public interface ImConversationService extends BaseService<ImConversation> {
* @return * @return
* @throws Exception * @throws Exception
*/ */
List<MyConversationListVo> getMyImConversationList() throws Exception; List<MyConversationListVo> getMyImConversationListAndMsgCount() throws Exception;
List<ImConversation> getMyImConversationList() throws Exception;
} }
...@@ -3,6 +3,8 @@ package com.wecloud.im.service; ...@@ -3,6 +3,8 @@ package com.wecloud.im.service;
import com.wecloud.im.entity.ImInbox; import com.wecloud.im.entity.ImInbox;
import com.wecloud.im.param.ImInboxPageParam; import com.wecloud.im.param.ImInboxPageParam;
import com.wecloud.im.param.ImInboxQueryVo; import com.wecloud.im.param.ImInboxQueryVo;
import com.wecloud.im.param.ImMsgReceivedUpdate;
import io.geekidea.springbootplus.framework.common.api.ApiResult;
import io.geekidea.springbootplus.framework.common.service.BaseService; import io.geekidea.springbootplus.framework.common.service.BaseService;
import io.geekidea.springbootplus.framework.core.pagination.Paging; import io.geekidea.springbootplus.framework.core.pagination.Paging;
...@@ -59,4 +61,13 @@ public interface ImInboxService extends BaseService<ImInbox> { ...@@ -59,4 +61,13 @@ public interface ImInboxService extends BaseService<ImInbox> {
*/ */
Paging<ImInboxQueryVo> getImInboxPageList(ImInboxPageParam imInboxPageParam) throws Exception; Paging<ImInboxQueryVo> getImInboxPageList(ImInboxPageParam imInboxPageParam) throws Exception;
/**
* 消息修改为已接收状态
*
* @param imMsgReceivedUpdate
* @return
*/
ApiResult<Boolean> updateImMsgReceived(ImMsgReceivedUpdate imMsgReceivedUpdate);
} }
...@@ -2,10 +2,14 @@ package com.wecloud.im.service; ...@@ -2,10 +2,14 @@ package com.wecloud.im.service;
import com.wecloud.im.entity.ImMessage; import com.wecloud.im.entity.ImMessage;
import com.wecloud.im.param.ImMessagePageParam; import com.wecloud.im.param.ImMessagePageParam;
import io.geekidea.springbootplus.framework.common.service.BaseService;
import com.wecloud.im.param.ImMessageQueryVo; import com.wecloud.im.param.ImMessageQueryVo;
import com.wecloud.im.vo.ImMessageOfflineListVo;
import com.wecloud.im.vo.OfflineMsgDto;
import io.geekidea.springbootplus.framework.common.service.BaseService;
import io.geekidea.springbootplus.framework.core.pagination.Paging; import io.geekidea.springbootplus.framework.core.pagination.Paging;
import java.util.List;
/** /**
* 消息存储表 服务类 * 消息存储表 服务类
* *
...@@ -21,7 +25,7 @@ public interface ImMessageService extends BaseService<ImMessage> { ...@@ -21,7 +25,7 @@ public interface ImMessageService extends BaseService<ImMessage> {
* @return * @return
* @throws Exception * @throws Exception
*/ */
boolean saveImMessage(ImMessage imMessage)throws Exception; boolean saveImMessage(ImMessage imMessage) throws Exception;
/** /**
* 修改 * 修改
...@@ -30,7 +34,7 @@ public interface ImMessageService extends BaseService<ImMessage> { ...@@ -30,7 +34,7 @@ public interface ImMessageService extends BaseService<ImMessage> {
* @return * @return
* @throws Exception * @throws Exception
*/ */
boolean updateImMessage(ImMessage imMessage)throws Exception; boolean updateImMessage(ImMessage imMessage) throws Exception;
/** /**
* 删除 * 删除
...@@ -39,7 +43,7 @@ public interface ImMessageService extends BaseService<ImMessage> { ...@@ -39,7 +43,7 @@ public interface ImMessageService extends BaseService<ImMessage> {
* @return * @return
* @throws Exception * @throws Exception
*/ */
boolean deleteImMessage(Long id)throws Exception; boolean deleteImMessage(Long id) throws Exception;
/** /**
* 根据ID获取查询对象 * 根据ID获取查询对象
...@@ -48,7 +52,7 @@ public interface ImMessageService extends BaseService<ImMessage> { ...@@ -48,7 +52,7 @@ public interface ImMessageService extends BaseService<ImMessage> {
* @return * @return
* @throws Exception * @throws Exception
*/ */
ImMessageQueryVo getImMessageById(Long id)throws Exception; ImMessageQueryVo getImMessageById(Long id) throws Exception;
/** /**
* 获取分页对象 * 获取分页对象
...@@ -59,4 +63,24 @@ public interface ImMessageService extends BaseService<ImMessage> { ...@@ -59,4 +63,24 @@ public interface ImMessageService extends BaseService<ImMessage> {
*/ */
Paging<ImMessageQueryVo> getImMessagePageList(ImMessagePageParam imMessagePageParam) throws Exception; Paging<ImMessageQueryVo> getImMessagePageList(ImMessagePageParam imMessagePageParam) throws Exception;
}
/**
* 查询用户所有离线消息
*
* @return
* @throws Exception
*/
List<ImMessageOfflineListVo> getOfflineList() throws Exception;
/**
* 根据客户端id与会话id 查询离线消息
*
* @param clientId
* @param conversationId
* @return
*/
List<OfflineMsgDto> getOfflineListByClientAndConversation(Long clientId, Long conversationId);
}
...@@ -68,7 +68,7 @@ public class ImClientLoginServiceImpl implements ImClientLoginService { ...@@ -68,7 +68,7 @@ public class ImClientLoginServiceImpl implements ImClientLoginService {
// 生成以数据库为准的签名 // 生成以数据库为准的签名
String secret = imApplication.getAppSecret(); String secret = imApplication.getAppSecret();
String mySign = new MD5().digestHex(imTokenVerify.getTimestemp() + imTokenVerify.getClientId() + imApplication.getAppKey() + secret); String mySign = new MD5().digestHex(imTokenVerify.getTimestamp() + imTokenVerify.getClientId() + imApplication.getAppKey() + secret);
// 验证签名 // 验证签名
if (mySign.equals(imTokenVerify.getSign())) { if (mySign.equals(imTokenVerify.getSign())) {
......
...@@ -76,10 +76,9 @@ public class ImClientServiceImpl extends BaseServiceImpl<ImClientMapper, ImClien ...@@ -76,10 +76,9 @@ public class ImClientServiceImpl extends BaseServiceImpl<ImClientMapper, ImClien
new QueryWrapper<ImApplication>().lambda().eq(ImApplication::getAppKey, curentJwtToken.getAppKey()) new QueryWrapper<ImApplication>().lambda().eq(ImApplication::getAppKey, curentJwtToken.getAppKey())
); );
ImClient client = this.getOne(new QueryWrapper<ImClient>().lambda() return this.getOne(new QueryWrapper<ImClient>().lambda()
.eq(ImClient::getFkAppid, imApplication.getId()) .eq(ImClient::getFkAppid, imApplication.getId())
.eq(ImClient::getClientId, curentJwtToken.getClientId())); .eq(ImClient::getClientId, curentJwtToken.getClientId()));
return client;
} }
} }
...@@ -146,12 +146,19 @@ public class ImConversationServiceImpl extends BaseServiceImpl<ImConversationMap ...@@ -146,12 +146,19 @@ public class ImConversationServiceImpl extends BaseServiceImpl<ImConversationMap
} }
@Override @Override
public List<MyConversationListVo> getMyImConversationList() throws Exception { public List<MyConversationListVo> getMyImConversationListAndMsgCount() throws Exception {
ImClient client = imClientService.getClient(); ImClient client = imClientService.getClient();
return imConversationMapper.getMyImConversationList(client.getId()); return imConversationMapper.getMyImConversationListAndMsgCount(client.getId());
}
@Override
public List<ImConversation> getMyImConversationList() throws Exception {
ImClient client = imClientService.getClient();
return imConversationMapper.getMyImConversationList(client.getId());
} }
} }
...@@ -3,11 +3,15 @@ package com.wecloud.im.service.impl; ...@@ -3,11 +3,15 @@ package com.wecloud.im.service.impl;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.metadata.OrderItem; import com.baomidou.mybatisplus.core.metadata.OrderItem;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wecloud.im.entity.ImClient;
import com.wecloud.im.entity.ImInbox; import com.wecloud.im.entity.ImInbox;
import com.wecloud.im.mapper.ImInboxMapper; import com.wecloud.im.mapper.ImInboxMapper;
import com.wecloud.im.param.ImInboxPageParam; import com.wecloud.im.param.ImInboxPageParam;
import com.wecloud.im.param.ImInboxQueryVo; import com.wecloud.im.param.ImInboxQueryVo;
import com.wecloud.im.param.ImMsgReceivedUpdate;
import com.wecloud.im.service.ImClientService;
import com.wecloud.im.service.ImInboxService; import com.wecloud.im.service.ImInboxService;
import io.geekidea.springbootplus.framework.common.api.ApiResult;
import io.geekidea.springbootplus.framework.common.service.impl.BaseServiceImpl; import io.geekidea.springbootplus.framework.common.service.impl.BaseServiceImpl;
import io.geekidea.springbootplus.framework.core.pagination.PageInfo; import io.geekidea.springbootplus.framework.core.pagination.PageInfo;
import io.geekidea.springbootplus.framework.core.pagination.Paging; import io.geekidea.springbootplus.framework.core.pagination.Paging;
...@@ -28,6 +32,8 @@ public class ImInboxServiceImpl extends BaseServiceImpl<ImInboxMapper, ImInbox> ...@@ -28,6 +32,8 @@ public class ImInboxServiceImpl extends BaseServiceImpl<ImInboxMapper, ImInbox>
@Autowired @Autowired
private ImInboxMapper imInboxMapper; private ImInboxMapper imInboxMapper;
@Autowired
private ImClientService imClientService;
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
@Override @Override
...@@ -59,4 +65,14 @@ public class ImInboxServiceImpl extends BaseServiceImpl<ImInboxMapper, ImInbox> ...@@ -59,4 +65,14 @@ public class ImInboxServiceImpl extends BaseServiceImpl<ImInboxMapper, ImInbox>
return new Paging<ImInboxQueryVo>(iPage); return new Paging<ImInboxQueryVo>(iPage);
} }
@Override
public ApiResult<Boolean> updateImMsgReceived(ImMsgReceivedUpdate imMsgReceivedUpdate) {
ImClient client = imClientService.getClient();
Long aLong = imInboxMapper.updateImMsgReceivedByIds(client.getId(), imMsgReceivedUpdate.getMsgIds());
return ApiResult.ok();
}
} }
package com.wecloud.im.service.impl; package com.wecloud.im.service.impl;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.metadata.OrderItem;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wecloud.im.entity.ImClient;
import com.wecloud.im.entity.ImConversation;
import com.wecloud.im.entity.ImMessage; import com.wecloud.im.entity.ImMessage;
import com.wecloud.im.mapper.ImMessageMapper; import com.wecloud.im.mapper.ImMessageMapper;
import com.wecloud.im.param.ImMessagePageParam;
import com.wecloud.im.param.ImMessageQueryVo;
import com.wecloud.im.service.ImClientService;
import com.wecloud.im.service.ImConversationService;
import com.wecloud.im.service.ImMessageService; import com.wecloud.im.service.ImMessageService;
import com.wecloud.im.param.ImMessagePageParam; import com.wecloud.im.vo.ImMessageOfflineListVo;
import com.wecloud.im.param.ImMessageQueryVo; import com.wecloud.im.vo.OfflineMsgDto;
import io.geekidea.springbootplus.framework.common.service.impl.BaseServiceImpl; import io.geekidea.springbootplus.framework.common.service.impl.BaseServiceImpl;
import io.geekidea.springbootplus.framework.core.pagination.Paging; import io.geekidea.springbootplus.framework.core.pagination.PageInfo;
import io.geekidea.springbootplus.framework.core.pagination.PageInfo; import io.geekidea.springbootplus.framework.core.pagination.Paging;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.metadata.OrderItem;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.transaction.annotation.Transactional;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.List;
/** /**
* 消息存储表 服务实现类 * 消息存储表 服务实现类
...@@ -26,37 +35,89 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -26,37 +35,89 @@ import org.springframework.beans.factory.annotation.Autowired;
@Service @Service
public class ImMessageServiceImpl extends BaseServiceImpl<ImMessageMapper, ImMessage> implements ImMessageService { public class ImMessageServiceImpl extends BaseServiceImpl<ImMessageMapper, ImMessage> implements ImMessageService {
@Autowired @Autowired
private ImMessageMapper imMessageMapper; private ImMessageMapper imMessageMapper;
@Autowired
private ImClientService imClientService;
@Transactional(rollbackFor = Exception.class) @Autowired
@Override private ImConversationService imConversationService;
public boolean saveImMessage(ImMessage imMessage)throws Exception{
@Transactional(rollbackFor = Exception.class)
@Override
public boolean saveImMessage(ImMessage imMessage) throws Exception {
return super.save(imMessage); return super.save(imMessage);
} }
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
@Override @Override
public boolean updateImMessage(ImMessage imMessage)throws Exception{ public boolean updateImMessage(ImMessage imMessage) throws Exception {
return super.updateById(imMessage); return super.updateById(imMessage);
} }
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
@Override @Override
public boolean deleteImMessage(Long id)throws Exception{ public boolean deleteImMessage(Long id) throws Exception {
return super.removeById(id); return super.removeById(id);
} }
@Override @Override
public ImMessageQueryVo getImMessageById(Long id)throws Exception{ public ImMessageQueryVo getImMessageById(Long id) throws Exception {
return imMessageMapper.getImMessageById(id); return imMessageMapper.getImMessageById(id);
} }
@Override @Override
public Paging<ImMessageQueryVo> getImMessagePageList(ImMessagePageParam imMessagePageParam)throws Exception{ public Paging<ImMessageQueryVo> getImMessagePageList(ImMessagePageParam imMessagePageParam) throws Exception {
Page<ImMessageQueryVo> page=new PageInfo<>(imMessagePageParam,OrderItem.desc(getLambdaColumn(ImMessage::getCreateTime))); Page<ImMessageQueryVo> page = new PageInfo<>(imMessagePageParam, OrderItem.desc(getLambdaColumn(ImMessage::getCreateTime)));
IPage<ImMessageQueryVo> iPage= imMessageMapper.getImMessagePageList(page, imMessagePageParam); IPage<ImMessageQueryVo> iPage = imMessageMapper.getImMessagePageList(page, imMessagePageParam);
return new Paging<ImMessageQueryVo>(iPage); return new Paging<ImMessageQueryVo>(iPage);
} }
/**
* 查询用户所有离线消息
*
* @return
* @throws Exception
*/
@Override
public List<ImMessageOfflineListVo> getOfflineList() throws Exception {
// 返回数据
List<ImMessageOfflineListVo> imMessageOfflineListVoList = new ArrayList<>();
ImClient client = imClientService.getClient();
// 获取加入的所有会话
List<ImConversation> myImConversationList = imConversationService.getMyImConversationList();
// 遍历会话列表, 查询每个会话列表的离线消息
for (ImConversation imConversation : myImConversationList) {
//根据客户端id与会话id 查询离线消息
List<OfflineMsgDto> offlineListByClientAndConversation = getOfflineListByClientAndConversation(client.getId(), imConversation.getId());
ImMessageOfflineListVo imMessageOfflineListVo = new ImMessageOfflineListVo();
imMessageOfflineListVo.setMsgList(offlineListByClientAndConversation);
imMessageOfflineListVo.setConversationId(imConversation.getId());
imMessageOfflineListVoList.add(imMessageOfflineListVo);
}
return imMessageOfflineListVoList;
} }
/**
* 根据客户端id与会话id 查询离线消息
*
* @param clientId
* @param conversationId
* @return
*/
@Override
public List<OfflineMsgDto> getOfflineListByClientAndConversation(Long clientId, Long conversationId) {
return imMessageMapper.getOfflineListByClientAndConversation(clientId, conversationId);
}
}
package com.wecloud.im.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import java.io.Serializable;
import java.util.List;
/**
* <pre>
* 离线消息列表 查询结果对象
* </pre>
*
* @author wei
* @date 2021-04-29
*/
@Data
@Accessors(chain = true)
@ApiModel(value = "ImMessageOfflineListVo")
public class ImMessageOfflineListVo implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty("会话id")
private Long conversationId;
@ApiModelProperty("消息列表")
private List<OfflineMsgDto> msgList;
}
\ No newline at end of file
package com.wecloud.im.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import java.io.Serializable;
import java.util.Date;
/**
* 离线消息内容实体
*/
@Data
@Accessors(chain = true)
@ApiModel(value = "OfflineMsgDto")
public class OfflineMsgDto implements Serializable {
@ApiModelProperty("消息id")
private Long id;
@ApiModelProperty("创建时间")
private Date createTime;
@ApiModelProperty("撤回时间")
private Date withdrawTime;
@ApiModelProperty("修改时间")
private Date updateDate;
@ApiModelProperty("发送者客户端id")
private String sender;
@ApiModelProperty("内容")
private String content;
@ApiModelProperty("0未撤回; 1已撤回")
private Boolean withdraw;
@ApiModelProperty("0非事件; 1为事件")
private Boolean event;
@ApiModelProperty("0非系统通知; 1为系统通知")
private Boolean system;
@ApiModelProperty("at他人,传入客户端id数组")
private String at;
}
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
<include refid="Base_Column_List"/> <include refid="Base_Column_List"/>
from im_conversation from im_conversation
</select> </select>
<select id="getMyImConversationList" resultType="com.wecloud.im.vo.MyConversationListVo"> <select id="getMyImConversationListAndMsgCount" resultType="com.wecloud.im.vo.MyConversationListVo">
SELECT imConversation.id, SELECT imConversation.id,
imConversation.create_time, imConversation.create_time,
imConversation.`name`, imConversation.`name`,
...@@ -30,7 +30,8 @@ ...@@ -30,7 +30,8 @@
(SELECT COUNT(im_inbox.id) (SELECT COUNT(im_inbox.id)
FROM im_inbox FROM im_inbox
WHERE im_inbox.fk_conversation_id = imConversation.id WHERE im_inbox.fk_conversation_id = imConversation.id
AND im_inbox.receiver = #{clientId}) AS msg_not_read_count, AND im_inbox.receiver = #{clientId}
AND im_inbox.read_msg = 0) AS msg_not_read_count,
( (
SELECT GROUP_CONCAT(im_client.client_id) SELECT GROUP_CONCAT(im_client.client_id)
FROM im_conversation_members AS im_conversation_members FROM im_conversation_members AS im_conversation_members
...@@ -45,4 +46,12 @@ ...@@ -45,4 +46,12 @@
GROUP BY imConversation.id GROUP BY imConversation.id
</select> </select>
<select id="getMyImConversationList" resultType="com.wecloud.im.entity.ImConversation">
SELECT imConversation.*
FROM im_conversation_members AS imConversationMembers
INNER JOIN im_conversation imConversation
ON imConversation.id = imConversationMembers.fk_conversation_id
WHERE imConversationMembers.fk_client_id = #{clientId}
</select>
</mapper> </mapper>
...@@ -7,6 +7,19 @@ ...@@ -7,6 +7,19 @@
id id
, create_time, update_time, receiver_date, fk_appid, receiver, fk_msg_id, read_msg, fk_conversation_id , create_time, update_time, receiver_date, fk_appid, receiver, fk_msg_id, read_msg, fk_conversation_id
</sql> </sql>
<update id="updateImMsgReceivedByIds">
UPDATE im_inbox
SET `im_inbox`.`update_time` = NOW(),
`im_inbox`.`read_msg` = 1,
`im_inbox`.`receiver_date` = NOW()
WHERE
im_inbox.receiver = #{clientId}
AND im_inbox.fk_msg_id IN
<foreach collection="msgIds" item="deptId" index="i" open="(" close=")" separator=",">
#{deptId}
</foreach>
</update>
<select id="getImInboxById" resultType="com.wecloud.im.param.ImInboxQueryVo"> <select id="getImInboxById" resultType="com.wecloud.im.param.ImInboxQueryVo">
select select
......
...@@ -4,7 +4,8 @@ ...@@ -4,7 +4,8 @@
<!-- 通用查询结果列 --> <!-- 通用查询结果列 -->
<sql id="Base_Column_List"> <sql id="Base_Column_List">
id, create_time, withdraw_time, update_date, fk_appid, sender, content, withdraw, event, system, at, send_status, fk_conversation_id id
, create_time, withdraw_time, update_date, fk_appid, sender, content, withdraw, event, system, at, send_status, fk_conversation_id
</sql> </sql>
<select id="getImMessageById" resultType="com.wecloud.im.param.ImMessageQueryVo"> <select id="getImMessageById" resultType="com.wecloud.im.param.ImMessageQueryVo">
...@@ -13,10 +14,21 @@ ...@@ -13,10 +14,21 @@
from im_message where id = #{id} from im_message where id = #{id}
</select> </select>
<select id="getImMessagePageList" parameterType="com.wecloud.im.param.ImMessagePageParam" resultType="com.wecloud.im.param.ImMessageQueryVo"> <select id="getImMessagePageList" parameterType="com.wecloud.im.param.ImMessagePageParam"
resultType="com.wecloud.im.param.ImMessageQueryVo">
select select
<include refid="Base_Column_List"/> <include refid="Base_Column_List"/>
from im_message from im_message
</select> </select>
<select id="getOfflineListByClientAndConversation" resultType="com.wecloud.im.vo.OfflineMsgDto">
SELECT im_message.*
FROM im_inbox
INNER JOIN im_message im_message ON im_message.id = im_inbox.fk_msg_id
WHERE im_inbox.fk_conversation_id = #{conversationId}
AND im_inbox.receiver = #{clientId}
AND im_inbox.read_msg = 0
</select>
</mapper> </mapper>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment