Pre Merge pull request !240 from 陈賝/dev

This commit is contained in:
陈賝 2022-10-17 12:14:51 +00:00 committed by Gitee
commit bfaffd814e
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
12 changed files with 314 additions and 162 deletions

View File

@ -15,6 +15,8 @@ import com.ruoyi.common.core.validate.QueryGroup;
import com.ruoyi.common.enums.BusinessType; import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.exception.ServiceException; import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.file.FileUtils; import com.ruoyi.common.utils.file.FileUtils;
import com.ruoyi.oss.core.OssClient;
import com.ruoyi.oss.factory.OssFactory;
import com.ruoyi.system.domain.SysOss; import com.ruoyi.system.domain.SysOss;
import com.ruoyi.system.domain.bo.SysOssBo; import com.ruoyi.system.domain.bo.SysOssBo;
import com.ruoyi.system.domain.vo.SysOssVo; import com.ruoyi.system.domain.vo.SysOssVo;
@ -80,7 +82,7 @@ public class SysOssController extends BaseController {
if (ObjectUtil.isNull(file)) { if (ObjectUtil.isNull(file)) {
throw new ServiceException("上传文件不能为空"); throw new ServiceException("上传文件不能为空");
} }
SysOss oss = iSysOssService.upload(file); SysOssVo oss = iSysOssService.upload(file);
Map<String, String> map = new HashMap<>(2); Map<String, String> map = new HashMap<>(2);
map.put("url", oss.getUrl()); map.put("url", oss.getUrl());
map.put("fileName", oss.getOriginalName()); map.put("fileName", oss.getOriginalName());
@ -96,23 +98,7 @@ public class SysOssController extends BaseController {
@SaCheckPermission("system:oss:download") @SaCheckPermission("system:oss:download")
@GetMapping("/download/{ossId}") @GetMapping("/download/{ossId}")
public void download(@PathVariable Long ossId, HttpServletResponse response) throws IOException { public void download(@PathVariable Long ossId, HttpServletResponse response) throws IOException {
SysOssVo sysOss = iSysOssService.getById(ossId); iSysOssService.download(ossId,response);
if (ObjectUtil.isNull(sysOss)) {
throw new ServiceException("文件数据不存在!");
}
FileUtils.setAttachmentResponseHeader(response, sysOss.getOriginalName());
response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE + "; charset=UTF-8");
long data;
try {
data = HttpUtil.download(sysOss.getUrl(), response.getOutputStream(), false);
} catch (HttpException e) {
if (e.getMessage().contains("403")) {
throw new ServiceException("无读取权限, 请在对应的OSS开启'公有读'权限!");
} else {
throw new ServiceException(e.getMessage());
}
}
response.setContentLength(Convert.toInt(data));
} }
/** /**

View File

@ -12,6 +12,7 @@ import com.ruoyi.common.helper.LoginHelper;
import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.file.MimeTypeUtils; import com.ruoyi.common.utils.file.MimeTypeUtils;
import com.ruoyi.system.domain.SysOss; import com.ruoyi.system.domain.SysOss;
import com.ruoyi.system.domain.vo.SysOssVo;
import com.ruoyi.system.service.ISysOssService; import com.ruoyi.system.service.ISysOssService;
import com.ruoyi.system.service.ISysUserService; import com.ruoyi.system.service.ISysUserService;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
@ -115,7 +116,7 @@ public class SysProfileController extends BaseController {
if (!StringUtils.equalsAnyIgnoreCase(extension, MimeTypeUtils.IMAGE_EXTENSION)) { if (!StringUtils.equalsAnyIgnoreCase(extension, MimeTypeUtils.IMAGE_EXTENSION)) {
return R.fail("文件格式不正确,请上传" + Arrays.toString(MimeTypeUtils.IMAGE_EXTENSION) + "格式"); return R.fail("文件格式不正确,请上传" + Arrays.toString(MimeTypeUtils.IMAGE_EXTENSION) + "格式");
} }
SysOss oss = iSysOssService.upload(avatarfile); SysOssVo oss = iSysOssService.upload(avatarfile);
String avatar = oss.getUrl(); String avatar = oss.getUrl();
if (userService.updateUserAvatar(getUsername(), avatar)) { if (userService.updateUserAvatar(getUsername(), avatar)) {
ajax.put("imgUrl", avatar); ajax.put("imgUrl", avatar);

View File

@ -2,6 +2,7 @@ package com.ruoyi.oss.core;
import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.IdUtil;
import com.amazonaws.ClientConfiguration; import com.amazonaws.ClientConfiguration;
import com.amazonaws.HttpMethod;
import com.amazonaws.Protocol; import com.amazonaws.Protocol;
import com.amazonaws.auth.AWSCredentials; import com.amazonaws.auth.AWSCredentials;
import com.amazonaws.auth.AWSCredentialsProvider; import com.amazonaws.auth.AWSCredentialsProvider;
@ -22,6 +23,9 @@ import com.ruoyi.oss.properties.OssProperties;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.io.InputStream; import java.io.InputStream;
import java.net.URL;
import java.time.Instant;
import java.util.Date;
/** /**
* S3 存储协议 所有兼容S3协议的云厂商均支持 * S3 存储协议 所有兼容S3协议的云厂商均支持
@ -167,6 +171,15 @@ public class OssClient {
return configKey; return configKey;
} }
public String getPrivateUrl(String objectKey, Integer second) {
GeneratePresignedUrlRequest generatePresignedUrlRequest =
new GeneratePresignedUrlRequest(properties.getBucketName(), objectKey)
.withMethod(HttpMethod.GET)
.withExpiration(new Date(System.currentTimeMillis() + 1000 * second));
URL url = client.generatePresignedUrl(generatePresignedUrlRequest);
return url.toString();
}
private static String getPolicy(String bucketName, PolicyType policyType) { private static String getPolicy(String bucketName, PolicyType policyType) {
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
builder.append("{\n\"Statement\": [\n{\n\"Action\": [\n"); builder.append("{\n\"Statement\": [\n{\n\"Action\": [\n");

View File

@ -0,0 +1,35 @@
package com.ruoyi.oss.enumd;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* 桶访问策略配置
*
* @author 陈賝
*/
@Getter
@AllArgsConstructor
public enum AccessPolicyType {
/**
* private
*/
PRIVATE("0"),
/**
* public
*/
PUBLIC("1"),
/**
* constum
*/
CONSTUM("2");
/**
* 类型
*/
private final String type;
}

View File

@ -50,4 +50,9 @@ public class OssProperties {
*/ */
private String isHttps; private String isHttps;
/**
* 桶权限类型(0private 1public 2custom)
*/
private String accessPolicy;
} }

View File

@ -82,4 +82,8 @@ public class SysOssConfig extends BaseEntity {
*/ */
private String remark; private String remark;
/**
* 桶权限类型(0private 1public 2custom)
*/
private String accessPolicy;
} }

View File

@ -98,4 +98,10 @@ public class SysOssConfigBo extends BaseEntity {
*/ */
private String remark; private String remark;
/**
* 桶权限类型(0private 1public 2custom)
*/
@NotBlank(message = "桶权限类型不能为空", groups = {AddGroup.class, EditGroup.class})
private String accessPolicy;
} }

View File

@ -82,4 +82,9 @@ public class SysOssConfigVo {
*/ */
private String remark; private String remark;
/**
* 桶权限类型(0private 1public 2custom)
*/
private String accessPolicy;
} }

View File

@ -7,6 +7,8 @@ import com.ruoyi.system.domain.bo.SysOssBo;
import com.ruoyi.system.domain.vo.SysOssVo; import com.ruoyi.system.domain.vo.SysOssVo;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
@ -23,7 +25,9 @@ public interface ISysOssService {
SysOssVo getById(Long ossId); SysOssVo getById(Long ossId);
SysOss upload(MultipartFile file); SysOssVo upload(MultipartFile file);
void download(Long ossId, HttpServletResponse response) throws IOException;
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid); Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);

View File

@ -1,6 +1,9 @@
package com.ruoyi.system.service.impl; package com.ruoyi.system.service.impl;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import cn.hutool.http.HttpException;
import cn.hutool.http.HttpUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@ -8,10 +11,19 @@ import com.ruoyi.common.constant.CacheNames;
import com.ruoyi.common.core.domain.PageQuery; import com.ruoyi.common.core.domain.PageQuery;
import com.ruoyi.common.core.page.TableDataInfo; import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.exception.ServiceException; import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.BeanCopyUtils;
import com.ruoyi.common.utils.JsonUtils;
import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.file.FileUtils;
import com.ruoyi.common.utils.redis.CacheUtils;
import com.ruoyi.common.utils.redis.RedisUtils;
import com.ruoyi.oss.constant.OssConstant;
import com.ruoyi.oss.core.OssClient; import com.ruoyi.oss.core.OssClient;
import com.ruoyi.oss.entity.UploadResult; import com.ruoyi.oss.entity.UploadResult;
import com.ruoyi.oss.enumd.AccessPolicyType;
import com.ruoyi.oss.exception.OssException;
import com.ruoyi.oss.factory.OssFactory; import com.ruoyi.oss.factory.OssFactory;
import com.ruoyi.oss.properties.OssProperties;
import com.ruoyi.system.domain.SysOss; import com.ruoyi.system.domain.SysOss;
import com.ruoyi.system.domain.bo.SysOssBo; import com.ruoyi.system.domain.bo.SysOssBo;
import com.ruoyi.system.domain.vo.SysOssVo; import com.ruoyi.system.domain.vo.SysOssVo;
@ -19,14 +31,17 @@ import com.ruoyi.system.mapper.SysOssMapper;
import com.ruoyi.system.service.ISysOssService; import com.ruoyi.system.service.ISysOssService;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.cache.annotation.Cacheable; import org.springframework.cache.annotation.Cacheable;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors;
/** /**
* 文件上传 服务层实现 * 文件上传 服务层实现
@ -43,6 +58,8 @@ public class SysOssServiceImpl implements ISysOssService {
public TableDataInfo<SysOssVo> queryPageList(SysOssBo bo, PageQuery pageQuery) { public TableDataInfo<SysOssVo> queryPageList(SysOssBo bo, PageQuery pageQuery) {
LambdaQueryWrapper<SysOss> lqw = buildQueryWrapper(bo); LambdaQueryWrapper<SysOss> lqw = buildQueryWrapper(bo);
Page<SysOssVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw); Page<SysOssVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
List<SysOssVo> filterResult = result.getRecords().stream().map(this::matchingUrl).collect(Collectors.toList());
result.setRecords(filterResult);
return TableDataInfo.build(result); return TableDataInfo.build(result);
} }
@ -52,7 +69,7 @@ public class SysOssServiceImpl implements ISysOssService {
for (Long id : ossIds) { for (Long id : ossIds) {
SysOssVo vo = getById(id); SysOssVo vo = getById(id);
if (ObjectUtil.isNotNull(vo)) { if (ObjectUtil.isNotNull(vo)) {
list.add(vo); list.add(this.matchingUrl(vo));
} }
} }
return list; return list;
@ -79,7 +96,28 @@ public class SysOssServiceImpl implements ISysOssService {
} }
@Override @Override
public SysOss upload(MultipartFile file) { public void download(Long ossId, HttpServletResponse response) throws IOException {
SysOssVo sysOss = this.matchingUrl(this.getById(ossId));
if (ObjectUtil.isNull(sysOss)) {
throw new ServiceException("文件数据不存在!");
}
FileUtils.setAttachmentResponseHeader(response, sysOss.getOriginalName());
response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE + "; charset=UTF-8");
long data;
try {
data = HttpUtil.download(sysOss.getUrl(), response.getOutputStream(), false);
} catch (HttpException e) {
if (e.getMessage().contains("403")) {
throw new ServiceException("无读取权限, 请在对应的OSS开启'公有读'权限!");
} else {
throw new ServiceException(e.getMessage());
}
}
response.setContentLength(Convert.toInt(data));
}
@Override
public SysOssVo upload(MultipartFile file) {
String originalfileName = file.getOriginalFilename(); String originalfileName = file.getOriginalFilename();
String suffix = StringUtils.substring(originalfileName, originalfileName.lastIndexOf("."), originalfileName.length()); String suffix = StringUtils.substring(originalfileName, originalfileName.lastIndexOf("."), originalfileName.length());
OssClient storage = OssFactory.instance(); OssClient storage = OssFactory.instance();
@ -97,7 +135,9 @@ public class SysOssServiceImpl implements ISysOssService {
oss.setOriginalName(originalfileName); oss.setOriginalName(originalfileName);
oss.setService(storage.getConfigKey()); oss.setService(storage.getConfigKey());
baseMapper.insert(oss); baseMapper.insert(oss);
return oss; SysOssVo sysOssVo = new SysOssVo();
BeanCopyUtils.copy(oss,sysOssVo);
return this.matchingUrl(sysOssVo);
} }
@Override @Override
@ -113,4 +153,24 @@ public class SysOssServiceImpl implements ISysOssService {
return baseMapper.deleteBatchIds(ids) > 0; return baseMapper.deleteBatchIds(ids) > 0;
} }
/**
* 匹配Url
*
* @param oss OSS对象
* @return oss 匹配Url的OSS对象
*/
private SysOssVo matchingUrl(SysOssVo oss) {
OssProperties properties = JsonUtils.parseObject(
CacheUtils.get(CacheNames.SYS_OSS_CONFIG, oss.getService()).toString(),
OssProperties.class
);
if (properties == null) {
throw new OssException("系统异常, '" + oss.getService() + "'配置信息不存在!");
}
if (StringUtils.equals(AccessPolicyType.PRIVATE.getType(), properties.getAccessPolicy())) {
OssClient storage = OssFactory.instance(oss.getService());
oss.setUrl(storage.getPrivateUrl(oss.getFileName(), 100));
}
return oss;
}
} }

View File

@ -80,6 +80,7 @@
<el-table-column label="桶名称" align="center" prop="bucketName" /> <el-table-column label="桶名称" align="center" prop="bucketName" />
<el-table-column label="前缀" align="center" prop="prefix" /> <el-table-column label="前缀" align="center" prop="prefix" />
<el-table-column label="域" align="center" prop="region" /> <el-table-column label="域" align="center" prop="region" />
<el-table-column label="桶权限类型" align="center" prop="accessPolicy" :formatter = "accessPolicyStateFormat" />
<el-table-column label="状态" align="center" prop="status"> <el-table-column label="状态" align="center" prop="status">
<template slot-scope="scope"> <template slot-scope="scope">
<el-switch <el-switch
@ -151,6 +152,13 @@
>{{dict.label}}</el-radio> >{{dict.label}}</el-radio>
</el-radio-group> </el-radio-group>
</el-form-item> </el-form-item>
<el-form-item label="桶权限类型">
<el-radio-group v-model="form.accessPolicy">
<el-radio label="0">private</el-radio>
<el-radio label="1">public</el-radio>
<el-radio label="2">custom</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="域" prop="region"> <el-form-item label="域" prop="region">
<el-input v-model="form.region" placeholder="请输入域" /> <el-input v-model="form.region" placeholder="请输入域" />
</el-form-item> </el-form-item>
@ -208,6 +216,21 @@ export default {
isHttpsOptions: [], isHttpsOptions: [],
// (0 1) // (0 1)
statusOptions: [], statusOptions: [],
//
accessPolicyOptions: [
{
label: 'private',
value: 0
},
{
label: 'public',
value: 1
},
{
label: 'custom',
value: 2
}
],
// //
queryParams: { queryParams: {
pageNum: 1, pageNum: 1,
@ -382,7 +405,17 @@ export default {
}).catch(() => { }).catch(() => {
row.status = row.status === "0" ? "1" : "0"; row.status = row.status === "0" ? "1" : "0";
}) })
} },
accessPolicyStateFormat(row) {
if (row.accessPolicy === "0") {
return <span class="el-tag el-tag--warning el-tag--medium el-tag--light" > private </span>
} else if (row.accessPolicy === "1") {
return <span class="el-tag el-tag--success el-tag--medium el-tag--light" > public </span>
} else if (row.accessPolicy === "2") {
return <span class="el-tag el-tag--medium el-tag--light" > constum </span>
}
}
} }
}; };
</script> </script>

View File

@ -1,138 +1,138 @@
<template> <template>
<!-- 授权用户 --> <!-- 授权用户 -->
<el-dialog title="选择用户" :visible.sync="visible" width="800px" top="5vh" append-to-body> <el-dialog title="选择用户" :visible.sync="visible" width="800px" top="5vh" append-to-body>
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true"> <el-form :model="queryParams" ref="queryForm" size="small" :inline="true">
<el-form-item label="用户名称" prop="userName"> <el-form-item label="用户名称" prop="userName">
<el-input <el-input
v-model="queryParams.userName" v-model="queryParams.userName"
placeholder="请输入用户名称" placeholder="请输入用户名称"
clearable clearable
@keyup.enter.native="handleQuery" @keyup.enter.native="handleQuery"
/> />
</el-form-item> </el-form-item>
<el-form-item label="手机号码" prop="phonenumber"> <el-form-item label="手机号码" prop="phonenumber">
<el-input <el-input
v-model="queryParams.phonenumber" v-model="queryParams.phonenumber"
placeholder="请输入手机号码" placeholder="请输入手机号码"
clearable clearable
@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 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-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
</el-form-item> </el-form-item>
</el-form> </el-form>
<el-row> <el-row>
<el-table @row-click="clickRow" ref="table" :data="userList" @selection-change="handleSelectionChange" height="260px"> <el-table @row-click="clickRow" ref="table" :data="userList" @selection-change="handleSelectionChange" height="260px">
<el-table-column type="selection" width="55"></el-table-column> <el-table-column type="selection" width="55"></el-table-column>
<el-table-column label="用户名称" prop="userName" :show-overflow-tooltip="true" /> <el-table-column label="用户名称" prop="userName" :show-overflow-tooltip="true" />
<el-table-column label="用户昵称" prop="nickName" :show-overflow-tooltip="true" /> <el-table-column label="用户昵称" prop="nickName" :show-overflow-tooltip="true" />
<el-table-column label="邮箱" prop="email" :show-overflow-tooltip="true" /> <el-table-column label="邮箱" prop="email" :show-overflow-tooltip="true" />
<el-table-column label="手机" prop="phonenumber" :show-overflow-tooltip="true" /> <el-table-column label="手机" prop="phonenumber" :show-overflow-tooltip="true" />
<el-table-column label="状态" align="center" prop="status"> <el-table-column label="状态" align="center" prop="status">
<template slot-scope="scope"> <template slot-scope="scope">
<dict-tag :options="dict.type.sys_normal_disable" :value="scope.row.status"/> <dict-tag :options="dict.type.sys_normal_disable" :value="scope.row.status"/>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="创建时间" align="center" prop="createTime" width="180"> <el-table-column label="创建时间" align="center" prop="createTime" width="180">
<template slot-scope="scope"> <template slot-scope="scope">
<span>{{ parseTime(scope.row.createTime) }}</span> <span>{{ parseTime(scope.row.createTime) }}</span>
</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"
@pagination="getList" @pagination="getList"
/> />
</el-row> </el-row>
<div slot="footer" class="dialog-footer"> <div slot="footer" class="dialog-footer">
<el-button type="primary" @click="handleSelectUser"> </el-button> <el-button type="primary" @click="handleSelectUser"> </el-button>
<el-button @click="visible = false"> </el-button> <el-button @click="visible = false"> </el-button>
</div> </div>
</el-dialog> </el-dialog>
</template> </template>
<script> <script>
import { unallocatedUserList, authUserSelectAll } from "@/api/system/role"; import { unallocatedUserList, authUserSelectAll } from "@/api/system/role";
export default { export default {
dicts: ['sys_normal_disable'], dicts: ['sys_normal_disable'],
props: { props: {
// //
roleId: { roleId: {
type: [Number, String] type: [Number, String]
} }
}, },
data() { data() {
return { return {
// //
visible: false, visible: false,
// //
userIds: [], userIds: [],
// //
total: 0, total: 0,
// //
userList: [], userList: [],
// //
queryParams: { queryParams: {
pageNum: 1, pageNum: 1,
pageSize: 10, pageSize: 10,
roleId: undefined, roleId: undefined,
userName: undefined, userName: undefined,
phonenumber: undefined phonenumber: undefined
} }
}; };
}, },
methods: { methods: {
// //
show() { show() {
this.queryParams.roleId = this.roleId; this.queryParams.roleId = this.roleId;
this.getList(); this.getList();
this.visible = true; this.visible = true;
}, },
clickRow(row) { clickRow(row) {
this.$refs.table.toggleRowSelection(row); this.$refs.table.toggleRowSelection(row);
}, },
// //
handleSelectionChange(selection) { handleSelectionChange(selection) {
this.userIds = selection.map(item => item.userId); this.userIds = selection.map(item => item.userId);
}, },
// //
getList() { getList() {
unallocatedUserList(this.queryParams).then(res => { unallocatedUserList(this.queryParams).then(res => {
this.userList = res.rows; this.userList = res.rows;
this.total = res.total; this.total = res.total;
}); });
}, },
/** 搜索按钮操作 */ /** 搜索按钮操作 */
handleQuery() { handleQuery() {
this.queryParams.pageNum = 1; this.queryParams.pageNum = 1;
this.getList(); this.getList();
}, },
/** 重置按钮操作 */ /** 重置按钮操作 */
resetQuery() { resetQuery() {
this.resetForm("queryForm"); this.resetForm("queryForm");
this.handleQuery(); this.handleQuery();
}, },
/** 选择授权用户操作 */ /** 选择授权用户操作 */
handleSelectUser() { handleSelectUser() {
const roleId = this.queryParams.roleId; const roleId = this.queryParams.roleId;
const userIds = this.userIds.join(","); const userIds = this.userIds.join(",");
if (userIds == "") { if (userIds == "") {
this.$modal.msgError("请选择要分配的用户"); this.$modal.msgError("请选择要分配的用户");
return; return;
} }
authUserSelectAll({ roleId: roleId, userIds: userIds }).then(res => { authUserSelectAll({ roleId: roleId, userIds: userIds }).then(res => {
this.$modal.msgSuccess(res.msg); this.$modal.msgSuccess(res.msg);
if (res.code === 200) { if (res.code === 200) {
this.visible = false; this.visible = false;
this.$emit("ok"); this.$emit("ok");
} }
}); });
} }
} }
}; };
</script> </script>