|
|
|
@@ -1,8 +1,12 @@ |
|
|
|
package com.ruoyi.platform.service.impl; |
|
|
|
|
|
|
|
import com.ruoyi.common.security.utils.SecurityUtils; |
|
|
|
import com.ruoyi.platform.constant.Constant; |
|
|
|
import com.ruoyi.platform.domain.AutoMl; |
|
|
|
import com.ruoyi.platform.mapper.AutoMLDao; |
|
|
|
import com.ruoyi.platform.service.AutoMLService; |
|
|
|
import com.ruoyi.system.api.model.LoginUser; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.springframework.data.domain.Page; |
|
|
|
import org.springframework.data.domain.PageImpl; |
|
|
|
import org.springframework.data.domain.PageRequest; |
|
|
|
@@ -22,4 +26,34 @@ public class AutoMLServiceImpl implements AutoMLService { |
|
|
|
List<AutoMl> autoMls = autoMLDao.queryByPage(mlName, pageRequest); |
|
|
|
return new PageImpl<>(autoMls, pageRequest, total); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public AutoMl save(AutoMl autoMl) { |
|
|
|
autoMLDao.save(autoMl); |
|
|
|
return autoMl; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public String edit(AutoMl autoMl) { |
|
|
|
autoMLDao.edit(autoMl); |
|
|
|
return "修改成功"; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public String delete(Long id) { |
|
|
|
AutoMl autoMl = autoMLDao.getAutoById(id); |
|
|
|
if (autoMl == null) { |
|
|
|
throw new RuntimeException("服务不存在"); |
|
|
|
} |
|
|
|
|
|
|
|
LoginUser loginUser = SecurityUtils.getLoginUser(); |
|
|
|
String username = loginUser.getUsername(); |
|
|
|
String createBy = autoMl.getCreateBy(); |
|
|
|
if (!(StringUtils.equals(username, "admin") || StringUtils.equals(username, createBy))) { |
|
|
|
throw new RuntimeException("无权限删除该服务"); |
|
|
|
} |
|
|
|
|
|
|
|
autoMl.setState(Constant.State_invalid); |
|
|
|
return autoMLDao.edit(autoMl) > 0 ? "删除成功" : "删除失败"; |
|
|
|
} |
|
|
|
} |