xuhy
2024-09-05 b7fc2805e29fbe44013179204541513893afb7c3
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
package com.ruoyi.web.controller.api;
 
 
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.system.domain.TFoundationConfig;
import com.ruoyi.system.domain.TFoundationPerson;
import com.ruoyi.system.dto.TFoundationPersonDTO;
import com.ruoyi.system.service.TFoundationConfigService;
import com.ruoyi.system.service.TFoundationPersonService;
import com.ruoyi.system.vo.TFoundationPersonVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
 
import java.util.List;
 
/**
 * <p>
 * 基础设置 前端控制器
 * </p>
 *
 * @author xiaochen
 * @since 2024-08-15
 */
@Api(tags = "基础设置")
@RestController
@RequestMapping("/t-foundation-person")
public class TFoundationPersonController {
    private final TFoundationPersonService foundationPersonService;
    private final TFoundationConfigService foundationConfigService;
 
    @Autowired
    public TFoundationPersonController(TFoundationPersonService foundationPersonService, TFoundationConfigService foundationConfigService) {
        this.foundationPersonService = foundationPersonService;
        this.foundationConfigService = foundationConfigService;
    }
    /**
     * 查询基础设置列表
     */
    @ApiOperation( value = "查询基础设置列表")
    @PostMapping(value = "/list")
    public AjaxResult<List<TFoundationPersonVO>> list() {
        return AjaxResult.success(foundationPersonService.getList());
    }
 
    /**
     * 添加基础设置管理
     */
    @ApiOperation( value = "添加基础设置")
    @PostMapping(value = "/add")
    public AjaxResult<Boolean> add(@RequestBody TFoundationPersonDTO dto) {
        foundationPersonService.add(dto);
        return AjaxResult.success();
    }
 
    /**
     * 修改基础设置
     */
    @ApiOperation( value = "修改基础设置")
    @PostMapping(value = "/update")
    public AjaxResult<Boolean> update(@RequestBody TFoundationPersonDTO dto) {
        foundationPersonService.edit(dto);
        return AjaxResult.success();
    }
 
    /**
     * 查看基础设置详情
     */
    @ApiOperation( value = "查看基础设置详情")
    @GetMapping(value = "/getDetailById")
    public AjaxResult<TFoundationPersonVO> getDetailById(@RequestParam("id") Long id) {
        // 查询基础设置
        List<TFoundationConfig> list = foundationConfigService.list(Wrappers.lambdaQuery(TFoundationConfig.class)
                .eq(TFoundationConfig::getPersonId, id));
        TFoundationPerson foundationPerson = foundationPersonService.getById(id);
        TFoundationPersonVO foundationPersonVO = new TFoundationPersonVO();
        BeanUtils.copyProperties(foundationPerson, foundationPersonVO);
        foundationPersonVO.setFoundationConfigs(list);
        return AjaxResult.success(foundationPersonVO);
    }
 
    /**
     * 删除基础设置
     */
    @ApiOperation( value = "删除基础设置")
    @DeleteMapping(value = "/deleteById")
    public AjaxResult<Boolean> deleteById(@RequestParam("id") Long id) {
        foundationConfigService.remove(Wrappers.lambdaQuery(TFoundationConfig.class)
                .eq(TFoundationConfig::getPersonId, id));
        return AjaxResult.success(foundationPersonService.removeById(id));
    }
}