xiaoyong931011
2021-08-25 a9332fa4358687c06f52f5ec887cfdee08eb5e35
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
43
44
45
46
47
48
49
50
51
52
53
54
55
package com.xzx.gc.system.service;
 
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateUtil;
import com.xzx.gc.entity.HomeServiceInfo;
import com.xzx.gc.entity.HomeServiceRef;
import com.xzx.gc.system.mapper.HomeServiceRefMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import tk.mybatis.mapper.entity.Example;
 
import java.util.Date;
import java.util.List;
 
@Service
@Transactional
public class HomeServiceRefService {
 
 
    @Autowired
    private HomeServiceRefMapper homeServiceRefMapper;
 
    /**
     * 添加
     */
    public void addBatch(List<HomeServiceRef> list){
 
        if(CollUtil.isNotEmpty(list)){
            for (HomeServiceRef homeServiceRef : list) {
                homeServiceRef.setCreateTime(DateUtil.now());
                homeServiceRef.setDelFlag(false);
                homeServiceRef.setId(null);
            }
            homeServiceRefMapper.insertList(list);
        }
    }
 
 
    public void deleteByServiceId(Long id) {
        Example example=new Example(HomeServiceRef.class);
        Example.Criteria criteria = example.createCriteria();
        criteria.andEqualTo("serviceId",id);
        HomeServiceRef homeServiceInfo = new HomeServiceRef();
        homeServiceInfo.setDelFlag(true);
        homeServiceRefMapper.updateByExampleSelective(homeServiceInfo,example);
    }
 
    public List<HomeServiceRef> findByServiceId(Long serviceId) {
        HomeServiceRef homeServiceInfo = new HomeServiceRef();
        homeServiceInfo.setDelFlag(false);
        homeServiceInfo.setServiceId(serviceId);
        return homeServiceRefMapper.select(homeServiceInfo);
    }
}