You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
tobacco/bs-admin/src/main/java/com/bs/ct/controller/CtTaskInfoController.java

240 lines
8.0 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

package com.bs.ct.controller;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
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.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.bs.common.annotation.Log;
import com.bs.common.core.controller.BaseController;
import com.bs.common.core.domain.AjaxResult;
import com.bs.common.core.page.TableDataInfo;
import com.bs.common.enums.BusinessType;
import com.bs.common.utils.poi.ExcelUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import cn.hutool.core.lang.Validator;
import com.bs.ct.domain.CtTaskInfo;
import com.bs.ct.service.ICtTaskInfoService;
import javax.annotation.Resource;
/**
* 任务信息Controller
*
* @author bs
* @date 2025-02-22
*/
@Api(tags = "任务信息")
@RestController
@RequestMapping("/task/info")
public class CtTaskInfoController extends BaseController {
@Resource
private ICtTaskInfoService ctTaskInfoService;
/**
* 分页查询任务信息列表
*/
@ApiOperation("分页查询任务信息列表")
@GetMapping("/pageList")
public TableDataInfo pageList(CtTaskInfo ctTaskInfo) {
startPage();
LambdaQueryWrapper<CtTaskInfo> queryWrapper = new LambdaQueryWrapper();
condition(queryWrapper,ctTaskInfo);
List<CtTaskInfo> list = ctTaskInfoService.list(queryWrapper);
return getDataTable(list);
}
/**
* 查询任务信息列表
*/
@ApiOperation("查询任务信息列表")
@GetMapping("/list")
public AjaxResult list(CtTaskInfo ctTaskInfo) {
LambdaQueryWrapper<CtTaskInfo> queryWrapper = new LambdaQueryWrapper();
condition(queryWrapper,ctTaskInfo);
List<CtTaskInfo> list = ctTaskInfoService.list(queryWrapper);
return success(list);
}
/**
* 导出任务信息列表
*/
@ApiOperation("导出任务信息列表")
@Log(title = "任务信息导出", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, CtTaskInfo ctTaskInfo) {
LambdaQueryWrapper<CtTaskInfo> queryWrapper = new LambdaQueryWrapper();
condition(queryWrapper,ctTaskInfo);
List<CtTaskInfo> list = ctTaskInfoService.list(queryWrapper);
ExcelUtil<CtTaskInfo> util = new ExcelUtil<CtTaskInfo>(CtTaskInfo. class);
util.exportExcel(response, list, "任务信息数据");
}
/**
* 获取任务信息详细信息
*/
@ApiOperation("获取任务信息详细信息")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id) {
return success(ctTaskInfoService.getById(id));
}
/**
* 新增任务信息
*/
@ApiOperation("新增任务信息")
@Log(title = "任务信息新增", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody CtTaskInfo ctTaskInfo) {
return toAjax(ctTaskInfoService.save(ctTaskInfo));
}
/**
* 修改任务信息
*/
@ApiOperation("修改任务信息")
@Log(title = "任务信息修改", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody CtTaskInfo ctTaskInfo) {
return toAjax(ctTaskInfoService.updateById(ctTaskInfo));
}
/**
* 删除任务信息
*/
@ApiOperation("删除任务信息")
@Log(title = "任务信息删除", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable List<Long> ids) {
return toAjax(ctTaskInfoService.removeBatchByIds(ids));
}
/**
* 条件设置
*/
private void condition (LambdaQueryWrapper<CtTaskInfo> queryWrapper,CtTaskInfo ctTaskInfo){
//id
if(Validator.isNotEmpty(ctTaskInfo.getId())){
queryWrapper.eq(CtTaskInfo::getId,ctTaskInfo.getId());
}
//任务类型
if(Validator.isNotEmpty(ctTaskInfo.getTaskType())){
queryWrapper.eq(CtTaskInfo::getTaskType,ctTaskInfo.getTaskType());
}
//任务标题
if(Validator.isNotEmpty(ctTaskInfo.getTaskTitle())){
queryWrapper.eq(CtTaskInfo::getTaskTitle,ctTaskInfo.getTaskTitle());
}
//任务编号
if(Validator.isNotEmpty(ctTaskInfo.getTaskCode())){
queryWrapper.eq(CtTaskInfo::getTaskCode,ctTaskInfo.getTaskCode());
}
//开始时间
if(Validator.isNotEmpty(ctTaskInfo.getStartDate())){
queryWrapper.eq(CtTaskInfo::getStartDate,ctTaskInfo.getStartDate());
}
//结束时间
if(Validator.isNotEmpty(ctTaskInfo.getEndDate())){
queryWrapper.eq(CtTaskInfo::getEndDate,ctTaskInfo.getEndDate());
}
//任务要求
if(Validator.isNotEmpty(ctTaskInfo.getTaskContent())){
queryWrapper.eq(CtTaskInfo::getTaskContent,ctTaskInfo.getTaskContent());
}
//完成状态
if(Validator.isNotEmpty(ctTaskInfo.getStatus())){
queryWrapper.eq(CtTaskInfo::getStatus,ctTaskInfo.getStatus());
}
//附件id
if(Validator.isNotEmpty(ctTaskInfo.getFileId())){
queryWrapper.eq(CtTaskInfo::getFileId,ctTaskInfo.getFileId());
}
//任务发起人
if(Validator.isNotEmpty(ctTaskInfo.getTaskInitiator())){
queryWrapper.eq(CtTaskInfo::getTaskInitiator,ctTaskInfo.getTaskInitiator());
}
//任务发起单位机构代码
if(Validator.isNotEmpty(ctTaskInfo.getBranchCode())){
queryWrapper.eq(CtTaskInfo::getBranchCode,ctTaskInfo.getBranchCode());
}
//任务发起单位
if(Validator.isNotEmpty(ctTaskInfo.getBranchName())){
queryWrapper.eq(CtTaskInfo::getBranchName,ctTaskInfo.getBranchName());
}
//任务发起部门
if(Validator.isNotEmpty(ctTaskInfo.getDeptId())){
queryWrapper.eq(CtTaskInfo::getDeptId,ctTaskInfo.getDeptId());
}
//任务发布日期
if(Validator.isNotEmpty(ctTaskInfo.getTaskDate())){
queryWrapper.eq(CtTaskInfo::getTaskDate,ctTaskInfo.getTaskDate());
}
//备注
if(Validator.isNotEmpty(ctTaskInfo.getRemarks())){
queryWrapper.eq(CtTaskInfo::getRemarks,ctTaskInfo.getRemarks());
}
//删除标志0代表存在 2代表删除
if(Validator.isNotEmpty(ctTaskInfo.getDelFlag())){
queryWrapper.eq(CtTaskInfo::getDelFlag,ctTaskInfo.getDelFlag());
}
//创建部门
if(Validator.isNotEmpty(ctTaskInfo.getCreateDept())){
queryWrapper.eq(CtTaskInfo::getCreateDept,ctTaskInfo.getCreateDept());
}
//创建人
if(Validator.isNotEmpty(ctTaskInfo.getCreateBy())){
queryWrapper.eq(CtTaskInfo::getCreateBy,ctTaskInfo.getCreateBy());
}
//创建时间
if(Validator.isNotEmpty(ctTaskInfo.getCreateTime())){
queryWrapper.eq(CtTaskInfo::getCreateTime,ctTaskInfo.getCreateTime());
}
//修改人
if(Validator.isNotEmpty(ctTaskInfo.getUpdateBy())){
queryWrapper.eq(CtTaskInfo::getUpdateBy,ctTaskInfo.getUpdateBy());
}
//修改时间
if(Validator.isNotEmpty(ctTaskInfo.getUpdateTime())){
queryWrapper.eq(CtTaskInfo::getUpdateTime,ctTaskInfo.getUpdateTime());
}
//租户ID
if(Validator.isNotEmpty(ctTaskInfo.getTenantId())){
queryWrapper.eq(CtTaskInfo::getTenantId,ctTaskInfo.getTenantId());
}
}
}