ChatsController.java 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. package com.sqx.modules.chats.controller;
  2. import com.sqx.modules.chats.entity.Chats;
  3. import com.sqx.modules.chats.service.ChatsService;
  4. import com.sqx.modules.chats.utils.Result;
  5. import icu.xuyijie.secureapi.annotation.DecryptParam;
  6. import io.swagger.annotations.Api;
  7. import io.swagger.annotations.ApiOperation;
  8. import io.swagger.annotations.ApiParam;
  9. import org.springframework.beans.factory.annotation.Autowired;
  10. import org.springframework.web.bind.annotation.GetMapping;
  11. import org.springframework.web.bind.annotation.PostMapping;
  12. import org.springframework.web.bind.annotation.RequestBody;
  13. import org.springframework.web.bind.annotation.RequestMapping;
  14. import org.springframework.web.bind.annotation.RestController;
  15. @RestController
  16. @Api(value="聊天会话",tags={"聊天会话"})
  17. @RequestMapping(value = "/chats")
  18. public class ChatsController {
  19. @Autowired
  20. private ChatsService service;
  21. @GetMapping("/count")
  22. @ApiOperation("商家端未读消息")
  23. public Result count(@ApiParam("店铺id(总后台商户传0)") @DecryptParam Long storeId) {
  24. return service.count(storeId);
  25. }
  26. @GetMapping("/userCount")
  27. @ApiOperation("用户端未读消息")
  28. public Result userCount(@ApiParam("店铺id(总后台商户传0)") @DecryptParam Long userId) {
  29. return service.userCount(userId);
  30. }
  31. @GetMapping("/list")
  32. @ApiOperation("商家端会话列表")
  33. public Result findAll(@ApiParam("店铺id(总后台商户传0)") @DecryptParam Long storeId,
  34. @ApiParam("用户类型(0全部 1用户 2 骑手 3商家)") @DecryptParam(required = false) Long type,
  35. @ApiParam("关键字") @DecryptParam(required = false) String keyWord,
  36. @ApiParam("开始时间") @DecryptParam(required = false) String starTime,
  37. @ApiParam("结束时间") @DecryptParam(required = false) String endTime,
  38. @ApiParam("用户昵称") @DecryptParam(required = false) String userName) {
  39. return service.findAll(storeId, keyWord,type,starTime,endTime);
  40. }
  41. @GetMapping("/listRead")
  42. @ApiOperation("商家端已读会话列表")
  43. public Result findRead(@ApiParam("店铺id(总后台商户传0)") @DecryptParam Long storeId,
  44. @ApiParam("用户类型") @DecryptParam(required = false) Long type,
  45. @ApiParam("关键字") @DecryptParam(required = false) String keyWord,
  46. @ApiParam("开始时间") @DecryptParam(required = false) String starTime,
  47. @ApiParam("结束时间") @DecryptParam(required = false) String endTime,
  48. @ApiParam("用户昵称") @DecryptParam(required = false) String userName) {
  49. return service.findRead(storeId, keyWord,type,starTime,endTime);
  50. }
  51. @GetMapping("/listUnRead")
  52. @ApiOperation("商家端未读会话列表")
  53. public Result findUnRead(@ApiParam("店铺id(总后台商户传0)") @DecryptParam Long storeId,
  54. @ApiParam("用户类型") @DecryptParam(required = false) Long type,
  55. @ApiParam("关键字") @DecryptParam(required = false) String keyWord,
  56. @ApiParam("开始时间") @DecryptParam(required = false) String starTime,
  57. @ApiParam("结束时间") @DecryptParam(required = false) String endTime,
  58. @ApiParam("用户昵称") @DecryptParam(required = false) String userName) {
  59. return service.findUnRead(storeId, keyWord,type,starTime,endTime);
  60. }
  61. @GetMapping("/userList")
  62. @ApiOperation("用户端会话列表")
  63. public Result userList(Long userId) {
  64. return service.userList(userId);
  65. }
  66. @GetMapping("/find")
  67. @ApiOperation("查询")
  68. public Result findOne(Long id) {
  69. return service.findOne(id);
  70. }
  71. @PostMapping("/save")
  72. @ApiOperation("用户端发起聊天")
  73. public Result saveBody(@RequestBody Chats entity) {
  74. return service.saveBody(entity);
  75. }
  76. @PostMapping("/update")
  77. @ApiOperation("修改")
  78. public Result updateBody(@RequestBody Chats entity) {
  79. return service.updateBody(entity);
  80. }
  81. @GetMapping("/delete")
  82. @ApiOperation("删除聊天会话")
  83. public Result delete(Long id) {
  84. return service.delete(id);
  85. }
  86. }