瀏覽代碼

聊天功能修改

shilin 4 年之前
父節點
當前提交
6ae8b69173

+ 17 - 0
src/main/java/com/gyee/frame/controller/gen/ChatDetailController.java

@@ -10,6 +10,7 @@ import com.gyee.frame.model.auto.GyeeBraceletuser;
 import com.gyee.frame.model.auto.Gyeeuser;
 import com.gyee.frame.model.custom.DataVo;
 import com.gyee.frame.model.custom.DatasVo;
+import com.gyee.frame.model.custom.NoReadVo;
 import com.gyee.frame.service.ChatDetailService;
 import com.gyee.frame.service.GyeeBraceletuserService;
 import com.gyee.frame.service.GyeeuserService;
@@ -122,6 +123,11 @@ public class ChatDetailController {
             SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
             for(ChatDetail po:result)
             {
+                if(po.getPointtoid().equals(send))
+                {
+                    po.setReceiveip("1");
+                    chatDetailService.updateByPrimaryKeySelective(po);
+                }
                 DatasVo vo=new DatasVo();
                 vo.setSend(po.getSendingid());
                 vo.setReceive(po.getPointtoid());
@@ -179,6 +185,16 @@ public class ChatDetailController {
     }
 
 
+    @GetMapping("/selectNoreadInfoByUserId")
+    @ResponseBody
+    public List<NoReadVo> selectNoreadInfoByUserId(String userid) {
+
+        List<NoReadVo> result=chatDetailService.selectNoreadInfoByUserId(userid);
+
+        return  result;
+    }
+
+
     @PostMapping("/insertSelective")
     @ResponseBody
     public int insertSelective(HttpServletRequest request, @RequestBody DatasVo vo) {
@@ -211,6 +227,7 @@ public class ChatDetailController {
             temp=temp.substring(0,temp.length()-4)+".jpg";
             po.setRemark2(temp);
         }
+
         //获取IP地址
         String ipAddress = IpUtil.getIpAddr(request);
 

+ 2 - 1
src/main/java/com/gyee/frame/mapper/auto/ChatDetailMapper.java

@@ -3,6 +3,7 @@ package com.gyee.frame.mapper.auto;
 
 import com.gyee.frame.model.auto.ChatDetail;
 import com.gyee.frame.model.auto.ChatDetailExample;
+import com.gyee.frame.model.custom.NoReadVo;
 import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
@@ -102,5 +103,5 @@ public interface ChatDetailMapper {
 
     List<ChatDetail> selectLimitByUserId(@Param("sendingid") String sendingid, @Param("pointtoid") String pointtoid,@Param("begin")int begin,@Param("end")int end);
 
-
+    List<NoReadVo> selectNoreadInfoByUserId(@Param("pointtoid") String pointtoid);
 }

+ 23 - 0
src/main/java/com/gyee/frame/model/custom/NoReadVo.java

@@ -0,0 +1,23 @@
+package com.gyee.frame.model.custom;
+
+public class NoReadVo {
+
+    private String sendingid;
+    private Integer num;
+
+    public String getSendingid() {
+        return sendingid;
+    }
+
+    public void setSendingid(String sendingid) {
+        this.sendingid = sendingid;
+    }
+
+    public Integer getNum() {
+        return num;
+    }
+
+    public void setNum(Integer num) {
+        this.num = num;
+    }
+}

+ 9 - 0
src/main/java/com/gyee/frame/service/ChatDetailService.java

@@ -5,6 +5,7 @@ import com.gyee.frame.common.base.BaseService;
 import com.gyee.frame.mapper.auto.ChatDetailMapper;
 import com.gyee.frame.model.auto.ChatDetail;
 import com.gyee.frame.model.auto.ChatDetailExample;
+import com.gyee.frame.model.custom.NoReadVo;
 import com.gyee.frame.util.Convert;
 import com.gyee.frame.util.StringUtils;
 import org.springframework.stereotype.Service;
@@ -120,4 +121,12 @@ public class ChatDetailService implements BaseService<ChatDetail, ChatDetailExam
 		return  list;
 	}
 
+
+	public List<NoReadVo> selectNoreadInfoByUserId(String pointtoid){
+
+		List<NoReadVo> list= chatDetailMapper.selectNoreadInfoByUserId(pointtoid);
+
+		return  list;
+	}
+
 }

+ 1 - 1
src/main/resources/application-dev.yml

@@ -20,7 +20,7 @@ spring:
         driver-class-name: com.mysql.jdbc.Driver
      #两票数据源
      ticket:
-        url: jdbc:sqlserver://10.155.32.2:1433;DatabaseName=test
+        url: jdbc:sqlserver://10.155.32.2:1433;DatabaseName=fdeam
         username: sa
         password: Gyee@321#!
         driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver

+ 22 - 6
src/main/resources/mybatis/auto/ChatDetailMapper.xml

@@ -21,6 +21,17 @@
     <result column="sendingip" jdbcType="VARCHAR" property="sendingip" />
     <result column="receiveip" jdbcType="VARCHAR" property="receiveip" />
   </resultMap>
+
+  <resultMap id="NoReadVo" type="com.gyee.frame.model.custom.NoReadVo">
+    <!--
+      WARNING - @mbg.generated
+      This element is automatically generated by MyBatis Generator, do not modify.
+    -->
+
+    <result column="pointtoid" jdbcType="VARCHAR" property="pointtoid" />
+    <result column="num" jdbcType="INTEGER" property="num" />
+
+  </resultMap>
   <sql id="Example_Where_Clause">
     <!--
       WARNING - @mbg.generated
@@ -450,14 +461,19 @@
 
   <select id="selectLastInfoByUserId"   resultMap="BaseResultMap">
     select * from (
-      select
-      ROW_NUMBER() Over(order by chattime desc) num, id, sendingid, sendingname, chattime, pointto, pointtoid, chattypes, chatcontent,
-      remark1, remark2, remark3, numericdate, sendingip, receiveip
-      from chatdetail
-      where  ((sendingid = #{sendingid} and pointtoid = #{pointtoid}
-      ) or (sendingid = #{pointtoid} and pointtoid = #{sendingid} ))
+    select
+    ROW_NUMBER() Over(order by chattime desc) num, id, sendingid, sendingname, chattime, pointto, pointtoid, chattypes, chatcontent,
+    remark1, remark2, remark3, numericdate, sendingip, receiveip
+    from chatdetail
+    where  ((sendingid = #{sendingid} and pointtoid = #{pointtoid}
+    ) or (sendingid = #{pointtoid} and pointtoid = #{sendingid} ))
     ) where num = 1
+  </select>
+
+  <select id="selectNoreadInfoByUserId"   resultMap="NoReadVo">
 
+    select  t.sendingid as sendingid,count(*) as num from chatdetail t  where t.pointtoid=#{pointtoid}
+    and t.receiveip is null group by  t.sendingid
 
   </select>
 </mapper>