package com.ruoyi.admin.controller;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.ruoyi.admin.entity.Problem;
|
import com.ruoyi.admin.service.ProblemService;
|
import com.ruoyi.common.core.domain.R;
|
import com.ruoyi.common.security.annotation.RequiresPermissions;
|
import io.swagger.annotations.Api;
|
import io.swagger.annotations.ApiImplicitParam;
|
import io.swagger.annotations.ApiImplicitParams;
|
import io.swagger.annotations.ApiOperation;
|
import org.springframework.web.bind.annotation.*;
|
|
import javax.annotation.Resource;
|
import java.util.Arrays;
|
import java.util.List;
|
import java.util.stream.Collectors;
|
|
/**
|
* <p>
|
* 常见问题管理 前端控制器
|
* </p>
|
*
|
* @author hjl
|
* @since 2024-05-29
|
*/
|
@RestController
|
@RequestMapping("/problem")
|
@Api(tags = {"后台-系统设置-常见问题管理"})
|
public class ProblemController {
|
|
@Resource
|
private ProblemService problemService;
|
|
/**
|
* 常见问题分页列表
|
*
|
* @param pageNum 页码
|
* @param pageSize 每页显示条数
|
*/
|
@RequiresPermissions("system_problem")
|
@ApiOperation(value = "常见问题分页查询列表", tags = {"后台-系统设置-常见问题管理"})
|
@GetMapping(value = "/page")
|
@ApiImplicitParams({
|
@ApiImplicitParam(value = "页码", name = "pageNum", dataType = "Integer", required = true),
|
@ApiImplicitParam(value = "每页条数", name = "pageSize", dataType = "Integer", required = true)
|
})
|
public R<IPage<Problem>> queryPageList(@RequestParam(name = "pageNum", defaultValue = "1") Integer pageNum,
|
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
|
return R.ok(problemService.lambdaQuery().eq(Problem::getIsDelete, 0)
|
.orderByDesc(Problem::getCreateTime).page(Page.of(pageNum, pageSize)));
|
}
|
|
/**
|
* 常见问题查询列表
|
*/
|
@GetMapping(value = "/problemList")
|
public R<List<Problem>> problemList() {
|
return R.ok(problemService.lambdaQuery().eq(Problem::getIsDelete, 0)
|
.orderByAsc(Problem::getSort).list());
|
}
|
|
/**
|
* 常见问题详情
|
*
|
* @param id 常见问题id
|
*/
|
@RequiresPermissions("system_problem")
|
@ApiOperation(value = "常见问题详情", tags = {"后台-系统设置-常见问题管理"})
|
@GetMapping(value = "/detail")
|
@ApiImplicitParams({
|
@ApiImplicitParam(value = "常见问题id", name = "id", dataType = "Integer", required = true)
|
})
|
public R<Problem> detail(@RequestParam Integer id) {
|
return R.ok(problemService.getById(id));
|
}
|
|
/**
|
* 新增常见问题
|
*
|
* @param problem 常见问题信息
|
*/
|
@RequiresPermissions("system_problem")
|
@ApiOperation(value = "新增常见问题", tags = {"后台-系统设置-常见问题管理"})
|
@PostMapping(value = "/save")
|
public R<String> save(@RequestBody Problem problem) {
|
return problemService.save(problem) ? R.ok() : R.fail();
|
}
|
|
/**
|
* 修改常见问题
|
*
|
* @param problem 常见问题信息
|
*/
|
@RequiresPermissions("system_problem")
|
@ApiOperation(value = "修改常见问题", tags = {"后台-系统设置-常见问题管理"})
|
@PostMapping(value = "/update")
|
public R<String> update(@RequestBody Problem problem) {
|
return problemService.updateById(problem) ? R.ok() : R.fail();
|
}
|
|
/**
|
* 根据id批量删除常见问题
|
*
|
* @param ids 常见问题多条id拼接
|
*/
|
@RequiresPermissions("system_problem")
|
@ApiOperation(value = "批量删除常见问题", tags = {"后台-系统设置-常见问题管理"})
|
@GetMapping(value = "/batchDelete")
|
@ApiImplicitParams({
|
@ApiImplicitParam(value = "多个id ',' 拼接", name = "ids", dataType = "String", required = true)
|
})
|
public R<String> batchDelete(@RequestParam String ids) {
|
List<String> idList = Arrays.stream(ids.split(",")).collect(Collectors.toList());
|
List<Problem> list = problemService.lambdaQuery().in(Problem::getId, idList).list();
|
list.forEach(data -> data.setIsDelete(1));
|
return problemService.updateBatchById(list) ? R.ok() : R.fail();
|
}
|
|
}
|