hjl
2024-07-02 242725f795b4cca830421c07f714a3ec36af0add
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
package com.ruoyi.admin.service.impl;
 
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.admin.entity.Agreement;
import com.ruoyi.admin.mapper.AgreementMapper;
import com.ruoyi.admin.service.AgreementService;
import com.ruoyi.common.core.constant.Constants;
import com.ruoyi.common.core.domain.R;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
 
/**
 * <p>
 * 协议政策、司机操作指导 服务实现类
 * </p>
 *
 * @author hjl
 * @since 2024-05-29
 */
@Service
public class AgreementServiceImpl extends ServiceImpl<AgreementMapper, Agreement> implements AgreementService {
 
    @Override
    public R<Agreement> dataInfo(Integer type) {
        if (!Constants.ZERO.equals(type) && !Constants.ONE.equals(type) && !Constants.TWO.equals(type)) {
            return R.fail("查询类型异常!(0注册协议;1:隐私政策;2:司机操作指导)");
        }
        return R.ok(lambdaQuery().eq(Agreement::getContentType, type).one());
    }
 
    @Override
    @Transactional(rollbackFor = Exception.class)
    public R<String> saveData(Agreement agreement) {
        Integer type = agreement.getContentType();
        if (!Constants.ZERO.equals(type) && !Constants.ONE.equals(type) && !Constants.TWO.equals(type)) {
            return R.fail("保存类型异常!(0注册协议;1:隐私政策;2:司机操作指导)");
        }
        Agreement dbDate = lambdaQuery().eq(Agreement::getContentType, type).one();
        if (null == dbDate) {
            return this.save(agreement) ? R.ok() : R.fail("协议政策保存失败!");
        } else {
            return this.updateById(agreement) ? R.ok() : R.fail("协议政策保存失败!");
        }
    }
}