228 lines
7.3 KiB
Java
228 lines
7.3 KiB
Java
package com.muyu.controller;
|
||
|
||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||
import com.muyu.common.core.domain.Result;
|
||
import com.muyu.common.core.utils.poi.ExcelUtil;
|
||
import com.muyu.common.core.web.controller.BaseController;
|
||
import com.muyu.context.GenerateConstant;
|
||
import com.muyu.domain.EngineMaintenance;
|
||
import com.muyu.domain.EngineVersion;
|
||
import com.muyu.domain.constants.PageResult;
|
||
import com.muyu.req.EngineMaintenanceQueryReq;
|
||
import com.muyu.req.EngineVersionListResp;
|
||
import com.muyu.service.EngIneService;
|
||
import com.muyu.service.EngineVersionService;
|
||
import io.swagger.v3.core.util.Json;
|
||
import jakarta.servlet.http.HttpServletResponse;
|
||
import org.springframework.beans.factory.annotation.Autowired;
|
||
import org.springframework.stereotype.Component;
|
||
import org.springframework.web.bind.annotation.*;
|
||
|
||
import java.util.List;
|
||
|
||
/**
|
||
* @Author:qdm
|
||
* @Package:com.muyu.controller
|
||
* @Project:cloud-etl-engine
|
||
* @name:EngIneController
|
||
* @Date:2024/8/22 15:36
|
||
*/
|
||
@Component
|
||
@RestController
|
||
@RequestMapping("/engine")
|
||
public class EngIneController extends BaseController {
|
||
|
||
@Autowired
|
||
EngIneService engIneService;
|
||
|
||
@Autowired
|
||
EngineVersionService engineVersionService;
|
||
|
||
/**
|
||
* 规则列表+条件查询+分页
|
||
*
|
||
* @param engineMaintenanceQueryReq
|
||
* @return
|
||
*/
|
||
@PostMapping("/getMaintenanceList")
|
||
public Result<PageResult<EngineMaintenance>> getMaintenanceList(@RequestBody EngineMaintenanceQueryReq engineMaintenanceQueryReq) {
|
||
//使用mabits-plus-plus的查询方法
|
||
// engineMaintenanceQueryReq.setPageNum(engineMaintenanceQueryReq.getPageNum());
|
||
// engineMaintenanceQueryReq.setPageSize(engineMaintenanceQueryReq.getPageSize());
|
||
return engIneService.getMaintenanceList(engineMaintenanceQueryReq);
|
||
}
|
||
|
||
/**
|
||
* 删除规则信息
|
||
*
|
||
* @param id
|
||
* @return
|
||
*/
|
||
@PostMapping("/delete/{id}")
|
||
public Integer remove(@PathVariable Long id) {
|
||
//使用mabits-plusplus的删除方法
|
||
// engIneService.delete(id);
|
||
return engIneService.deletes(id);
|
||
}
|
||
|
||
/**
|
||
* 修改规则信息
|
||
*
|
||
* @param engineMaintenance
|
||
* @return
|
||
*/
|
||
@PostMapping("/update")
|
||
public Result<EngineMaintenance> update(@RequestBody EngineMaintenance engineMaintenance) {
|
||
Result<EngineMaintenance> engineMaintenanceResult = engIneService.updateMsg(engineMaintenance);
|
||
return Result.success(engineMaintenanceResult.getData());
|
||
|
||
}
|
||
|
||
/**
|
||
* 添加规则信息
|
||
*
|
||
* @param engineMaintenance
|
||
* @return
|
||
*/
|
||
@PostMapping("/insert")
|
||
public Boolean insert(@RequestBody EngineMaintenance engineMaintenance) {
|
||
//使用mabits-plus-plus的添加方法
|
||
Boolean b = engIneService.save(engineMaintenance);
|
||
return b;
|
||
// return engIneService.add(engineMaintenance);
|
||
}
|
||
|
||
/**
|
||
* 查询规则引擎版本列表
|
||
*/
|
||
@PutMapping("/getRuleEngineInfo/{id}")
|
||
public Result getRuleEngineInfo(@PathVariable(name = "id") Long id) {
|
||
//使用mabits-plus-plus的查询方法
|
||
// engIneService.getRuleEngineInfo(id);
|
||
EngineVersionListResp engineConfigListResp = engIneService.getRuleEngineInfo(id);
|
||
return Result.success(engineConfigListResp);
|
||
}
|
||
|
||
/**
|
||
* 导出
|
||
*/
|
||
@PostMapping("/export")
|
||
public void export(HttpServletResponse httpServletResponse, EngineMaintenance engineMaintenance) {
|
||
List<EngineMaintenance> list = engIneService.list();
|
||
ExcelUtil<EngineMaintenance> engineMaintenanceExcelUtil = new ExcelUtil<>(EngineMaintenance.class);
|
||
engineMaintenanceExcelUtil.exportExcel(httpServletResponse, list, "规则引擎版本");
|
||
}
|
||
|
||
// /**
|
||
// * 通过引擎维护编号禁用引擎
|
||
// */
|
||
// @PostMapping("/forbiddenEngine/{id}")
|
||
// public Result forbiddenEngine(@PathVariable Integer id) {
|
||
// //使用mybatis-plus的禁用方法
|
||
//// engIneService.forbiddenEngine(id);
|
||
// return engIneService.forbiddenEngine(id);
|
||
// }
|
||
//
|
||
// /**
|
||
// * 通过引擎维护编号开启引擎
|
||
// */
|
||
// @PostMapping("/onEngine/{id}")
|
||
// public Result onEngine(@PathVariable Integer id) {
|
||
// //使用mybatis-plus的开启方法
|
||
//// engIneService.onEngine(id);
|
||
// engIneService.onEngine(id);
|
||
// return Result.success();
|
||
// }
|
||
|
||
/**
|
||
* 通过引擎维护编号关闭引擎
|
||
*/
|
||
@PostMapping("/closeEngine/{id}")
|
||
public Result closeEngine(@PathVariable Integer id) {
|
||
//使用mybatis-plus的关闭方法
|
||
// engIneService.closeEngine(id);
|
||
engIneService.closeEngine(id);
|
||
return Result.success();
|
||
}
|
||
|
||
/**
|
||
* 通过引擎维护编号激活引擎
|
||
*/
|
||
@PostMapping("/activateEngine/{id}")
|
||
public Result activateEngine(@PathVariable Integer id) {
|
||
//使用mybatis-plus的激活方法
|
||
// engIneService.activateEngine(id);
|
||
engIneService.activateEngine(id);
|
||
return Result.success();
|
||
}
|
||
|
||
/**
|
||
* 通过id查询
|
||
*
|
||
* @param id
|
||
* @return
|
||
*/
|
||
@GetMapping("/findById/{id}")
|
||
public Result findById(@PathVariable Long id) {
|
||
//使用mybatis-plus的查询方法
|
||
//List<EngineMaintenance> list = engIneService.list();
|
||
//List<EngineMaintenance> list = engIneService.list(new LambdaQueryWrapper<>() {{
|
||
// eq(EngineMaintenance::getId, id);
|
||
//}});
|
||
List<EngineMaintenance> list = engIneService.list(new LambdaQueryWrapper<>() {{
|
||
eq(EngineMaintenance::getId, id);
|
||
}});
|
||
return Result.success(list);
|
||
}
|
||
|
||
/**
|
||
* 通过id查询
|
||
*
|
||
* @param id
|
||
* @return
|
||
*/
|
||
@GetMapping("/findByIdsfindByIds/{id}")
|
||
public Result findVersionByIds(@PathVariable("id") Long id) {
|
||
//使用mybatis-plus的查询方法
|
||
// return Result.success(engineVersionService.getByIds(id));
|
||
return Result.success(engineVersionService.list(new LambdaQueryWrapper<>() {{
|
||
eq(EngineVersion::getEngineMaintenanceId, id);
|
||
}}));
|
||
}
|
||
|
||
/**
|
||
* 规则详情
|
||
*/
|
||
@PostMapping("/selectEngineById/{versionId}")
|
||
public List<EngineMaintenance> selectEngineById(@PathVariable Integer versionId) {
|
||
//使用mybatis-plus的查询方法
|
||
// List<EngineMaintenance> engineMaintenances = engIneService.list(new LambdaQueryWrapper<>() {{
|
||
// eq(EngineMaintenance::getVersionId, versionId);
|
||
// }});
|
||
List<EngineMaintenance> engineMaintenances = engineVersionService.getByIds(versionId);
|
||
return engineMaintenances;
|
||
}
|
||
|
||
/**
|
||
* 生成引擎类
|
||
*
|
||
* @param engineVersion
|
||
* @return
|
||
*/
|
||
@PostMapping("/generate")
|
||
public EngineVersion generate(@RequestBody EngineVersion engineVersion) {
|
||
EngineMaintenance byId = engIneService.selectById(engineVersion.getId());
|
||
byId.setName("generate" + "_" + byId.getEngineCode() + "_" + engineVersion.getVersionCode());
|
||
engineVersion.setRuleContent(GenerateConstant.generateConstant(byId, engineVersion));
|
||
return engineVersion;
|
||
}
|
||
|
||
/**
|
||
*
|
||
*/
|
||
@GetMapping("/findVersionById/{id}")
|
||
public Result findVersionById(@PathVariable("id") Long id) {
|
||
return Result.success(engineVersionService.getById(id));
|
||
}
|
||
}
|