【fix sonar】OnlCgformIndexController文件

This commit is contained in:
梁琦涛
2023-03-13 14:52:03 +08:00
parent 5238616e92
commit 3eabfab4b7
@@ -3,9 +3,6 @@ package com.jero.generater.modules.online.cgform.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import java.util.Arrays;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import com.jero.common.api.vo.Result;
import com.jero.common.constant.CommonConstant;
import com.jero.common.system.query.QueryGenerator;
@@ -13,14 +10,11 @@ import com.jero.generater.modules.online.cgform.entity.OnlCgformIndex;
import com.jero.generater.modules.online.cgform.service.IOnlCgformIndexService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import java.util.Arrays;
import java.util.List;
@RestController("onlCgformIndexController")
@RequestMapping({"/online/cgform/index"})
@@ -30,16 +24,15 @@ public class OnlCgformIndexController {
@Autowired
private IOnlCgformIndexService onlCgformIndexService;
public OnlCgformIndexController() {
}
private static final String EN_IS_NULL = "未找到对应实体";
@GetMapping({"/listByHeadId"})
public Result<?> listByHeadId(@RequestParam("headId") String headId) {
QueryWrapper queryWrapper = new QueryWrapper();
public Result<List<OnlCgformIndex>> listByHeadId(@RequestParam("headId") String headId) {
QueryWrapper<OnlCgformIndex> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("cgform_head_id", headId);
queryWrapper.eq("del_flag", CommonConstant.DEL_FLAG_0);
queryWrapper.orderByDesc("create_time");
List cgformIndexList = this.onlCgformIndexService.list(queryWrapper);
List<OnlCgformIndex> cgformIndexList = this.onlCgformIndexService.list(queryWrapper);
return Result.OK(cgformIndexList);
}
@@ -48,9 +41,9 @@ public class OnlCgformIndexController {
@RequestParam(name = "pageNo",defaultValue = "1") Integer pageNo,
@RequestParam(name = "pageSize",defaultValue = "10") Integer pageSize,
HttpServletRequest request) {
QueryWrapper queryWrapper = QueryGenerator.initQueryWrapper(cgformIndex, request.getParameterMap());
Page page = new Page((long)pageNo, (long)pageSize);
IPage cgformIndexPage = this.onlCgformIndexService.page(page, queryWrapper);
QueryWrapper<OnlCgformIndex> queryWrapper = QueryGenerator.initQueryWrapper(cgformIndex, request.getParameterMap());
Page<OnlCgformIndex> page = new Page<>(pageNo, pageSize);
IPage<OnlCgformIndex> cgformIndexPage = this.onlCgformIndexService.page(page, queryWrapper);
return Result.OK(cgformIndexPage);
}
@@ -67,9 +60,9 @@ public class OnlCgformIndexController {
@PutMapping({"/edit"})
public Result<Object> edit(@RequestBody OnlCgformIndex cgformIndex) {
OnlCgformIndex existCgformIndex = (OnlCgformIndex)this.onlCgformIndexService.getById(cgformIndex.getId());
OnlCgformIndex existCgformIndex = this.onlCgformIndexService.getById(cgformIndex.getId());
if (existCgformIndex == null) {
return Result.error("未找到对应实体");
return Result.error(EN_IS_NULL);
} else {
boolean flag = this.onlCgformIndexService.updateById(cgformIndex);
if (flag) {
@@ -82,9 +75,9 @@ public class OnlCgformIndexController {
@DeleteMapping({"/delete"})
public Result<Object> delete(@RequestParam(name = "id",required = true) String id) {
OnlCgformIndex cgformIndex = (OnlCgformIndex)this.onlCgformIndexService.getById(id);
OnlCgformIndex cgformIndex = this.onlCgformIndexService.getById(id);
if (cgformIndex == null) {
return Result.error("未找到对应实体");
return Result.error(EN_IS_NULL);
} else {
boolean flag = this.onlCgformIndexService.removeById(id);
if (flag) {
@@ -107,9 +100,9 @@ public class OnlCgformIndexController {
@GetMapping({"/queryById"})
public Result<OnlCgformIndex> queryById(@RequestParam(name = "id",required = true) String var1) {
OnlCgformIndex cgformIndex = (OnlCgformIndex)this.onlCgformIndexService.getById(var1);
OnlCgformIndex cgformIndex = this.onlCgformIndexService.getById(var1);
if (cgformIndex == null) {
return Result.error("未找到对应实体");
return Result.error(EN_IS_NULL);
} else {
return Result.OK(cgformIndex);
}