xuhy
2024-05-28 5470d21a35286abe41fafc25a7deaabefd7c55da
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
package com.stylefeng.guns.modular.system.service.impl;
 
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.stylefeng.guns.modular.system.dao.GDInterfaceMapper;
import com.stylefeng.guns.modular.system.model.GDInterface;
import com.stylefeng.guns.modular.system.service.IGDInterfaceService;
import org.springframework.stereotype.Service;
 
import javax.annotation.Resource;
import java.text.SimpleDateFormat;
import java.util.Date;
 
 
@Service
public class GDInterfaceServiceImpl extends ServiceImpl<GDInterfaceMapper, GDInterface> implements IGDInterfaceService {
 
    @Resource
    private GDInterfaceMapper gdInterfaceMapper;
 
 
 
    @Override
    public void saveData(String name, String explanation) {
        Date date = new Date();
        SimpleDateFormat sdf = new SimpleDateFormat("YYYY-MM-dd");
        GDInterface query = gdInterfaceMapper.query(name, explanation, sdf.format(date));
        if(null == query){
            query = new GDInterface();
            query.setName(name);
            query.setExplanation(explanation);
            query.setTime(sdf.format(date));
            query.setNum(1);
            this.insert(query);
        }else{
            query.setNum(query.getNum() + 1);
            this.updateById(query);
        }
    }
}