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
This commit is contained in:
commit
7312b56df9
|
@ -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: '';
|
||||
}
|
||||
}
|
|
@ -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;
|
|
@ -22,4 +22,9 @@ spring:
|
|||
file-extension: yml
|
||||
# 共享配置
|
||||
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
|
|
@ -22,7 +22,12 @@ spring:
|
|||
file-extension: yml
|
||||
# 共享配置
|
||||
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:
|
||||
# 取消控制台懒加载
|
||||
eager: true
|
||||
|
|
|
@ -31,10 +31,12 @@ public class CodeConfigController extends BaseController {
|
|||
@GetMapping
|
||||
public GenericsAjaxResult<Page<CodeConfig>> queryByPage(@RequestParam("page") int page,
|
||||
@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);
|
||||
CodeConfig codeConfig = new CodeConfig();
|
||||
codeConfig.setCodeRepoName(codeRepoName);
|
||||
codeConfig.setCodeRepoVis(codeRepoVis);
|
||||
return genericsSuccess(this.codeConfigService.queryByPage(codeConfig, pageRequest));
|
||||
}
|
||||
|
||||
|
@ -45,8 +47,8 @@ public class CodeConfigController extends BaseController {
|
|||
* @return 单条数据
|
||||
*/
|
||||
@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));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ public class ImageController extends BaseController {
|
|||
@RequestParam("size") int size,
|
||||
@RequestParam(value = "image_type") int imageType) {
|
||||
image.setImageType(imageType);
|
||||
PageRequest pageRequest = PageRequest.of(page,size);
|
||||
PageRequest pageRequest = PageRequest.of(page, size);
|
||||
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) {
|
||||
return genericsSuccess(this.imageService.queryByName(name));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增数据
|
||||
*
|
||||
|
@ -84,9 +85,8 @@ public class ImageController extends BaseController {
|
|||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param imageVo 实体
|
||||
* 新增镜像和版本 @PostMapping
|
||||
* 新增镜像和版本 @PostMapping
|
||||
* @return 新增结果
|
||||
*/
|
||||
@PostMapping("/addImageAndVersion")
|
||||
|
@ -122,21 +122,20 @@ public class ImageController extends BaseController {
|
|||
@PostMapping("/net")
|
||||
@ApiOperation("从网络上传构建镜像")
|
||||
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")
|
||||
@ApiOperation("从本地上传构建镜像")
|
||||
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")
|
||||
@ApiOperation(value = "上传镜像文件", notes = "上传镜像tar包,返回存储路径")
|
||||
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")
|
||||
@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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.ruoyi.platform.domain;
|
|||
import com.fasterxml.jackson.databind.PropertyNamingStrategy;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonNaming;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
import java.io.Serializable;
|
||||
|
@ -14,6 +15,7 @@ import java.io.Serializable;
|
|||
* @since 2024-03-05 15:00:02
|
||||
*/
|
||||
@JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy.class)
|
||||
@Data
|
||||
public class ImageVersion implements Serializable {
|
||||
private static final long serialVersionUID = 251017725389874890L;
|
||||
/**
|
||||
|
@ -56,102 +58,7 @@ public class ImageVersion implements Serializable {
|
|||
@ApiModelProperty(value = "状态,0失效,1生效")
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -14,6 +14,8 @@ public interface CodeConfigDao {
|
|||
|
||||
CodeConfig queryById(Long id);
|
||||
|
||||
Long queryByCodeRepoName(@Param("codeRepoName") String codeRepoName);
|
||||
|
||||
int insert(@Param("codeConfig") CodeConfig codeConfig);
|
||||
|
||||
int update(@Param("codeConfig") CodeConfig codeConfig);
|
||||
|
|
|
@ -93,5 +93,5 @@ public interface ImageService {
|
|||
Map<String, String> createImageFromNet(String imageName, String imageTag, String NetPath) throws Exception;
|
||||
Map<String, String> uploadImageFiles(MultipartFile file) throws Exception;
|
||||
|
||||
String saveImage(ImageVo imageVo);
|
||||
void saveImage(ImageVo imageVo);
|
||||
}
|
||||
|
|
|
@ -38,6 +38,10 @@ public class CodeConfigServiceImpl implements CodeConfigService {
|
|||
|
||||
@Override
|
||||
public CodeConfig insert(CodeConfig codeConfig) {
|
||||
Long id = this.codeConfigDao.queryByCodeRepoName(codeConfig.getCodeRepoName());
|
||||
if(id != null){
|
||||
throw new IllegalStateException("代码仓库名称已存在");
|
||||
}
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
codeConfig.setCreateBy(loginUser.getUsername());
|
||||
codeConfig.setUpdateBy(loginUser.getUsername());
|
||||
|
@ -49,6 +53,10 @@ public class CodeConfigServiceImpl implements CodeConfigService {
|
|||
|
||||
@Override
|
||||
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();
|
||||
codeConfig.setUpdateBy(loginUser.getUsername());
|
||||
|
|
|
@ -32,6 +32,7 @@ import org.springframework.web.multipart.MultipartFile;
|
|||
import javax.annotation.Resource;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
|
@ -85,6 +86,7 @@ public class ImageServiceImpl implements ImageService {
|
|||
private String pvcName;
|
||||
@Value("${jupyter.namespace}")
|
||||
private String namespace;
|
||||
|
||||
/**
|
||||
* 通过ID查询单条数据
|
||||
*
|
||||
|
@ -99,8 +101,8 @@ public class ImageServiceImpl implements ImageService {
|
|||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param image 筛选条件
|
||||
* @param pageRequest 分页对象
|
||||
* @param image 筛选条件
|
||||
* @param pageRequest 分页对象
|
||||
* @return 查询结果
|
||||
*/
|
||||
@Override
|
||||
|
@ -110,7 +112,6 @@ public class ImageServiceImpl implements ImageService {
|
|||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 新增数据
|
||||
*
|
||||
|
@ -138,7 +139,7 @@ public class ImageServiceImpl implements ImageService {
|
|||
@Override
|
||||
public Image update(Image image) {
|
||||
int currentState = image.getState();
|
||||
if(currentState == 0){
|
||||
if (currentState == 0) {
|
||||
throw new RuntimeException("镜像已被删除,无法更新。");
|
||||
}
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
|
@ -163,7 +164,7 @@ public class ImageServiceImpl implements ImageService {
|
|||
@Override
|
||||
public String removeById(Integer id) throws Exception {
|
||||
Image image = this.imageDao.queryById(id);
|
||||
if (image == null){
|
||||
if (image == null) {
|
||||
throw new Exception("镜像不存在");
|
||||
}
|
||||
|
||||
|
@ -173,14 +174,20 @@ public class ImageServiceImpl implements ImageService {
|
|||
|
||||
|
||||
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("无权限删除该镜像");
|
||||
}
|
||||
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);
|
||||
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 {
|
||||
Image existingImage = getByName(imageVo.getName());
|
||||
Image imageToUse;
|
||||
if(existingImage == null) {
|
||||
if (existingImage == null) {
|
||||
// 如果不存在相同名称的镜像,则创建新的镜像记录
|
||||
Image newImage = new Image();
|
||||
newImage.setName(imageVo.getName());
|
||||
|
@ -217,7 +224,7 @@ public class ImageServiceImpl implements ImageService {
|
|||
if (imageToUse == null) {
|
||||
throw new Exception("新增镜像失败");
|
||||
}
|
||||
}else{
|
||||
} else {
|
||||
// 如果已存在相同名称的镜像,使用已存在的镜像
|
||||
imageToUse = existingImage;
|
||||
}
|
||||
|
@ -235,9 +242,9 @@ public class ImageServiceImpl implements ImageService {
|
|||
CompletableFuture.supplyAsync(() -> {
|
||||
Map<String, String> resultMap = new HashMap<>();
|
||||
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());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
@ -246,7 +253,7 @@ public class ImageServiceImpl implements ImageService {
|
|||
throw new RuntimeException("镜像构建失败: " + e.getMessage(), e);
|
||||
}
|
||||
return resultMap;
|
||||
}).thenAccept(resultMap ->{
|
||||
}).thenAccept(resultMap -> {
|
||||
try {
|
||||
String imageUrl = resultMap.get("url");
|
||||
String fileSize = resultMap.get("fileSize");
|
||||
|
@ -272,27 +279,27 @@ public class ImageServiceImpl implements ImageService {
|
|||
// 得到容器
|
||||
V1Pod pod = k8sClientUtil.getNSPodList(serviceNS, deploymentName);
|
||||
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
|
||||
String loginlog = k8sClientUtil.executeCommand(pod,loginCmd);
|
||||
String loginlog = k8sClientUtil.executeCommand(pod, loginCmd);
|
||||
// 在这个容器的/data/admin 目录下执行命令 docker load -i fileName 得到返回的镜像名字name:tag
|
||||
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
|
||||
if (StringUtils.isNoneBlank(logs2)){
|
||||
if (StringUtils.isNoneBlank(logs2)) {
|
||||
String[] lines = logs2.split("\n");
|
||||
String lastLine = lines[lines.length - 1].trim();
|
||||
String tagCmd = "docker tag " + lastLine + " " + 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 s = k8sClientUtil.executeCommand(pod, tagCmd);
|
||||
|
||||
if (StringUtils.isNotEmpty(k8sClientUtil.executeCommand(pod, pushCmd))){
|
||||
if (StringUtils.isNotEmpty(k8sClientUtil.executeCommand(pod, pushCmd))) {
|
||||
resultMap.put("url", imageUrl);
|
||||
//得到镜像文件大小
|
||||
String imageSizeStr = k8sClientUtil.executeCommand(pod, sizeCmd);
|
||||
|
@ -301,10 +308,10 @@ public class ImageServiceImpl implements ImageService {
|
|||
resultMap.put("fileSize", formattedImageSize);
|
||||
return resultMap;
|
||||
|
||||
}else {
|
||||
} else {
|
||||
throw new Exception("拉取公网镜像失败,请检查网络或者镜像地址");
|
||||
}
|
||||
}else {
|
||||
} else {
|
||||
throw new Exception("拉取公网镜像失败,请检查网络或者镜像地址");
|
||||
}
|
||||
}
|
||||
|
@ -315,27 +322,27 @@ public class ImageServiceImpl implements ImageService {
|
|||
// 得到容器
|
||||
V1Pod pod = k8sClientUtil.getNSPodList(serviceNS, deploymentName);
|
||||
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
|
||||
String loginlog = k8sClientUtil.executeCommand(pod,loginCmd);
|
||||
String loginlog = k8sClientUtil.executeCommand(pod, loginCmd);
|
||||
// 在这个容器的/data/admin 目录下执行命令 docker load -i fileName 得到返回的镜像名字name:tag
|
||||
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
|
||||
|
||||
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 imageUrl = harborUrl + "/" + repository + "/" + username + "/" + imageName + ":" + imageTag;
|
||||
String pushCmd = "docker push " + imageUrl;
|
||||
String pushCmd = "docker push " + imageUrl;
|
||||
String sizeCmd = "docker inspect --format='{{.Size}}' " + imageUrl;
|
||||
String s = k8sClientUtil.executeCommand(pod, tagCmd);
|
||||
if (StringUtils.isNotEmpty(k8sClientUtil.executeCommand(pod, pushCmd))){
|
||||
if (StringUtils.isNotEmpty(k8sClientUtil.executeCommand(pod, pushCmd))) {
|
||||
resultMap.put("url", imageUrl);
|
||||
//得到镜像文件大小
|
||||
String imageSizeStr = k8sClientUtil.executeCommand(pod, sizeCmd);
|
||||
|
@ -343,43 +350,49 @@ public class ImageServiceImpl implements ImageService {
|
|||
String formattedImageSize = FileUtil.formatFileSize(sizeInBytes); // 格式化镜像文件大小
|
||||
resultMap.put("fileSize", formattedImageSize);
|
||||
return resultMap;
|
||||
}else {
|
||||
} else {
|
||||
throw new Exception("解析镜像压缩包失败,请检查镜像文件");
|
||||
}
|
||||
}else {
|
||||
} else {
|
||||
throw new Exception("解析镜像压缩包失败,请检查镜像文件");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public Map<String, String> uploadImageFiles(MultipartFile file) throws Exception {
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
String path = loginUser.getUsername()+"/"+file.getOriginalFilename();
|
||||
String path = loginUser.getUsername() + "/" + file.getOriginalFilename();
|
||||
return minioService.uploadFile(bucketName, path, file);
|
||||
}
|
||||
|
||||
@Override
|
||||
@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();
|
||||
String username = loginUser.getUsername().toLowerCase();
|
||||
String podName = username +"-editor-pod" + "-" + imageVo.getDevEnvironmentId().toString();
|
||||
String podName = username + "-editor-pod" + "-" + imageVo.getDevEnvironmentId().toString();
|
||||
|
||||
try {
|
||||
String containerId = k8sClientUtil.getPodContainerId(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);
|
||||
|
||||
Image image = new Image();
|
||||
BeanUtils.copyProperties(imageVo,image);
|
||||
BeanUtils.copyProperties(imageVo, image);
|
||||
image.setImageType(Constant.Image_Type_Pri);
|
||||
image.setCreateBy(username);
|
||||
image.setUpdateBy(username);
|
||||
|
@ -396,6 +409,7 @@ public class ImageServiceImpl implements ImageService {
|
|||
imageVersion.setFileSize(resultMap.get("size"));
|
||||
imageVersion.setCreateBy(username);
|
||||
imageVersion.setUpdateBy(username);
|
||||
imageVersion.setHostIp(hostIp);
|
||||
imageVersion.setUpdateTime(new Date());
|
||||
imageVersion.setCreateTime(new Date());
|
||||
imageVersion.setState(1);
|
||||
|
@ -407,10 +421,8 @@ public class ImageServiceImpl implements ImageService {
|
|||
devEnvironment.setId(imageVo.getDevEnvironmentId());
|
||||
devEnvironment.setImage(resultMap.get("imageName"));
|
||||
devEnvironmentDao.update(devEnvironment);
|
||||
|
||||
return "保存镜像成功";
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("保存镜像失败:" +e);
|
||||
throw new RuntimeException("保存镜像失败:" + e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -106,4 +106,9 @@ public class DockerClientUtil {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
public void removeImage(String imageName, String hostIp){
|
||||
DockerClient dockerClient = getDockerClient(hostIp);
|
||||
dockerClient.removeImageCmd(imageName).withForce(true).exec();
|
||||
}
|
||||
}
|
|
@ -501,9 +501,9 @@ public class K8sClientUtil {
|
|||
computingResourceDao.updateUsedStateByNode(nodeName, Constant.Used_State_used);
|
||||
}
|
||||
} catch (ApiException e) {
|
||||
log.error("创建pod异常:" + e.getResponseBody(), e);
|
||||
throw new RuntimeException("创建pod异常:" + e.getResponseBody());
|
||||
} catch (Exception e) {
|
||||
log.error("创建pod系统异常:", e);
|
||||
throw new RuntimeException("创建pod系统异常:", e);
|
||||
}
|
||||
|
||||
V1Service service = createService(namespace, podName + "-svc", port, selector);
|
||||
|
|
|
@ -22,4 +22,9 @@ spring:
|
|||
file-extension: yml
|
||||
# 共享配置
|
||||
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
|
|
@ -3,9 +3,12 @@
|
|||
<mapper namespace="com.ruoyi.platform.mapper.CodeConfigDao">
|
||||
|
||||
<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>
|
||||
|
||||
<update id="update">
|
||||
|
@ -64,6 +67,13 @@
|
|||
and state = 1
|
||||
</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">
|
||||
<where>
|
||||
state = 1
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
<result property="updateBy" column="update_by" jdbcType="VARCHAR"/>
|
||||
<result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
|
||||
<result property="state" column="state" jdbcType="INTEGER"/>
|
||||
<result property="hostIp" column="host_ip" jdbcType="VARCHAR"/>
|
||||
</resultMap>
|
||||
|
||||
<!--根据模型id返回版本列表-->
|
||||
|
|
|
@ -22,4 +22,6 @@ spring:
|
|||
file-extension: yml
|
||||
# 共享配置
|
||||
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
|
||||
|
|
|
@ -22,4 +22,6 @@ spring:
|
|||
file-extension: yml
|
||||
# 共享配置
|
||||
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
|
||||
|
|
|
@ -22,4 +22,9 @@ spring:
|
|||
file-extension: yml
|
||||
# 共享配置
|
||||
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
|
|
@ -156,7 +156,8 @@ public class SysUserController extends BaseController {
|
|||
userService.checkUserDataScope(userId);
|
||||
AjaxResult ajax = AjaxResult.success();
|
||||
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());
|
||||
if (StringUtils.isNotNull(userId)) {
|
||||
SysUser sysUser = userService.selectUserById(userId);
|
||||
|
|
|
@ -22,4 +22,6 @@ spring:
|
|||
file-extension: yml
|
||||
# 共享配置
|
||||
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
|
||||
|
|
|
@ -1,52 +1,54 @@
|
|||
<?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">
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.ruoyi.system.mapper.SysUserMapper">
|
||||
|
||||
<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 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 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>
|
||||
|
||||
<sql id="selectUserVo">
|
||||
|
||||
<sql id="selectUserVo">
|
||||
select u.user_id,
|
||||
u.dept_id,
|
||||
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_role r on r.role_id = ur.role_id
|
||||
</sql>
|
||||
|
||||
|
||||
<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
|
||||
from sys_user u
|
||||
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}
|
||||
</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 user_id, git_link_username
|
||||
|
@ -181,81 +194,93 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
</select>
|
||||
|
||||
<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>
|
|
@ -15,6 +15,10 @@ spring:
|
|||
discovery:
|
||||
# 服务注册地址
|
||||
server-addr: nacos-ci4s.ci4s-test.svc:8848
|
||||
username: nacos
|
||||
password: nacos
|
||||
retry:
|
||||
enabled: true
|
||||
config:
|
||||
# 配置中心地址
|
||||
server-addr: nacos-ci4s.ci4s-test.svc:8848
|
||||
|
@ -22,4 +26,6 @@ spring:
|
|||
file-extension: yml
|
||||
# 共享配置
|
||||
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…
Reference in New Issue