10 changed files with 324 additions and 4 deletions
@ -0,0 +1,110 @@ |
|||||
|
package app.bcms.jchat.entity; |
||||
|
|
||||
|
import org.springframework.stereotype.Component; |
||||
|
|
||||
|
/** |
||||
|
* 客服聊天记录 |
||||
|
*/ |
||||
|
@Component |
||||
|
public class ChatRecord { |
||||
|
private Integer id;//
|
||||
|
private String fid;// 发消息人
|
||||
|
private Integer cuid;//当前客户登录id
|
||||
|
private String toid;//接收人
|
||||
|
private String content;//消息内容
|
||||
|
private String time;//发送时间
|
||||
|
private Integer isonline;// 是否为在线消息
|
||||
|
private String type;//操作类型
|
||||
|
// foid toid 是否针对回复时候使用??
|
||||
|
private String foid;//消息发送人
|
||||
|
private String ftoid;//消息接收人
|
||||
|
private String state;//状态 1已读 0未读
|
||||
|
|
||||
|
public Integer getId() { |
||||
|
return id; |
||||
|
} |
||||
|
|
||||
|
public void setId(Integer id) { |
||||
|
this.id = id; |
||||
|
} |
||||
|
|
||||
|
public String getFid() { |
||||
|
return fid; |
||||
|
} |
||||
|
|
||||
|
public void setFid(String fid) { |
||||
|
this.fid = fid; |
||||
|
} |
||||
|
|
||||
|
public Integer getCuid() { |
||||
|
return cuid; |
||||
|
} |
||||
|
|
||||
|
public void setCuid(Integer cuid) { |
||||
|
this.cuid = cuid; |
||||
|
} |
||||
|
|
||||
|
public String getToid() { |
||||
|
return toid; |
||||
|
} |
||||
|
|
||||
|
public void setToid(String toid) { |
||||
|
this.toid = toid; |
||||
|
} |
||||
|
|
||||
|
public String getContent() { |
||||
|
return content; |
||||
|
} |
||||
|
|
||||
|
public void setContent(String content) { |
||||
|
this.content = content; |
||||
|
} |
||||
|
|
||||
|
public String getTime() { |
||||
|
return time; |
||||
|
} |
||||
|
|
||||
|
public void setTime(String time) { |
||||
|
this.time = time; |
||||
|
} |
||||
|
|
||||
|
public Integer getIsonline() { |
||||
|
return isonline; |
||||
|
} |
||||
|
|
||||
|
public void setIsonline(Integer isonline) { |
||||
|
this.isonline = isonline; |
||||
|
} |
||||
|
|
||||
|
public String getType() { |
||||
|
return type; |
||||
|
} |
||||
|
|
||||
|
public void setType(String type) { |
||||
|
this.type = type; |
||||
|
} |
||||
|
|
||||
|
public String getFoid() { |
||||
|
return foid; |
||||
|
} |
||||
|
|
||||
|
public void setFoid(String foid) { |
||||
|
this.foid = foid; |
||||
|
} |
||||
|
|
||||
|
public String getFtoid() { |
||||
|
return ftoid; |
||||
|
} |
||||
|
|
||||
|
public void setFtoid(String ftoid) { |
||||
|
this.ftoid = ftoid; |
||||
|
} |
||||
|
|
||||
|
public String getState() { |
||||
|
return state; |
||||
|
} |
||||
|
|
||||
|
public void setState(String state) { |
||||
|
this.state = state; |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,40 @@ |
|||||
|
package app.bcms.jchat.mapper; |
||||
|
|
||||
|
import app.bcms.jchat.entity.ChatRecord; |
||||
|
import org.apache.ibatis.annotations.Param; |
||||
|
import org.springframework.stereotype.Component; |
||||
|
|
||||
|
import java.util.List; |
||||
|
import java.util.Map; |
||||
|
|
||||
|
/** |
||||
|
* 聊天记录 |
||||
|
*/ |
||||
|
@Component |
||||
|
public interface ChatRecordMapper { |
||||
|
/** |
||||
|
* get single record |
||||
|
* @param id |
||||
|
* @return |
||||
|
*/ |
||||
|
ChatRecord getChatRecordById(Integer id); |
||||
|
/** |
||||
|
* 条件查询聊天记录 |
||||
|
* @param somap |
||||
|
* @return |
||||
|
*/ |
||||
|
List<ChatRecord> getChatRecordByMap(@Param("map") Map somap); |
||||
|
|
||||
|
/** |
||||
|
* 统计记录 |
||||
|
* @param somap |
||||
|
* @return |
||||
|
*/ |
||||
|
int countRs(@Param("map") Map somap); |
||||
|
/** |
||||
|
* 保存聊天记录 |
||||
|
* @param chatRecord |
||||
|
* @return |
||||
|
*/ |
||||
|
int addChatRecord(ChatRecord chatRecord); |
||||
|
} |
||||
@ -0,0 +1,35 @@ |
|||||
|
package app.bcms.jchat.service; |
||||
|
|
||||
|
import app.bcms.jchat.entity.ChatRecord; |
||||
|
import org.apache.ibatis.annotations.Param; |
||||
|
|
||||
|
import java.util.List; |
||||
|
import java.util.Map; |
||||
|
|
||||
|
public interface ChatRecordService { |
||||
|
/** |
||||
|
* get single record |
||||
|
* @param id |
||||
|
* @return |
||||
|
*/ |
||||
|
ChatRecord getChatRecordById(Integer id); |
||||
|
/** |
||||
|
* 条件查询聊天记录 |
||||
|
* @param somap |
||||
|
* @return |
||||
|
*/ |
||||
|
List<ChatRecord> getChatRecordByMap(@Param("map") Map somap); |
||||
|
|
||||
|
/** |
||||
|
* 统计记录 |
||||
|
* @param somap |
||||
|
* @return |
||||
|
*/ |
||||
|
int countRs(@Param("map") Map somap); |
||||
|
/** |
||||
|
* 保存聊天记录 |
||||
|
* @param chatRecord |
||||
|
* @return |
||||
|
*/ |
||||
|
int addChatRecord(ChatRecord chatRecord); |
||||
|
} |
||||
@ -0,0 +1,36 @@ |
|||||
|
package app.bcms.jchat.service.impl; |
||||
|
|
||||
|
import app.bcms.jchat.entity.ChatRecord; |
||||
|
import app.bcms.jchat.mapper.ChatRecordMapper; |
||||
|
import app.bcms.jchat.service.ChatRecordService; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
|
||||
|
import java.util.List; |
||||
|
import java.util.Map; |
||||
|
|
||||
|
@Service |
||||
|
public class ChatRecordServiceImpl implements ChatRecordService { |
||||
|
@Autowired |
||||
|
private ChatRecordMapper chatRecordMapper; |
||||
|
|
||||
|
@Override |
||||
|
public ChatRecord getChatRecordById(Integer id) { |
||||
|
return chatRecordMapper.getChatRecordById(id); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public List<ChatRecord> getChatRecordByMap(Map somap) { |
||||
|
return chatRecordMapper.getChatRecordByMap(somap); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public int countRs(Map somap) { |
||||
|
return chatRecordMapper.countRs(somap); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public int addChatRecord(ChatRecord chatRecord) { |
||||
|
return chatRecordMapper.addChatRecord(chatRecord); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,58 @@ |
|||||
|
<?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="app.bcms.jchat.mapper.ChatRecordMapper"> |
||||
|
|
||||
|
<sql id="column"> |
||||
|
id,fid,cuid,toid,content,`time`,isonline,`type` ,foid,ftoid,state |
||||
|
</sql> |
||||
|
<sql id="tbName">chat_chat_record</sql> |
||||
|
|
||||
|
<!-- 查询详情 --> |
||||
|
<select id="getChatRecordById" resultType="app.bcms.jchat.entity.ChatRecord" parameterType="java.lang.Integer"> |
||||
|
SELECT <include refid="column"></include> |
||||
|
FROM <include refid="tbName"></include> |
||||
|
WHERE id=#{id} |
||||
|
</select> |
||||
|
|
||||
|
<!-- 带分页查询--> |
||||
|
<select id="getChatRecordByMap" resultType="app.bcms.jchat.entity.ChatRecord" parameterType="java.util.Map"> |
||||
|
SELECT <include refid="column"/> |
||||
|
FROM <include refid="tbName"/> |
||||
|
<if test="map!=null and map!=''"> |
||||
|
<where> |
||||
|
<foreach collection="map" index="k" item="v" separator="and"> |
||||
|
<if test="k!='sokey'"> |
||||
|
${k}=${v} |
||||
|
</if> |
||||
|
<if test="k=='sokey'"> |
||||
|
${v} |
||||
|
</if> |
||||
|
</foreach> |
||||
|
</where> |
||||
|
</if> |
||||
|
<if test="start!=-1"> |
||||
|
LIMIT #{start},#{limit}; |
||||
|
</if> |
||||
|
</select> |
||||
|
|
||||
|
<!-- 统计记录--> |
||||
|
<select id="countRs" resultType="java.lang.Integer" parameterType="java.util.Map"> |
||||
|
SELECT COUNT(*) |
||||
|
FROM <include refid="tbName"/> |
||||
|
<if test="map!=null and map!=''"> |
||||
|
<where> |
||||
|
<foreach collection="map" index="k" item="v" separator="and"> |
||||
|
<if test="k!='okey'"> |
||||
|
${k}=${v} |
||||
|
</if> |
||||
|
<if test="k=='sokey'"> |
||||
|
${v} |
||||
|
</if> |
||||
|
</foreach> |
||||
|
</where> |
||||
|
</if> |
||||
|
</select> |
||||
|
|
||||
|
</mapper> |
||||
@ -0,0 +1,36 @@ |
|||||
|
package app.bcms.jchat.mapper; |
||||
|
|
||||
|
import app.bcms.jchat.entity.ChatRecord; |
||||
|
import org.junit.runner.RunWith; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.boot.test.context.SpringBootTest; |
||||
|
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; |
||||
|
|
||||
|
import static org.junit.Assert.*; |
||||
|
|
||||
|
@SpringBootTest |
||||
|
@RunWith(SpringJUnit4ClassRunner.class) |
||||
|
public class ChatRecordMapperTest { |
||||
|
@Autowired |
||||
|
private ChatRecordMapper chatRecordMapper; |
||||
|
|
||||
|
@org.junit.Test |
||||
|
public void getChatRecordById() { |
||||
|
int id=424; |
||||
|
ChatRecord chatRecord = chatRecordMapper.getChatRecordById(id); |
||||
|
String ccont = chatRecord.getFid(); |
||||
|
System.out.println(ccont); |
||||
|
} |
||||
|
|
||||
|
@org.junit.Test |
||||
|
public void getChatRecordByMap() { |
||||
|
} |
||||
|
|
||||
|
@org.junit.Test |
||||
|
public void countRs() { |
||||
|
} |
||||
|
|
||||
|
@org.junit.Test |
||||
|
public void addChatRecord() { |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue