修改对象存储配置

This commit is contained in:
liyang 2021-08-12 23:13:51 +08:00
parent 8356141a62
commit fc54c77d11
6 changed files with 314 additions and 205 deletions

View File

@ -1,36 +1,34 @@
package com.ruoyi.web.controller.system; package com.ruoyi.web.controller.system;
import java.util.List; import cn.hutool.core.util.ObjectUtil;
import java.util.Arrays; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import java.util.concurrent.TimeUnit;
import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.system.domain.SysOssConfig;
import lombok.RequiredArgsConstructor;
import javax.servlet.http.HttpServletResponse;
import javax.validation.constraints.*;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.validation.annotation.Validated;
import com.ruoyi.common.annotation.RepeatSubmit;
import com.ruoyi.common.annotation.Log; import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.annotation.RepeatSubmit;
import com.ruoyi.common.constant.Constants;
import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.core.validate.AddGroup; import com.ruoyi.common.core.validate.AddGroup;
import com.ruoyi.common.core.validate.EditGroup; import com.ruoyi.common.core.validate.EditGroup;
import com.ruoyi.common.enums.BusinessType; import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil; import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.system.domain.vo.SysOssConfigVo; import com.ruoyi.system.domain.SysOssConfig;
import com.ruoyi.system.domain.bo.SysOssConfigBo; import com.ruoyi.system.domain.bo.SysOssConfigBo;
import com.ruoyi.system.domain.vo.SysOssConfigVo;
import com.ruoyi.system.service.ISysOssConfigService; import com.ruoyi.system.service.ISysOssConfigService;
import com.ruoyi.common.core.page.TableDataInfo;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.util.Arrays;
import java.util.List;
/** /**
* 云存储配置Controller * 云存储配置Controller
@ -57,18 +55,6 @@ public class SysOssConfigController extends BaseController {
return iSysOssConfigService.queryPageList(bo); return iSysOssConfigService.queryPageList(bo);
} }
/**
* 导出云存储配置列表
*/
@ApiOperation("导出云存储配置列表")
@PreAuthorize("@ss.hasPermi('system:sysOssConfig:export')")
@Log(title = "云存储配置", businessType = BusinessType.EXPORT)
@GetMapping("/export")
public void export(@Validated SysOssConfigBo bo, HttpServletResponse response) {
List<SysOssConfigVo> list = iSysOssConfigService.queryList(bo);
ExcelUtil.exportExcel(list, "云存储配置", SysOssConfigVo.class, response);
}
/** /**
* 获取云存储配置详细信息 * 获取云存储配置详细信息
*/ */
@ -121,6 +107,10 @@ public class SysOssConfigController extends BaseController {
@DeleteMapping("/{ossConfigIds}") @DeleteMapping("/{ossConfigIds}")
public AjaxResult<Void> remove(@NotEmpty(message = "主键不能为空") public AjaxResult<Void> remove(@NotEmpty(message = "主键不能为空")
@PathVariable Integer[] ossConfigIds) { @PathVariable Integer[] ossConfigIds) {
List<SysOssConfig> list = iSysOssConfigService.list();
if(ObjectUtil.isNotNull(list)&&list.size()==1){
return AjaxResult.error("必须保留一条云配置文件");
}
return toAjax(iSysOssConfigService.deleteWithValidByIds(Arrays.asList(ossConfigIds), true) ? 1 : 0); return toAjax(iSysOssConfigService.deleteWithValidByIds(Arrays.asList(ossConfigIds), true) ? 1 : 0);
} }
@ -131,7 +121,6 @@ public class SysOssConfigController extends BaseController {
@Log(title = "云存储状态修改", businessType = BusinessType.UPDATE) @Log(title = "云存储状态修改", businessType = BusinessType.UPDATE)
@PutMapping("/changeStatus") @PutMapping("/changeStatus")
public AjaxResult changeStatus(@RequestBody SysOssConfig sysOssConfig) { public AjaxResult changeStatus(@RequestBody SysOssConfig sysOssConfig) {
sysOssConfig.setUpdateBy(getUsername());
return toAjax(iSysOssConfigService.updateOssConfigStatus(sysOssConfig)); return toAjax(iSysOssConfigService.updateOssConfigStatus(sysOssConfig));
} }
} }

View File

@ -33,26 +33,33 @@ public class SysOssConfigBo extends BaseEntity {
/** /**
* 配置key * 配置key
*/ */
@ApiModelProperty(value = "配置key", required = true) @ApiModelProperty(value = "configKey", required = true)
@NotBlank(message = "配置key不能为空", groups = { AddGroup.class, EditGroup.class }) @NotBlank(message = "configKey不能为空", groups = { AddGroup.class, EditGroup.class })
@Size(min = 2, max = 100, message = "configKey长度必须介于2和20 之间")
private String configKey; private String configKey;
/** /**
* accessKey * accessKey
*/ */
@ApiModelProperty(value = "accessKey") @ApiModelProperty(value = "accessKey")
@NotBlank(message = "accessKey不能为空", groups = { AddGroup.class, EditGroup.class })
@Size(min = 2, max = 100, message = "accessKey长度必须介于2和100 之间")
private String accessKey; private String accessKey;
/** /**
* 秘钥 * 秘钥
*/ */
@ApiModelProperty(value = "secretKey") @ApiModelProperty(value = "secretKey")
@NotBlank(message = "secretKey不能为空", groups = { AddGroup.class, EditGroup.class })
@Size(min = 2, max = 100, message = "secretKey长度必须介于2和100 之间")
private String secretKey; private String secretKey;
/** /**
* 桶名称 * 桶名称
*/ */
@ApiModelProperty(value = "桶名称") @ApiModelProperty(value = "bucketName")
@NotBlank(message = "bucketName不能为空", groups = { AddGroup.class, EditGroup.class })
@Size(min = 2, max = 100, message = "bucketName长度必须介于2和100之间")
private String bucketName; private String bucketName;
/** /**
@ -64,7 +71,9 @@ public class SysOssConfigBo extends BaseEntity {
/** /**
* 访问站点 * 访问站点
*/ */
@ApiModelProperty(value = "访问站点") @ApiModelProperty(value = "endpoint")
@NotBlank(message = "endpoint不能为空", groups = { AddGroup.class, EditGroup.class })
@Size(min = 2, max = 100, message = "endpoint长度必须介于2和100之间")
private String endpoint; private String endpoint;
/** /**
@ -76,7 +85,7 @@ public class SysOssConfigBo extends BaseEntity {
/** /**
* *
*/ */
@ApiModelProperty(value = "") @ApiModelProperty(value = "region")
private String region; private String region;
/** /**
@ -109,5 +118,9 @@ public class SysOssConfigBo extends BaseEntity {
*/ */
@ApiModelProperty(value = "排序的方向", example = "asc,desc") @ApiModelProperty(value = "排序的方向", example = "asc,desc")
private String isAsc; private String isAsc;
/**
* 状态(0正常 1停用)
*/
@ApiModelProperty("状态(0正常 1停用)")
private String status;
} }

View File

@ -33,71 +33,60 @@ public class SysOssConfigVo {
/** /**
* 配置key * 配置key
*/ */
@ExcelProperty(value = "配置key")
@ApiModelProperty("配置key") @ApiModelProperty("配置key")
private String configKey; private String configKey;
/** /**
* accessKey * accessKey
*/ */
@ExcelProperty(value = "accessKey")
@ApiModelProperty("accessKey") @ApiModelProperty("accessKey")
private String accessKey; private String accessKey;
/** /**
* 秘钥 * 秘钥
*/ */
@ExcelProperty(value = "secretKey")
@ApiModelProperty("secretKey") @ApiModelProperty("secretKey")
private String secretKey; private String secretKey;
/** /**
* 桶名称 * 桶名称
*/ */
@ExcelProperty(value = "桶名称")
@ApiModelProperty("桶名称") @ApiModelProperty("桶名称")
private String bucketName; private String bucketName;
/** /**
* 前缀 * 前缀
*/ */
@ExcelProperty(value = "前缀")
@ApiModelProperty("前缀") @ApiModelProperty("前缀")
private String prefix; private String prefix;
/** /**
* 访问站点 * 访问站点
*/ */
@ExcelProperty(value = "访问站点")
@ApiModelProperty("访问站点") @ApiModelProperty("访问站点")
private String endpoint; private String endpoint;
/** /**
* 是否htpps0否 1是 * 是否htpps0否 1是
*/ */
@ExcelProperty(value = "是否htpps", converter = ExcelDictConvert.class)
@ExcelDictFormat(dictType = "sys_yes_no")
@ApiModelProperty("是否htpps0否 1是") @ApiModelProperty("是否htpps0否 1是")
private String isHttps; private String isHttps;
/** /**
* *
*/ */
@ExcelProperty(value = "")
@ApiModelProperty("") @ApiModelProperty("")
private String region; private String region;
/** /**
* 状态(0正常 1停用) * 状态(0正常 1停用)
*/ */
@ExcelProperty(value = "状态(0正常 1停用)")
@ApiModelProperty("状态(0正常 1停用)") @ApiModelProperty("状态(0正常 1停用)")
private String status; private String status;
/** /**
* 扩展字段 * 扩展字段
*/ */
@ExcelProperty(value = "扩展字段")
@ApiModelProperty("扩展字段") @ApiModelProperty("扩展字段")
private String ext1; private String ext1;

View File

@ -27,10 +27,6 @@ public interface ISysOssConfigService extends IServicePlus<SysOssConfig, SysOssC
*/ */
TableDataInfo<SysOssConfigVo> queryPageList(SysOssConfigBo bo); TableDataInfo<SysOssConfigVo> queryPageList(SysOssConfigBo bo);
/**
* 查询列表
*/
List<SysOssConfigVo> queryList(SysOssConfigBo bo);
/** /**
* 根据新增业务对象插入云存储配置 * 根据新增业务对象插入云存储配置

View File

@ -8,11 +8,14 @@ import com.ruoyi.common.constant.Constants;
import com.ruoyi.common.constant.UserConstants; import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.common.core.domain.entity.SysUser; import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.core.redis.RedisCache; import com.ruoyi.common.core.redis.RedisCache;
import com.ruoyi.common.exception.CustomException;
import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.PageUtils; import com.ruoyi.common.utils.PageUtils;
import com.ruoyi.common.core.page.PagePlus; import com.ruoyi.common.core.page.PagePlus;
import com.ruoyi.common.core.page.TableDataInfo; import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.oss.constant.CloudConstant;
import com.ruoyi.system.domain.SysConfig; import com.ruoyi.system.domain.SysConfig;
import com.ruoyi.system.mapper.SysConfigMapper;
import com.ruoyi.system.service.ISysConfigService; import com.ruoyi.system.service.ISysConfigService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -41,8 +44,9 @@ public class SysOssConfigServiceImpl extends ServicePlusImpl<SysOssConfigMapper,
@Autowired @Autowired
private ISysConfigService iSysConfigService; private ISysConfigService iSysConfigService;
@Autowired @Autowired
private SysConfigMapper sysConfigMapper;
@Autowired
private RedisCache redisCache; private RedisCache redisCache;
public static final String sysConfigOss="sys.oss.cloudStorageService";
@Override @Override
public SysOssConfigVo queryById(Integer ossConfigId){ public SysOssConfigVo queryById(Integer ossConfigId){
@ -55,10 +59,6 @@ public class SysOssConfigServiceImpl extends ServicePlusImpl<SysOssConfigMapper,
return PageUtils.buildDataInfo(result); return PageUtils.buildDataInfo(result);
} }
@Override
public List<SysOssConfigVo> queryList(SysOssConfigBo bo) {
return listVo(buildQueryWrapper(bo));
}
private LambdaQueryWrapper<SysOssConfig> buildQueryWrapper(SysOssConfigBo bo) { private LambdaQueryWrapper<SysOssConfig> buildQueryWrapper(SysOssConfigBo bo) {
Map<String, Object> params = bo.getParams(); Map<String, Object> params = bo.getParams();
@ -93,12 +93,14 @@ public class SysOssConfigServiceImpl extends ServicePlusImpl<SysOssConfigMapper,
@Override @Override
public Boolean deleteWithValidByIds(Collection<Integer> ids, Boolean isValid) { public Boolean deleteWithValidByIds(Collection<Integer> ids, Boolean isValid) {
if(isValid){
//TODO 做一些业务上的校验,判断是否需要校验
}
return removeByIds(ids); return removeByIds(ids);
} }
/**
* 判断configKey是否唯一
* @param bo
* @return
*/
@Override @Override
public String checkConfigKeyUnique(SysOssConfigBo bo) { public String checkConfigKeyUnique(SysOssConfigBo bo) {
Long ossConfigId = StringUtils.isNull(bo.getOssConfigId()) ? -1L : bo.getOssConfigId(); Long ossConfigId = StringUtils.isNull(bo.getOssConfigId()) ? -1L : bo.getOssConfigId();
@ -111,23 +113,20 @@ public class SysOssConfigServiceImpl extends ServicePlusImpl<SysOssConfigMapper,
return UserConstants.UNIQUE; return UserConstants.UNIQUE;
} }
/**
* 启用禁用状态
* @param sysOssConfig
* @return
*/
@Override @Override
public int updateOssConfigStatus(SysOssConfig sysOssConfig) { public int updateOssConfigStatus(SysOssConfig sysOssConfig) {
LambdaQueryWrapper<SysConfig> queryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<SysConfig> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(SysConfig::getConfigKey,sysConfigOss); queryWrapper.eq(SysConfig::getConfigKey, CloudConstant.CLOUD_STORAGE_CONFIG_KEY);
List<SysConfig> sysConfigs = iSysConfigService.list(queryWrapper); SysConfig sysConfig = sysConfigMapper.selectOne(queryWrapper);
SysConfig config = null;
if(ObjectUtil.isNotNull(sysConfigs)){ if(ObjectUtil.isNotNull(sysConfig)){
config = sysConfigs.get(0); sysConfig.setConfigValue(sysOssConfig.getConfigKey());
} iSysConfigService.updateConfig(sysConfig);
//更新sysconfig
LambdaUpdateWrapper<SysConfig> updateWrapper = new LambdaUpdateWrapper<>();
updateWrapper.eq(SysConfig::getConfigKey,sysConfigOss);
updateWrapper.set(SysConfig::getConfigValue,sysOssConfig.getConfigKey());
boolean bool = iSysConfigService.update(updateWrapper);
if(bool){
//更新redis缓存
redisCache.setCacheObject(getCacheKey(config.getConfigKey()), sysOssConfig.getConfigKey());
} }
return baseMapper.updateById(sysOssConfig); return baseMapper.updateById(sysOssConfig);
} }

View File

@ -1,27 +1,41 @@
<template> <template>
<div class="app-container"> <div class="app-container">
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="100px"> <el-form
<el-form-item label="配置key" prop="configKey"> :model="queryParams"
ref="queryForm"
:inline="true"
v-show="showSearch"
label-width="100px"
>
<el-form-item label="configKey" prop="configKey">
<el-input <el-input
v-model="queryParams.configKey" v-model="queryParams.configKey"
placeholder="请输入配置key" placeholder="请输入configKey"
clearable clearable
size="small" size="small"
@keyup.enter.native="handleQuery" @keyup.enter.native="handleQuery"
/> />
</el-form-item> </el-form-item>
<el-form-item label="桶名称" prop="bucketName"> <el-form-item label="bucketName" prop="bucketName">
<el-input <el-input
v-model="queryParams.bucketName" v-model="queryParams.bucketName"
placeholder="请输入桶名称" placeholder="请输入bucketName"
clearable clearable
size="small" size="small"
@keyup.enter.native="handleQuery" @keyup.enter.native="handleQuery"
/> />
</el-form-item> </el-form-item>
<el-form-item> <el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button> <el-button
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button> type="primary"
icon="el-icon-search"
size="mini"
@click="handleQuery"
>搜索</el-button
>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
>重置</el-button
>
</el-form-item> </el-form-item>
</el-form> </el-form>
@ -34,7 +48,8 @@
size="mini" size="mini"
@click="handleAdd" @click="handleAdd"
v-hasPermi="['system:sysOssConfig:add']" v-hasPermi="['system:sysOssConfig:add']"
>新增</el-button> >新增</el-button
>
</el-col> </el-col>
<el-col :span="1.5"> <el-col :span="1.5">
<el-button <el-button
@ -45,7 +60,8 @@
:disabled="single" :disabled="single"
@click="handleUpdate" @click="handleUpdate"
v-hasPermi="['system:sysOssConfig:edit']" v-hasPermi="['system:sysOssConfig:edit']"
>修改</el-button> >修改</el-button
>
</el-col> </el-col>
<el-col :span="1.5"> <el-col :span="1.5">
<el-button <el-button
@ -56,23 +72,41 @@
:loading="exportLoading" :loading="exportLoading"
@click="handleExport" @click="handleExport"
v-hasPermi="['system:sysOssConfig:export']" v-hasPermi="['system:sysOssConfig:export']"
>导出</el-button> >导出</el-button
>
</el-col> </el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar> <right-toolbar
:showSearch.sync="showSearch"
@queryTable="getList"
></right-toolbar>
</el-row> </el-row>
<el-table v-loading="loading" :data="sysOssConfigList"> <el-table v-loading="loading" :data="sysOssConfigList">
<el-table-column type="selection" width="55" align="center" /> <el-table-column
<el-table-column label="主建" align="center" prop="ossConfigId" v-if="false"/> label="主建"
<el-table-column label="配置key" align="center" prop="configKey" /> align="center"
prop="ossConfigId"
v-if="false"
/>
<el-table-column label="configKey" align="center" prop="configKey" />
<el-table-column label="accessKey" align="center" prop="accessKey" /> <el-table-column label="accessKey" align="center" prop="accessKey" />
<el-table-column label="seretKey" align="center" prop="secretKey" /> <el-table-column label="seretKey" align="center" prop="secretKey" />
<el-table-column label="桶名称" align="center" prop="bucketName" /> <el-table-column label="bucketName" align="center" prop="bucketName" />
<el-table-column label="endpoint" align="center" prop="endpoint" /> <el-table-column
label="endpoint"
width="200"
align="center"
prop="endpoint"
/>
<el-table-column label="前缀" align="center" prop="prefix" /> <el-table-column label="前缀" align="center" prop="prefix" />
<el-table-column label="是否htpps" align="center" prop="isHttps" :formatter="isHttpsFormat" /> <el-table-column
<el-table-column label="域" align="center" prop="region" /> label="是否htpps"
<el-table-column label="状态" align="center" prop="status" > align="center"
prop="isHttps"
:formatter="isHttpsFormat"
/>
<el-table-column label="region" align="center" prop="region" />
<el-table-column label="状态" align="center" prop="status">
<template slot-scope="scope"> <template slot-scope="scope">
<el-switch <el-switch
v-model="scope.row.status" v-model="scope.row.status"
@ -82,7 +116,11 @@
></el-switch> ></el-switch>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width"> <el-table-column
label="操作"
align="center"
class-name="small-padding fixed-width"
>
<template slot-scope="scope"> <template slot-scope="scope">
<el-button <el-button
size="mini" size="mini"
@ -90,20 +128,22 @@
icon="el-icon-edit" icon="el-icon-edit"
@click="handleUpdate(scope.row)" @click="handleUpdate(scope.row)"
v-hasPermi="['system:sysOssConfig:edit']" v-hasPermi="['system:sysOssConfig:edit']"
>修改</el-button> >修改</el-button
>
<el-button <el-button
size="mini" size="mini"
type="text" type="text"
icon="el-icon-delete" icon="el-icon-delete"
@click="handleDelete(scope.row)" @click="handleDelete(scope.row)"
v-hasPermi="['system:sysOssConfig:remove']" v-hasPermi="['system:sysOssConfig:remove']"
>删除</el-button> >删除</el-button
>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
<pagination <pagination
v-show="total>0" v-show="total > 0"
:total="total" :total="total"
:page.sync="queryParams.pageNum" :page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize" :limit.sync="queryParams.pageSize"
@ -112,52 +152,91 @@
<!-- 添加或修改云存储配置对话框 --> <!-- 添加或修改云存储配置对话框 -->
<el-dialog :title="title" :visible.sync="open" width="800px" append-to-body> <el-dialog :title="title" :visible.sync="open" width="800px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="100px"> <el-form ref="form" :model="form" :rules="rules" label-width="120px">
<el-form-item label="配置key" prop="configKey"> <el-form-item label="configKey" prop="configKey">
<el-input v-model="form.configKey" placeholder="请输入配置key" /> <el-row>
<el-col :span="12">
<el-select v-model="form.configKey" placeholder="请选择">
<el-option
v-for="item in configKeyOptions"
:key="item.configKey"
:label="item.label"
:value="item.configKey"
>
<span style="float: left">{{ item.configKey }}</span>
<span style="float: right; color: #8492a6; font-size: 13px">{{
item.label
}}</span>
</el-option>
</el-select>
</el-col>
<el-col :span="12">
<el-form-item label="bucketName" prop="bucketName">
<el-input
v-model="form.bucketName"
placeholder="请输入bucketName"
/>
</el-form-item> </el-form-item>
</el-col>
</el-row>
</el-form-item>
<el-row>
<el-col :span="12">
<el-form-item label="accessKey" prop="accessKey"> <el-form-item label="accessKey" prop="accessKey">
<el-input v-model="form.accessKey" placeholder="请输入accessKey" /> <el-input
v-model="form.accessKey"
placeholder="请输入accessKey"
/>
</el-form-item> </el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="secretKey" prop="secretKey"> <el-form-item label="secretKey" prop="secretKey">
<el-input v-model="form.secretKey" placeholder="请输入秘钥" /> <el-input
</el-form-item> v-model="form.secretKey"
<el-form-item label="桶名称" prop="bucketName"> placeholder="请输入secretKey"
<el-input v-model="form.bucketName" placeholder="请输入桶名称" /> />
</el-form-item> </el-form-item>
</el-col>
</el-row>
<el-form-item label="endpoint" prop="endpoint"> <el-form-item label="endpoint" prop="endpoint">
<el-input v-model="form.endpoint" placeholder="请输入访问站点" /> <el-input v-model="form.endpoint" placeholder="请输入endpoint" />
</el-form-item> </el-form-item>
<el-form-item label="前缀" prop="prefix"> <el-form-item label="前缀" prop="prefix">
<el-input v-model="form.prefix" placeholder="请输入前缀" /> <el-input v-model="form.prefix" placeholder="请输入前缀" />
</el-form-item> </el-form-item>
<el-form-item label="配置状态"> <el-row>
<el-col :span="12">
<el-form-item label="状态">
<el-radio-group v-model="form.status"> <el-radio-group v-model="form.status">
<el-radio <el-radio label="0">启用</el-radio>
v-for="dict in statusOptions" <el-radio label="1">禁用</el-radio>
:key="dict.dictValue"
:label="dict.dictValue"
>{{dict.dictLabel}}</el-radio>
</el-radio-group> </el-radio-group>
</el-form-item> </el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="是否htpps"> <el-form-item label="是否htpps">
<el-radio-group v-model="form.isHttps"> <el-radio-group v-model="form.isHttps">
<el-radio <el-radio label="0"></el-radio>
v-for="dict in httpsStatusOptions" <el-radio label="1"></el-radio>
:key="dict.dictValue"
:label="dict.dictValue"
>{{dict.dictLabel}}</el-radio>
</el-radio-group> </el-radio-group>
</el-form-item> </el-form-item>
<el-form-item label="域" prop="region"> </el-col>
<el-input v-model="form.region" placeholder="请输入域" /> </el-row>
<el-form-item label="region" prop="region">
<el-input v-model="form.region" placeholder="请输入region" />
</el-form-item> </el-form-item>
<el-form-item label="备注" prop="remark"> <el-form-item label="备注" prop="remark">
<el-input v-model="form.remark" type="textarea" placeholder="请输入内容" /> <el-input
v-model="form.remark"
type="textarea"
placeholder="请输入内容"
/>
</el-form-item> </el-form-item>
</el-form> </el-form>
<div slot="footer" class="dialog-footer"> <div slot="footer" class="dialog-footer">
<el-button :loading="buttonLoading" type="primary" @click="submitForm"> </el-button> <el-button :loading="buttonLoading" type="primary" @click="submitForm"
> </el-button
>
<el-button @click="cancel"> </el-button> <el-button @click="cancel"> </el-button>
</div> </div>
</el-dialog> </el-dialog>
@ -165,7 +244,14 @@
</template> </template>
<script> <script>
import { listSysOssConfig, getSysOssConfig, delSysOssConfig, addSysOssConfig, updateSysOssConfig,changeOssConfigStatus } from "@/api/system/sysOssConfig"; import {
listSysOssConfig,
getSysOssConfig,
delSysOssConfig,
addSysOssConfig,
updateSysOssConfig,
changeOssConfigStatus,
} from "@/api/system/sysOssConfig";
import { downLoadExcel } from "@/utils/download"; import { downLoadExcel } from "@/utils/download";
export default { export default {
@ -190,16 +276,18 @@ export default {
total: 0, total: 0,
// //
sysOssConfigList: [], sysOssConfigList: [],
// //configKeyOptions
statusOptions: [], configKeyOptions: [],
// https configKeyDatas: [
httpsStatusOptions: [], { configKey: "monio", label: "minio" },
{ configKey: "qcloud", label: "腾讯云" },
{ configKey: "aliyun", label: "阿里云" },
{ configKey: "qiniu", label: "七牛云" },
],
// //
title: "", title: "",
// //
open: false, open: false,
// htpps
isHttpsOptions: [],
// //
queryParams: { queryParams: {
pageNum: 1, pageNum: 1,
@ -212,42 +300,56 @@ export default {
// //
rules: { rules: {
configKey: [ configKey: [
{ required: true, message: "配置key不能为空", trigger: "blur" }, { required: true, message: "configKey不能为空", trigger: "blur" },
{ min: 2, max: 20, message: '配置key长度必须介于 2 和 20 之间', trigger: 'blur' }
], ],
accessKey: [ accessKey: [
{ required: true, message: "accessKey不能为空", trigger: "blur" }, { required: true, message: "accessKey不能为空", trigger: "blur" },
{ min: 2, max: 200, message: 'accessKey长度必须介于 2 和 200 之间', trigger: 'blur' } {
min: 2,
max: 200,
message: "accessKey长度必须介于 2 和 100 之间",
trigger: "blur",
},
], ],
secretKey: [ secretKey: [
{ required: true, message: "secretKey不能为空", trigger: "blur" }, { required: true, message: "secretKey不能为空", trigger: "blur" },
{ min: 2, max: 20, message: 'secretKey长度必须介于 2 和 200 之间', trigger: 'blur' } {
min: 2,
max: 100,
message: "secretKey长度必须介于 2 和 100 之间",
trigger: "blur",
},
], ],
bucketName: [ bucketName: [
{ required: true, message: "桶名称不能为空", trigger: "blur" }, { required: true, message: "bucketName不能为空", trigger: "blur" },
{ min: 2, max: 20, message: '桶名称长度必须介于 2 和 100 之间', trigger: 'blur' } {
min: 2,
max: 100,
message: "bucketName长度必须介于 2 和 100 之间",
trigger: "blur",
},
], ],
endpoint: [ endpoint: [
{ required: true, message: "endpoint不能为空", trigger: "blur" }, { required: true, message: "endpoint不能为空", trigger: "blur" },
//{ min: 2, max: 20, message: 'endpoint 2 100 ', trigger: 'blur' } {
min: 2,
max: 100,
message: "endpoint名称长度必须介于 2 和 100 之间",
trigger: "blur",
},
], ],
} },
}; };
}, },
created() { created() {
this.getList(); this.getList();
this.getDicts("sys_normal_disable").then(response => { this.configKeyOptions = this.configKeyDatas;
this.statusOptions = response.data;
});
this.getDicts("https_yes_no").then(response => {
this.httpsStatusOptions = response.data;
});
}, },
methods: { methods: {
/** 查询云存储配置列表 */ /** 查询云存储配置列表 */
getList() { getList() {
this.loading = true; this.loading = true;
listSysOssConfig(this.queryParams).then(response => { listSysOssConfig(this.queryParams).then((response) => {
this.sysOssConfigList = response.rows; this.sysOssConfigList = response.rows;
this.total = response.total; this.total = response.total;
this.loading = false; this.loading = false;
@ -255,7 +357,7 @@ export default {
}, },
// htpps // htpps
isHttpsFormat(row, column) { isHttpsFormat(row, column) {
return this.selectDictLabel(this.isHttpsOptions, row.isHttps); return row.isHttps == "0" ? "否" : "是";
}, },
// //
cancel() { cancel() {
@ -274,8 +376,8 @@ export default {
endpoint: undefined, endpoint: undefined,
isHttps: "0", isHttps: "0",
region: undefined, region: undefined,
status: "0", status: "1",
remark: undefined remark: undefined,
}; };
this.resetForm("form"); this.resetForm("form");
}, },
@ -299,8 +401,8 @@ export default {
handleUpdate(row) { handleUpdate(row) {
this.loading = true; this.loading = true;
this.reset(); this.reset();
const ossConfigId = row.ossConfigId || this.ids const ossConfigId = row.ossConfigId || this.ids;
getSysOssConfig(ossConfigId).then(response => { getSysOssConfig(ossConfigId).then((response) => {
this.loading = false; this.loading = false;
this.form = response.data; this.form = response.data;
this.open = true; this.open = true;
@ -309,23 +411,27 @@ export default {
}, },
/** 提交按钮 */ /** 提交按钮 */
submitForm() { submitForm() {
this.$refs["form"].validate(valid => { this.$refs["form"].validate((valid) => {
if (valid) { if (valid) {
this.buttonLoading = true; this.buttonLoading = true;
if (this.form.ossConfigId != null) { if (this.form.ossConfigId != null) {
updateSysOssConfig(this.form).then(response => { updateSysOssConfig(this.form)
.then((response) => {
this.msgSuccess("修改成功"); this.msgSuccess("修改成功");
this.open = false; this.open = false;
this.getList(); this.getList();
}).finally(() => { })
.finally(() => {
this.buttonLoading = false; this.buttonLoading = false;
}); });
} else { } else {
addSysOssConfig(this.form).then(response => { addSysOssConfig(this.form)
.then((response) => {
this.msgSuccess("新增成功"); this.msgSuccess("新增成功");
this.open = false; this.open = false;
this.getList(); this.getList();
}).finally(() => { })
.finally(() => {
this.buttonLoading = false; this.buttonLoading = false;
}); });
} }
@ -335,38 +441,55 @@ export default {
/** 删除按钮操作 */ /** 删除按钮操作 */
handleDelete(row) { handleDelete(row) {
const ossConfigIds = row.ossConfigId || this.ids; const ossConfigIds = row.ossConfigId || this.ids;
this.$confirm('是否确认删除云存储配置编号为"' + ossConfigIds + '"的数据项?', "警告", { this.$confirm(
'是否确认删除configKey为"' + row.configKey + '"的数据项?',
"警告",
{
confirmButtonText: "确定", confirmButtonText: "确定",
cancelButtonText: "取消", cancelButtonText: "取消",
type: "warning" type: "warning",
}).then(() => { }
this.loading = true; )
.then(() => {
return delSysOssConfig(ossConfigIds); return delSysOssConfig(ossConfigIds);
}).then(() => { })
.then(() => {
this.loading = false; this.loading = false;
this.getList(); this.getList();
this.msgSuccess("删除成功"); this.msgSuccess("删除成功");
}).catch(() => {}); })
.catch(() => {});
}, },
/** 导出按钮操作 */ /** 导出按钮操作 */
handleExport() { handleExport() {
downLoadExcel('/system/sysOssConfig/export', this.queryParams); downLoadExcel("/system/sysOssConfig/export", this.queryParams);
}, },
// //
handleStatusChange(row) { handleStatusChange(row) {
let text = row.status === "0" ? "启用" : "停用"; let text = row.status === "0" ? "启用" : "停用";
this.$confirm('确认要"' + text + '""' + row.configKey + '"配置吗?', "警告", { this.$confirm(
'确认要"' + text + '""' + row.configKey + '"配置吗?',
"警告",
{
confirmButtonText: "确定", confirmButtonText: "确定",
cancelButtonText: "取消", cancelButtonText: "取消",
type: "warning" type: "warning",
}).then(function() { }
return changeOssConfigStatus(row.ossConfigId, row.status,row.configKey); )
}).then(() => { .then(function () {
return changeOssConfigStatus(
row.ossConfigId,
row.status,
row.configKey
);
})
.then(() => {
this.msgSuccess(text + "成功"); this.msgSuccess(text + "成功");
}).catch(function() { })
.catch(function () {
row.status = row.status === "0" ? "1" : "0"; row.status = row.status === "0" ? "1" : "0";
}); });
}, },
} },
}; };
</script> </script>