新增聊天模块

This commit is contained in:
gxwebsoft
2024-04-28 23:03:52 +08:00
parent fb785964c5
commit 386b0feac5
25 changed files with 1265 additions and 9 deletions
@@ -68,7 +68,7 @@ public class RequestUtil {
}
// 新增用户
public void saveUserByPhone(MerchantAccount merchantAccount) {
public boolean saveUserByPhone(MerchantAccount merchantAccount) {
String path = "/system/user/";
try {
HashMap<String, Object> map = new HashMap<>();
@@ -92,9 +92,9 @@ public class RequestUtil {
.body(JSONUtil.toJSONString(map))//表单内容
.timeout(20000)//超时,毫秒
.execute().body();
System.out.println("result = " + result);
} catch (Exception e) {
e.printStackTrace();
}
return true;
}
}
@@ -0,0 +1,115 @@
package com.gxwebsoft.shop.controller;
import com.gxwebsoft.common.core.web.BaseController;
import com.gxwebsoft.shop.service.ChatConversationService;
import com.gxwebsoft.shop.entity.ChatConversation;
import com.gxwebsoft.shop.param.ChatConversationParam;
import com.gxwebsoft.common.core.web.ApiResult;
import com.gxwebsoft.common.core.web.PageResult;
import com.gxwebsoft.common.core.web.PageParam;
import com.gxwebsoft.common.core.web.BatchParam;
import com.gxwebsoft.common.core.annotation.OperationLog;
import com.gxwebsoft.common.system.entity.User;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;
/**
* 聊天消息表控制器
*
* @author 科技小王子
* @since 2024-04-27 16:08:04
*/
@Api(tags = "聊天消息表管理")
@RestController
@RequestMapping("/api/shop/chat-conversation")
public class ChatConversationController extends BaseController {
@Resource
private ChatConversationService chatConversationService;
@ApiOperation("分页查询聊天消息表")
@GetMapping("/page")
public ApiResult<PageResult<ChatConversation>> page(ChatConversationParam param) {
// 使用关联查询
return success(chatConversationService.pageRel(param));
}
@ApiOperation("查询全部聊天消息表")
@GetMapping()
public ApiResult<List<ChatConversation>> list(ChatConversationParam param) {
// 使用关联查询
return success(chatConversationService.listRel(param));
}
@PreAuthorize("hasAuthority('shop:chatConversation:list')")
@ApiOperation("根据id查询聊天消息表")
@GetMapping("/{id}")
public ApiResult<ChatConversation> get(@PathVariable("id") Integer id) {
// 使用关联查询
return success(chatConversationService.getByIdRel(id));
}
@ApiOperation("添加聊天消息表")
@PostMapping()
public ApiResult<?> save(@RequestBody ChatConversation chatConversation) {
// 记录当前登录用户id
// User loginUser = getLoginUser();
// if (loginUser != null) {
// chatConversation.setUserId(loginUser.getUserId());
// }
if (chatConversationService.save(chatConversation)) {
return success("添加成功");
}
return fail("添加失败");
}
@ApiOperation("修改聊天消息表")
@PutMapping()
public ApiResult<?> update(@RequestBody ChatConversation chatConversation) {
if (chatConversationService.updateById(chatConversation)) {
return success("修改成功");
}
return fail("修改失败");
}
@ApiOperation("删除聊天消息表")
@DeleteMapping("/{id}")
public ApiResult<?> remove(@PathVariable("id") Integer id) {
if (chatConversationService.removeById(id)) {
return success("删除成功");
}
return fail("删除失败");
}
@ApiOperation("批量添加聊天消息表")
@PostMapping("/batch")
public ApiResult<?> saveBatch(@RequestBody List<ChatConversation> list) {
if (chatConversationService.saveBatch(list)) {
return success("添加成功");
}
return fail("添加失败");
}
@ApiOperation("批量修改聊天消息表")
@PutMapping("/batch")
public ApiResult<?> removeBatch(@RequestBody BatchParam<ChatConversation> batchParam) {
if (batchParam.update(chatConversationService, "id")) {
return success("修改成功");
}
return fail("修改失败");
}
@ApiOperation("批量删除聊天消息表")
@DeleteMapping("/batch")
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
if (chatConversationService.removeByIds(ids)) {
return success("删除成功");
}
return fail("删除失败");
}
}
@@ -0,0 +1,115 @@
package com.gxwebsoft.shop.controller;
import com.gxwebsoft.common.core.web.BaseController;
import com.gxwebsoft.shop.service.ChatMessageService;
import com.gxwebsoft.shop.entity.ChatMessage;
import com.gxwebsoft.shop.param.ChatMessageParam;
import com.gxwebsoft.common.core.web.ApiResult;
import com.gxwebsoft.common.core.web.PageResult;
import com.gxwebsoft.common.core.web.PageParam;
import com.gxwebsoft.common.core.web.BatchParam;
import com.gxwebsoft.common.core.annotation.OperationLog;
import com.gxwebsoft.common.system.entity.User;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;
/**
* 聊天消息表控制器
*
* @author 科技小王子
* @since 2024-04-27 16:08:04
*/
@Api(tags = "聊天消息表管理")
@RestController
@RequestMapping("/api/shop/chat-message")
public class ChatMessageController extends BaseController {
@Resource
private ChatMessageService chatMessageService;
@ApiOperation("分页查询聊天消息表")
@GetMapping("/page")
public ApiResult<PageResult<ChatMessage>> page(ChatMessageParam param) {
// 使用关联查询
return success(chatMessageService.pageRel(param));
}
@ApiOperation("查询全部聊天消息表")
@GetMapping()
public ApiResult<List<ChatMessage>> list(ChatMessageParam param) {
// 使用关联查询
return success(chatMessageService.listRel(param));
}
@PreAuthorize("hasAuthority('shop:chatMessage:list')")
@ApiOperation("根据id查询聊天消息表")
@GetMapping("/{id}")
public ApiResult<ChatMessage> get(@PathVariable("id") Integer id) {
// 使用关联查询
return success(chatMessageService.getByIdRel(id));
}
@ApiOperation("添加聊天消息表")
@PostMapping()
public ApiResult<?> save(@RequestBody ChatMessage chatMessage) {
// 记录当前登录用户id
// User loginUser = getLoginUser();
// if (loginUser != null) {
// chatMessage.setUserId(loginUser.getUserId());
// }
if (chatMessageService.save(chatMessage)) {
return success("添加成功");
}
return fail("添加失败");
}
@ApiOperation("修改聊天消息表")
@PutMapping()
public ApiResult<?> update(@RequestBody ChatMessage chatMessage) {
if (chatMessageService.updateById(chatMessage)) {
return success("修改成功");
}
return fail("修改失败");
}
@ApiOperation("删除聊天消息表")
@DeleteMapping("/{id}")
public ApiResult<?> remove(@PathVariable("id") Integer id) {
if (chatMessageService.removeById(id)) {
return success("删除成功");
}
return fail("删除失败");
}
@ApiOperation("批量添加聊天消息表")
@PostMapping("/batch")
public ApiResult<?> saveBatch(@RequestBody List<ChatMessage> list) {
if (chatMessageService.saveBatch(list)) {
return success("添加成功");
}
return fail("添加失败");
}
@ApiOperation("批量修改聊天消息表")
@PutMapping("/batch")
public ApiResult<?> removeBatch(@RequestBody BatchParam<ChatMessage> batchParam) {
if (batchParam.update(chatMessageService, "id")) {
return success("修改成功");
}
return fail("修改失败");
}
@ApiOperation("批量删除聊天消息表")
@DeleteMapping("/batch")
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
if (chatMessageService.removeByIds(ids)) {
return success("删除成功");
}
return fail("删除失败");
}
}
@@ -65,17 +65,20 @@ public class MerchantAccountController extends BaseController {
if (merchantAccountService.count(new LambdaQueryWrapper<MerchantAccount>().eq(MerchantAccount::getPhone,merchantAccount.getPhone())) > 0) {
return fail("手机号码已存在");
}
// 获取用户信息
// 获取远程用户信息
final RequestUtil requestUtil = new RequestUtil();
String access_token = JwtUtil.getAccessToken(request);
requestUtil.setAccessToken(access_token);
requestUtil.setTenantId(getTenantId().toString());
final User userByPhone = requestUtil.getUserByPhone(merchantAccount.getPhone());
if (userByPhone != null) {
merchantAccount.setUserId(userByPhone.getUserId());
User userByPhone = requestUtil.getUserByPhone(merchantAccount.getPhone());
// 新增注册
if (userByPhone == null) {
if (requestUtil.saveUserByPhone(merchantAccount)) {
userByPhone = requestUtil.getUserByPhone(merchantAccount.getPhone());
}
}
merchantAccount.setUserId(userByPhone.getUserId());
if (merchantAccountService.save(merchantAccount)) {
requestUtil.saveUserByPhone(merchantAccount);
return success("添加成功");
}
return fail("添加失败");
@@ -0,0 +1,115 @@
package com.gxwebsoft.shop.controller;
import com.gxwebsoft.common.core.web.BaseController;
import com.gxwebsoft.shop.service.UserCollectionService;
import com.gxwebsoft.shop.entity.UserCollection;
import com.gxwebsoft.shop.param.UserCollectionParam;
import com.gxwebsoft.common.core.web.ApiResult;
import com.gxwebsoft.common.core.web.PageResult;
import com.gxwebsoft.common.core.web.PageParam;
import com.gxwebsoft.common.core.web.BatchParam;
import com.gxwebsoft.common.core.annotation.OperationLog;
import com.gxwebsoft.common.system.entity.User;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;
/**
* 我的收藏控制器
*
* @author 科技小王子
* @since 2024-04-28 18:17:37
*/
@Api(tags = "我的收藏管理")
@RestController
@RequestMapping("/api/shop/user-collection")
public class UserCollectionController extends BaseController {
@Resource
private UserCollectionService userCollectionService;
@ApiOperation("分页查询我的收藏")
@GetMapping("/page")
public ApiResult<PageResult<UserCollection>> page(UserCollectionParam param) {
// 使用关联查询
return success(userCollectionService.pageRel(param));
}
@ApiOperation("查询全部我的收藏")
@GetMapping()
public ApiResult<List<UserCollection>> list(UserCollectionParam param) {
// 使用关联查询
return success(userCollectionService.listRel(param));
}
@PreAuthorize("hasAuthority('shop:userCollection:list')")
@ApiOperation("根据id查询我的收藏")
@GetMapping("/{id}")
public ApiResult<UserCollection> get(@PathVariable("id") Integer id) {
// 使用关联查询
return success(userCollectionService.getByIdRel(id));
}
@ApiOperation("添加我的收藏")
@PostMapping()
public ApiResult<?> save(@RequestBody UserCollection userCollection) {
// 记录当前登录用户id
// User loginUser = getLoginUser();
// if (loginUser != null) {
// userCollection.setUserId(loginUser.getUserId());
// }
if (userCollectionService.save(userCollection)) {
return success("添加成功");
}
return fail("添加失败");
}
@ApiOperation("修改我的收藏")
@PutMapping()
public ApiResult<?> update(@RequestBody UserCollection userCollection) {
if (userCollectionService.updateById(userCollection)) {
return success("修改成功");
}
return fail("修改失败");
}
@ApiOperation("删除我的收藏")
@DeleteMapping("/{id}")
public ApiResult<?> remove(@PathVariable("id") Integer id) {
if (userCollectionService.removeById(id)) {
return success("删除成功");
}
return fail("删除失败");
}
@ApiOperation("批量添加我的收藏")
@PostMapping("/batch")
public ApiResult<?> saveBatch(@RequestBody List<UserCollection> list) {
if (userCollectionService.saveBatch(list)) {
return success("添加成功");
}
return fail("添加失败");
}
@ApiOperation("批量修改我的收藏")
@PutMapping("/batch")
public ApiResult<?> removeBatch(@RequestBody BatchParam<UserCollection> batchParam) {
if (batchParam.update(userCollectionService, "id")) {
return success("修改成功");
}
return fail("修改失败");
}
@ApiOperation("批量删除我的收藏")
@DeleteMapping("/batch")
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
if (userCollectionService.removeByIds(ids)) {
return success("删除成功");
}
return fail("删除失败");
}
}
@@ -0,0 +1,62 @@
package com.gxwebsoft.shop.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import java.time.LocalDateTime;
import com.baomidou.mybatisplus.annotation.TableLogic;
import java.io.Serializable;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* 聊天消息表
*
* @author 科技小王子
* @since 2024-04-27 16:08:04
*/
@Data
@EqualsAndHashCode(callSuper = false)
@ApiModel(value = "ChatConversation对象", description = "聊天消息表")
@TableName("shop_chat_conversation")
public class ChatConversation implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "自增ID")
@TableId(value = "id", type = IdType.AUTO)
private Integer id;
@ApiModelProperty(value = "用户ID")
private Integer userId;
@ApiModelProperty(value = "好友ID")
private Integer friendId;
@ApiModelProperty(value = "消息类型")
private Integer type;
@ApiModelProperty(value = "消息内容")
private String content;
@ApiModelProperty(value = "未读消息")
private Integer unRead;
@ApiModelProperty(value = "状态, 0未读, 1已读")
private Integer status;
@ApiModelProperty(value = "是否删除, 0否, 1是")
@TableLogic
private Integer deleted;
@ApiModelProperty(value = "租户id")
private Integer tenantId;
@ApiModelProperty(value = "注册时间")
private LocalDateTime createTime;
@ApiModelProperty(value = "修改时间")
private LocalDateTime updateTime;
}
@@ -0,0 +1,74 @@
package com.gxwebsoft.shop.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import java.time.LocalDateTime;
import com.baomidou.mybatisplus.annotation.TableLogic;
import java.io.Serializable;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* 聊天消息表
*
* @author 科技小王子
* @since 2024-04-27 16:08:04
*/
@Data
@EqualsAndHashCode(callSuper = false)
@ApiModel(value = "ChatMessage对象", description = "聊天消息表")
@TableName("shop_chat_message")
public class ChatMessage implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "自增ID")
@TableId(value = "id", type = IdType.AUTO)
private Integer id;
@ApiModelProperty(value = "发送人ID")
private Integer formUserId;
@ApiModelProperty(value = "接收人ID")
private Integer toUserId;
@ApiModelProperty(value = "消息类型")
private String type;
@ApiModelProperty(value = "消息内容")
private String content;
@ApiModelProperty(value = "屏蔽接收方")
private Integer sideTo;
@ApiModelProperty(value = "屏蔽发送方")
private Integer sideFrom;
@ApiModelProperty(value = "是否撤回")
private Integer withdraw;
@ApiModelProperty(value = "文件信息")
private String fileInfo;
@ApiModelProperty(value = "存在联系方式")
private Integer hasContact;
@ApiModelProperty(value = "状态, 0未读, 1已读")
private Integer status;
@ApiModelProperty(value = "是否删除, 0否, 1是")
@TableLogic
private Integer deleted;
@ApiModelProperty(value = "租户id")
private Integer tenantId;
@ApiModelProperty(value = "注册时间")
private LocalDateTime createTime;
@ApiModelProperty(value = "修改时间")
private LocalDateTime updateTime;
}
@@ -1,5 +1,6 @@
package com.gxwebsoft.shop.entity;
import cn.hutool.core.util.DesensitizedUtil;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.IdType;
@@ -76,4 +77,12 @@ public class MerchantAccount implements Serializable {
@TableField(exist = false)
private Boolean goodsReview;
@ApiModelProperty("手机号(脱敏)")
@TableField(exist = false)
private String mobile;
public String getMobile(){
return DesensitizedUtil.mobilePhone(this.phone);
}
}
@@ -0,0 +1,42 @@
package com.gxwebsoft.shop.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import java.time.LocalDateTime;
import java.io.Serializable;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* 我的收藏
*
* @author 科技小王子
* @since 2024-04-28 18:17:37
*/
@Data
@EqualsAndHashCode(callSuper = false)
@ApiModel(value = "UserCollection对象", description = "我的收藏")
@TableName("shop_user_collection")
public class UserCollection implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "主键ID")
@TableId(value = "id", type = IdType.AUTO)
private Integer id;
@ApiModelProperty(value = "租户ID")
private Integer tid;
@ApiModelProperty(value = "用户ID")
private Integer userId;
@ApiModelProperty(value = "租户id")
private Integer tenantId;
@ApiModelProperty(value = "注册时间")
private LocalDateTime createTime;
}
@@ -0,0 +1,37 @@
package com.gxwebsoft.shop.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.gxwebsoft.shop.entity.ChatConversation;
import com.gxwebsoft.shop.param.ChatConversationParam;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 聊天消息表Mapper
*
* @author 科技小王子
* @since 2024-04-27 16:08:04
*/
public interface ChatConversationMapper extends BaseMapper<ChatConversation> {
/**
* 分页查询
*
* @param page 分页对象
* @param param 查询参数
* @return List<ChatConversation>
*/
List<ChatConversation> selectPageRel(@Param("page") IPage<ChatConversation> page,
@Param("param") ChatConversationParam param);
/**
* 查询全部
*
* @param param 查询参数
* @return List<User>
*/
List<ChatConversation> selectListRel(@Param("param") ChatConversationParam param);
}
@@ -0,0 +1,37 @@
package com.gxwebsoft.shop.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.gxwebsoft.shop.entity.ChatMessage;
import com.gxwebsoft.shop.param.ChatMessageParam;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 聊天消息表Mapper
*
* @author 科技小王子
* @since 2024-04-27 16:08:04
*/
public interface ChatMessageMapper extends BaseMapper<ChatMessage> {
/**
* 分页查询
*
* @param page 分页对象
* @param param 查询参数
* @return List<ChatMessage>
*/
List<ChatMessage> selectPageRel(@Param("page") IPage<ChatMessage> page,
@Param("param") ChatMessageParam param);
/**
* 查询全部
*
* @param param 查询参数
* @return List<User>
*/
List<ChatMessage> selectListRel(@Param("param") ChatMessageParam param);
}
@@ -0,0 +1,37 @@
package com.gxwebsoft.shop.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.gxwebsoft.shop.entity.UserCollection;
import com.gxwebsoft.shop.param.UserCollectionParam;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 我的收藏Mapper
*
* @author 科技小王子
* @since 2024-04-28 18:17:37
*/
public interface UserCollectionMapper extends BaseMapper<UserCollection> {
/**
* 分页查询
*
* @param page 分页对象
* @param param 查询参数
* @return List<UserCollection>
*/
List<UserCollection> selectPageRel(@Param("page") IPage<UserCollection> page,
@Param("param") UserCollectionParam param);
/**
* 查询全部
*
* @param param 查询参数
* @return List<User>
*/
List<UserCollection> selectListRel(@Param("param") UserCollectionParam param);
}
@@ -0,0 +1,60 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.gxwebsoft.shop.mapper.ChatConversationMapper">
<!-- 关联查询sql -->
<sql id="selectSql">
SELECT a.*
FROM shop_chat_conversation a
<where>
<if test="param.id != null">
AND a.id = #{param.id}
</if>
<if test="param.userId != null">
AND a.user_id = #{param.userId}
</if>
<if test="param.friendId != null">
AND a.friend_id = #{param.friendId}
</if>
<if test="param.type != null">
AND a.type = #{param.type}
</if>
<if test="param.content != null">
AND a.content LIKE CONCAT('%', #{param.content}, '%')
</if>
<if test="param.unRead != null">
AND a.un_read = #{param.unRead}
</if>
<if test="param.status != null">
AND a.status = #{param.status}
</if>
<if test="param.deleted != null">
AND a.deleted = #{param.deleted}
</if>
<if test="param.deleted == null">
AND a.deleted = 0
</if>
<if test="param.createTimeStart != null">
AND a.create_time &gt;= #{param.createTimeStart}
</if>
<if test="param.createTimeEnd != null">
AND a.create_time &lt;= #{param.createTimeEnd}
</if>
<if test="param.keywords != null">
AND (a.comments LIKE CONCAT('%', #{param.keywords}, '%')
)
</if>
</where>
</sql>
<!-- 分页查询 -->
<select id="selectPageRel" resultType="com.gxwebsoft.shop.entity.ChatConversation">
<include refid="selectSql"></include>
</select>
<!-- 查询全部 -->
<select id="selectListRel" resultType="com.gxwebsoft.shop.entity.ChatConversation">
<include refid="selectSql"></include>
</select>
</mapper>
@@ -0,0 +1,72 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.gxwebsoft.shop.mapper.ChatMessageMapper">
<!-- 关联查询sql -->
<sql id="selectSql">
SELECT a.*
FROM shop_chat_message a
<where>
<if test="param.id != null">
AND a.id = #{param.id}
</if>
<if test="param.formUserId != null">
AND a.form_user_id = #{param.formUserId}
</if>
<if test="param.toUserId != null">
AND a.to_user_id = #{param.toUserId}
</if>
<if test="param.type != null">
AND a.type LIKE CONCAT('%', #{param.type}, '%')
</if>
<if test="param.content != null">
AND a.content LIKE CONCAT('%', #{param.content}, '%')
</if>
<if test="param.sideTo != null">
AND a.side_to = #{param.sideTo}
</if>
<if test="param.sideFrom != null">
AND a.side_from = #{param.sideFrom}
</if>
<if test="param.withdraw != null">
AND a.withdraw = #{param.withdraw}
</if>
<if test="param.fileInfo != null">
AND a.file_info LIKE CONCAT('%', #{param.fileInfo}, '%')
</if>
<if test="param.hasContact != null">
AND a.has_contact = #{param.hasContact}
</if>
<if test="param.status != null">
AND a.status = #{param.status}
</if>
<if test="param.deleted != null">
AND a.deleted = #{param.deleted}
</if>
<if test="param.deleted == null">
AND a.deleted = 0
</if>
<if test="param.createTimeStart != null">
AND a.create_time &gt;= #{param.createTimeStart}
</if>
<if test="param.createTimeEnd != null">
AND a.create_time &lt;= #{param.createTimeEnd}
</if>
<if test="param.keywords != null">
AND (a.comments LIKE CONCAT('%', #{param.keywords}, '%')
)
</if>
</where>
</sql>
<!-- 分页查询 -->
<select id="selectPageRel" resultType="com.gxwebsoft.shop.entity.ChatMessage">
<include refid="selectSql"></include>
</select>
<!-- 查询全部 -->
<select id="selectListRel" resultType="com.gxwebsoft.shop.entity.ChatMessage">
<include refid="selectSql"></include>
</select>
</mapper>
@@ -0,0 +1,42 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.gxwebsoft.shop.mapper.UserCollectionMapper">
<!-- 关联查询sql -->
<sql id="selectSql">
SELECT a.*
FROM shop_user_collection a
<where>
<if test="param.id != null">
AND a.id = #{param.id}
</if>
<if test="param.tid != null">
AND a.tid = #{param.tid}
</if>
<if test="param.userId != null">
AND a.user_id = #{param.userId}
</if>
<if test="param.createTimeStart != null">
AND a.create_time &gt;= #{param.createTimeStart}
</if>
<if test="param.createTimeEnd != null">
AND a.create_time &lt;= #{param.createTimeEnd}
</if>
<if test="param.keywords != null">
AND (a.comments LIKE CONCAT('%', #{param.keywords}, '%')
)
</if>
</where>
</sql>
<!-- 分页查询 -->
<select id="selectPageRel" resultType="com.gxwebsoft.shop.entity.UserCollection">
<include refid="selectSql"></include>
</select>
<!-- 查询全部 -->
<select id="selectListRel" resultType="com.gxwebsoft.shop.entity.UserCollection">
<include refid="selectSql"></include>
</select>
</mapper>
@@ -0,0 +1,57 @@
package com.gxwebsoft.shop.param;
import java.math.BigDecimal;
import com.gxwebsoft.common.core.annotation.QueryField;
import com.gxwebsoft.common.core.annotation.QueryType;
import com.gxwebsoft.common.core.web.BaseParam;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* 聊天消息表查询参数
*
* @author 科技小王子
* @since 2024-04-27 16:08:04
*/
@Data
@EqualsAndHashCode(callSuper = false)
@JsonInclude(JsonInclude.Include.NON_NULL)
@ApiModel(value = "ChatConversationParam对象", description = "聊天消息表查询参数")
public class ChatConversationParam extends BaseParam {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "自增ID")
@QueryField(type = QueryType.EQ)
private Integer id;
@ApiModelProperty(value = "用户ID")
@QueryField(type = QueryType.EQ)
private Integer userId;
@ApiModelProperty(value = "好友ID")
@QueryField(type = QueryType.EQ)
private Integer friendId;
@ApiModelProperty(value = "消息类型")
@QueryField(type = QueryType.EQ)
private Integer type;
@ApiModelProperty(value = "消息内容")
private String content;
@ApiModelProperty(value = "未读消息")
@QueryField(type = QueryType.EQ)
private Integer unRead;
@ApiModelProperty(value = "状态, 0未读, 1已读")
@QueryField(type = QueryType.EQ)
private Integer status;
@ApiModelProperty(value = "是否删除, 0否, 1是")
@QueryField(type = QueryType.EQ)
private Integer deleted;
}
@@ -0,0 +1,71 @@
package com.gxwebsoft.shop.param;
import java.math.BigDecimal;
import com.gxwebsoft.common.core.annotation.QueryField;
import com.gxwebsoft.common.core.annotation.QueryType;
import com.gxwebsoft.common.core.web.BaseParam;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* 聊天消息表查询参数
*
* @author 科技小王子
* @since 2024-04-27 16:08:04
*/
@Data
@EqualsAndHashCode(callSuper = false)
@JsonInclude(JsonInclude.Include.NON_NULL)
@ApiModel(value = "ChatMessageParam对象", description = "聊天消息表查询参数")
public class ChatMessageParam extends BaseParam {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "自增ID")
@QueryField(type = QueryType.EQ)
private Integer id;
@ApiModelProperty(value = "发送人ID")
@QueryField(type = QueryType.EQ)
private Integer formUserId;
@ApiModelProperty(value = "接收人ID")
@QueryField(type = QueryType.EQ)
private Integer toUserId;
@ApiModelProperty(value = "消息类型")
private String type;
@ApiModelProperty(value = "消息内容")
private String content;
@ApiModelProperty(value = "屏蔽接收方")
@QueryField(type = QueryType.EQ)
private Integer sideTo;
@ApiModelProperty(value = "屏蔽发送方")
@QueryField(type = QueryType.EQ)
private Integer sideFrom;
@ApiModelProperty(value = "是否撤回")
@QueryField(type = QueryType.EQ)
private Integer withdraw;
@ApiModelProperty(value = "文件信息")
private String fileInfo;
@ApiModelProperty(value = "存在联系方式")
@QueryField(type = QueryType.EQ)
private Integer hasContact;
@ApiModelProperty(value = "状态, 0未读, 1已读")
@QueryField(type = QueryType.EQ)
private Integer status;
@ApiModelProperty(value = "是否删除, 0否, 1是")
@QueryField(type = QueryType.EQ)
private Integer deleted;
}
@@ -0,0 +1,38 @@
package com.gxwebsoft.shop.param;
import java.math.BigDecimal;
import com.gxwebsoft.common.core.annotation.QueryField;
import com.gxwebsoft.common.core.annotation.QueryType;
import com.gxwebsoft.common.core.web.BaseParam;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* 我的收藏查询参数
*
* @author 科技小王子
* @since 2024-04-28 18:17:37
*/
@Data
@EqualsAndHashCode(callSuper = false)
@JsonInclude(JsonInclude.Include.NON_NULL)
@ApiModel(value = "UserCollectionParam对象", description = "我的收藏查询参数")
public class UserCollectionParam extends BaseParam {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "主键ID")
@QueryField(type = QueryType.EQ)
private Integer id;
@ApiModelProperty(value = "租户ID")
@QueryField(type = QueryType.EQ)
private Integer tid;
@ApiModelProperty(value = "用户ID")
@QueryField(type = QueryType.EQ)
private Integer userId;
}
@@ -0,0 +1,42 @@
package com.gxwebsoft.shop.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.gxwebsoft.common.core.web.PageResult;
import com.gxwebsoft.shop.entity.ChatConversation;
import com.gxwebsoft.shop.param.ChatConversationParam;
import java.util.List;
/**
* 聊天消息表Service
*
* @author 科技小王子
* @since 2024-04-27 16:08:04
*/
public interface ChatConversationService extends IService<ChatConversation> {
/**
* 分页关联查询
*
* @param param 查询参数
* @return PageResult<ChatConversation>
*/
PageResult<ChatConversation> pageRel(ChatConversationParam param);
/**
* 关联查询全部
*
* @param param 查询参数
* @return List<ChatConversation>
*/
List<ChatConversation> listRel(ChatConversationParam param);
/**
* 根据id查询
*
* @param id 自增ID
* @return ChatConversation
*/
ChatConversation getByIdRel(Integer id);
}
@@ -0,0 +1,42 @@
package com.gxwebsoft.shop.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.gxwebsoft.common.core.web.PageResult;
import com.gxwebsoft.shop.entity.ChatMessage;
import com.gxwebsoft.shop.param.ChatMessageParam;
import java.util.List;
/**
* 聊天消息表Service
*
* @author 科技小王子
* @since 2024-04-27 16:08:04
*/
public interface ChatMessageService extends IService<ChatMessage> {
/**
* 分页关联查询
*
* @param param 查询参数
* @return PageResult<ChatMessage>
*/
PageResult<ChatMessage> pageRel(ChatMessageParam param);
/**
* 关联查询全部
*
* @param param 查询参数
* @return List<ChatMessage>
*/
List<ChatMessage> listRel(ChatMessageParam param);
/**
* 根据id查询
*
* @param id 自增ID
* @return ChatMessage
*/
ChatMessage getByIdRel(Integer id);
}
@@ -0,0 +1,42 @@
package com.gxwebsoft.shop.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.gxwebsoft.common.core.web.PageResult;
import com.gxwebsoft.shop.entity.UserCollection;
import com.gxwebsoft.shop.param.UserCollectionParam;
import java.util.List;
/**
* 我的收藏Service
*
* @author 科技小王子
* @since 2024-04-28 18:17:37
*/
public interface UserCollectionService extends IService<UserCollection> {
/**
* 分页关联查询
*
* @param param 查询参数
* @return PageResult<UserCollection>
*/
PageResult<UserCollection> pageRel(UserCollectionParam param);
/**
* 关联查询全部
*
* @param param 查询参数
* @return List<UserCollection>
*/
List<UserCollection> listRel(UserCollectionParam param);
/**
* 根据id查询
*
* @param id 主键ID
* @return UserCollection
*/
UserCollection getByIdRel(Integer id);
}
@@ -0,0 +1,47 @@
package com.gxwebsoft.shop.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.shop.mapper.ChatConversationMapper;
import com.gxwebsoft.shop.service.ChatConversationService;
import com.gxwebsoft.shop.entity.ChatConversation;
import com.gxwebsoft.shop.param.ChatConversationParam;
import com.gxwebsoft.common.core.web.PageParam;
import com.gxwebsoft.common.core.web.PageResult;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* 聊天消息表Service实现
*
* @author 科技小王子
* @since 2024-04-27 16:08:04
*/
@Service
public class ChatConversationServiceImpl extends ServiceImpl<ChatConversationMapper, ChatConversation> implements ChatConversationService {
@Override
public PageResult<ChatConversation> pageRel(ChatConversationParam param) {
PageParam<ChatConversation, ChatConversationParam> page = new PageParam<>(param);
page.setDefaultOrder("sort_number asc, create_time desc");
List<ChatConversation> list = baseMapper.selectPageRel(page, param);
return new PageResult<>(list, page.getTotal());
}
@Override
public List<ChatConversation> listRel(ChatConversationParam param) {
List<ChatConversation> list = baseMapper.selectListRel(param);
// 排序
PageParam<ChatConversation, ChatConversationParam> page = new PageParam<>();
page.setDefaultOrder("sort_number asc, create_time desc");
return page.sortRecords(list);
}
@Override
public ChatConversation getByIdRel(Integer id) {
ChatConversationParam param = new ChatConversationParam();
param.setId(id);
return param.getOne(baseMapper.selectListRel(param));
}
}
@@ -0,0 +1,47 @@
package com.gxwebsoft.shop.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.shop.mapper.ChatMessageMapper;
import com.gxwebsoft.shop.service.ChatMessageService;
import com.gxwebsoft.shop.entity.ChatMessage;
import com.gxwebsoft.shop.param.ChatMessageParam;
import com.gxwebsoft.common.core.web.PageParam;
import com.gxwebsoft.common.core.web.PageResult;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* 聊天消息表Service实现
*
* @author 科技小王子
* @since 2024-04-27 16:08:04
*/
@Service
public class ChatMessageServiceImpl extends ServiceImpl<ChatMessageMapper, ChatMessage> implements ChatMessageService {
@Override
public PageResult<ChatMessage> pageRel(ChatMessageParam param) {
PageParam<ChatMessage, ChatMessageParam> page = new PageParam<>(param);
page.setDefaultOrder("sort_number asc, create_time desc");
List<ChatMessage> list = baseMapper.selectPageRel(page, param);
return new PageResult<>(list, page.getTotal());
}
@Override
public List<ChatMessage> listRel(ChatMessageParam param) {
List<ChatMessage> list = baseMapper.selectListRel(param);
// 排序
PageParam<ChatMessage, ChatMessageParam> page = new PageParam<>();
page.setDefaultOrder("sort_number asc, create_time desc");
return page.sortRecords(list);
}
@Override
public ChatMessage getByIdRel(Integer id) {
ChatMessageParam param = new ChatMessageParam();
param.setId(id);
return param.getOne(baseMapper.selectListRel(param));
}
}
@@ -0,0 +1,47 @@
package com.gxwebsoft.shop.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.shop.mapper.UserCollectionMapper;
import com.gxwebsoft.shop.service.UserCollectionService;
import com.gxwebsoft.shop.entity.UserCollection;
import com.gxwebsoft.shop.param.UserCollectionParam;
import com.gxwebsoft.common.core.web.PageParam;
import com.gxwebsoft.common.core.web.PageResult;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* 我的收藏Service实现
*
* @author 科技小王子
* @since 2024-04-28 18:17:37
*/
@Service
public class UserCollectionServiceImpl extends ServiceImpl<UserCollectionMapper, UserCollection> implements UserCollectionService {
@Override
public PageResult<UserCollection> pageRel(UserCollectionParam param) {
PageParam<UserCollection, UserCollectionParam> page = new PageParam<>(param);
page.setDefaultOrder("sort_number asc, create_time desc");
List<UserCollection> list = baseMapper.selectPageRel(page, param);
return new PageResult<>(list, page.getTotal());
}
@Override
public List<UserCollection> listRel(UserCollectionParam param) {
List<UserCollection> list = baseMapper.selectListRel(param);
// 排序
PageParam<UserCollection, UserCollectionParam> page = new PageParam<>();
page.setDefaultOrder("sort_number asc, create_time desc");
return page.sortRecords(list);
}
@Override
public UserCollection getByIdRel(Integer id) {
UserCollectionParam param = new UserCollectionParam();
param.setId(id);
return param.getOne(baseMapper.selectListRel(param));
}
}