SmartUserRelationServiceImpl.java
2.31 KB
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
package com.glsx.smart.service.impl;
import com.glsx.smart.dao.entity.SmartUserRelation;
import com.glsx.smart.dao.mapper.SmartUserRelationMapper;
import com.glsx.smart.exception.BusinessException;
import com.glsx.smart.exception.ResultEnum;
import com.glsx.smart.service.SmartUserRelationService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
/**
* <p>Description:
* <p>Project: chejia-smart
*
* @author wbh
* @date 2021-03-15
*/
@Slf4j
@Service
public class SmartUserRelationServiceImpl implements SmartUserRelationService {
@Resource
private SmartUserRelationMapper smartUserRelationMapper;
@Override
public int deleteByPrimaryKey(Long id) {
return smartUserRelationMapper.deleteByPrimaryKey(id);
}
@Override
public int insertOrUpdate(SmartUserRelation userRelation) {
if (userRelation.getId() == null) {
return smartUserRelationMapper.insertSelective(userRelation);
} else {
SmartUserRelation record = smartUserRelationMapper.selectByPrimaryKey(
userRelation.getId());
if (record != null) {
return smartUserRelationMapper.updateByPrimaryKeySelective(userRelation);
} else {
throw new BusinessException(ResultEnum.ID_NOT_FOUND);
}
}
}
@Override
public Long insertSelective(SmartUserRelation record) {
int i = smartUserRelationMapper.insertSelective(record);
return i > 0 ? record.getId() : 0L;
}
@Override
public SmartUserRelation getSingle(SmartUserRelation record) {
return smartUserRelationMapper.getSingle(record);
}
@Override
public SmartUserRelation selectByPrimaryKey(Long id) {
return smartUserRelationMapper.selectByPrimaryKey(id);
}
@Override
public int updateByPrimaryKeySelective(SmartUserRelation record) {
return smartUserRelationMapper.updateByPrimaryKeySelective(record);
}
@Override
public int updateBatchSelective(List<SmartUserRelation> list) {
return smartUserRelationMapper.updateBatchSelective(list);
}
@Override
public int batchInsert(List<SmartUserRelation> list) {
return smartUserRelationMapper.batchInsert(list);
}
}