Browse Source

Merge remote-tracking branch 'origin/dev'

# Conflicts:
#	ruoyi-auth/src/main/resources/bootstrap.yml
#	ruoyi-gateway/src/main/resources/bootstrap.yml
#	ruoyi-modules/management-platform/src/main/resources/bootstrap.yml
#	ruoyi-modules/ruoyi-file/src/main/resources/bootstrap.yml
#	ruoyi-modules/ruoyi-gen/src/main/resources/bootstrap.yml
#	ruoyi-modules/ruoyi-job/src/main/resources/bootstrap.yml
#	ruoyi-modules/ruoyi-system/src/main/resources/bootstrap.yml
dev-lhz
chenzhihang 1 year ago
parent
commit
7312b56df9
23 changed files with 356 additions and 467 deletions
  1. +0
    -61
      react-ui/src/pages/Dataset/components/ResourceItem/index.less
  2. +0
    -54
      react-ui/src/pages/Dataset/components/ResourceItem/index.tsx
  3. +6
    -1
      ruoyi-auth/src/main/resources/bootstrap.yml
  4. +6
    -1
      ruoyi-gateway/src/main/resources/bootstrap.yml
  5. +5
    -3
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/codeConfig/CodeConfigController.java
  6. +12
    -13
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/image/ImageController.java
  7. +4
    -97
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/domain/ImageVersion.java
  8. +2
    -0
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/mapper/CodeConfigDao.java
  9. +1
    -1
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/ImageService.java
  10. +8
    -0
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/CodeConfigServiceImpl.java
  11. +61
    -49
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ImageServiceImpl.java
  12. +5
    -0
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/utils/DockerClientUtil.java
  13. +2
    -2
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/utils/K8sClientUtil.java
  14. +6
    -1
      ruoyi-modules/management-platform/src/main/resources/bootstrap.yml
  15. +13
    -3
      ruoyi-modules/management-platform/src/main/resources/mapper/managementPlatform/CodeConfigDaoMapper.xml
  16. +1
    -0
      ruoyi-modules/management-platform/src/main/resources/mapper/managementPlatform/ImageVersionDaoMapper.xml
  17. +3
    -1
      ruoyi-modules/ruoyi-file/src/main/resources/bootstrap.yml
  18. +3
    -1
      ruoyi-modules/ruoyi-gen/src/main/resources/bootstrap.yml
  19. +6
    -1
      ruoyi-modules/ruoyi-job/src/main/resources/bootstrap.yml
  20. +2
    -1
      ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysUserController.java
  21. +3
    -1
      ruoyi-modules/ruoyi-system/src/main/resources/bootstrap.yml
  22. +200
    -175
      ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml
  23. +7
    -1
      ruoyi-visual/ruoyi-monitor/src/main/resources/bootstrap.yml

+ 0
- 61
react-ui/src/pages/Dataset/components/ResourceItem/index.less View File

@@ -1,61 +0,0 @@
.resource-item {
position: relative;
width: calc(25% - 15px);
padding: 20px;
background: white;
border: 1px solid #eaeaea;
border-radius: 4px;
cursor: pointer;

@media screen and (max-width: 1860px) {
& {
width: calc(33.33% - 13.33px);
}
}

&__name {
position: relative;
display: inline-block;
height: 24px;
margin: 0 10px 0 0 !important;
color: @text-color;
font-size: 16px;
}

&__description {
height: 44px;
margin-bottom: 20px;
color: @text-color-secondary;
font-size: 14px;
.multiLine(2);
}
&__time {
display: flex;
flex: 0 1 content;
align-items: center;
width: 100%;
color: #808080;
font-size: 13px;
}

&:hover {
border-color: @primary-color;
box-shadow: 0px 0px 6px 1px rgba(0, 0, 0, 0.1);

.resource-item__name {
color: @primary-color;
}
}
}

.resource-item__name {
&::after {
position: absolute;
top: 14px;
left: 0;
width: 100%;
height: 6px;
background: linear-gradient(to right, rgba(22, 100, 255, 0.3) 0, rgba(22, 100, 255, 0) 100%);
content: '';
}
}

+ 0
- 54
react-ui/src/pages/Dataset/components/ResourceItem/index.tsx View File

@@ -1,54 +0,0 @@
import clock from '@/assets/img/clock.png';
import creatByImg from '@/assets/img/creatBy.png';
import KFIcon from '@/components/KFIcon';
import { formatDate } from '@/utils/date';
import { Button, Flex, Typography } from 'antd';
import { ResourceData } from '../../config';
import styles from './index.less';

type ResourceItemProps = {
item: ResourceData;
isPublic: boolean;
onRemove: (item: ResourceData) => void;
onClick: (item: ResourceData) => void;
};

function ResourceItem({ item, isPublic, onClick, onRemove }: ResourceItemProps) {
return (
<div className={styles['resource-item']} onClick={() => onClick(item)}>
<Flex justify="space-between" align="center" style={{ marginBottom: '20px', height: '32px' }}>
<Typography.Paragraph
className={styles['resource-item__name']}
ellipsis={{ tooltip: item.name }}
>
{item.name}
</Typography.Paragraph>
{!isPublic && (
<Button
type="text"
shape="circle"
onClick={(e) => {
e.stopPropagation();
onRemove(item);
}}
>
<KFIcon type="icon-shanchu" font={17} />
</Button>
)}
</Flex>
<div className={styles['resource-item__description']}>{item.description}</div>
<Flex justify="space-between">
<div className={styles['resource-item__time']}>
<img style={{ width: '17px', marginRight: '6px' }} src={creatByImg} alt="" />
<span>{item.create_by}</span>
</div>
<div className={styles['resource-item__time']}>
<img style={{ width: '12px', marginRight: '5px' }} src={clock} alt="" />
<span>最近更新: {formatDate(item.update_time, 'YYYY-MM-DD')}</span>
</div>
</Flex>
</div>
);
}

export default ResourceItem;

+ 6
- 1
ruoyi-auth/src/main/resources/bootstrap.yml View File

@@ -22,4 +22,9 @@ spring:
file-extension: yml file-extension: yml
# 共享配置 # 共享配置
shared-configs: shared-configs:
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
- data-id: application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
group: DEFAULT_GROUP
refresh: true
- data-id: ${spring.application.name}-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
group: DEFAULT_GROUP
refresh: true

+ 6
- 1
ruoyi-gateway/src/main/resources/bootstrap.yml View File

@@ -22,7 +22,12 @@ spring:
file-extension: yml file-extension: yml
# 共享配置 # 共享配置
shared-configs: shared-configs:
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
- data-id: application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
group: DEFAULT_GROUP
refresh: true
- data-id: ${spring.application.name}-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
group: DEFAULT_GROUP
refresh: true
sentinel: sentinel:
# 取消控制台懒加载 # 取消控制台懒加载
eager: true eager: true


+ 5
- 3
ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/codeConfig/CodeConfigController.java View File

@@ -31,10 +31,12 @@ public class CodeConfigController extends BaseController {
@GetMapping @GetMapping
public GenericsAjaxResult<Page<CodeConfig>> queryByPage(@RequestParam("page") int page, public GenericsAjaxResult<Page<CodeConfig>> queryByPage(@RequestParam("page") int page,
@RequestParam("size") int size, @RequestParam("size") int size,
@RequestParam(value = "code_repo_name", required = false) String codeRepoName) {
@RequestParam(value = "code_repo_name", required = false) String codeRepoName,
@RequestParam(value = "code_repo_vis", required = false)Integer codeRepoVis) {
PageRequest pageRequest = PageRequest.of(page, size); PageRequest pageRequest = PageRequest.of(page, size);
CodeConfig codeConfig = new CodeConfig(); CodeConfig codeConfig = new CodeConfig();
codeConfig.setCodeRepoName(codeRepoName); codeConfig.setCodeRepoName(codeRepoName);
codeConfig.setCodeRepoVis(codeRepoVis);
return genericsSuccess(this.codeConfigService.queryByPage(codeConfig, pageRequest)); return genericsSuccess(this.codeConfigService.queryByPage(codeConfig, pageRequest));
} }


@@ -45,8 +47,8 @@ public class CodeConfigController extends BaseController {
* @return 单条数据 * @return 单条数据
*/ */
@GetMapping("{id}") @GetMapping("{id}")
public ResponseEntity<CodeConfig> queryById(@PathVariable("id") Long id) {
return ResponseEntity.ok(this.codeConfigService.queryById(id));
public GenericsAjaxResult<CodeConfig> queryById(@PathVariable("id") Long id) {
return genericsSuccess(this.codeConfigService.queryById(id));
} }






+ 12
- 13
ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/image/ImageController.java View File

@@ -45,7 +45,7 @@ public class ImageController extends BaseController {
@RequestParam("size") int size, @RequestParam("size") int size,
@RequestParam(value = "image_type") int imageType) { @RequestParam(value = "image_type") int imageType) {
image.setImageType(imageType); image.setImageType(imageType);
PageRequest pageRequest = PageRequest.of(page,size);
PageRequest pageRequest = PageRequest.of(page, size);
return genericsSuccess(this.imageService.queryByPage(image, pageRequest)); return genericsSuccess(this.imageService.queryByPage(image, pageRequest));
} }


@@ -72,6 +72,7 @@ public class ImageController extends BaseController {
public GenericsAjaxResult<Page<Image>> queryByName(@PathVariable("name") String name) { public GenericsAjaxResult<Page<Image>> queryByName(@PathVariable("name") String name) {
return genericsSuccess(this.imageService.queryByName(name)); return genericsSuccess(this.imageService.queryByName(name));
} }

/** /**
* 新增数据 * 新增数据
* *
@@ -84,9 +85,8 @@ public class ImageController extends BaseController {
} }


/** /**
*
* @param imageVo 实体 * @param imageVo 实体
* 新增镜像和版本 @PostMapping
* 新增镜像和版本 @PostMapping
* @return 新增结果 * @return 新增结果
*/ */
@PostMapping("/addImageAndVersion") @PostMapping("/addImageAndVersion")
@@ -122,21 +122,20 @@ public class ImageController extends BaseController {
@PostMapping("/net") @PostMapping("/net")
@ApiOperation("从网络上传构建镜像") @ApiOperation("从网络上传构建镜像")
public GenericsAjaxResult<Map<String, String>> createImageFromNet(@RequestParam("name") String imageName, public GenericsAjaxResult<Map<String, String>> createImageFromNet(@RequestParam("name") String imageName,
@RequestParam("tag") String imageTag,
@RequestParam("path") String path) throws Exception {
return genericsSuccess(this.imageService.createImageFromNet(imageName,imageTag,path));
@RequestParam("tag") String imageTag,
@RequestParam("path") String path) throws Exception {
return genericsSuccess(this.imageService.createImageFromNet(imageName, imageTag, path));
} }


@PostMapping("/local") @PostMapping("/local")
@ApiOperation("从本地上传构建镜像") @ApiOperation("从本地上传构建镜像")
public GenericsAjaxResult<Map<String, String>> createImageFromLocal(@RequestParam("name") String imageName, public GenericsAjaxResult<Map<String, String>> createImageFromLocal(@RequestParam("name") String imageName,
@RequestParam("tag") String imageTag,
@RequestParam("path") String path) throws Exception {
return genericsSuccess(this.imageService.createImageFromLocal(imageName,imageTag,path));
@RequestParam("tag") String imageTag,
@RequestParam("path") String path) throws Exception {
return genericsSuccess(this.imageService.createImageFromLocal(imageName, imageTag, path));
} }





/** /**
* 镜像上传 * 镜像上传
* *
@@ -145,14 +144,14 @@ public class ImageController extends BaseController {
@PostMapping("/upload") @PostMapping("/upload")
@ApiOperation(value = "上传镜像文件", notes = "上传镜像tar包,返回存储路径") @ApiOperation(value = "上传镜像文件", notes = "上传镜像tar包,返回存储路径")
public GenericsAjaxResult<Map<String, String>> uploadImageFiles(@RequestParam("file") MultipartFile file) throws Exception { public GenericsAjaxResult<Map<String, String>> uploadImageFiles(@RequestParam("file") MultipartFile file) throws Exception {
return genericsSuccess(this.imageService.uploadImageFiles(file));
return genericsSuccess(this.imageService.uploadImageFiles(file));
} }




@PostMapping("/saveImage") @PostMapping("/saveImage")
@ApiOperation(value = "保存环境为镜像", notes = "docker commit方式保存,并推送到horbor") @ApiOperation(value = "保存环境为镜像", notes = "docker commit方式保存,并推送到horbor")
public GenericsAjaxResult<String> saveImage(@RequestBody ImageVo imageVo){
return genericsSuccess(this.imageService.saveImage(imageVo));
public void saveImage(@RequestBody ImageVo imageVo) {
this.imageService.saveImage(imageVo);
} }
} }



+ 4
- 97
ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/domain/ImageVersion.java View File

@@ -3,6 +3,7 @@ package com.ruoyi.platform.domain;
import com.fasterxml.jackson.databind.PropertyNamingStrategy; import com.fasterxml.jackson.databind.PropertyNamingStrategy;
import com.fasterxml.jackson.databind.annotation.JsonNaming; import com.fasterxml.jackson.databind.annotation.JsonNaming;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data;


import java.util.Date; import java.util.Date;
import java.io.Serializable; import java.io.Serializable;
@@ -14,6 +15,7 @@ import java.io.Serializable;
* @since 2024-03-05 15:00:02 * @since 2024-03-05 15:00:02
*/ */
@JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy.class) @JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy.class)
@Data
public class ImageVersion implements Serializable { public class ImageVersion implements Serializable {
private static final long serialVersionUID = 251017725389874890L; private static final long serialVersionUID = 251017725389874890L;
/** /**
@@ -56,102 +58,7 @@ public class ImageVersion implements Serializable {
@ApiModelProperty(value = "状态,0失效,1生效") @ApiModelProperty(value = "状态,0失效,1生效")
private Integer state; private Integer state;



public Integer getId() {
return id;
}

public void setId(Integer id) {
this.id = id;
}

public Integer getImageId() {
return imageId;
}

public void setImageId(Integer imageId) {
this.imageId = imageId;
}

public String getVersion() {
return version;
}

public void setVersion(String version) {
this.version = version;
}

public String getUrl() {
return url;
}

public void setUrl(String url) {
this.url = url;
}

public String getTagName() {
return tagName;
}

public void setTagName(String tagName) {
this.tagName = tagName;
}

public String getFileSize() {
return fileSize;
}

public void setFileSize(String fileSize) {
this.fileSize = fileSize;
}

public String getStatus() {
return status;
}

public void setStatus(String status) {
this.status = status;
}

public String getCreateBy() {
return createBy;
}

public void setCreateBy(String createBy) {
this.createBy = createBy;
}

public Date getCreateTime() {
return createTime;
}

public void setCreateTime(Date createTime) {
this.createTime = createTime;
}

public String getUpdateBy() {
return updateBy;
}

public void setUpdateBy(String updateBy) {
this.updateBy = updateBy;
}

public Date getUpdateTime() {
return updateTime;
}

public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}

public Integer getState() {
return state;
}

public void setState(Integer state) {
this.state = state;
}

@ApiModelProperty(value = "镜像所在主机ip")
private String hostIp;
} }



+ 2
- 0
ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/mapper/CodeConfigDao.java View File

@@ -14,6 +14,8 @@ public interface CodeConfigDao {


CodeConfig queryById(Long id); CodeConfig queryById(Long id);


Long queryByCodeRepoName(@Param("codeRepoName") String codeRepoName);

int insert(@Param("codeConfig") CodeConfig codeConfig); int insert(@Param("codeConfig") CodeConfig codeConfig);


int update(@Param("codeConfig") CodeConfig codeConfig); int update(@Param("codeConfig") CodeConfig codeConfig);


+ 1
- 1
ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/ImageService.java View File

@@ -93,5 +93,5 @@ public interface ImageService {
Map<String, String> createImageFromNet(String imageName, String imageTag, String NetPath) throws Exception; Map<String, String> createImageFromNet(String imageName, String imageTag, String NetPath) throws Exception;
Map<String, String> uploadImageFiles(MultipartFile file) throws Exception; Map<String, String> uploadImageFiles(MultipartFile file) throws Exception;


String saveImage(ImageVo imageVo);
void saveImage(ImageVo imageVo);
} }

+ 8
- 0
ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/CodeConfigServiceImpl.java View File

@@ -38,6 +38,10 @@ public class CodeConfigServiceImpl implements CodeConfigService {


@Override @Override
public CodeConfig insert(CodeConfig codeConfig) { public CodeConfig insert(CodeConfig codeConfig) {
Long id = this.codeConfigDao.queryByCodeRepoName(codeConfig.getCodeRepoName());
if(id != null){
throw new IllegalStateException("代码仓库名称已存在");
}
LoginUser loginUser = SecurityUtils.getLoginUser(); LoginUser loginUser = SecurityUtils.getLoginUser();
codeConfig.setCreateBy(loginUser.getUsername()); codeConfig.setCreateBy(loginUser.getUsername());
codeConfig.setUpdateBy(loginUser.getUsername()); codeConfig.setUpdateBy(loginUser.getUsername());
@@ -49,6 +53,10 @@ public class CodeConfigServiceImpl implements CodeConfigService {


@Override @Override
public CodeConfig update(CodeConfig codeConfig) { public CodeConfig update(CodeConfig codeConfig) {
Long id = this.codeConfigDao.queryByCodeRepoName(codeConfig.getCodeRepoName());
if(id != null && !id.equals(codeConfig.getId())){
throw new IllegalStateException("代码仓库名称已存在");
}


LoginUser loginUser = SecurityUtils.getLoginUser(); LoginUser loginUser = SecurityUtils.getLoginUser();
codeConfig.setUpdateBy(loginUser.getUsername()); codeConfig.setUpdateBy(loginUser.getUsername());


+ 61
- 49
ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ImageServiceImpl.java View File

@@ -32,6 +32,7 @@ import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;


@@ -85,6 +86,7 @@ public class ImageServiceImpl implements ImageService {
private String pvcName; private String pvcName;
@Value("${jupyter.namespace}") @Value("${jupyter.namespace}")
private String namespace; private String namespace;

/** /**
* 通过ID查询单条数据 * 通过ID查询单条数据
* *
@@ -99,8 +101,8 @@ public class ImageServiceImpl implements ImageService {
/** /**
* 分页查询 * 分页查询
* *
* @param image 筛选条件
* @param pageRequest 分页对象
* @param image 筛选条件
* @param pageRequest 分页对象
* @return 查询结果 * @return 查询结果
*/ */
@Override @Override
@@ -110,7 +112,6 @@ public class ImageServiceImpl implements ImageService {
} }





/** /**
* 新增数据 * 新增数据
* *
@@ -138,7 +139,7 @@ public class ImageServiceImpl implements ImageService {
@Override @Override
public Image update(Image image) { public Image update(Image image) {
int currentState = image.getState(); int currentState = image.getState();
if(currentState == 0){
if (currentState == 0) {
throw new RuntimeException("镜像已被删除,无法更新。"); throw new RuntimeException("镜像已被删除,无法更新。");
} }
LoginUser loginUser = SecurityUtils.getLoginUser(); LoginUser loginUser = SecurityUtils.getLoginUser();
@@ -163,7 +164,7 @@ public class ImageServiceImpl implements ImageService {
@Override @Override
public String removeById(Integer id) throws Exception { public String removeById(Integer id) throws Exception {
Image image = this.imageDao.queryById(id); Image image = this.imageDao.queryById(id);
if (image == null){
if (image == null) {
throw new Exception("镜像不存在"); throw new Exception("镜像不存在");
} }


@@ -173,14 +174,20 @@ public class ImageServiceImpl implements ImageService {




String createdBy = image.getCreateBy(); String createdBy = image.getCreateBy();
if (!(StringUtils.equals(username,"admin") || !StringUtils.equals(username,createdBy))){
if (!(StringUtils.equals(username, "admin") || !StringUtils.equals(username, createdBy))) {
throw new Exception("无权限删除该镜像"); throw new Exception("无权限删除该镜像");
} }
if (!imageVersionService.queryByImageId(id).isEmpty()){
throw new Exception("请先删除该镜像下的版本文件");
// if (!imageVersionService.queryByImageId(id).isEmpty()){
// throw new Exception("请先删除该镜像下的版本文件");
// }
List<ImageVersion> imageVersions = imageVersionService.queryByImageId(id);

for (ImageVersion imageVersion :imageVersions) {
dockerClientUtil.removeImage(imageVersion.getUrl(), imageVersion.getHostIp());
} }

image.setState(0); image.setState(0);
return this.imageDao.update(image)>0?"删除成功":"删除失败";
return this.imageDao.update(image) > 0 ? "删除成功" : "删除失败";




} }
@@ -207,7 +214,7 @@ public class ImageServiceImpl implements ImageService {
public String insertImageAndVersion(ImageVo imageVo) throws Exception { public String insertImageAndVersion(ImageVo imageVo) throws Exception {
Image existingImage = getByName(imageVo.getName()); Image existingImage = getByName(imageVo.getName());
Image imageToUse; Image imageToUse;
if(existingImage == null) {
if (existingImage == null) {
// 如果不存在相同名称的镜像,则创建新的镜像记录 // 如果不存在相同名称的镜像,则创建新的镜像记录
Image newImage = new Image(); Image newImage = new Image();
newImage.setName(imageVo.getName()); newImage.setName(imageVo.getName());
@@ -217,7 +224,7 @@ public class ImageServiceImpl implements ImageService {
if (imageToUse == null) { if (imageToUse == null) {
throw new Exception("新增镜像失败"); throw new Exception("新增镜像失败");
} }
}else{
} else {
// 如果已存在相同名称的镜像,使用已存在的镜像 // 如果已存在相同名称的镜像,使用已存在的镜像
imageToUse = existingImage; imageToUse = existingImage;
} }
@@ -235,9 +242,9 @@ public class ImageServiceImpl implements ImageService {
CompletableFuture.supplyAsync(() -> { CompletableFuture.supplyAsync(() -> {
Map<String, String> resultMap = new HashMap<>(); Map<String, String> resultMap = new HashMap<>();
try { try {
if(imageVo.getUploadType()==0){
resultMap = createImageFromNet(imageVo.getName(), imageVo.getTagName(), imageVo.getPath());
}else{
if (imageVo.getUploadType() == 0) {
resultMap = createImageFromNet(imageVo.getName(), imageVo.getTagName(), imageVo.getPath());
} else {
resultMap = createImageFromLocal(imageVo.getName(), imageVo.getTagName(), imageVo.getPath()); resultMap = createImageFromLocal(imageVo.getName(), imageVo.getTagName(), imageVo.getPath());
} }
} catch (Exception e) { } catch (Exception e) {
@@ -246,7 +253,7 @@ public class ImageServiceImpl implements ImageService {
throw new RuntimeException("镜像构建失败: " + e.getMessage(), e); throw new RuntimeException("镜像构建失败: " + e.getMessage(), e);
} }
return resultMap; return resultMap;
}).thenAccept(resultMap ->{
}).thenAccept(resultMap -> {
try { try {
String imageUrl = resultMap.get("url"); String imageUrl = resultMap.get("url");
String fileSize = resultMap.get("fileSize"); String fileSize = resultMap.get("fileSize");
@@ -272,27 +279,27 @@ public class ImageServiceImpl implements ImageService {
// 得到容器 // 得到容器
V1Pod pod = k8sClientUtil.getNSPodList(serviceNS, deploymentName); V1Pod pod = k8sClientUtil.getNSPodList(serviceNS, deploymentName);
if (pod == null) { if (pod == null) {
String podName = deploymentName+"-"+ DateUtils.formatYMD10(new Date());
pod = k8sClientUtil.createPodWithEnv(podName,serviceNS,proxyUrl,mountPath,pvcName,image);
String podName = deploymentName + "-" + DateUtils.formatYMD10(new Date());
pod = k8sClientUtil.createPodWithEnv(podName, serviceNS, proxyUrl, mountPath, pvcName, image);
} }
String loginCmd = "docker login -u " + harborUser +" -p "+harborpassword+" "+harborUrl;
String loginCmd = "docker login -u " + harborUser + " -p " + harborpassword + " " + harborUrl;
// 执行命令 docker login -u admin -p Harbor12345 172.20.32.187 // 执行命令 docker login -u admin -p Harbor12345 172.20.32.187
String loginlog = k8sClientUtil.executeCommand(pod,loginCmd);
String loginlog = k8sClientUtil.executeCommand(pod, loginCmd);
// 在这个容器的/data/admin 目录下执行命令 docker load -i fileName 得到返回的镜像名字name:tag // 在这个容器的/data/admin 目录下执行命令 docker load -i fileName 得到返回的镜像名字name:tag
String username = SecurityUtils.getLoginUser().getUsername(); String username = SecurityUtils.getLoginUser().getUsername();
// //
String logs2 = k8sClientUtil.executeCommand(pod,"docker pull "+ netPath);
String logs2 = k8sClientUtil.executeCommand(pod, "docker pull " + netPath);
// 在容器里执行 docker tag name:tag nexus3.kube-system.svc:8083/imageName:imageTag // 在容器里执行 docker tag name:tag nexus3.kube-system.svc:8083/imageName:imageTag
if (StringUtils.isNoneBlank(logs2)){
if (StringUtils.isNoneBlank(logs2)) {
String[] lines = logs2.split("\n"); String[] lines = logs2.split("\n");
String lastLine = lines[lines.length - 1].trim(); String lastLine = lines[lines.length - 1].trim();
String tagCmd = "docker tag " + lastLine + " " + harborUrl + "/" + repository + "/" + username + "/" + imageName + ":" + imageTag; String tagCmd = "docker tag " + lastLine + " " + harborUrl + "/" + repository + "/" + username + "/" + imageName + ":" + imageTag;
String imageUrl = harborUrl + "/" + repository + "/" + username + "/" + imageName + ":" + imageTag; String imageUrl = harborUrl + "/" + repository + "/" + username + "/" + imageName + ":" + imageTag;
String pushCmd = "docker push " + imageUrl;
String pushCmd = "docker push " + imageUrl;
String sizeCmd = "docker inspect --format='{{.Size}}' " + imageUrl; String sizeCmd = "docker inspect --format='{{.Size}}' " + imageUrl;
String s = k8sClientUtil.executeCommand(pod, tagCmd); String s = k8sClientUtil.executeCommand(pod, tagCmd);


if (StringUtils.isNotEmpty(k8sClientUtil.executeCommand(pod, pushCmd))){
if (StringUtils.isNotEmpty(k8sClientUtil.executeCommand(pod, pushCmd))) {
resultMap.put("url", imageUrl); resultMap.put("url", imageUrl);
//得到镜像文件大小 //得到镜像文件大小
String imageSizeStr = k8sClientUtil.executeCommand(pod, sizeCmd); String imageSizeStr = k8sClientUtil.executeCommand(pod, sizeCmd);
@@ -301,10 +308,10 @@ public class ImageServiceImpl implements ImageService {
resultMap.put("fileSize", formattedImageSize); resultMap.put("fileSize", formattedImageSize);
return resultMap; return resultMap;


}else {
} else {
throw new Exception("拉取公网镜像失败,请检查网络或者镜像地址"); throw new Exception("拉取公网镜像失败,请检查网络或者镜像地址");
} }
}else {
} else {
throw new Exception("拉取公网镜像失败,请检查网络或者镜像地址"); throw new Exception("拉取公网镜像失败,请检查网络或者镜像地址");
} }
} }
@@ -315,27 +322,27 @@ public class ImageServiceImpl implements ImageService {
// 得到容器 // 得到容器
V1Pod pod = k8sClientUtil.getNSPodList(serviceNS, deploymentName); V1Pod pod = k8sClientUtil.getNSPodList(serviceNS, deploymentName);
if (pod == null) { if (pod == null) {
String podName = deploymentName+"-"+ DateUtils.formatYMD10(new Date());
pod = k8sClientUtil.createPodWithEnv(podName,serviceNS,proxyUrl,mountPath,pvcName,image);
String podName = deploymentName + "-" + DateUtils.formatYMD10(new Date());
pod = k8sClientUtil.createPodWithEnv(podName, serviceNS, proxyUrl, mountPath, pvcName, image);
} }
String loginCmd = "docker login -u " + harborUser +" -p "+harborpassword+" "+harborUrl;
String loginCmd = "docker login -u " + harborUser + " -p " + harborpassword + " " + harborUrl;
// 执行命令 docker login -u admin -p Harbor12345 172.20.32.187 // 执行命令 docker login -u admin -p Harbor12345 172.20.32.187
String loginlog = k8sClientUtil.executeCommand(pod,loginCmd);
String loginlog = k8sClientUtil.executeCommand(pod, loginCmd);
// 在这个容器的/data/admin 目录下执行命令 docker load -i fileName 得到返回的镜像名字name:tag // 在这个容器的/data/admin 目录下执行命令 docker load -i fileName 得到返回的镜像名字name:tag
String username = SecurityUtils.getLoginUser().getUsername(); String username = SecurityUtils.getLoginUser().getUsername();
// //
String filePath = "/data/argo-workflow/" + bucketName + "/" +path;
String logs2 = k8sClientUtil.executeCommand(pod,"docker load -i "+filePath);
String filePath = "/data/argo-workflow/" + bucketName + "/" + path;
String logs2 = k8sClientUtil.executeCommand(pod, "docker load -i " + filePath);
// 在容器里执行 docker tag name:tag nexus3.kube-system.svc:8083/imageName:imageTag // 在容器里执行 docker tag name:tag nexus3.kube-system.svc:8083/imageName:imageTag


if (StringUtils.isNoneBlank(logs2)){
String substring = logs2.substring(logs2.indexOf(":")+1).trim();
if (StringUtils.isNoneBlank(logs2)) {
String substring = logs2.substring(logs2.indexOf(":") + 1).trim();
String tagCmd = "docker tag " + substring + " " + harborUrl + "/" + repository + "/" + username + "/" + imageName + ":" + imageTag; String tagCmd = "docker tag " + substring + " " + harborUrl + "/" + repository + "/" + username + "/" + imageName + ":" + imageTag;
String imageUrl = harborUrl + "/" + repository + "/" + username + "/" + imageName + ":" + imageTag; String imageUrl = harborUrl + "/" + repository + "/" + username + "/" + imageName + ":" + imageTag;
String pushCmd = "docker push " + imageUrl;
String pushCmd = "docker push " + imageUrl;
String sizeCmd = "docker inspect --format='{{.Size}}' " + imageUrl; String sizeCmd = "docker inspect --format='{{.Size}}' " + imageUrl;
String s = k8sClientUtil.executeCommand(pod, tagCmd); String s = k8sClientUtil.executeCommand(pod, tagCmd);
if (StringUtils.isNotEmpty(k8sClientUtil.executeCommand(pod, pushCmd))){
if (StringUtils.isNotEmpty(k8sClientUtil.executeCommand(pod, pushCmd))) {
resultMap.put("url", imageUrl); resultMap.put("url", imageUrl);
//得到镜像文件大小 //得到镜像文件大小
String imageSizeStr = k8sClientUtil.executeCommand(pod, sizeCmd); String imageSizeStr = k8sClientUtil.executeCommand(pod, sizeCmd);
@@ -343,43 +350,49 @@ public class ImageServiceImpl implements ImageService {
String formattedImageSize = FileUtil.formatFileSize(sizeInBytes); // 格式化镜像文件大小 String formattedImageSize = FileUtil.formatFileSize(sizeInBytes); // 格式化镜像文件大小
resultMap.put("fileSize", formattedImageSize); resultMap.put("fileSize", formattedImageSize);
return resultMap; return resultMap;
}else {
} else {
throw new Exception("解析镜像压缩包失败,请检查镜像文件"); throw new Exception("解析镜像压缩包失败,请检查镜像文件");
} }
}else {
} else {
throw new Exception("解析镜像压缩包失败,请检查镜像文件"); throw new Exception("解析镜像压缩包失败,请检查镜像文件");
} }
} }






@Override @Override
public Map<String, String> uploadImageFiles(MultipartFile file) throws Exception { public Map<String, String> uploadImageFiles(MultipartFile file) throws Exception {
LoginUser loginUser = SecurityUtils.getLoginUser(); LoginUser loginUser = SecurityUtils.getLoginUser();
String path = loginUser.getUsername()+"/"+file.getOriginalFilename();
String path = loginUser.getUsername() + "/" + file.getOriginalFilename();
return minioService.uploadFile(bucketName, path, file); return minioService.uploadFile(bucketName, path, file);
} }


@Override @Override
@Transactional @Transactional
public String saveImage(ImageVo imageVo) {
if(imageDao.getByName(imageVo.getName()) != null){
throw new IllegalStateException("镜像名称已存在");
@Async
public void saveImage(ImageVo imageVo) {
Image oldImage = imageDao.getByName(imageVo.getName());
if (oldImage != null) {
List<ImageVersion> oldImageVersions = imageVersionDao.queryByImageId(oldImage.getId());
for (ImageVersion oldImageVersion : oldImageVersions) {
if(oldImageVersion.getTagName().equals(imageVo.getTagName())){
throw new IllegalStateException("镜像tag不能重复");
}
}
} }

LoginUser loginUser = SecurityUtils.getLoginUser(); LoginUser loginUser = SecurityUtils.getLoginUser();
String username = loginUser.getUsername().toLowerCase(); String username = loginUser.getUsername().toLowerCase();
String podName = username +"-editor-pod" + "-" + imageVo.getDevEnvironmentId().toString();
String podName = username + "-editor-pod" + "-" + imageVo.getDevEnvironmentId().toString();


try { try {
String containerId = k8sClientUtil.getPodContainerId(podName, namespace); String containerId = k8sClientUtil.getPodContainerId(podName, namespace);
String hostIp = k8sClientUtil.getHostIp(podName, namespace); String hostIp = k8sClientUtil.getHostIp(podName, namespace);


dockerClientUtil.commitImage(imageVo,containerId,hostIp,username);
dockerClientUtil.commitImage(imageVo, containerId, hostIp, username);
HashMap<String, String> resultMap = dockerClientUtil.pushImageToHorbor(imageVo, hostIp); HashMap<String, String> resultMap = dockerClientUtil.pushImageToHorbor(imageVo, hostIp);


Image image = new Image(); Image image = new Image();
BeanUtils.copyProperties(imageVo,image);
BeanUtils.copyProperties(imageVo, image);
image.setImageType(Constant.Image_Type_Pri); image.setImageType(Constant.Image_Type_Pri);
image.setCreateBy(username); image.setCreateBy(username);
image.setUpdateBy(username); image.setUpdateBy(username);
@@ -396,6 +409,7 @@ public class ImageServiceImpl implements ImageService {
imageVersion.setFileSize(resultMap.get("size")); imageVersion.setFileSize(resultMap.get("size"));
imageVersion.setCreateBy(username); imageVersion.setCreateBy(username);
imageVersion.setUpdateBy(username); imageVersion.setUpdateBy(username);
imageVersion.setHostIp(hostIp);
imageVersion.setUpdateTime(new Date()); imageVersion.setUpdateTime(new Date());
imageVersion.setCreateTime(new Date()); imageVersion.setCreateTime(new Date());
imageVersion.setState(1); imageVersion.setState(1);
@@ -407,10 +421,8 @@ public class ImageServiceImpl implements ImageService {
devEnvironment.setId(imageVo.getDevEnvironmentId()); devEnvironment.setId(imageVo.getDevEnvironmentId());
devEnvironment.setImage(resultMap.get("imageName")); devEnvironment.setImage(resultMap.get("imageName"));
devEnvironmentDao.update(devEnvironment); devEnvironmentDao.update(devEnvironment);

return "保存镜像成功";
} catch (Exception e) { } catch (Exception e) {
throw new RuntimeException("保存镜像失败:" +e);
throw new RuntimeException("保存镜像失败:" + e);
} }
} }
} }

+ 5
- 0
ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/utils/DockerClientUtil.java View File

@@ -106,4 +106,9 @@ public class DockerClientUtil {
} }


} }

public void removeImage(String imageName, String hostIp){
DockerClient dockerClient = getDockerClient(hostIp);
dockerClient.removeImageCmd(imageName).withForce(true).exec();
}
} }

+ 2
- 2
ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/utils/K8sClientUtil.java View File

@@ -501,9 +501,9 @@ public class K8sClientUtil {
computingResourceDao.updateUsedStateByNode(nodeName, Constant.Used_State_used); computingResourceDao.updateUsedStateByNode(nodeName, Constant.Used_State_used);
} }
} catch (ApiException e) { } catch (ApiException e) {
log.error("创建pod异常:" + e.getResponseBody(), e);
throw new RuntimeException("创建pod异常:" + e.getResponseBody());
} catch (Exception e) { } catch (Exception e) {
log.error("创建pod系统异常:", e);
throw new RuntimeException("创建pod系统异常:", e);
} }


V1Service service = createService(namespace, podName + "-svc", port, selector); V1Service service = createService(namespace, podName + "-svc", port, selector);


+ 6
- 1
ruoyi-modules/management-platform/src/main/resources/bootstrap.yml View File

@@ -22,4 +22,9 @@ spring:
file-extension: yml file-extension: yml
# 共享配置 # 共享配置
shared-configs: shared-configs:
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
- data-id: application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
group: DEFAULT_GROUP
refresh: true
- data-id: management-platform-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
group: DEFAULT_GROUP
refresh: true

+ 13
- 3
ruoyi-modules/management-platform/src/main/resources/mapper/managementPlatform/CodeConfigDaoMapper.xml View File

@@ -3,9 +3,12 @@
<mapper namespace="com.ruoyi.platform.mapper.CodeConfigDao"> <mapper namespace="com.ruoyi.platform.mapper.CodeConfigDao">


<insert id="insert"> <insert id="insert">
insert into code_config(code_repo_name, code_repo_vis, git_url, git_branch, verify_mode, git_user_name, git_password,ssh_key, create_by, create_time, update_by, update_time)
values(#{codeConfig.codeRepoName}, #{codeConfig.codeRepoVis}, #{codeConfig.gitUrl}, #{codeConfig.gitBranch}, #{codeConfig.verifyMode}, #{codeConfig.gitUserName}, #{codeConfig.gitPassword},
#{codeConfig.sshKey}, #{codeConfig.createBy}, #{codeConfig.createTime}, #{codeConfig.updateBy}, #{codeConfig.updateTime})
insert into code_config(code_repo_name, code_repo_vis, git_url, git_branch, verify_mode, git_user_name,
git_password, ssh_key, create_by, create_time, update_by, update_time)
values (#{codeConfig.codeRepoName}, #{codeConfig.codeRepoVis}, #{codeConfig.gitUrl}, #{codeConfig.gitBranch},
#{codeConfig.verifyMode}, #{codeConfig.gitUserName}, #{codeConfig.gitPassword},
#{codeConfig.sshKey}, #{codeConfig.createBy}, #{codeConfig.createTime}, #{codeConfig.updateBy},
#{codeConfig.updateTime})
</insert> </insert>


<update id="update"> <update id="update">
@@ -64,6 +67,13 @@
and state = 1 and state = 1
</select> </select>


<select id="queryByCodeRepoName" resultType="java.lang.Long">
select id
from code_config
where code_repo_name = #{codeRepoName}
and state = 1
</select>

<sql id="common_condition"> <sql id="common_condition">
<where> <where>
state = 1 state = 1


+ 1
- 0
ruoyi-modules/management-platform/src/main/resources/mapper/managementPlatform/ImageVersionDaoMapper.xml View File

@@ -15,6 +15,7 @@
<result property="updateBy" column="update_by" jdbcType="VARCHAR"/> <result property="updateBy" column="update_by" jdbcType="VARCHAR"/>
<result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/> <result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
<result property="state" column="state" jdbcType="INTEGER"/> <result property="state" column="state" jdbcType="INTEGER"/>
<result property="hostIp" column="host_ip" jdbcType="VARCHAR"/>
</resultMap> </resultMap>


<!--根据模型id返回版本列表--> <!--根据模型id返回版本列表-->


+ 3
- 1
ruoyi-modules/ruoyi-file/src/main/resources/bootstrap.yml View File

@@ -22,4 +22,6 @@ spring:
file-extension: yml file-extension: yml
# 共享配置 # 共享配置
shared-configs: shared-configs:
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
- data-id: application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
group: DEFAULT_GROUP
refresh: true

+ 3
- 1
ruoyi-modules/ruoyi-gen/src/main/resources/bootstrap.yml View File

@@ -22,4 +22,6 @@ spring:
file-extension: yml file-extension: yml
# 共享配置 # 共享配置
shared-configs: shared-configs:
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
- data-id: application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
group: DEFAULT_GROUP
refresh: true

+ 6
- 1
ruoyi-modules/ruoyi-job/src/main/resources/bootstrap.yml View File

@@ -22,4 +22,9 @@ spring:
file-extension: yml file-extension: yml
# 共享配置 # 共享配置
shared-configs: shared-configs:
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
- data-id: application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
group: DEFAULT_GROUP
refresh: true
- data-id: ${spring.application.name}-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
group: DEFAULT_GROUP
refresh: true

+ 2
- 1
ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysUserController.java View File

@@ -156,7 +156,8 @@ public class SysUserController extends BaseController {
userService.checkUserDataScope(userId); userService.checkUserDataScope(userId);
AjaxResult ajax = AjaxResult.success(); AjaxResult ajax = AjaxResult.success();
List<SysRole> roles = roleService.selectRoleAll(); List<SysRole> roles = roleService.selectRoleAll();
ajax.put("roles", SysUser.isAdmin(userId) ? roles : roles.stream().filter(r -> !r.isAdmin()).collect(Collectors.toList()));
ajax.put("roles", roles);
// ajax.put("roles", SysUser.isAdmin(userId) ? roles : roles.stream().filter(r -> !r.isAdmin()).collect(Collectors.toList()));
ajax.put("posts", postService.selectPostAll()); ajax.put("posts", postService.selectPostAll());
if (StringUtils.isNotNull(userId)) { if (StringUtils.isNotNull(userId)) {
SysUser sysUser = userService.selectUserById(userId); SysUser sysUser = userService.selectUserById(userId);


+ 3
- 1
ruoyi-modules/ruoyi-system/src/main/resources/bootstrap.yml View File

@@ -22,4 +22,6 @@ spring:
file-extension: yml file-extension: yml
# 共享配置 # 共享配置
shared-configs: shared-configs:
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
- data-id: application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
group: DEFAULT_GROUP
refresh: true

+ 200
- 175
ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml View File

@@ -1,52 +1,54 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper <!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.system.mapper.SysUserMapper"> <mapper namespace="com.ruoyi.system.mapper.SysUserMapper">


<resultMap type="SysUser" id="SysUserResult"> <resultMap type="SysUser" id="SysUserResult">
<id property="userId" column="user_id" />
<result property="deptId" column="dept_id" />
<result property="userName" column="user_name" />
<result property="nickName" column="nick_name" />
<result property="email" column="email" />
<result property="phonenumber" column="phonenumber" />
<result property="sex" column="sex" />
<result property="avatar" column="avatar" />
<result property="password" column="password" />
<result property="status" column="status" />
<result property="delFlag" column="del_flag" />
<result property="loginIp" column="login_ip" />
<result property="loginDate" column="login_date" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
<result property="remark" column="remark" />
<association property="dept" javaType="SysDept" resultMap="deptResult" />
<collection property="roles" javaType="java.util.List" resultMap="RoleResult" />
<id property="userId" column="user_id"/>
<result property="deptId" column="dept_id"/>
<result property="userName" column="user_name"/>
<result property="nickName" column="nick_name"/>
<result property="email" column="email"/>
<result property="phonenumber" column="phonenumber"/>
<result property="sex" column="sex"/>
<result property="avatar" column="avatar"/>
<result property="password" column="password"/>
<result property="status" column="status"/>
<result property="delFlag" column="del_flag"/>
<result property="loginIp" column="login_ip"/>
<result property="loginDate" column="login_date"/>
<result property="createBy" column="create_by"/>
<result property="createTime" column="create_time"/>
<result property="updateBy" column="update_by"/>
<result property="updateTime" column="update_time"/>
<result property="remark" column="remark"/>
<result property="gitLinkUsername" column="git_link_username"/>
<result property="gitLinkPassword" column="git_link_password"/>
<association property="dept" javaType="SysDept" resultMap="deptResult"/>
<collection property="roles" javaType="java.util.List" resultMap="RoleResult"/>
</resultMap> </resultMap>
<resultMap id="deptResult" type="SysDept"> <resultMap id="deptResult" type="SysDept">
<id property="deptId" column="dept_id" />
<result property="parentId" column="parent_id" />
<result property="deptName" column="dept_name" />
<result property="ancestors" column="ancestors" />
<result property="orderNum" column="order_num" />
<result property="leader" column="leader" />
<result property="status" column="dept_status" />
<id property="deptId" column="dept_id"/>
<result property="parentId" column="parent_id"/>
<result property="deptName" column="dept_name"/>
<result property="ancestors" column="ancestors"/>
<result property="orderNum" column="order_num"/>
<result property="leader" column="leader"/>
<result property="status" column="dept_status"/>
</resultMap> </resultMap>
<resultMap id="RoleResult" type="SysRole"> <resultMap id="RoleResult" type="SysRole">
<id property="roleId" column="role_id" />
<result property="roleName" column="role_name" />
<result property="roleKey" column="role_key" />
<result property="roleSort" column="role_sort" />
<result property="dataScope" column="data_scope" />
<result property="status" column="role_status" />
<id property="roleId" column="role_id"/>
<result property="roleName" column="role_name"/>
<result property="roleKey" column="role_key"/>
<result property="roleSort" column="role_sort"/>
<result property="dataScope" column="data_scope"/>
<result property="status" column="role_status"/>
</resultMap> </resultMap>
<sql id="selectUserVo">
<sql id="selectUserVo">
select u.user_id, select u.user_id,
u.dept_id, u.dept_id,
u.user_name, u.user_name,
@@ -83,9 +85,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
left join sys_user_role ur on u.user_id = ur.user_id left join sys_user_role ur on u.user_id = ur.user_id
left join sys_role r on r.role_id = ur.role_id left join sys_role r on r.role_id = ur.role_id
</sql> </sql>
<select id="selectUserList" parameterType="SysUser" resultMap="SysUserResult"> <select id="selectUserList" parameterType="SysUser" resultMap="SysUserResult">
select u.user_id, u.dept_id, u.nick_name, u.user_name, u.email, u.avatar, u.phonenumber, u.sex, u.status, u.git_link_username,
select u.user_id, u.dept_id, u.nick_name, u.user_name, u.email, u.avatar, u.phonenumber, u.sex, u.status,
u.git_link_username,
u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark, d.dept_name, d.leader u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark, d.dept_name, d.leader
from sys_user u from sys_user u
left join sys_dept d on u.dept_id = d.dept_id left join sys_dept d on u.dept_id = d.dept_id
@@ -115,63 +118,73 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<!-- 数据范围过滤 --> <!-- 数据范围过滤 -->
${params.dataScope} ${params.dataScope}
</select> </select>
<select id="selectAllocatedList" parameterType="SysUser" resultMap="SysUserResult">
select distinct u.user_id, u.dept_id, u.user_name, u.nick_name, u.email, u.phonenumber, u.status, u.create_time
from sys_user u
left join sys_dept d on u.dept_id = d.dept_id
left join sys_user_role ur on u.user_id = ur.user_id
left join sys_role r on r.role_id = ur.role_id
where u.del_flag = '0' and r.role_id = #{roleId}
<if test="userName != null and userName != ''">
AND u.user_name like concat('%', #{userName}, '%')
</if>
<if test="phonenumber != null and phonenumber != ''">
AND u.phonenumber like concat('%', #{phonenumber}, '%')
</if>
<!-- 数据范围过滤 -->
${params.dataScope}
</select>
<select id="selectUnallocatedList" parameterType="SysUser" resultMap="SysUserResult">
select distinct u.user_id, u.dept_id, u.user_name, u.nick_name, u.email, u.phonenumber, u.status, u.create_time
from sys_user u
left join sys_dept d on u.dept_id = d.dept_id
left join sys_user_role ur on u.user_id = ur.user_id
left join sys_role r on r.role_id = ur.role_id
where u.del_flag = '0' and (r.role_id != #{roleId} or r.role_id IS NULL)
and u.user_id not in (select u.user_id from sys_user u inner join sys_user_role ur on u.user_id = ur.user_id and ur.role_id = #{roleId})
<if test="userName != null and userName != ''">
AND u.user_name like concat('%', #{userName}, '%')
</if>
<if test="phonenumber != null and phonenumber != ''">
AND u.phonenumber like concat('%', #{phonenumber}, '%')
</if>
<!-- 数据范围过滤 -->
${params.dataScope}
</select>
<select id="selectUserByUserName" parameterType="String" resultMap="SysUserResult">
<include refid="selectUserVo"/>
where u.user_name = #{userName} and u.del_flag = '0'
</select>
<select id="selectUserById" parameterType="Long" resultMap="SysUserResult">
<include refid="selectUserVo"/>
where u.user_id = #{userId}
</select>
<select id="checkUserNameUnique" parameterType="String" resultMap="SysUserResult">
select user_id, user_name from sys_user where user_name = #{userName} and del_flag = '0' limit 1
</select>
<select id="checkPhoneUnique" parameterType="String" resultMap="SysUserResult">
select user_id, phonenumber from sys_user where phonenumber = #{phonenumber} and del_flag = '0' limit 1
</select>
<select id="checkEmailUnique" parameterType="String" resultMap="SysUserResult">
select user_id, email from sys_user where email = #{email} and del_flag = '0' limit 1
</select>

<select id="selectAllocatedList" parameterType="SysUser" resultMap="SysUserResult">
select distinct u.user_id, u.dept_id, u.user_name, u.nick_name, u.email, u.phonenumber, u.status, u.create_time, u.git_link_username
from sys_user u
left join sys_dept d on u.dept_id = d.dept_id
left join sys_user_role ur on u.user_id = ur.user_id
left join sys_role r on r.role_id = ur.role_id
where u.del_flag = '0' and r.role_id = #{roleId}
<if test="userName != null and userName != ''">
AND u.user_name like concat('%', #{userName}, '%')
</if>
<if test="phonenumber != null and phonenumber != ''">
AND u.phonenumber like concat('%', #{phonenumber}, '%')
</if>
<!-- 数据范围过滤 -->
${params.dataScope}
</select>

<select id="selectUnallocatedList" parameterType="SysUser" resultMap="SysUserResult">
select distinct u.user_id, u.dept_id, u.user_name, u.nick_name, u.email, u.phonenumber, u.status, u.create_time ,u.git_link_username
from sys_user u
left join sys_dept d on u.dept_id = d.dept_id
left join sys_user_role ur on u.user_id = ur.user_id
left join sys_role r on r.role_id = ur.role_id
where u.del_flag = '0' and (r.role_id != #{roleId} or r.role_id IS NULL)
and u.user_id not in (select u.user_id from sys_user u inner join sys_user_role ur on u.user_id = ur.user_id and
ur.role_id = #{roleId})
<if test="userName != null and userName != ''">
AND u.user_name like concat('%', #{userName}, '%')
</if>
<if test="phonenumber != null and phonenumber != ''">
AND u.phonenumber like concat('%', #{phonenumber}, '%')
</if>
<!-- 数据范围过滤 -->
${params.dataScope}
</select>

<select id="selectUserByUserName" parameterType="String" resultMap="SysUserResult">
<include refid="selectUserVo"/>
where u.user_name = #{userName} and u.del_flag = '0'
</select>

<select id="selectUserById" parameterType="Long" resultMap="SysUserResult">
<include refid="selectUserVo"/>
where u.user_id = #{userId}
</select>

<select id="checkUserNameUnique" parameterType="String" resultMap="SysUserResult">
select user_id, user_name
from sys_user
where user_name = #{userName}
and del_flag = '0' limit 1
</select>

<select id="checkPhoneUnique" parameterType="String" resultMap="SysUserResult">
select user_id, phonenumber
from sys_user
where phonenumber = #{phonenumber}
and del_flag = '0' limit 1
</select>

<select id="checkEmailUnique" parameterType="String" resultMap="SysUserResult">
select user_id, email
from sys_user
where email = #{email}
and del_flag = '0' limit 1
</select>


<select id="checktGitLinkUsernameUnique" resultType="com.ruoyi.system.api.domain.SysUser"> <select id="checktGitLinkUsernameUnique" resultType="com.ruoyi.system.api.domain.SysUser">
select user_id, git_link_username select user_id, git_link_username
@@ -181,81 +194,93 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select> </select>


<insert id="insertUser" parameterType="SysUser" useGeneratedKeys="true" keyProperty="userId"> <insert id="insertUser" parameterType="SysUser" useGeneratedKeys="true" keyProperty="userId">
insert into sys_user(
<if test="userId != null and userId != 0">user_id,</if>
<if test="deptId != null and deptId != 0">dept_id,</if>
<if test="userName != null and userName != ''">user_name,</if>
<if test="nickName != null and nickName != ''">nick_name,</if>
<if test="email != null and email != ''">email,</if>
<if test="avatar != null and avatar != ''">avatar,</if>
<if test="phonenumber != null and phonenumber != ''">phonenumber,</if>
<if test="sex != null and sex != ''">sex,</if>
<if test="password != null and password != ''">password,</if>
<if test="status != null and status != ''">status,</if>
<if test="createBy != null and createBy != ''">create_by,</if>
<if test="remark != null and remark != ''">remark,</if>
create_time
)values(
<if test="userId != null and userId != ''">#{userId},</if>
<if test="deptId != null and deptId != ''">#{deptId},</if>
<if test="userName != null and userName != ''">#{userName},</if>
<if test="nickName != null and nickName != ''">#{nickName},</if>
<if test="email != null and email != ''">#{email},</if>
<if test="avatar != null and avatar != ''">#{avatar},</if>
<if test="phonenumber != null and phonenumber != ''">#{phonenumber},</if>
<if test="sex != null and sex != ''">#{sex},</if>
<if test="password != null and password != ''">#{password},</if>
<if test="status != null and status != ''">#{status},</if>
<if test="createBy != null and createBy != ''">#{createBy},</if>
<if test="remark != null and remark != ''">#{remark},</if>
sysdate()
)
</insert>
<update id="updateUser" parameterType="SysUser">
update sys_user
<set>
<if test="deptId != null and deptId != 0">dept_id = #{deptId},</if>
<if test="userName != null and userName != ''">user_name = #{userName},</if>
<if test="nickName != null and nickName != ''">nick_name = #{nickName},</if>
<if test="email != null ">email = #{email},</if>
<if test="phonenumber != null ">phonenumber = #{phonenumber},</if>
<if test="sex != null and sex != ''">sex = #{sex},</if>
<if test="avatar != null and avatar != ''">avatar = #{avatar},</if>
<if test="password != null and password != ''">password = #{password},</if>
<if test="status != null and status != ''">status = #{status},</if>
<if test="loginIp != null and loginIp != ''">login_ip = #{loginIp},</if>
<if test="loginDate != null">login_date = #{loginDate},</if>
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
<if test="remark != null">remark = #{remark},</if>
<if test="gitLinkUsername != null and gitLinkUsername != ''">git_link_username = #{gitLinkUsername},</if>
<if test="gitLinkPassword != null and gitLinkPassword != ''">git_link_password = #{gitLinkPassword},</if>
update_time = sysdate()
</set>
where user_id = #{userId}
</update>
<update id="updateUserStatus" parameterType="SysUser">
update sys_user set status = #{status} where user_id = #{userId}
</update>
<update id="updateUserAvatar" parameterType="SysUser">
update sys_user set avatar = #{avatar} where user_name = #{userName}
</update>
<update id="resetUserPwd" parameterType="SysUser">
update sys_user set password = #{password} where user_name = #{userName}
</update>
<delete id="deleteUserById" parameterType="Long">
update sys_user set del_flag = '2' where user_id = #{userId}
</delete>
<delete id="deleteUserByIds" parameterType="Long">
update sys_user set del_flag = '2' where user_id in
<foreach collection="array" item="userId" open="(" separator="," close=")">
#{userId}
</foreach>
</delete>
insert into sys_user(
<if test="userId != null and userId != 0">user_id,</if>
<if test="deptId != null and deptId != 0">dept_id,</if>
<if test="userName != null and userName != ''">user_name,</if>
<if test="nickName != null and nickName != ''">nick_name,</if>
<if test="email != null and email != ''">email,</if>
<if test="avatar != null and avatar != ''">avatar,</if>
<if test="phonenumber != null and phonenumber != ''">phonenumber,</if>
<if test="sex != null and sex != ''">sex,</if>
<if test="password != null and password != ''">password,</if>
<if test="status != null and status != ''">status,</if>
<if test="createBy != null and createBy != ''">create_by,</if>
<if test="remark != null and remark != ''">remark,</if>
<if test="remark != null and remark != ''">git_link_username,</if>
<if test="remark != null and remark != ''">git_link_password,</if>
create_time
)values(
<if test="userId != null and userId != ''">#{userId},</if>
<if test="deptId != null and deptId != ''">#{deptId},</if>
<if test="userName != null and userName != ''">#{userName},</if>
<if test="nickName != null and nickName != ''">#{nickName},</if>
<if test="email != null and email != ''">#{email},</if>
<if test="avatar != null and avatar != ''">#{avatar},</if>
<if test="phonenumber != null and phonenumber != ''">#{phonenumber},</if>
<if test="sex != null and sex != ''">#{sex},</if>
<if test="password != null and password != ''">#{password},</if>
<if test="status != null and status != ''">#{status},</if>
<if test="createBy != null and createBy != ''">#{createBy},</if>
<if test="remark != null and remark != ''">#{remark},</if>
<if test="gitLinkUsername != null and gitLinkUsername != ''">#{gitLinkUsername},</if>
<if test="gitLinkPassword != null and gitLinkPassword != ''">#{gitLinkPassword},</if>
sysdate()
)
</insert>

<update id="updateUser" parameterType="SysUser">
update sys_user
<set>
<if test="deptId != null and deptId != 0">dept_id = #{deptId},</if>
<if test="userName != null and userName != ''">user_name = #{userName},</if>
<if test="nickName != null and nickName != ''">nick_name = #{nickName},</if>
<if test="email != null ">email = #{email},</if>
<if test="phonenumber != null ">phonenumber = #{phonenumber},</if>
<if test="sex != null and sex != ''">sex = #{sex},</if>
<if test="avatar != null and avatar != ''">avatar = #{avatar},</if>
<if test="password != null and password != ''">password = #{password},</if>
<if test="status != null and status != ''">status = #{status},</if>
<if test="loginIp != null and loginIp != ''">login_ip = #{loginIp},</if>
<if test="loginDate != null">login_date = #{loginDate},</if>
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
<if test="remark != null">remark = #{remark},</if>
<if test="gitLinkUsername != null and gitLinkUsername != ''">git_link_username = #{gitLinkUsername},</if>
<if test="gitLinkPassword != null and gitLinkPassword != ''">git_link_password = #{gitLinkPassword},</if>
update_time = sysdate()
</set>
where user_id = #{userId}
</update>

<update id="updateUserStatus" parameterType="SysUser">
update sys_user
set status = #{status}
where user_id = #{userId}
</update>

<update id="updateUserAvatar" parameterType="SysUser">
update sys_user
set avatar = #{avatar}
where user_name = #{userName}
</update>

<update id="resetUserPwd" parameterType="SysUser">
update sys_user
set password = #{password}
where user_name = #{userName}
</update>

<delete id="deleteUserById" parameterType="Long">
update sys_user
set del_flag = '2'
where user_id = #{userId}
</delete>

<delete id="deleteUserByIds" parameterType="Long">
update sys_user set del_flag = '2' where user_id in
<foreach collection="array" item="userId" open="(" separator="," close=")">
#{userId}
</foreach>
</delete>

</mapper> </mapper>

+ 7
- 1
ruoyi-visual/ruoyi-monitor/src/main/resources/bootstrap.yml View File

@@ -15,6 +15,10 @@ spring:
discovery: discovery:
# 服务注册地址 # 服务注册地址
server-addr: nacos-ci4s.ci4s-test.svc:8848 server-addr: nacos-ci4s.ci4s-test.svc:8848
username: nacos
password: nacos
retry:
enabled: true
config: config:
# 配置中心地址 # 配置中心地址
server-addr: nacos-ci4s.ci4s-test.svc:8848 server-addr: nacos-ci4s.ci4s-test.svc:8848
@@ -22,4 +26,6 @@ spring:
file-extension: yml file-extension: yml
# 共享配置 # 共享配置
shared-configs: shared-configs:
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
- data-id: application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
group: DEFAULT_GROUP
refresh: true

Loading…
Cancel
Save