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'
|
import request from '@/utils/request'
|
||||||
|
|
||||||
export function listMetadata(query) {
|
export function listMetadata(query) {
|
||||||
const params = {
|
|
||||||
blurry: query
|
|
||||||
}
|
|
||||||
return request({
|
return request({
|
||||||
url: 'api/component/CuteUserSelect/listMetadata',
|
url: 'api/component/CuteUserSelect/listMetadata',
|
||||||
method: 'post',
|
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() {
|
data() {
|
||||||
return {
|
return {
|
||||||
user: this.value,
|
user: [],
|
||||||
loading: false,
|
loading: false,
|
||||||
options: []
|
options: []
|
||||||
}
|
}
|
||||||
@@ -51,6 +51,13 @@ export default {
|
|||||||
this.user = newVal
|
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: {
|
methods: {
|
||||||
remoteMethod(query) {
|
remoteMethod(query) {
|
||||||
if (query !== '') {
|
if (query !== '') {
|
||||||
|
|||||||
@@ -37,16 +37,11 @@ export default {
|
|||||||
type: Array,
|
type: Array,
|
||||||
required: false,
|
required: false,
|
||||||
default: null
|
default: null
|
||||||
},
|
|
||||||
dataSource: {
|
|
||||||
type: Array,
|
|
||||||
required: false,
|
|
||||||
default: null
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
users: this.value,
|
users: [],
|
||||||
loading: false,
|
loading: false,
|
||||||
options: []
|
options: []
|
||||||
}
|
}
|
||||||
@@ -56,9 +51,11 @@ export default {
|
|||||||
this.users = newVal
|
this.users = newVal
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
async mounted() {
|
||||||
if (this.dataSource && this.dataSource.length > 0) {
|
const that = this
|
||||||
this.options = this.dataSource
|
if (that.value && that.value.length > 0) {
|
||||||
|
that.options = await CuteUserSelectApi.listMetadataByUsernames(that.value)
|
||||||
|
that.users = that.value
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ export default {
|
|||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
form: {
|
form: {
|
||||||
user: null,
|
user: [],
|
||||||
dept: null,
|
dept: null,
|
||||||
productLine: null,
|
productLine: null,
|
||||||
productLinePro: null
|
productLinePro: null
|
||||||
|
|||||||
+8
@@ -30,4 +30,12 @@ public class CuteUserSelectApi {
|
|||||||
List<CuteUserSelectVo> collect = cuteUserSelectService.listMetadata(args);
|
List<CuteUserSelectVo> collect = cuteUserSelectService.listMetadata(args);
|
||||||
return ResponseEntity.ok(collect);
|
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;
|
package cn.odboy.system.application.service;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.odboy.system.application.model.CuteUserSelectVo;
|
import cn.odboy.system.application.model.CuteUserSelectVo;
|
||||||
import cn.odboy.system.dal.dataobject.SystemUserTb;
|
import cn.odboy.system.dal.dataobject.SystemUserTb;
|
||||||
import cn.odboy.system.dal.model.request.SystemQueryUserArgs;
|
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 com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class CuteUserSelectService {
|
public class CuteUserSelectService {
|
||||||
@@ -44,4 +47,22 @@ public class CuteUserSelectService {
|
|||||||
return selectVo;
|
return selectVo;
|
||||||
}).getRecords();
|
}).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