package com.ips.system.controller; import java.util.List; import javax.servlet.http.HttpServletResponse; import com.fasterxml.jackson.core.JsonProcessingException; import com.ips.common.utils.StringUtils; 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.ips.common.annotation.Log; import com.ips.common.core.controller.BaseController; import com.ips.common.core.domain.AjaxResult; import com.ips.common.enums.BusinessType; import com.ips.system.domain.Distillation; import com.ips.system.service.IDistillationService; import com.ips.common.utils.poi.ExcelUtil; import com.ips.common.core.page.TableDataInfo; /** * 知识蒸馏Controller * * @author Allen * @date 2025-05-21 */ @RestController @RequestMapping("/biz/distillation") public class DistillationController extends BaseController { @Autowired private IDistillationService distillationService; /** * 查询知识蒸馏列表 */ @PreAuthorize("@ss.hasPermi('biz:distillation:list')") @GetMapping("/list") public TableDataInfo list(Distillation distillation) { startPage(); List list = distillationService.selectDistillationList(distillation); return getDataTable(list); } /** * 导出知识蒸馏列表 */ @PreAuthorize("@ss.hasPermi('biz:distillation:export')") @Log(title = "知识蒸馏", businessType = BusinessType.EXPORT) @PostMapping("/export") public void export(HttpServletResponse response, Distillation distillation) { List list = distillationService.selectDistillationList(distillation); ExcelUtil util = new ExcelUtil(Distillation.class); util.exportExcel(response, list, "知识蒸馏数据"); } /** * 获取知识蒸馏详细信息 */ @PreAuthorize("@ss.hasPermi('biz:distillation:query')") @GetMapping(value = "/{id}") public AjaxResult getInfo(@PathVariable("id") Long id) { return success(distillationService.selectDistillationById(id)); } /** * 新增知识蒸馏 */ @PreAuthorize("@ss.hasPermi('biz:distillation:add')") @Log(title = "知识蒸馏", businessType = BusinessType.INSERT) @PostMapping public AjaxResult add(@RequestBody Distillation distillation) { return toAjax(distillationService.insertDistillation(distillation)); } /** * 修改知识蒸馏 */ @PreAuthorize("@ss.hasPermi('biz:distillation:edit')") @Log(title = "知识蒸馏", businessType = BusinessType.UPDATE) @PutMapping public AjaxResult edit(@RequestBody Distillation distillation) { return toAjax(distillationService.updateDistillation(distillation)); } /** * 删除知识蒸馏 */ @PreAuthorize("@ss.hasPermi('biz:distillation:remove')") @Log(title = "知识蒸馏", businessType = BusinessType.DELETE) @DeleteMapping("/{ids}") public AjaxResult remove(@PathVariable Long[] ids) { return toAjax(distillationService.deleteDistillationByIds(ids)); } /** * 运行算法模型 * @param id * @return * @throws JsonProcessingException */ @PreAuthorize("@ss.hasPermi('biz:distillation:add')") @GetMapping(value = "/run/{id}") public AjaxResult run(@PathVariable("id") Long id) throws JsonProcessingException { String errorMsg = distillationService.run(id); if(StringUtils.isEmpty(errorMsg)){ return success(errorMsg); } else { return error(errorMsg); } } /** * 获取结果详情 * @param id * @return * @throws JsonProcessingException */ @PreAuthorize("@ss.hasPermi('biz:distillation:add')") @GetMapping(value = "/getResultDetails/{id}") public AjaxResult getResultDetails(@PathVariable("id") Long id) throws JsonProcessingException { Distillation obj = distillationService.getResultDetails(id); if(obj != null){ return success(obj); } else { return error("获取详情失败"); } } @PreAuthorize("@ss.hasPermi('biz:distillation:add')") @GetMapping(value = "/getTaskStatusIsChanged/{id}") public AjaxResult getTaskStatusIsChanged(@PathVariable("id") Long id){ return success(distillationService.getTaskStatusIsChanged(id)); } }