Commit c2131284 by huluobin

美甲师登陆流程修改 线程变量保存登陆Seesion

parent 8f507877
package com.gogirl.domain.xcx;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.gogirl.domain.store.oa.TakeLeaveEvent;
......@@ -21,23 +22,29 @@ public class Message {
@ApiModelProperty("美甲师id")
private Integer technicianId;
@ApiModelProperty("1.新预约消息")
@ApiModelProperty("消息分类 1.请假审核 2.排班提醒 3请假申请 4采购信息 5-培训课程 6-假期调整")
private Integer type;
@ApiModelProperty("消息时间")
private Date time;
@ApiModelProperty("0-未读 1-已读")
private Boolean isRead;
private Integer isRead;
@ApiModelProperty("标题")
private String title;
@ApiModelProperty("消息")
private String message;
private String content;
private String paramJson;
private Integer tab;
@TableField(exist = false)
private Integer unread;
@TableField(exist = false)
private TakeLeaveEvent takeLeaveEvent;
}
package com.gogirl.infrastructure.mapper.xcx;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.gogirl.domain.xcx.Message;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface MessageMapper {
public interface MessageMapper extends BaseMapper<Message> {
List<Message> selectMyMessage(Integer customerId);
/**
* 美甲师获取我的消息
*
* @param id
* @param technicianId 美甲师id
* @return 消息列表
*/
IPage<Message> selectMyMessage(@Param("page") IPage page, @Param("technicianId") Integer technicianId, @Param("type") Integer type, @Param("tab") Integer tab);
List<Message> myMessageManage(@Param("technicianId") Integer technicianId, @Param("tab") Integer tab);
Integer selectUnReadCount(@Param("technicianId") Integer technicianId, @Param("type") Integer type);
}
package com.gogirl.interfaces.xcx;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.gogirl.application.xcx.GogirlTokenService;
import com.gogirl.domain.store.oa.TakeLeaveEvent;
import com.gogirl.domain.store.store.StoreTechnician;
import com.gogirl.domain.xcx.GogirlToken;
import com.gogirl.domain.xcx.Message;
import com.gogirl.infrastructure.common.base.JsonResult;
import com.gogirl.infrastructure.common.util.JsonUtilByFsJson;
import com.gogirl.infrastructure.mapper.xcx.MessageMapper;
import com.gogirl.infrastructure.util.SessionUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@RestController
@RequestMapping("/message")
@Api(tags = {"10.美甲师消息和用户登入登出记录"}, value = "美甲师消息和用户登入登出记录")
@AllArgsConstructor
@Slf4j
public class TechnicianMessageController {
private final MessageMapper messageMapper;
private final GogirlTokenService gogirlTokenService;
@ApiOperation(value = "获取我的消息")
@PostMapping(value = "/technician/message/selectMyMessage")
public JsonResult<Page<Message>> selectMyMessage(@RequestHeader String token,
Integer pageSize,
Integer pageNum,
Integer type,
Integer tab) {
GogirlToken gogirlToken = gogirlTokenService.getByToken(token);
IPage<Message> page = new Page<>(pageNum, pageSize);
StoreTechnician storeTechnician = SessionUtils.getStoreTechnician();
page = messageMapper.selectMyMessage(page, storeTechnician.getId(), type, tab);
page.getRecords().forEach(val -> {
if (val.getType() == 1 || val.getType() == 3)
val.setTakeLeaveEvent(JsonUtilByFsJson.jsonToBean(val.getParamJson(), TakeLeaveEvent.class));
});
return JsonResult.success((Page<Message>) page);
}
@ApiOperation(value = "我的消息管理")
@PostMapping(value = "/technician/message/myMessageManage")
public JsonResult<List<Message>> myMessageManage(@RequestHeader String token,
Integer pageSize,
Integer pageNum,
Integer tab) {
StoreTechnician storeTechnician = SessionUtils.getStoreTechnician();
List<Message> list = messageMapper.myMessageManage(storeTechnician.getId(), tab);
list.forEach(message -> {
Integer unread = messageMapper.selectUnReadCount(message.getTechnicianId(), message.getType());
message.setUnread(unread);
});
return JsonResult.success(list);
}
@ApiOperation(value = "阅读消息")
@GetMapping(value = "/technician/message/readMessage")
public JsonResult<Void> readMessage(@RequestParam Integer id) {
Message message = messageMapper.selectById(id);
message.setIsRead(1);
messageMapper.updateById(message);
return JsonResult.success();
}
}
<?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.gogirl.infrastructure.mapper.xcx.MessageMapper">
<resultMap id="BaseResultMap" type="com.gogirl.domain.xcx.Message">
<id column="id" property="id" jdbcType="INTEGER"/>
<result column="technician_id" property="technicianId" jdbcType="INTEGER"/>
<result column="type" property="type" jdbcType="INTEGER"/>
<result column="time" property="time" jdbcType="TIMESTAMP"/>
<result column="is_read" property="isRead" jdbcType="BIT"/>
<result column="title" property="title" jdbcType="VARCHAR"/>
<result column="message" property="message" jdbcType="VARCHAR"/>
</resultMap>
<sql id="Base_Column_List">
id, technician_id, type, time, is_read, title, message
</sql>
<select id="selectMyMessage" resultMap="BaseResultMap" parameterType="java.lang.Integer">
<select id="selectMyMessage" resultType="com.gogirl.domain.xcx.Message" parameterType="java.lang.Integer">
select
<include refid="Base_Column_List"/>
*
from message
where technician_id = #{technicianId,jdbcType=INTEGER}
<if test="type != null">
and type =#{type}
</if>
<if test="tab != null">
and tab =#{tab}
</if>
order by time desc
</select>
<select id="myMessageManage" resultType="com.gogirl.domain.xcx.Message">
SELECT *
from (SELECT *
FROM message
where true
<if test="tab != null">
and tab =#{tab}
</if>
and technician_id =#{technicianId}
ORDER BY time DESC) t
GROUP BY t.type
</select>
<select id="selectUnReadCount" resultType="java.lang.Integer">
select count(id)
from message
where technician_id = #{technicianId}
and type = #{type}
and is_read = 0
</select>
</mapper>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment