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.SwxContents;
|
import com.gear.swx.service.ISwxContentsService;
|
import com.gear.common.utils.poi.ExcelUtil;
|
|
/**
|
* 内容管理Controller
|
*
|
* @author czx
|
* @date 2023-11-25
|
*/
|
@RestController
|
@RequestMapping("/swx/contents")
|
public class SwxContentsController extends BaseController
|
{
|
@Autowired
|
private ISwxContentsService swxContentsService;
|
|
/**
|
* 查询内容管理列表
|
*/
|
@PreAuthorize("@ss.hasPermi('swx:contents:list')")
|
@GetMapping("/list")
|
public Result<IPage<SwxContents>> list(SwxContents swxContents,
|
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
|
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize){
|
QueryWrapper<SwxContents> queryWrapper = WhereBuilder.build(swxContents);
|
queryWrapper.lambda().orderByDesc(SwxContents::getCreateTime);
|
Page<SwxContents> page = new Page<SwxContents>(pageNo, pageSize);
|
IPage<SwxContents> pageList = swxContentsService.page(page, queryWrapper);
|
return Result.OK(pageList);
|
}
|
|
/**
|
* 导出内容管理列表
|
*/
|
@PreAuthorize("@ss.hasPermi('swx:contents:export')")
|
@Log(title = "内容管理", businessType = BusinessType.EXPORT)
|
@PostMapping("/export")
|
public void export(HttpServletResponse response, SwxContents swxContents){
|
QueryWrapper<SwxContents> queryWrapper = WhereBuilder.build(swxContents);
|
List<SwxContents> list = swxContentsService.list(queryWrapper);
|
ExcelUtil<SwxContents> util = new ExcelUtil<SwxContents>(SwxContents.class);
|
util.exportExcel(response, list, "内容管理数据");
|
}
|
|
/**
|
* 获取内容管理详细信息
|
*/
|
@PreAuthorize("@ss.hasPermi('swx:contents:query')")
|
@GetMapping(value = "/{id}")
|
public Result<SwxContents> getInfo(@PathVariable("id") String id){
|
SwxContents swxContents = swxContentsService.getById(id);
|
if(swxContents==null) {
|
return Result.error("未找到对应数据");
|
}
|
return Result.OK(swxContents);
|
}
|
|
/**
|
* 新增内容管理
|
*/
|
@PreAuthorize("@ss.hasPermi('swx:contents:add')")
|
@Log(title = "内容管理", businessType = BusinessType.INSERT)
|
@PostMapping
|
public Result<String> add(@RequestBody SwxContents swxContents){
|
swxContentsService.save(swxContents);
|
return Result.ok("添加成功!");
|
}
|
|
/**
|
* 修改内容管理
|
*/
|
@PreAuthorize("@ss.hasPermi('swx:contents:edit')")
|
@Log(title = "内容管理", businessType = BusinessType.UPDATE)
|
@PutMapping
|
public Result<String> edit(@RequestBody SwxContents swxContents){
|
swxContentsService.updateById(swxContents);
|
return Result.ok("编辑成功!");
|
}
|
|
/**
|
* 删除内容管理
|
*/
|
@PreAuthorize("@ss.hasPermi('swx:contents:remove')")
|
@Log(title = "内容管理", businessType = BusinessType.DELETE)
|
@DeleteMapping("/{ids}")
|
public Result<String> remove(@PathVariable List<String> ids){
|
swxContentsService.removeBatchByIds(ids);
|
return Result.ok("删除成功!");
|
}
|
}
|