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.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
|
*/
|
@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));
|
}
|
}
|