chat
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
package com.newyetai.component.chat.controller;
|
||||
|
||||
import com.newyetai.common.AlitaResult;
|
||||
import com.newyetai.component.chat.dto.ChatMsgCreateDTO;
|
||||
import com.newyetai.component.chat.dto.ChatMsgDTO;
|
||||
import com.newyetai.component.chat.dto.ChatMsgQueryDTO;
|
||||
import com.newyetai.component.chat.service.ChatMsgService;
|
||||
import com.newyetai.tkmybatis.pojo.Page;
|
||||
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
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.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("chat/msg")
|
||||
@Api(tags = "聊天消息")
|
||||
public class ChatMsgController {
|
||||
|
||||
@Autowired
|
||||
private ChatMsgService chatMsgService;
|
||||
|
||||
|
||||
@PostMapping("/create")
|
||||
@ApiOperation("创建")
|
||||
public AlitaResult<Long> create(
|
||||
@Validated @RequestBody ChatMsgCreateDTO chatMsgCreateDTO){
|
||||
return AlitaResult.success(chatMsgService.create(chatMsgCreateDTO));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@ApiOperation("分页查询")
|
||||
public AlitaResult<Page<ChatMsgDTO>> pageCurr(@Validated ChatMsgQueryDTO chatMsgQueryDTO){
|
||||
chatMsgService.page(chatMsgQueryDTO);
|
||||
return AlitaResult.success(chatMsgQueryDTO.getPageResult());
|
||||
}
|
||||
}
|
||||
@@ -33,13 +33,17 @@ public class ChatDTO extends BaseDTO {
|
||||
/** 个人用户id */
|
||||
private Long personUserId;
|
||||
/** @see ChatTypeEnum 类型 */
|
||||
private Integer type;
|
||||
private String type;
|
||||
/** 状态:1有效,2关闭 */
|
||||
private Integer status;
|
||||
|
||||
/** 机构名称 */
|
||||
private String orgName;
|
||||
/** 个人用户名称*/
|
||||
private String personUserName;
|
||||
/** 机构logo */
|
||||
private String orgLogo;
|
||||
/** 个人用户昵称*/
|
||||
private String personUserNickname;
|
||||
/** 个人用户头像 */
|
||||
private String personUserAvatar;
|
||||
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package com.newyetai.component.chat.dto;
|
||||
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
@@ -23,6 +24,12 @@ public class ChatMsgQueryDTO extends PageQueryDTO<ChatMsgDTO>{
|
||||
/** **/
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Long id;
|
||||
@NotNull(message = "会话id不能为空")
|
||||
private Long chatId;
|
||||
|
||||
/** 大于id **/
|
||||
private Long idGt;
|
||||
|
||||
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.newyetai.component.chat.dto;
|
||||
|
||||
|
||||
import com.newyetai.component.chat.constant.ChatStatusEnum;
|
||||
import com.newyetai.component.chat.constant.ChatTypeEnum;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
@@ -34,7 +35,8 @@ public class ChatQueryDTO extends PageQueryDTO<ChatDTO>{
|
||||
/** 个人用户id */
|
||||
private Long personUserId;
|
||||
/** 状态:1有效,2关闭 */
|
||||
private Integer status;
|
||||
@Default
|
||||
private Integer status = ChatStatusEnum.ACTIVE.getStatus();
|
||||
/** @see ChatTypeEnum 类型 */
|
||||
@Default
|
||||
private String type = ChatTypeEnum.POSITION.getType();
|
||||
|
||||
@@ -3,8 +3,10 @@ package com.newyetai.component.chat.entity;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.newyetai.common.entity.BaseEntity;
|
||||
|
||||
import com.newyetai.component.chat.constant.ChatStatusEnum;
|
||||
import com.newyetai.component.chat.constant.ChatTypeEnum;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder.Default;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
@@ -34,7 +36,8 @@ public class Chat extends BaseEntity {
|
||||
/** @see ChatTypeEnum 类型 */
|
||||
private String type;
|
||||
/** 状态:1有效,2关闭 */
|
||||
private Integer status;
|
||||
@Default
|
||||
private Integer status = ChatStatusEnum.ACTIVE.getStatus();
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -5,26 +5,30 @@
|
||||
<mapper namespace="com.newyetai.component.chat.dao.ChatMapper">
|
||||
<select id="listChatDTO" resultType="com.newyetai.component.chat.dto.ChatDTO">
|
||||
select
|
||||
*,
|
||||
(select org_name from xs_org o where o.id = org_id) orgName,
|
||||
(select username from uc_user u where u.id = person_user_id) personUserName
|
||||
from xs_chat
|
||||
c.*,
|
||||
o.org_name orgName,
|
||||
o.org_logo orgLogo,
|
||||
u.nickname personUserNickname,
|
||||
u.avatar personUserAvatar
|
||||
from xs_chat c
|
||||
inner join xs_org o on o.id = c.org_id
|
||||
inner join uc_user u on u.id = c.person_user_id
|
||||
where
|
||||
deleted = 0
|
||||
c.deleted = 0
|
||||
<if test="param.id != null">
|
||||
and id = #{param.id}
|
||||
and c.id = #{param.id}
|
||||
</if>
|
||||
<if test="param.orgId != null">
|
||||
and org_id = #{param.orgId}
|
||||
and c.org_id = #{param.orgId}
|
||||
</if>
|
||||
<if test="param.orgUserId != null">
|
||||
and org_user_id = #{param.orgUserId}
|
||||
and c.org_user_id = #{param.orgUserId}
|
||||
</if>
|
||||
<if test="param.personUserId != null">
|
||||
and person_user_id = #{param.personUserId}
|
||||
and c.person_user_id = #{param.personUserId}
|
||||
</if>
|
||||
<if test="param.status != null">
|
||||
and status = #{param.status}
|
||||
and c.status = #{param.status}
|
||||
</if>
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -15,5 +15,9 @@
|
||||
<if test="param.chatId != null">
|
||||
and chat_id = #{param.chatId}
|
||||
</if>
|
||||
<if test="param.idGt != null">
|
||||
and id > #{param.idGt}
|
||||
</if>
|
||||
order by id desc
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -67,6 +67,7 @@ public class ChatServiceImpl implements ChatService {
|
||||
Chat chat =
|
||||
ChatMapMapper.INSTANCE.toEntity(createDTO);
|
||||
chat.setOrgUserId(orgUserDTOs.get(0).getUserId());
|
||||
chat.setStatus(ChatStatusEnum.ACTIVE.getStatus());
|
||||
chatMapper.saveEntity(chat);
|
||||
return chat.getId();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user