| @@ -8,10 +8,7 @@ import io.swagger.annotations.Api; | |||||
| import io.swagger.annotations.ApiOperation; | import io.swagger.annotations.ApiOperation; | ||||
| import org.springframework.data.domain.Page; | import org.springframework.data.domain.Page; | ||||
| import org.springframework.data.domain.PageRequest; | import org.springframework.data.domain.PageRequest; | ||||
| import org.springframework.web.bind.annotation.GetMapping; | |||||
| import org.springframework.web.bind.annotation.RequestMapping; | |||||
| import org.springframework.web.bind.annotation.RequestParam; | |||||
| import org.springframework.web.bind.annotation.RestController; | |||||
| import org.springframework.web.bind.annotation.*; | |||||
| import javax.annotation.Resource; | import javax.annotation.Resource; | ||||
| @@ -30,6 +27,24 @@ public class AutoMLController extends BaseController { | |||||
| @RequestParam(value = "mlName", required = false) String mlName) { | @RequestParam(value = "mlName", required = false) String mlName) { | ||||
| PageRequest pageRequest = PageRequest.of(page, size); | PageRequest pageRequest = PageRequest.of(page, size); | ||||
| return genericsSuccess(this.autoMLService.queryByPage(mlName, pageRequest)); | return genericsSuccess(this.autoMLService.queryByPage(mlName, pageRequest)); | ||||
| } | |||||
| @PostMapping | |||||
| @ApiOperation("新增自动机器学习") | |||||
| public GenericsAjaxResult<AutoMl> addAutoMl(@RequestBody AutoMl autoMl) { | |||||
| return genericsSuccess(this.autoMLService.save(autoMl)); | |||||
| } | |||||
| @PutMapping | |||||
| @ApiOperation("编辑自动机器学习") | |||||
| public GenericsAjaxResult<String> editAutoMl(@RequestBody AutoMl autoMl){ | |||||
| return genericsSuccess(this.autoMLService.edit(autoMl)); | |||||
| } | } | ||||
| @DeleteMapping("{id}") | |||||
| @ApiOperation("删除自动机器学习") | |||||
| public GenericsAjaxResult<String> deleteAutoMl(@PathVariable("id") Long id){ | |||||
| return genericsSuccess(this.autoMLService.delete(id)); | |||||
| } | |||||
| } | } | ||||
| @@ -10,4 +10,10 @@ public interface AutoMLDao { | |||||
| long count(@Param("mlName") String mlName); | long count(@Param("mlName") String mlName); | ||||
| List<AutoMl> queryByPage(@Param("mlName") String mlName, @Param("pageable") Pageable pageable); | List<AutoMl> queryByPage(@Param("mlName") String mlName, @Param("pageable") Pageable pageable); | ||||
| AutoMl getAutoById(@Param("id") Long id); | |||||
| int save(@Param("autoMl") AutoMl autoMl); | |||||
| int edit(@Param("autoMl") AutoMl autoMl); | |||||
| } | } | ||||
| @@ -6,4 +6,10 @@ import org.springframework.data.domain.PageRequest; | |||||
| public interface AutoMLService { | public interface AutoMLService { | ||||
| Page<AutoMl> queryByPage(String mlName, PageRequest pageRequest); | Page<AutoMl> queryByPage(String mlName, PageRequest pageRequest); | ||||
| AutoMl save(AutoMl autoMl); | |||||
| String edit(AutoMl autoMl); | |||||
| String delete(Long id); | |||||
| } | } | ||||
| @@ -1,8 +1,12 @@ | |||||
| package com.ruoyi.platform.service.impl; | 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.domain.AutoMl; | ||||
| import com.ruoyi.platform.mapper.AutoMLDao; | import com.ruoyi.platform.mapper.AutoMLDao; | ||||
| import com.ruoyi.platform.service.AutoMLService; | 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.Page; | ||||
| import org.springframework.data.domain.PageImpl; | import org.springframework.data.domain.PageImpl; | ||||
| import org.springframework.data.domain.PageRequest; | import org.springframework.data.domain.PageRequest; | ||||
| @@ -22,4 +26,34 @@ public class AutoMLServiceImpl implements AutoMLService { | |||||
| List<AutoMl> autoMls = autoMLDao.queryByPage(mlName, pageRequest); | List<AutoMl> autoMls = autoMLDao.queryByPage(mlName, pageRequest); | ||||
| return new PageImpl<>(autoMls, pageRequest, total); | 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 ? "删除成功" : "删除失败"; | |||||
| } | |||||
| } | } | ||||
| @@ -14,16 +14,16 @@ spring: | |||||
| nacos: | nacos: | ||||
| discovery: | discovery: | ||||
| # 服务注册地址 | # 服务注册地址 | ||||
| server-addr: nacos-ci4s.argo.svc:8848 | |||||
| server-addr: 172.20.32.181:18848 | |||||
| username: nacos | username: nacos | ||||
| password: h1n2x3j4y5@ | |||||
| password: nacos | |||||
| retry: | retry: | ||||
| enabled: true | enabled: true | ||||
| # namespace: 6caf5d79-c4ce-4e3b-a357-141b74e52a01 | |||||
| config: | config: | ||||
| username: nacos | |||||
| password: h1n2x3j4y5@ | |||||
| # namespace: 6caf5d79-c4ce-4e3b-a357-141b74e52a01 | |||||
| # 配置中心地址 | # 配置中心地址 | ||||
| server-addr: nacos-ci4s.argo.svc:8848 | |||||
| server-addr: 172.20.32.181:18848 | |||||
| # 配置文件格式 | # 配置文件格式 | ||||
| file-extension: yml | file-extension: yml | ||||
| # 共享配置 | # 共享配置 | ||||
| @@ -1,6 +1,32 @@ | |||||
| <?xml version="1.0" encoding="UTF-8"?> | <?xml version="1.0" encoding="UTF-8"?> | ||||
| <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | ||||
| <mapper namespace="com.ruoyi.platform.mapper.AutoMLDao"> | <mapper namespace="com.ruoyi.platform.mapper.AutoMLDao"> | ||||
| <insert id="save"> | |||||
| insert into auto_ml(ml_name, ml_description) | |||||
| values (#{autoMl.mlName}, #{autoMl.mlDescription}) | |||||
| </insert> | |||||
| <update id="edit"> | |||||
| update auto_ml | |||||
| <set> | |||||
| <if test="autoMl.mlName != null and autoMl.mlName !=''"> | |||||
| ml_name = #{autoMl.mlName}, | |||||
| </if> | |||||
| <if test="autoMl.mlDescription != null and autoMl.mlDescription !=''"> | |||||
| ml_description = #{autoMl.mlDescription}, | |||||
| </if> | |||||
| <if test="autoMl.runState != null and autoMl.runState !=''"> | |||||
| run_state = #{autoMl.runState}, | |||||
| </if> | |||||
| <if test="autoMl.progress != null"> | |||||
| progress = #{autoMl.progress}, | |||||
| </if> | |||||
| <if test="autoMl.state != null"> | |||||
| state = #{autoMl.state}, | |||||
| </if> | |||||
| </set> | |||||
| where id = #{autoMl.id} | |||||
| </update> | |||||
| <select id="count" resultType="java.lang.Long"> | <select id="count" resultType="java.lang.Long"> | ||||
| select count(1) from auto_ml | select count(1) from auto_ml | ||||
| @@ -12,6 +38,10 @@ | |||||
| <include refid="common_condition"></include> | <include refid="common_condition"></include> | ||||
| </select> | </select> | ||||
| <select id="getAutoById" resultType="com.ruoyi.platform.domain.AutoMl"> | |||||
| select * from auto_ml where id = #{id} | |||||
| </select> | |||||
| <sql id="common_condition"> | <sql id="common_condition"> | ||||
| <where> | <where> | ||||
| state = 1 | state = 1 | ||||