查看消息列表

master
382696293@qq.com 2 years ago
parent 082ca6ff3a
commit aa5e71b065

@ -62,4 +62,8 @@ public interface WxUserScriptLogMapper {
public int deleteWxUserScriptLogByIds(Long[] ids);
void deleteWxUserScriptLogByWxUserId(@Param("userId") Long userId);
Integer getNoReadMessageNum(WxUserScriptLog query);
void hasBeenRead(WxUserScriptLog query);
}

@ -56,13 +56,23 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="tagIds != null and tagIds != ''"> and tag_ids = #{tagIds}</if>
<if test="status != null "> and status = #{status}</if>
</where>
order by create_time desc
</select>
<select id="selectWxUserScriptLogById" parameterType="Long" resultMap="WxUserScriptLogResult">
<include refid="selectWxUserScriptLogVo"/>
where id = #{id}
</select>
<select id="getNoReadMessageNum" resultType="java.lang.Integer">
select count(1) from wx_user_script_log
<where>
<if test="wxUserId != null "> and wx_user_id = #{wxUserId}</if>
<if test="isRead != null "> and is_read = #{isRead}</if>
<if test="status != null "> and status = #{status}</if>
</where>
</select>
<insert id="insertWxUserScriptLog" parameterType="WxUserScriptLog" useGeneratedKeys="true" keyProperty="id">
insert into wx_user_script_log
<trim prefix="(" suffix=")" suffixOverrides=",">
@ -141,6 +151,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where id = #{id}
</update>
<update id="hasBeenRead">
update wx_user_script_log set
`is_read` = 1
<where>
<if test="wxUserId != null "> and wx_user_id = #{wxUserId}</if>
<if test="isRead != null "> and is_read = #{isRead}</if>
<if test="status != null "> and status = #{status}</if>
</where>
</update>
<delete id="deleteWxUserScriptLogById" parameterType="Long">
delete from wx_user_script_log where id = #{id}
</delete>
@ -154,4 +174,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<delete id="deleteWxUserScriptLogByWxUserId" parameterType="Long">
delete from wx_user_script_log where wx_user_id = #{userId}
</delete>
</mapper>

@ -0,0 +1,55 @@
package com.flossom.miniProgram.controller;
import com.flossom.common.core.domain.R;
import com.flossom.common.core.domain.entity.WxUserScriptLog;
import com.flossom.common.core.web.controller.BaseController;
import com.flossom.common.core.web.page.TableDataInfo;
import com.flossom.miniProgram.service.IWxUserScriptLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* Controller
*
* @author flossom
* @date 2023-12-20
*/
@RestController
@RequestMapping("/userScriptLog")
public class WxUserScriptLogController extends BaseController {
@Autowired
private IWxUserScriptLogService wxUserScriptLogService;
/**
*
*/
@GetMapping("/list")
public TableDataInfo list() {
startPage();
List<WxUserScriptLog> list = wxUserScriptLogService.selectWxUserScriptLogList();
return getDataTable(list);
}
/**
*
*/
@GetMapping("getNoReadMessageNum")
public R getNoReadMessageNum() {
return R.ok(wxUserScriptLogService.getNoReadMessageNum());
}
/**
*
*/
@GetMapping("/hasBeenRead")
public R hasBeenRead() {
wxUserScriptLogService.hasBeenRead();
return R.ok();
}
}

@ -0,0 +1,14 @@
package com.flossom.miniProgram.service;
import com.flossom.common.core.domain.entity.WxUserScriptLog;
import java.util.List;
public interface IWxUserScriptLogService {
List<WxUserScriptLog> selectWxUserScriptLogList();
Integer getNoReadMessageNum();
void hasBeenRead();
}

@ -0,0 +1,53 @@
package com.flossom.miniProgram.service.impl;
import com.flossom.common.core.domain.entity.WxUserScriptLog;
import com.flossom.common.core.enums.Status;
import com.flossom.common.core.mapper.WxUserScriptLogMapper;
import com.flossom.common.security.utils.SecurityUtils;
import com.flossom.miniProgram.service.IWxUserScriptLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class WxUserScriptLogServiceImpl implements IWxUserScriptLogService {
@Autowired
private WxUserScriptLogMapper wxUserScriptLogMapper;
@Override
public List<WxUserScriptLog> selectWxUserScriptLogList() {
WxUserScriptLog query = new WxUserScriptLog();
// 消息归属人
query.setWxUserId(SecurityUtils.getWxUserId());
// 消息状态正常
query.setStatus(Status.OK.getCode());
return wxUserScriptLogMapper.selectWxUserScriptLogList(query);
}
@Override
public Integer getNoReadMessageNum() {
WxUserScriptLog query = new WxUserScriptLog();
// 消息归属人
query.setWxUserId(SecurityUtils.getWxUserId());
// 消息状态正常
query.setStatus(Status.OK.getCode());
// 未读
query.setIsRead(0);
return wxUserScriptLogMapper.getNoReadMessageNum(query);
}
@Override
public void hasBeenRead() {
WxUserScriptLog query = new WxUserScriptLog();
// 消息归属人
query.setWxUserId(20L);
// 消息状态正常
query.setStatus(Status.OK.getCode());
// 未读
query.setIsRead(0);
wxUserScriptLogMapper.hasBeenRead(query);
}
}
Loading…
Cancel
Save