fix: 去除无用的ImUserController,调整IM代码
This commit is contained in:
@@ -2,6 +2,7 @@ package cn.lili.controller.im;
|
||||
|
||||
import cn.lili.common.enums.ResultCode;
|
||||
import cn.lili.common.enums.ResultUtil;
|
||||
import cn.lili.common.exception.ServiceException;
|
||||
import cn.lili.common.vo.ResultMessage;
|
||||
import cn.lili.modules.im.entity.dos.ImMessage;
|
||||
import cn.lili.modules.im.entity.dto.MessageQueryParams;
|
||||
@@ -32,39 +33,39 @@ public class ImMessageController {
|
||||
@ApiOperation(value = "查看Im消息详情")
|
||||
public ResultMessage<ImMessage> get(@PathVariable String id) {
|
||||
ImMessage imMessage = imMessageService.getById(id);
|
||||
return new ResultUtil<ImMessage>().setData(imMessage);
|
||||
return ResultUtil.data(imMessage);
|
||||
}
|
||||
|
||||
@GetMapping
|
||||
@ApiOperation(value = "分页获取Im消息")
|
||||
public ResultMessage<List<ImMessage>> historyMessage(MessageQueryParams messageQueryParams) {
|
||||
List<ImMessage> data = imMessageService.getList(messageQueryParams);
|
||||
return new ResultUtil<List<ImMessage>>().setData(data);
|
||||
return ResultUtil.data(data);
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
@ApiOperation(value = "新增Im消息")
|
||||
public ResultMessage<ImMessage> save(ImMessage imMessage) {
|
||||
if (imMessageService.save(imMessage)) {
|
||||
return new ResultUtil<ImMessage>().setData(imMessage);
|
||||
return ResultUtil.data(imMessage);
|
||||
}
|
||||
return new ResultUtil<ImMessage>().setErrorMsg(ResultCode.ERROR);
|
||||
throw new ServiceException(ResultCode.IM_MESSAGE_ADD_ERROR);
|
||||
}
|
||||
|
||||
@PutMapping("/{id}")
|
||||
@ApiOperation(value = "更新Im消息")
|
||||
public ResultMessage<ImMessage> update(@PathVariable String id, ImMessage imMessage) {
|
||||
if (imMessageService.updateById(imMessage)) {
|
||||
return new ResultUtil<ImMessage>().setData(imMessage);
|
||||
return ResultUtil.data(imMessage);
|
||||
}
|
||||
return new ResultUtil<ImMessage>().setErrorMsg(ResultCode.ERROR);
|
||||
throw new ServiceException(ResultCode.IM_MESSAGE_EDIT_ERROR);
|
||||
}
|
||||
|
||||
@DeleteMapping(value = "/{ids}")
|
||||
@ApiOperation(value = "删除Im消息")
|
||||
public ResultMessage<Object> delAllByIds(@PathVariable List ids) {
|
||||
imMessageService.removeByIds(ids);
|
||||
return ResultUtil.success(ResultCode.SUCCESS);
|
||||
return ResultUtil.success();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -2,16 +2,11 @@ package cn.lili.controller.im;
|
||||
|
||||
import cn.lili.common.enums.ResultCode;
|
||||
import cn.lili.common.enums.ResultUtil;
|
||||
import cn.lili.common.security.AuthUser;
|
||||
import cn.lili.common.security.context.UserContext;
|
||||
import cn.lili.common.vo.ResultMessage;
|
||||
import cn.lili.modules.im.entity.dos.ImTalk;
|
||||
import cn.lili.modules.im.entity.vo.ImTalkVO;
|
||||
import cn.lili.modules.im.service.ImTalkService;
|
||||
import cn.lili.modules.store.service.StoreService;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -19,7 +14,6 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
/**
|
||||
@@ -34,43 +28,38 @@ public class ImTalkController {
|
||||
|
||||
private final ImTalkService imTalkService;
|
||||
|
||||
@Autowired
|
||||
private StoreService storeService;
|
||||
|
||||
@GetMapping(value = "/{id}")
|
||||
@ApiOperation(value = "查看聊天详情")
|
||||
public ResultMessage<ImTalk> get(@PathVariable String id) {
|
||||
|
||||
ImTalk imTalk = imTalkService.getById(id);
|
||||
return new ResultUtil<ImTalk>().setData(imTalk);
|
||||
return ResultUtil.data(imTalk);
|
||||
}
|
||||
|
||||
@GetMapping(value = "/user/{uid}")
|
||||
@ApiOperation(value = "查看与某人聊天详情")
|
||||
public ResultMessage<ImTalk> getUser(@PathVariable String uid) {
|
||||
AuthUser authUser = UserContext.getCurrentUser();
|
||||
return ResultUtil.data(imTalkService.getTalkByUser(authUser.getId(), uid));
|
||||
//通过长度判断,保证每次都是同一个聊天
|
||||
return ResultUtil.data(imTalkService.getTalkByUser(uid));
|
||||
}
|
||||
|
||||
@GetMapping(value = "/by/user/{userId}")
|
||||
@ApiOperation(value = "查看与某人聊天详情")
|
||||
public ResultMessage<ImTalkVO> getByUser(@PathVariable String userId) {
|
||||
AuthUser authUser = UserContext.getCurrentUser();
|
||||
return ResultUtil.data(new ImTalkVO(imTalkService.getTalkByUser(authUser.getId(), userId), authUser.getId()));
|
||||
return ResultUtil.data(new ImTalkVO(imTalkService.getTalkByUser(userId),userId));
|
||||
}
|
||||
|
||||
@GetMapping(value = "/top")
|
||||
@ApiOperation(value = "查看与某人聊天详情")
|
||||
public ResultMessage top(String id, Boolean top) {
|
||||
public ResultMessage<Object> top(String id, Boolean top) {
|
||||
imTalkService.top(id, top);
|
||||
return ResultUtil.success();
|
||||
}
|
||||
|
||||
@GetMapping("/list")
|
||||
@ApiOperation(value = "分页获取聊天")
|
||||
@ApiImplicitParam(name = "userName", value = "用户名称", paramType = "query", dataType = "String")
|
||||
public ResultMessage<List<ImTalkVO>> getUserTalkList(String userName) {
|
||||
return ResultUtil.data(imTalkService.getUserTalkList(userName));
|
||||
@ApiOperation(value = "分页获取用户聊天")
|
||||
public ResultMessage<List<ImTalkVO>> getUserTalkList() {
|
||||
return ResultUtil.data(imTalkService.getUserTalkList());
|
||||
}
|
||||
|
||||
@GetMapping("/store/list")
|
||||
|
||||
@@ -1,80 +0,0 @@
|
||||
package cn.lili.controller.im;
|
||||
|
||||
|
||||
import cn.lili.common.enums.ResultUtil;
|
||||
import cn.lili.common.security.AuthUser;
|
||||
import cn.lili.common.security.context.UserContext;
|
||||
import cn.lili.common.vo.ResultMessage;
|
||||
import cn.lili.modules.member.entity.dos.Member;
|
||||
import cn.lili.modules.member.entity.dto.FootPrintQueryParams;
|
||||
import cn.lili.modules.member.service.FootprintService;
|
||||
import cn.lili.modules.member.service.MemberService;
|
||||
import cn.lili.modules.search.entity.dos.EsGoodsIndex;
|
||||
import cn.lili.modules.store.entity.dos.Store;
|
||||
import cn.lili.modules.store.service.StoreService;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
|
||||
/**
|
||||
* @author Chopper
|
||||
*/
|
||||
@RestController
|
||||
@Api(tags = "Im消息接口")
|
||||
@RequestMapping("/im/user")
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
|
||||
public class ImUserController {
|
||||
|
||||
private final MemberService memberService;
|
||||
|
||||
@Autowired
|
||||
private StoreService storeService;
|
||||
|
||||
@Autowired
|
||||
private FootprintService footprintService;
|
||||
|
||||
@GetMapping
|
||||
@ApiOperation(value = "获取用户信息")
|
||||
public ResultMessage<Member> getImUser() {
|
||||
AuthUser authUser = UserContext.getCurrentUser();
|
||||
return ResultUtil.data(memberService.getById(authUser.getId()));
|
||||
}
|
||||
|
||||
@GetMapping("/store")
|
||||
@ApiOperation(value = "获取店铺信息")
|
||||
public ResultMessage<Store> getStoreUser() {
|
||||
AuthUser authUser = UserContext.getCurrentUser();
|
||||
return ResultUtil.data(storeService.getById(authUser.getStoreId()));
|
||||
}
|
||||
|
||||
@GetMapping("/{memberId}")
|
||||
@ApiImplicitParam(name = "memberId", value = "店铺Id", required = true, dataType = "String", paramType = "path")
|
||||
@ApiOperation(value = "获取用户信息")
|
||||
public ResultMessage<Member> getImUserDetail(@PathVariable String memberId) {
|
||||
return ResultUtil.data(memberService.getById(memberId));
|
||||
}
|
||||
|
||||
@GetMapping("/store/{storeId}")
|
||||
@ApiImplicitParam(name = "storeId", value = "店铺Id", required = true, dataType = "String", paramType = "path")
|
||||
@ApiOperation(value = "获取店铺信息")
|
||||
public ResultMessage<Store> getStoreUserDetail(@PathVariable String storeId) {
|
||||
return ResultUtil.data(storeService.getById(storeId));
|
||||
}
|
||||
|
||||
@GetMapping("/history")
|
||||
@ApiOperation(value = "获取会员的历史足迹")
|
||||
public ResultMessage<IPage<EsGoodsIndex>> getMemberHistory(FootPrintQueryParams params) {
|
||||
return ResultUtil.data(footprintService.footPrintPage(params));
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user