Skip to content

Commit

Permalink
feat: 新增[运维管理:上传文件部署]完成
Browse files Browse the repository at this point in the history
  • Loading branch information
xaopohi committed Jan 10, 2023
1 parent 086900f commit 6d44e59
Show file tree
Hide file tree
Showing 17 changed files with 412 additions and 148 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,10 @@ public R<List<BaseErrDto>> add(@Validated @RequestBody CreateOraDeployVo createO
@PutMapping
@PreAuthorize("@eh.check('operation:oraDeploy:edit')")
public R<List<BaseErrDto>> edit(@Validated @RequestBody ValidList<UpdateOraDeployVo> updateOraDeployList,
BindingResult bindingResult){
BindingResult bindingResult,List<UpdateOraDeployVo> updatebeforOraDeployList){
List<BaseErrDto> errDtoList = ValidUtils.getBaseErrDtoByBindingRes(updateOraDeployList, bindingResult);
if (errDtoList.isEmpty()) {
oraDeployService.edit(updateOraDeployList,errDtoList);
oraDeployService.edit(updateOraDeployList,errDtoList,updatebeforOraDeployList);
if (errDtoList.isEmpty()){
return R.ok();
}else {
Expand Down Expand Up @@ -110,18 +110,22 @@ public void download(HttpServletResponse response){
@Log("上传文件部署")
@ApiOperation(value = "上传文件部署")
@PostMapping(value = "/upload")
@PreAuthorize("@el.check('operation:oraDeploy:edit')")
@PreAuthorize("@eh.check('operation:oraDeploy:edit')")
public R uploadDeploy(@RequestBody MultipartFile file, HttpServletRequest request)throws Exception{
Long id = Long.valueOf(request.getParameter("id"));
Long projectid = Long.valueOf(request.getParameter("projectid"));
String fileName = "";
if(file != null){
fileName = file.getOriginalFilename();
File deployFile = new File(FileUtil.getFileDir()+ DateUtil.date() +fileName);
File dir = new File(FileUtil.getFileDir());
File deployFile = new File(FileUtil.getFileDir()+fileName);
if (!dir.exists()&&!dir.isDirectory()) {
dir.mkdirs();
}
FileUtil.del(deployFile);
file.transferTo(deployFile);
//文件下一步要根据文件名字来
oraDeployService.deploy(FileUtil.getFileDir()+ DateUtil.date() +fileName ,id,projectid);
oraDeployService.deploy(FileUtil.getFileDir() +fileName ,id,projectid);
}else{
System.out.println("没有找到相对应的文件");
}
Expand All @@ -134,31 +138,31 @@ public R uploadDeploy(@RequestBody MultipartFile file, HttpServletRequest reques
@Log("系统还原")
@ApiOperation(value = "系统还原")
@PostMapping(value = "/serverReduction")
@PreAuthorize("@el.check('operation:oraDeploy:edit')")
@PreAuthorize("@eh.check('operation:oraDeploy:edit')")
public R serverReduction(@Validated @RequestBody OraDeployHistory resources){
String result = oraDeployService.serverReduction(resources);
return R.ok().setData(result);
}
@Log("服务运行状态")
@ApiOperation(value = "服务运行状态")
@PostMapping(value = "/serverStatus")
@PreAuthorize("@el.check('operation:oraDeploy:edit')")
@PreAuthorize("@eh.check('operation:oraDeploy:edit')")
public R serverStatus(@Validated @RequestBody OraDeploy resources){
String result = oraDeployService.serverStatus(resources);
return R.ok().setData(result);
}
@Log("启动服务")
@ApiOperation(value = "启动服务")
@PostMapping(value = "/startServer")
@PreAuthorize("@el.check('operation:oraDeploy:edit')")
@PreAuthorize("@eh.check('operation:oraDeploy:edit')")
public R startServer(@Validated @RequestBody OraDeploy resources){
String result = oraDeployService.startServer(resources);
return R.ok().setData(result);
}
@Log("停止服务")
@ApiOperation(value = "停止服务")
@PostMapping(value = "/stopServer")
@PreAuthorize("@el.check('operation:oraDeploy:edit')")
@PreAuthorize("@eh.check('operation:oraDeploy:edit')")
public R stopServer(@Validated @RequestBody OraDeploy resources){
String result = oraDeployService.stopServer(resources);
return R.ok().setData(result);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import lombok.Data;

import java.sql.Timestamp;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;

Expand Down Expand Up @@ -52,8 +53,10 @@ public class OraDeploy implements Serializable{
@ApiModelProperty(value = "更新时间")
@ExcelExport("更新时间")
private Timestamp updateTime;


@TableField(exist = false)
private OraApp app;
@TableField(exist = false)
private List<OraServer> server;

private static final long serialVersionUID = 1L;

Expand All @@ -69,8 +72,8 @@ public class OraDeploy implements Serializable{

public static final String COL_UPDATE_TIME = "update_time";

public static final String COL_PROJECT_ID = "project_id";
// public static final String COL_PROJECT_ID = "project_id";

public static final String COL_SERVER_ID = "server_id";
// public static final String COL_SERVER_ID = "server_id";

}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
@TableName(value = "ora_deploy_history")
public class OraDeployHistory implements Serializable{

@TableId(value = "history_id", type = IdType.INPUT)
@TableId(value = "history_id", type = IdType.AUTO)
@ApiModelProperty(value = "ID")
@ExcelExport("id")
private Long id;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package fun.yizhierha.operation.domain;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import fun.yizhierha.common.utils.file.ExcelExport;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.io.Serializable;

@ApiModel(value = "应用管理")
@Data
@TableName(value = "ora_deploy_server")
public class OraDeployServer implements Serializable {
@TableField(value = "deploy_id")
@ApiModelProperty(value = "部署ID")
@ExcelExport("部署ID")
private Long deployId;
@TableField(value = "server_id")
@ApiModelProperty(value = "服务ID")
@ExcelExport("服务ID")
private Long serverId;
@TableField(value = "project_id")
@ApiModelProperty(value = "项目ID")
@ExcelExport("项目ID")
private Long projectId;
}
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ public class OraServer implements Serializable{
@ExcelExport("项目ID")
private Long projectId;

private OraProject project;

private static final long serialVersionUID = 1L;

public static final String COL_SERVER_ID = "server_id";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import lombok.Data;

import javax.validation.constraints.NotNull;
import java.util.List;

@Data
public class CreateOraDeployVo {
Expand All @@ -19,7 +20,7 @@ public class CreateOraDeployVo {
private Long projectId;
@NotNull(message = "新增时[服务器]不能为空")
@ApiModelProperty(value = "服务器")
private Long serverId;
private List<Long> serverId;
@ApiModelProperty(value = "创建者")
private String createBy;
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.util.List;


@EqualsAndHashCode(callSuper = true)
@Data
Expand All @@ -20,7 +22,7 @@ public class UpdateOraDeployVo extends UpdateVo {
private Long projectId;

@ApiModelProperty(value = "服务器")
private Long serverId;
private List<Long> serverId;
@ApiModelProperty("更新者")
private String updateBy;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package fun.yizhierha.operation.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import fun.yizhierha.operation.domain.OraDeployServer;
import org.apache.ibatis.annotations.Mapper;

@Mapper
public interface OraDeployServerMapper extends BaseMapper<OraDeployServer> {
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@
**/
@Mapper
public interface OraServerMapper extends BaseMapper<OraServer>{
public OraServer findByIp(String ip);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package fun.yizhierha.operation.service;

import com.baomidou.mybatisplus.extension.service.IService;
import fun.yizhierha.operation.domain.OraDeployServer;

import java.util.List;

public interface OraDeployServerService extends IService<OraDeployServer> {
boolean save(List<OraDeployServer> vo);

void edit(List<OraDeployServer> editbeforvo, List<OraDeployServer> editaftervo);
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public interface OraDeployService extends IService<OraDeploy>{

void save(CreateOraDeployVo createOraDeployVo);

void edit(ValidList<UpdateOraDeployVo> updateOraDeployVoList, List<BaseErrDto> errDtoList);
void edit(ValidList<UpdateOraDeployVo> updateOraDeployVoList, List<BaseErrDto> errDtoList,List<UpdateOraDeployVo> updatebeforOraDeployList);

void remove(Set<Long> ids);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package fun.yizhierha.operation.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import fun.yizhierha.operation.domain.OraDeploy;
import fun.yizhierha.operation.domain.OraDeployServer;
import fun.yizhierha.operation.mapper.OraDeployServerMapper;
import fun.yizhierha.operation.service.OraDeployServerService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;

@Slf4j
@Service
@RequiredArgsConstructor
public class OraDeployServerServiceImpl extends ServiceImpl<OraDeployServerMapper, OraDeployServer> implements OraDeployServerService {
@Override
public boolean save(List<OraDeployServer> vo) {
this.saveBatch(vo);
return true;
}

@Override
public void edit(List<OraDeployServer> editbeforvo, List<OraDeployServer> editaftervo) {
this.removeBatchByIds(editbeforvo);
this.saveBatch(editaftervo);
}
}
Loading

0 comments on commit 6d44e59

Please sign in to comment.