yujian
2020-04-13 817761e47af7ea7bae164d3aa47337a7442f1c14
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package com.yeshi.fanli.service.impl.msg;
 
import java.util.Date;
 
import javax.annotation.Resource;
 
import org.springframework.stereotype.Service;
 
import com.yeshi.fanli.dao.mybatis.msg.MsgExtraMapper;
import com.yeshi.fanli.entity.bus.msg.MsgExtra;
import com.yeshi.fanli.service.inter.msg.MsgExtraService;
 
@Service
public class MsgExtraServiceImpl implements MsgExtraService {
 
    @Resource
    private MsgExtraMapper msgExtraMapper;
 
    @Override
    public void addMsgExtra(long rid, String content, String type){
        MsgExtra msgExtra = new MsgExtra();
        msgExtra.setRid(rid);
        msgExtra.setType(type);
        msgExtra.setContent(content);
        msgExtra.setCreateTime(new Date());
        msgExtraMapper.insertSelective(msgExtra);
    }
 
    @Override
    public void updateMsgExtra(long rid, String content, String type) {
        MsgExtra msgExtra = msgExtraMapper.getByRidAndType(rid, type);
        if (msgExtra == null) {
            addMsgExtra(rid, content, type);
        } else {
            MsgExtra upExtra = new MsgExtra();
            upExtra.setId(msgExtra.getId());
            upExtra.setContent(content);
            msgExtraMapper.updateByPrimaryKeySelective(upExtra);
        }
    }
    
}