diff --git a/jero-boot/jero-boot-base/jero-boot-base-generater/src/main/java/com/jero/generater/modules/online/cgform/controller/OnlCgformIndexController.java b/jero-boot/jero-boot-base/jero-boot-base-generater/src/main/java/com/jero/generater/modules/online/cgform/controller/OnlCgformIndexController.java index de4f4c69..5774ce36 100644 --- a/jero-boot/jero-boot-base/jero-boot-base-generater/src/main/java/com/jero/generater/modules/online/cgform/controller/OnlCgformIndexController.java +++ b/jero-boot/jero-boot-base/jero-boot-base-generater/src/main/java/com/jero/generater/modules/online/cgform/controller/OnlCgformIndexController.java @@ -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> listByHeadId(@RequestParam("headId") String headId) { + QueryWrapper 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 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 queryWrapper = QueryGenerator.initQueryWrapper(cgformIndex, request.getParameterMap()); + Page page = new Page<>(pageNo, pageSize); + IPage cgformIndexPage = this.onlCgformIndexService.page(page, queryWrapper); return Result.OK(cgformIndexPage); } @@ -67,9 +60,9 @@ public class OnlCgformIndexController { @PutMapping({"/edit"}) public Result 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 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 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); }