package com.pj.project.tb_message;

import java.util.Date;
import java.util.List;
import java.util.Map;

import com.pj.current.satoken.StpAPPUserUtil;
import com.pj.utils.so.SoMap;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.transaction.annotation.Transactional;
import com.pj.utils.sg.*;

import javax.xml.crypto.Data;

/**
 * Service: tb_message -- 通知消息
 *
 * @author lsw
 */
@Service
@Transactional(rollbackFor = Exception.class)
public class TbMessageService extends ServiceImpl<TbMessageMapper, TbMessage> implements IService<TbMessage> {

    /**
     * 底层 Mapper 对象
     */
    @Autowired
    TbMessageMapper tbMessageMapper;

    /**
     * 增
     */
    void add(TbMessage t) {
        t.setCreateTime(new Date());
        save(t);
    }

    /**
     * 删
     */
    void delete(Long id) {
        removeById(id);
    }

    /**
     * 改
     */
    void update(TbMessage t) {
        updateById(t);

    }

    boolean clearRead(Long userId) {
        return tbMessageMapper.clearRead(userId);
    }

    Map<Object, String> getRead(Long userId) {
        return tbMessageMapper.getRead(userId);
    }

    /**
     * 查
     */
    TbMessage getById(Integer id) {
        return super.getById(id);
    }

    /**
     * 查集合 - 根据条件（参数为空时代表忽略指定条件）
     */
    List<TbMessage> getList(SoMap so) {
        return tbMessageMapper.getList(so);
    }
}
