【fix sonar】QuartzJobController.java、 ImportExcelUtil.java 文件
This commit is contained in:
+2
-1
@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
|||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import com.jero.common.api.vo.Result;
|
import com.jero.common.api.vo.Result;
|
||||||
import com.jero.common.constant.CommonConstant;
|
import com.jero.common.constant.CommonConstant;
|
||||||
|
import org.apache.poi.ss.formula.functions.T;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@@ -16,7 +17,7 @@ import java.util.List;
|
|||||||
@Slf4j
|
@Slf4j
|
||||||
public class ImportExcelUtil {
|
public class ImportExcelUtil {
|
||||||
|
|
||||||
public static Result<?> imporReturnRes(int errorLines,int successLines,List<String> errorMessage) throws IOException {
|
public static Result<T> imporReturnRes(int errorLines, int successLines, List<String> errorMessage) throws IOException {
|
||||||
if (errorLines == 0) {
|
if (errorLines == 0) {
|
||||||
return Result.OK("共" + successLines + "行数据全部导入成功!");
|
return Result.OK("共" + successLines + "行数据全部导入成功!");
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
+19
-18
@@ -9,6 +9,7 @@ import java.util.Map;
|
|||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
|
import org.apache.poi.ss.formula.functions.T;
|
||||||
import org.apache.shiro.authz.annotation.RequiresRoles;
|
import org.apache.shiro.authz.annotation.RequiresRoles;
|
||||||
import com.jero.common.api.vo.Result;
|
import com.jero.common.api.vo.Result;
|
||||||
import com.jero.common.constant.CommonConstant;
|
import com.jero.common.constant.CommonConstant;
|
||||||
@@ -63,7 +64,7 @@ public class QuartzJobController {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 分页列表查询
|
* 分页列表查询
|
||||||
*
|
*
|
||||||
* @param quartzJob
|
* @param quartzJob
|
||||||
* @param pageNo
|
* @param pageNo
|
||||||
* @param pageSize
|
* @param pageSize
|
||||||
@@ -71,8 +72,8 @@ public class QuartzJobController {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@RequestMapping(value = "/page", method = RequestMethod.GET)
|
@RequestMapping(value = "/page", method = RequestMethod.GET)
|
||||||
public Result<?> queryPageList(QuartzJob quartzJob, @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
|
public Result<IPage<QuartzJob>> queryPageList(QuartzJob quartzJob, @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
|
||||||
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize, HttpServletRequest req) {
|
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize, HttpServletRequest req) {
|
||||||
QueryWrapper<QuartzJob> queryWrapper = QueryGenerator.initQueryWrapper(quartzJob, req.getParameterMap());
|
QueryWrapper<QuartzJob> queryWrapper = QueryGenerator.initQueryWrapper(quartzJob, req.getParameterMap());
|
||||||
Page<QuartzJob> page = new Page<QuartzJob>(pageNo, pageSize);
|
Page<QuartzJob> page = new Page<QuartzJob>(pageNo, pageSize);
|
||||||
IPage<QuartzJob> pageList = quartzJobService.page(page, queryWrapper);
|
IPage<QuartzJob> pageList = quartzJobService.page(page, queryWrapper);
|
||||||
@@ -82,26 +83,26 @@ public class QuartzJobController {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 添加定时任务
|
* 添加定时任务
|
||||||
*
|
*
|
||||||
* @param quartzJob
|
* @param quartzJob
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
//@RequiresRoles("admin")
|
//@RequiresRoles("admin")
|
||||||
@RequestMapping(value = "/add", method = RequestMethod.POST)
|
@RequestMapping(value = "/add", method = RequestMethod.POST)
|
||||||
public Result<?> add(@RequestBody QuartzJob quartzJob) {
|
public Result<T> add(@RequestBody QuartzJob quartzJob) {
|
||||||
quartzJobService.saveAndScheduleJob(quartzJob);
|
quartzJobService.saveAndScheduleJob(quartzJob);
|
||||||
return Result.OK("创建定时任务成功");
|
return Result.OK("创建定时任务成功");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新定时任务
|
* 更新定时任务
|
||||||
*
|
*
|
||||||
* @param quartzJob
|
* @param quartzJob
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
//@RequiresRoles("admin")
|
//@RequiresRoles("admin")
|
||||||
@RequestMapping(value = "/edit", method = RequestMethod.PUT)
|
@RequestMapping(value = "/edit", method = RequestMethod.PUT)
|
||||||
public Result<?> eidt(@RequestBody QuartzJob quartzJob) {
|
public Result<T> eidt(@RequestBody QuartzJob quartzJob) {
|
||||||
try {
|
try {
|
||||||
quartzJobService.editAndScheduleJob(quartzJob);
|
quartzJobService.editAndScheduleJob(quartzJob);
|
||||||
} catch (SchedulerException e) {
|
} catch (SchedulerException e) {
|
||||||
@@ -113,13 +114,13 @@ public class QuartzJobController {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 通过id删除
|
* 通过id删除
|
||||||
*
|
*
|
||||||
* @param id
|
* @param id
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
//@RequiresRoles("admin")
|
//@RequiresRoles("admin")
|
||||||
@RequestMapping(value = "/delete", method = RequestMethod.DELETE)
|
@RequestMapping(value = "/delete", method = RequestMethod.DELETE)
|
||||||
public Result<?> delete(@RequestParam(name = "id", required = true) String id) {
|
public Result<T> delete(@RequestParam(name = "id", required = true) String id) {
|
||||||
QuartzJob quartzJob = quartzJobService.getById(id);
|
QuartzJob quartzJob = quartzJobService.getById(id);
|
||||||
if (quartzJob == null) {
|
if (quartzJob == null) {
|
||||||
return Result.error("未找到对应实体");
|
return Result.error("未找到对应实体");
|
||||||
@@ -131,13 +132,13 @@ public class QuartzJobController {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 批量删除
|
* 批量删除
|
||||||
*
|
*
|
||||||
* @param ids
|
* @param ids
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
//@RequiresRoles("admin")
|
//@RequiresRoles("admin")
|
||||||
@RequestMapping(value = "/deleteBatch", method = RequestMethod.DELETE)
|
@RequestMapping(value = "/deleteBatch", method = RequestMethod.DELETE)
|
||||||
public Result<?> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
|
public Result<T> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
|
||||||
if (ids == null || "".equals(ids.trim())) {
|
if (ids == null || "".equals(ids.trim())) {
|
||||||
return Result.error("参数不识别!");
|
return Result.error("参数不识别!");
|
||||||
}
|
}
|
||||||
@@ -150,7 +151,7 @@ public class QuartzJobController {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 暂停定时任务
|
* 暂停定时任务
|
||||||
*
|
*
|
||||||
* @param id
|
* @param id
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@@ -186,19 +187,19 @@ public class QuartzJobController {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 通过id查询
|
* 通过id查询
|
||||||
*
|
*
|
||||||
* @param id
|
* @param id
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@RequestMapping(value = "/queryById", method = RequestMethod.GET)
|
@RequestMapping(value = "/queryById", method = RequestMethod.GET)
|
||||||
public Result<?> queryById(@RequestParam(name = "id", required = true) String id) {
|
public Result<QuartzJob> queryById(@RequestParam(name = "id", required = true) String id) {
|
||||||
QuartzJob quartzJob = quartzJobService.getById(id);
|
QuartzJob quartzJob = quartzJobService.getById(id);
|
||||||
return Result.OK(quartzJob);
|
return Result.OK(quartzJob);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 导出excel
|
* 导出excel
|
||||||
*
|
*
|
||||||
* @param request
|
* @param request
|
||||||
* @param quartzJob
|
* @param quartzJob
|
||||||
*/
|
*/
|
||||||
@@ -219,13 +220,13 @@ public class QuartzJobController {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 通过excel导入数据
|
* 通过excel导入数据
|
||||||
*
|
*
|
||||||
* @param request
|
* @param request
|
||||||
* @param response
|
* @param response
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
|
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
|
||||||
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) throws IOException {
|
public Result<T> importExcel(HttpServletRequest request, HttpServletResponse response) throws IOException {
|
||||||
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
|
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
|
||||||
Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
|
Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
|
||||||
// 错误信息
|
// 错误信息
|
||||||
@@ -263,7 +264,7 @@ public class QuartzJobController {
|
|||||||
*/
|
*/
|
||||||
//@RequiresRoles("admin")
|
//@RequiresRoles("admin")
|
||||||
@GetMapping("/execute")
|
@GetMapping("/execute")
|
||||||
public Result<?> execute(@RequestParam(name = "id", required = true) String id) {
|
public Result<T> execute(@RequestParam(name = "id", required = true) String id) {
|
||||||
QuartzJob quartzJob = quartzJobService.getById(id);
|
QuartzJob quartzJob = quartzJobService.getById(id);
|
||||||
if (quartzJob == null) {
|
if (quartzJob == null) {
|
||||||
return Result.error("未找到对应实体");
|
return Result.error("未找到对应实体");
|
||||||
|
|||||||
Reference in New Issue
Block a user