feat(user): 添加根据用户名列表查询用户基础数据功能
- 在CuteUserSelectService中新增listMetadataByUsernames方法 - 为CuteUserSelectApi添加listMetadataByUsernames接口 - 在前端cute-user-select.js中新增listMetadataByUsernames请求方法 - 修改CuteSingleUserSelect组件支持初始化时根据用户名加载用户信息 - 修改CuteUserSelect组件移除dataSource属性并支持初始化加载 - 更新CuteBusinessDemo演示页面用户字段默认值为空数组
This commit is contained in:
@@ -1,15 +1,22 @@
|
||||
import request from '@/utils/request'
|
||||
|
||||
export function listMetadata(query) {
|
||||
const params = {
|
||||
blurry: query
|
||||
}
|
||||
return request({
|
||||
url: 'api/component/CuteUserSelect/listMetadata',
|
||||
method: 'post',
|
||||
data: params
|
||||
data: {
|
||||
blurry: query
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
export default { listMetadata }
|
||||
export function listMetadataByUsernames(usernameList = []) {
|
||||
return request({
|
||||
url: 'api/component/CuteUserSelect/listMetadataByUsernames',
|
||||
method: 'post',
|
||||
data: usernameList
|
||||
})
|
||||
}
|
||||
|
||||
export default { listMetadata, listMetadataByUsernames }
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ export default {
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
user: this.value,
|
||||
user: [],
|
||||
loading: false,
|
||||
options: []
|
||||
}
|
||||
@@ -51,6 +51,13 @@ export default {
|
||||
this.user = newVal
|
||||
}
|
||||
},
|
||||
async mounted() {
|
||||
const that = this
|
||||
if (that.value && that.value.length > 0) {
|
||||
that.options = await CuteUserSelectApi.listMetadataByUsernames(that.value)
|
||||
that.users = that.value
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
remoteMethod(query) {
|
||||
if (query !== '') {
|
||||
|
||||
@@ -37,16 +37,11 @@ export default {
|
||||
type: Array,
|
||||
required: false,
|
||||
default: null
|
||||
},
|
||||
dataSource: {
|
||||
type: Array,
|
||||
required: false,
|
||||
default: null
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
users: this.value,
|
||||
users: [],
|
||||
loading: false,
|
||||
options: []
|
||||
}
|
||||
@@ -56,9 +51,11 @@ export default {
|
||||
this.users = newVal
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
if (this.dataSource && this.dataSource.length > 0) {
|
||||
this.options = this.dataSource
|
||||
async mounted() {
|
||||
const that = this
|
||||
if (that.value && that.value.length > 0) {
|
||||
that.options = await CuteUserSelectApi.listMetadataByUsernames(that.value)
|
||||
that.users = that.value
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
|
||||
@@ -65,7 +65,7 @@ export default {
|
||||
data() {
|
||||
return {
|
||||
form: {
|
||||
user: null,
|
||||
user: [],
|
||||
dept: null,
|
||||
productLine: null,
|
||||
productLinePro: null
|
||||
|
||||
+8
@@ -30,4 +30,12 @@ public class CuteUserSelectApi {
|
||||
List<CuteUserSelectVo> collect = cuteUserSelectService.listMetadata(args);
|
||||
return ResponseEntity.ok(collect);
|
||||
}
|
||||
|
||||
@ApiOperation("根据用户名称集合查询用户基础数据")
|
||||
@PostMapping(value = "/listMetadataByUsernames")
|
||||
@PreAuthorize("@el.check()")
|
||||
public ResponseEntity<List<CuteUserSelectVo>> listMetadataByUsernames(@RequestBody List<String> usernameList) {
|
||||
List<CuteUserSelectVo> collect = cuteUserSelectService.listMetadataByUsernames(usernameList);
|
||||
return ResponseEntity.ok(collect);
|
||||
}
|
||||
}
|
||||
|
||||
+21
@@ -1,5 +1,6 @@
|
||||
package cn.odboy.system.application.service;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.odboy.system.application.model.CuteUserSelectVo;
|
||||
import cn.odboy.system.dal.dataobject.SystemUserTb;
|
||||
import cn.odboy.system.dal.model.request.SystemQueryUserArgs;
|
||||
@@ -8,7 +9,9 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
public class CuteUserSelectService {
|
||||
@@ -44,4 +47,22 @@ public class CuteUserSelectService {
|
||||
return selectVo;
|
||||
}).getRecords();
|
||||
}
|
||||
|
||||
public List<CuteUserSelectVo> listMetadataByUsernames(List<String> usernameList) {
|
||||
if (CollUtil.isEmpty(usernameList)) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
LambdaQueryWrapper<SystemUserTb> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.select(SystemUserTb::getUsername, SystemUserTb::getNickName, SystemUserTb::getDeptId, SystemUserTb::getEmail, SystemUserTb::getPhone);
|
||||
wrapper.in(SystemUserTb::getUsername, usernameList);
|
||||
return systemUserMapper.selectList(wrapper).stream().map(m -> {
|
||||
CuteUserSelectVo selectVo = new CuteUserSelectVo();
|
||||
selectVo.setValue(m.getUsername());
|
||||
selectVo.setLabel(m.getNickName());
|
||||
selectVo.setDeptId(Long.toString(m.getDeptId()));
|
||||
selectVo.setEmail(m.getEmail());
|
||||
selectVo.setPhone(m.getPhone());
|
||||
return selectVo;
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user