package cn.stylefeng.guns.modular.business.controller;
|
|
import cn.hutool.core.collection.ListUtil;
|
import cn.hutool.core.util.StrUtil;
|
import cn.stylefeng.guns.modular.business.entity.MentalTestClass;
|
import cn.stylefeng.guns.modular.business.service.IMentalTestClassService;
|
import cn.stylefeng.roses.kernel.db.api.factory.PageFactory;
|
import cn.stylefeng.roses.kernel.db.api.factory.PageResultFactory;
|
import cn.stylefeng.roses.kernel.db.api.pojo.page.PageResult;
|
import cn.stylefeng.roses.kernel.rule.annotation.BusinessLog;
|
import cn.stylefeng.roses.kernel.rule.enums.ResBizTypeEnum;
|
import cn.stylefeng.roses.kernel.rule.pojo.response.ErrorResponseData;
|
import cn.stylefeng.roses.kernel.rule.pojo.response.ResponseData;
|
import cn.stylefeng.roses.kernel.rule.pojo.response.SuccessResponseData;
|
import cn.stylefeng.roses.kernel.scanner.api.annotation.ApiResource;
|
import cn.stylefeng.roses.kernel.scanner.api.annotation.GetResource;
|
import cn.stylefeng.roses.kernel.scanner.api.annotation.PostResource;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
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.List;
|
|
/**
|
* 心理测试分类管理
|
* @author guo
|
*/
|
@RestController
|
@Api(tags = "心理测试分类管理")
|
@ApiResource(name = "心理测试分类管理", resBizType = ResBizTypeEnum.BUSINESS)
|
@RequestMapping("/business")
|
public class MentalTestClassController {
|
|
@Resource
|
private IMentalTestClassService mentalTestClassService;
|
|
/**
|
* 添加心理测试分类 *
|
*/
|
@ApiOperation("添加心理测试分类")
|
@PostResource(name = "添加心理测试分类", path = "/mentalTestClass/add")
|
@BusinessLog
|
public ResponseData<?> add(@RequestBody MentalTestClass mentalTestClass) {
|
this.mentalTestClassService.save(mentalTestClass);
|
return new SuccessResponseData<>();
|
}
|
|
/**
|
* 删除心理测试分类 *
|
*/
|
@ApiOperation("删除心理测试分类")
|
@PostResource(name = "删除心理测试分类", path = "/mentalTestClass/delete")
|
@BusinessLog
|
public ResponseData<?> delete(@RequestParam String ids) {
|
if (StrUtil.isBlank(ids)){
|
return new ErrorResponseData<>("500","id不能为空");
|
}
|
LambdaUpdateWrapper<MentalTestClass> lambdaUpdateWrapper = new LambdaUpdateWrapper<MentalTestClass>().set(MentalTestClass::getIsDelete,true);
|
lambdaUpdateWrapper.in(MentalTestClass::getId, ListUtil.toList(ids.split(",")));
|
this.mentalTestClassService.update(lambdaUpdateWrapper);
|
return new SuccessResponseData<>();
|
}
|
|
/**
|
* 修改心理测试分类 *
|
*/
|
@ApiOperation("修改心理测试分类")
|
@PostResource(name = "修改心理测试分类", path = "/mentalTestClass/edit")
|
@BusinessLog
|
public ResponseData<?> edit(@RequestBody MentalTestClass mentalTestClass) {
|
this.mentalTestClassService.updateById(mentalTestClass);
|
return new SuccessResponseData<>();
|
}
|
|
/**
|
* 修改心理测试分类状态 *
|
*/
|
@ApiOperation("修改心理测试分类状态")
|
@PostResource(name = "修改心理测试分类状态", path = "/mentalTestClass/updateStatus")
|
@BusinessLog
|
public ResponseData<?> updateStatus(String ids, Integer status) {
|
if (StrUtil.isBlank(ids)){
|
return new ErrorResponseData<>("500","id不能为空");
|
}
|
LambdaUpdateWrapper<MentalTestClass> lambdaUpdateWrapper = new LambdaUpdateWrapper<MentalTestClass>().set(MentalTestClass::getStatusFlag,status);
|
lambdaUpdateWrapper.in(MentalTestClass::getId, ListUtil.toList(ids.split(",")));
|
this.mentalTestClassService.update(lambdaUpdateWrapper);
|
return new SuccessResponseData<>();
|
}
|
|
/**
|
* 获取心理测试分类详情
|
*/
|
@ApiOperation("获取心理测试分类详情")
|
@GetResource(name = "获取心理测试分类详情", path = "/mentalTestClass/detail/{id}", requiredPermission = false)
|
public ResponseData<MentalTestClass> detail(@PathVariable("id") Long id) {
|
MentalTestClass mentalTestClass = this.mentalTestClassService.getById(id);
|
return new SuccessResponseData<>(mentalTestClass);
|
}
|
|
/**
|
* 获取心理测试分类列表
|
*
|
*/
|
@ApiOperation("获取心理测试分类列表")
|
@GetResource(name = "获取心理测试分类列表", path = "/mentalTestClass/list", requiredPermission = false)
|
@ApiImplicitParams({
|
@ApiImplicitParam(name = "name", value = "分类名称", dataTypeClass = String.class, paramType = "query"),
|
})
|
public ResponseData<List<MentalTestClass>> list(String name) {
|
LambdaQueryWrapper<MentalTestClass> lambdaQueryWrapper = new LambdaQueryWrapper<MentalTestClass>()
|
.like(StrUtil.isNotBlank(name), MentalTestClass::getName, name)
|
.eq(MentalTestClass::getIsDelete, false)
|
.orderByDesc(MentalTestClass::getId);
|
return new SuccessResponseData<>(mentalTestClassService.list(lambdaQueryWrapper));
|
}
|
|
/**
|
* 获取心理测试分类列表(分页)
|
*/
|
@ApiOperation("获取心理测试分类列表(分页)")
|
@GetResource(name = "获取心理测试分类列表(分页)", path = "/mentalTestClass/page", requiredPermission = false)
|
@ApiImplicitParams({
|
@ApiImplicitParam(name = "pageNo", value = "分页:第几页(从1开始)", dataTypeClass = Integer.class, paramType = "query"),
|
@ApiImplicitParam(name = "pageSize", value = "分页:每页大小(默认20)", dataTypeClass = Integer.class, paramType = "query"),
|
@ApiImplicitParam(name = "name", value = "分类名称", dataTypeClass = String.class, paramType = "query"),
|
})
|
public ResponseData<PageResult<MentalTestClass>> page(Integer pageNo, Integer pageSize, String name) {
|
LambdaQueryWrapper<MentalTestClass> lambdaQueryWrapper = new LambdaQueryWrapper<MentalTestClass>()
|
.like(StrUtil.isNotBlank(name), MentalTestClass::getName, name)
|
.eq(MentalTestClass::getIsDelete, false)
|
.orderByDesc(MentalTestClass::getId);
|
Page<MentalTestClass> page = this.mentalTestClassService.page(PageFactory.page(pageNo, pageSize), lambdaQueryWrapper);
|
return new SuccessResponseData<>(PageResultFactory.createPageResult(page));
|
}
|
|
}
|