huliguo
2 天以前 5d7b65670282a4fad015e37d567cfa171b162052
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
package com.ruoyi.web.controller.errand;
 
 
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.errand.domain.Agreement;
import com.ruoyi.errand.object.dto.app.AgreementDTO;
import com.ruoyi.errand.service.AgreementService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
 
@RestController
@RequestMapping(value = "/app/agreement")
@Api(value = "协议", tags = "协议操作控制器")
@Slf4j
public class AgreementController {
 
    @Autowired
    private AgreementService agreementService;
 
    /**
     * 协议 类型(1=用户协议,2=隐私协议,3=下单须知,4=注销协议,5=首页介绍,6=快递代拿下单说明,7=商品代买下单说明)
     */
    @GetMapping("/getAgreementByType")
    @ApiOperation(value = "根据类型获取不同协议",tags = "app用户端-协议")
    public R<Agreement> getAgreementByType(@RequestParam(value = "type") Integer type) {
        return R.ok(agreementService.getAgreementByType(type));
    }
 
    @PostMapping("/addAgreement")
    @PreAuthorize("@ss.hasPermi('system:agreement:list')")
    @ApiOperation(value = "协议管理-添加", tags = {"管理后台-系统管理"})
    public R<Void> addAgreement(@RequestBody AgreementDTO agreementDTO){
        //先删除启动页的数据
        Agreement one = agreementService.getOne(new LambdaQueryWrapper<Agreement>().eq(Agreement::getType, agreementDTO.getType()));
        if (one!=null){
            agreementService.removeById(one);
        }
        Agreement agreement = new Agreement();
        BeanUtils.copyProperties(agreementDTO,agreement);
        agreementService.save(agreement);
        return R.ok();
    }
 
 
}