package com.gear.admin.controller.swx;
|
|
import java.util.List;
|
import javax.servlet.http.HttpServletResponse;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.gear.common.builder.WhereBuilder;
|
import com.gear.common.vo.Result;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.web.bind.annotation.*;
|
import com.gear.common.annotation.Log;
|
import com.gear.common.core.controller.BaseController;
|
import com.gear.common.enums.BusinessType;
|
import com.gear.swx.domain.SwxSettings;
|
import com.gear.swx.service.ISwxSettingsService;
|
import com.gear.common.utils.poi.ExcelUtil;
|
|
/**
|
* 系统参数Controller
|
*
|
* @author czx
|
* @date 2023-11-18
|
*/
|
@RestController
|
@RequestMapping("/swx/settings")
|
public class SwxSettingsController extends BaseController
|
{
|
@Autowired
|
private ISwxSettingsService swxSettingsService;
|
|
/**
|
* 查询系统参数列表
|
*/
|
@PreAuthorize("@ss.hasPermi('swx:settings:list')")
|
@GetMapping("/listAllByType")
|
public Result<List<SwxSettings>> list(@RequestParam("type") Integer type){
|
QueryWrapper<SwxSettings> queryWrapper = new QueryWrapper<>();
|
queryWrapper.lambda().eq(SwxSettings::getType,type);
|
List<SwxSettings> result = swxSettingsService.list(queryWrapper);
|
return Result.OK(result);
|
}
|
|
/**
|
* 导出系统参数列表
|
*/
|
@PreAuthorize("@ss.hasPermi('swx:settings:export')")
|
@Log(title = "系统参数", businessType = BusinessType.EXPORT)
|
@PostMapping("/export")
|
public void export(HttpServletResponse response, SwxSettings swxSettings){
|
QueryWrapper<SwxSettings> queryWrapper = WhereBuilder.build(swxSettings);
|
List<SwxSettings> list = swxSettingsService.list(queryWrapper);
|
ExcelUtil<SwxSettings> util = new ExcelUtil<SwxSettings>(SwxSettings.class);
|
util.exportExcel(response, list, "系统参数数据");
|
}
|
|
/**
|
* 获取系统参数详细信息
|
*/
|
@PreAuthorize("@ss.hasPermi('swx:settings:query')")
|
@GetMapping(value = "/{id}")
|
public Result<SwxSettings> getInfo(@PathVariable("id") String id){
|
SwxSettings swxSettings = swxSettingsService.getById(id);
|
if(swxSettings==null) {
|
return Result.error("未找到对应数据");
|
}
|
return Result.OK(swxSettings);
|
}
|
|
/**
|
* 新增系统参数
|
*/
|
@PreAuthorize("@ss.hasPermi('swx:settings:add')")
|
@Log(title = "系统参数", businessType = BusinessType.INSERT)
|
@PostMapping
|
public Result<String> add(@RequestBody SwxSettings swxSettings){
|
swxSettingsService.save(swxSettings);
|
return Result.ok("添加成功!");
|
}
|
|
/**
|
* 修改系统参数
|
*/
|
@PreAuthorize("@ss.hasPermi('swx:settings:edit')")
|
@Log(title = "系统参数", businessType = BusinessType.UPDATE)
|
@PutMapping
|
public Result<String> edit(@RequestBody SwxSettings swxSettings){
|
swxSettingsService.updateById(swxSettings);
|
return Result.ok("编辑成功!");
|
}
|
|
/**
|
* 删除系统参数
|
*/
|
@PreAuthorize("@ss.hasPermi('swx:settings:remove')")
|
@Log(title = "系统参数", businessType = BusinessType.DELETE)
|
@DeleteMapping("/{ids}")
|
public Result<String> remove(@PathVariable List<String> ids){
|
swxSettingsService.removeBatchByIds(ids);
|
return Result.ok("删除成功!");
|
}
|
}
|