角色
This commit is contained in:
@@ -321,7 +321,7 @@
|
||||
],
|
||||
"body": {
|
||||
"mode": "raw",
|
||||
"raw": "{\"code\":\"test22\",\"is_active\":\"8\",\"create_time\":\"2022-10-14 13:33:52\",\"remark\":\"888\",\"update_time\":\"2022-10-14 13:33:52\",\"update_optname\":\"管理员\",\"create_id\":1,\"name\":\"888\",\"id\":\"3f1901b5814d40908bad602854b22aa6\",\"value\":\"8888\",\"update_optid\":1,\"create_name\":\"管理员\"}"
|
||||
"raw": "{\"code\":\"test22\",\"is_active\":\"8\",\"create_time\":\"2022-10-14 13:33:52\",\"remark\":\"888\",\"update_time\":\"2022-10-14 13:33:52\",\"update_optname\":\"管理员\",\"create_id\":1,\"name\":\"888\",\"id\":\"3f1901b5814d40908bad602854b22aa6\",\"value\":\"8888\",\"update_id\":1,\"create_name\":\"管理员\"}"
|
||||
},
|
||||
"url": {
|
||||
"raw": "{{lms_url}}/api/param",
|
||||
|
||||
@@ -0,0 +1,173 @@
|
||||
package org.nl;
|
||||
|
||||
|
||||
/**
|
||||
* @Author:JCccc
|
||||
* @Description:
|
||||
* @Date: created in 15:31 2019/6/12
|
||||
*/
|
||||
public class SnowflakeIdUtils {
|
||||
// ==============================Fields===========================================
|
||||
/**
|
||||
* 开始时间截 (2015-01-01)
|
||||
*/
|
||||
private final long twepoch = 1420041600000L;
|
||||
|
||||
/**
|
||||
* 机器id所占的位数
|
||||
*/
|
||||
private final long workerIdBits = 5L;
|
||||
|
||||
/**
|
||||
* 数据标识id所占的位数
|
||||
*/
|
||||
private final long datacenterIdBits = 5L;
|
||||
|
||||
/**
|
||||
* 支持的最大机器id,结果是31 (这个移位算法可以很快的计算出几位二进制数所能表示的最大十进制数)
|
||||
*/
|
||||
private final long maxWorkerId = -1L ^ (-1L << workerIdBits);
|
||||
|
||||
/**
|
||||
* 支持的最大数据标识id,结果是31
|
||||
*/
|
||||
private final long maxDatacenterId = -1L ^ (-1L << datacenterIdBits);
|
||||
|
||||
/**
|
||||
* 序列在id中占的位数
|
||||
*/
|
||||
private final long sequenceBits = 12L;
|
||||
|
||||
/**
|
||||
* 机器ID向左移12位
|
||||
*/
|
||||
private final long workerIdShift = sequenceBits;
|
||||
|
||||
/**
|
||||
* 数据标识id向左移17位(12+5)
|
||||
*/
|
||||
private final long datacenterIdShift = sequenceBits + workerIdBits;
|
||||
|
||||
/**
|
||||
* 时间截向左移22位(5+5+12)
|
||||
*/
|
||||
private final long timestampLeftShift = sequenceBits + workerIdBits + datacenterIdBits;
|
||||
|
||||
/**
|
||||
* 生成序列的掩码,这里为4095 (0b111111111111=0xfff=4095)
|
||||
*/
|
||||
private final long sequenceMask = -1L ^ (-1L << sequenceBits);
|
||||
|
||||
/**
|
||||
* 工作机器ID(0~31)
|
||||
*/
|
||||
private long workerId;
|
||||
|
||||
/**
|
||||
* 数据中心ID(0~31)
|
||||
*/
|
||||
private long datacenterId;
|
||||
|
||||
/**
|
||||
* 毫秒内序列(0~4095)
|
||||
*/
|
||||
private long sequence = 0L;
|
||||
|
||||
/**
|
||||
* 上次生成ID的时间截
|
||||
*/
|
||||
private long lastTimestamp = -1L;
|
||||
|
||||
//==============================Constructors=====================================
|
||||
|
||||
/**
|
||||
* 构造函数
|
||||
*
|
||||
* @param workerId 工作ID (0~31)
|
||||
* @param datacenterId 数据中心ID (0~31)
|
||||
*/
|
||||
public SnowflakeIdUtils(long workerId, long datacenterId) {
|
||||
if (workerId > maxWorkerId || workerId < 0) {
|
||||
throw new IllegalArgumentException(String.format("worker Id can't be greater than %d or less than 0", maxWorkerId));
|
||||
}
|
||||
if (datacenterId > maxDatacenterId || datacenterId < 0) {
|
||||
throw new IllegalArgumentException(String.format("datacenter Id can't be greater than %d or less than 0", maxDatacenterId));
|
||||
}
|
||||
this.workerId = workerId;
|
||||
this.datacenterId = datacenterId;
|
||||
}
|
||||
|
||||
// ==============================Methods==========================================
|
||||
|
||||
/**
|
||||
* 获得下一个ID (该方法是线程安全的)
|
||||
*
|
||||
* @return SnowflakeId
|
||||
*/
|
||||
public synchronized long nextId() {
|
||||
long timestamp = timeGen();
|
||||
|
||||
//如果当前时间小于上一次ID生成的时间戳,说明系统时钟回退过这个时候应当抛出异常
|
||||
if (timestamp < lastTimestamp) {
|
||||
throw new RuntimeException(
|
||||
String.format("Clock moved backwards. Refusing to generate id for %d milliseconds", lastTimestamp - timestamp));
|
||||
}
|
||||
|
||||
//如果是同一时间生成的,则进行毫秒内序列
|
||||
if (lastTimestamp == timestamp) {
|
||||
sequence = (sequence + 1) & sequenceMask;
|
||||
//毫秒内序列溢出
|
||||
if (sequence == 0) {
|
||||
//阻塞到下一个毫秒,获得新的时间戳
|
||||
timestamp = tilNextMillis(lastTimestamp);
|
||||
}
|
||||
}
|
||||
//时间戳改变,毫秒内序列重置
|
||||
else {
|
||||
sequence = 0L;
|
||||
}
|
||||
|
||||
//上次生成ID的时间截
|
||||
lastTimestamp = timestamp;
|
||||
|
||||
//移位并通过或运算拼到一起组成64位的ID
|
||||
return ((timestamp - twepoch) << timestampLeftShift) //
|
||||
| (datacenterId << datacenterIdShift) //
|
||||
| (workerId << workerIdShift) //
|
||||
| sequence;
|
||||
}
|
||||
|
||||
/**
|
||||
* 阻塞到下一个毫秒,直到获得新的时间戳
|
||||
*
|
||||
* @param lastTimestamp 上次生成ID的时间截
|
||||
* @return 当前时间戳
|
||||
*/
|
||||
protected long tilNextMillis(long lastTimestamp) {
|
||||
long timestamp = timeGen();
|
||||
while (timestamp <= lastTimestamp) {
|
||||
timestamp = timeGen();
|
||||
}
|
||||
return timestamp;
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回以毫秒为单位的当前时间
|
||||
*
|
||||
* @return 当前时间(毫秒)
|
||||
*/
|
||||
protected long timeGen() {
|
||||
return System.currentTimeMillis();
|
||||
}
|
||||
|
||||
//==============================Test=============================================
|
||||
|
||||
/**
|
||||
* 测试
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
SnowflakeIdUtils idWorker = new SnowflakeIdUtils(3, 1);
|
||||
System.out.println(idWorker.nextId());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -61,6 +61,7 @@ public class PageQuery implements Serializable {
|
||||
OrderItem item = new OrderItem();
|
||||
item.setColumn(split[0]);
|
||||
item.setAsc(split[1].toLowerCase(Locale.ROOT).equals("asc"));
|
||||
page.addOrder(item);
|
||||
}
|
||||
return page;
|
||||
}
|
||||
|
||||
@@ -1,53 +0,0 @@
|
||||
/*
|
||||
* Copyright 2019-2020 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.nl.config;
|
||||
|
||||
import org.nl.modules.common.config.FileProperties;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.cors.CorsConfiguration;
|
||||
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
|
||||
import org.springframework.web.filter.CorsFilter;
|
||||
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
|
||||
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
/**
|
||||
* WebMvcConfigurer
|
||||
*
|
||||
* @author Zheng Jie
|
||||
* @date 2018-11-30
|
||||
*/
|
||||
@Configuration
|
||||
@EnableWebMvc
|
||||
public class ConfigurerAdapter implements WebMvcConfigurer {
|
||||
/** 文件配置 */
|
||||
private final FileProperties properties;
|
||||
|
||||
public ConfigurerAdapter(FileProperties properties) {
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addResourceHandlers(ResourceHandlerRegistry registry) {
|
||||
FileProperties.ElPath path = properties.getPath();
|
||||
String avatarUtl = "file:" + path.getAvatar().replace("\\","/");
|
||||
String pathUtl = "file:" + path.getPath().replace("\\","/");
|
||||
registry.addResourceHandler("/avatar/**").addResourceLocations(avatarUtl).setCachePeriod(0);
|
||||
registry.addResourceHandler("/file/**").addResourceLocations(pathUtl).setCachePeriod(0);
|
||||
registry.addResourceHandler("/**").addResourceLocations("classpath:/META-INF/resources/").setCachePeriod(0);
|
||||
}
|
||||
}
|
||||
@@ -1,32 +1,31 @@
|
||||
/*
|
||||
* Copyright 2019-2020 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.nl.config;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.support.ConversionServiceFactoryBean;
|
||||
import org.springframework.core.convert.ConversionService;
|
||||
import org.springframework.core.convert.converter.Converter;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
/**
|
||||
* WebMvcConfigurer
|
||||
*
|
||||
* @author Zheng Jie
|
||||
* @date 2018-11-30
|
||||
*/
|
||||
@Configuration
|
||||
public class WebMvcConfig extends WebMvcConfigurerAdapter {
|
||||
/**
|
||||
* 配置全局日期转换器
|
||||
*/
|
||||
@Bean
|
||||
@Autowired
|
||||
public ConversionService getConversionService(StringConverter dateConverter){
|
||||
ConversionServiceFactoryBean factoryBean = new ConversionServiceFactoryBean();
|
||||
public class WebMvcConfig implements WebMvcConfigurer {
|
||||
|
||||
Set<Converter> converters = new HashSet<Converter>();
|
||||
|
||||
converters.add(dateConverter);
|
||||
|
||||
factoryBean.setConverters(converters);
|
||||
|
||||
return factoryBean.getObject();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
package org.nl.config.jackson;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonGenerator;
|
||||
import com.fasterxml.jackson.databind.SerializerProvider;
|
||||
import com.fasterxml.jackson.databind.annotation.JacksonStdImpl;
|
||||
import com.fasterxml.jackson.databind.ser.std.NumberSerializer;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* 超出 JS 最大最小值 处理
|
||||
*
|
||||
* @author Lion Li
|
||||
*/
|
||||
@JacksonStdImpl
|
||||
public class BigNumberSerializer extends NumberSerializer {
|
||||
|
||||
/**
|
||||
* 根据 JS Number.MAX_SAFE_INTEGER 与 Number.MIN_SAFE_INTEGER 得来
|
||||
*/
|
||||
private static final long MAX_SAFE_INTEGER = 9007199254740991L;
|
||||
private static final long MIN_SAFE_INTEGER = -9007199254740991L;
|
||||
|
||||
/**
|
||||
* 提供实例
|
||||
*/
|
||||
public static final BigNumberSerializer INSTANCE = new BigNumberSerializer(Number.class);
|
||||
|
||||
public BigNumberSerializer(Class<? extends Number> rawType) {
|
||||
super(rawType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serialize(Number value, JsonGenerator gen, SerializerProvider provider) throws IOException {
|
||||
// 超出范围 序列化位字符串
|
||||
if (value.longValue() > MIN_SAFE_INTEGER && value.longValue() < MAX_SAFE_INTEGER) {
|
||||
super.serialize(value, gen, provider);
|
||||
} else {
|
||||
gen.writeString(value.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
package org.nl.config.jackson;
|
||||
|
||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.module.SimpleModule;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateDeserializer;
|
||||
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
|
||||
import com.fasterxml.jackson.datatype.jsr310.deser.LocalTimeDeserializer;
|
||||
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateSerializer;
|
||||
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
|
||||
import com.fasterxml.jackson.datatype.jsr310.ser.LocalTimeSerializer;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
|
||||
import static com.fasterxml.jackson.databind.DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES;
|
||||
|
||||
/**
|
||||
* jackson 配置
|
||||
*
|
||||
* @author Lion Li
|
||||
* @author JohanChan
|
||||
* @ProjectName Demo
|
||||
* @Description 与前端交互时对实体类中Long类型的ID字段序列号
|
||||
* @time 2021/6/23 11:30
|
||||
*/
|
||||
/**
|
||||
* @author JohanChan
|
||||
* @ProjectName Demo
|
||||
* @Description 与前端交互时对实体类中Long类型的ID字段序列号
|
||||
* @time 2021/6/23 11:30
|
||||
*/
|
||||
|
||||
/**
|
||||
* 对象映射器:基于jackson将Java对象转为json,或者将json转为Java对象
|
||||
* 将JSON解析为Java对象的过程称为 [从JSON反序列化Java对象]
|
||||
* 从Java对象生成JSON的过程称为 [序列化Java对象到JSON]
|
||||
*/
|
||||
public class JacksonObjectMapper extends ObjectMapper {
|
||||
|
||||
public static final String DEFAULT_DATE_FORMAT = "yyyy-MM-dd";
|
||||
public static final String DEFAULT_DATE_TIME_FORMAT = "yyyy-MM-dd HH:mm:ss";
|
||||
public static final String DEFAULT_TIME_FORMAT = "HH:mm:ss";
|
||||
|
||||
public JacksonObjectMapper() {
|
||||
super();
|
||||
//收到未知属性时不报异常
|
||||
this.configure(FAIL_ON_UNKNOWN_PROPERTIES, false);
|
||||
|
||||
//反序列化时,属性不存在的兼容处理
|
||||
this.getDeserializationConfig().withoutFeatures(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
|
||||
|
||||
SimpleModule simpleModule = new SimpleModule()
|
||||
//将BigInteger型数字转换成字符串,避免丢失精度
|
||||
.addSerializer(BigInteger.class, ToStringSerializer.instance)
|
||||
//将Long型数字转换成字符串,避免丢失精度
|
||||
.addSerializer(Long.class, ToStringSerializer.instance)
|
||||
//将Integer型数字转换成字符串
|
||||
.addSerializer(Integer.class, ToStringSerializer.instance)
|
||||
//将int型数字转换成字符串
|
||||
.addSerializer(int.class, ToStringSerializer.instance)
|
||||
//将long型数字转换成字符串
|
||||
.addSerializer(long.class, ToStringSerializer.instance)
|
||||
//序列化和反序列化日期格式
|
||||
.addDeserializer(LocalDateTime.class, new LocalDateTimeDeserializer(DateTimeFormatter.ofPattern(DEFAULT_DATE_TIME_FORMAT)))
|
||||
.addDeserializer(LocalDate.class, new LocalDateDeserializer(DateTimeFormatter.ofPattern(DEFAULT_DATE_FORMAT)))
|
||||
.addDeserializer(LocalTime.class, new LocalTimeDeserializer(DateTimeFormatter.ofPattern(DEFAULT_TIME_FORMAT)))
|
||||
.addSerializer(LocalDateTime.class, new LocalDateTimeSerializer(DateTimeFormatter.ofPattern(DEFAULT_DATE_TIME_FORMAT)))
|
||||
.addSerializer(LocalDate.class, new LocalDateSerializer(DateTimeFormatter.ofPattern(DEFAULT_DATE_FORMAT)))
|
||||
.addSerializer(LocalTime.class, new LocalTimeSerializer(DateTimeFormatter.ofPattern(DEFAULT_TIME_FORMAT)));
|
||||
|
||||
|
||||
//注册功能模块 例如,可以添加自定义序列化器和反序列化器
|
||||
this.registerModule(simpleModule);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ public class QuartzJobServiceImpl implements QuartzJobService {
|
||||
resources.put("create_id", userId);
|
||||
resources.put("create_name", nickName);
|
||||
resources.put("create_time", now);
|
||||
resources.put("update_optid", userId);
|
||||
resources.put("update_id", userId);
|
||||
resources.put("update_optname", nickName);
|
||||
resources.put("update_time", now);
|
||||
quartzTab.insert(resources);
|
||||
@@ -124,7 +124,7 @@ public class QuartzJobServiceImpl implements QuartzJobService {
|
||||
throw new BadRequestException("子任务中不能添加当前任务ID");
|
||||
}
|
||||
}
|
||||
resources.put("update_optid", SecurityUtils.getCurrentUserId());
|
||||
resources.put("update_id", SecurityUtils.getCurrentUserId());
|
||||
resources.put("update_optname", SecurityUtils.getCurrentNickName());
|
||||
resources.put("update_time", DateUtil.now());
|
||||
jobTab.update(resources);
|
||||
|
||||
@@ -58,7 +58,7 @@ public class DictDto implements Serializable {
|
||||
private String create_time;
|
||||
|
||||
/** 修改人 */
|
||||
private Long update_optid;
|
||||
private Long update_id;
|
||||
|
||||
/** 修改人 */
|
||||
private String update_optname;
|
||||
|
||||
@@ -47,7 +47,7 @@ public class GridDto {
|
||||
/**
|
||||
* 更新人id
|
||||
*/
|
||||
private String update_optid;
|
||||
private String update_id;
|
||||
|
||||
/**
|
||||
* 更新人
|
||||
|
||||
@@ -72,7 +72,7 @@ public class GridFieldDto {
|
||||
/**
|
||||
* 更新人id
|
||||
*/
|
||||
private String update_optid;
|
||||
private String update_id;
|
||||
|
||||
/**
|
||||
* 更新人
|
||||
|
||||
@@ -28,7 +28,7 @@ public class ParamDto implements Serializable {
|
||||
|
||||
private Long create_id;
|
||||
|
||||
private Long update_optid;
|
||||
private Long update_id;
|
||||
|
||||
private String create_name;
|
||||
|
||||
|
||||
@@ -70,7 +70,7 @@ public class CodeDetailServiceImpl implements CodeDetailService {
|
||||
public void update(JSONObject json) {
|
||||
String now = DateUtil.now();
|
||||
json.put("update_time",now);
|
||||
json.put("update_optid", SecurityUtils.getCurrentUserId());
|
||||
json.put("update_id", SecurityUtils.getCurrentUserId());
|
||||
json.put("update_optname", SecurityUtils.getCurrentNickName());
|
||||
WQLObject.getWQLObject("sys_code_rule_detail").update(json);
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ public class DictDetailServiceImpl implements DictDetailService {
|
||||
dictObj.put("para1", resources.getPara1());
|
||||
dictObj.put("para2", resources.getPara2());
|
||||
dictObj.put("para3", resources.getPara3());
|
||||
dictObj.put("update_optid", SecurityUtils.getCurrentUserId());
|
||||
dictObj.put("update_id", SecurityUtils.getCurrentUserId());
|
||||
dictObj.put("update_optname", SecurityUtils.getCurrentNickName());
|
||||
dictObj.put("update_time", DateUtil.now());
|
||||
wo.update(dictObj);
|
||||
@@ -89,7 +89,7 @@ public class DictDetailServiceImpl implements DictDetailService {
|
||||
resources.setCreate_id(SecurityUtils.getCurrentUserId());
|
||||
resources.setCreate_name(SecurityUtils.getCurrentNickName());
|
||||
resources.setCreate_time(DateUtil.now());
|
||||
resources.setUpdate_optid(SecurityUtils.getCurrentUserId());
|
||||
resources.setUpdate_id(SecurityUtils.getCurrentUserId());
|
||||
resources.setUpdate_optname(SecurityUtils.getCurrentNickName());
|
||||
resources.setUpdate_time(DateUtil.now());
|
||||
JSONObject json = JSONObject.parseObject(JSON.toJSONString(resources));
|
||||
@@ -106,7 +106,7 @@ public class DictDetailServiceImpl implements DictDetailService {
|
||||
}
|
||||
dto.setUpdate_time(DateUtil.now());
|
||||
dto.setUpdate_optname(SecurityUtils.getCurrentNickName());
|
||||
dto.setUpdate_optid(SecurityUtils.getCurrentUserId());
|
||||
dto.setUpdate_id(SecurityUtils.getCurrentUserId());
|
||||
JSONObject json = JSONObject.parseObject(JSON.toJSONString(dto));
|
||||
dictTab.update(json);
|
||||
// 清理缓存
|
||||
|
||||
@@ -81,7 +81,7 @@ public class DictService2Impl implements DictService2 {
|
||||
dto.setDict_id(IdUtil.getSnowflake(1, 1).nextId());
|
||||
dto.setCreate_id(currentUserId);
|
||||
dto.setCreate_name(nickName);
|
||||
dto.setUpdate_optid(currentUserId);
|
||||
dto.setUpdate_id(currentUserId);
|
||||
dto.setUpdate_optname(nickName);
|
||||
dto.setUpdate_time(date);
|
||||
dto.setCreate_time(date);
|
||||
@@ -102,7 +102,7 @@ public class DictService2Impl implements DictService2 {
|
||||
dictObj.put("code", dto.getCode());
|
||||
dictObj.put("name", dto.getName());
|
||||
dictObj.put("update_time", DateUtil.now());
|
||||
dictObj.put("update_optid", currentUserId);
|
||||
dictObj.put("update_id", currentUserId);
|
||||
dictObj.put("update_optname", nickName);
|
||||
wo.update(dictObj);
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ public class GenCodeServiceImpl implements GenCodeService {
|
||||
json.put("code", form.get("code"));
|
||||
json.put("name", form.get("name"));
|
||||
json.put("create_id", currentUserId);
|
||||
json.put("update_optid", currentUserId);
|
||||
json.put("update_id", currentUserId);
|
||||
json.put("create_name", currentUsername);
|
||||
json.put("update_optname", currentUsername);
|
||||
json.put("create_time", now);
|
||||
@@ -89,7 +89,7 @@ public class GenCodeServiceImpl implements GenCodeService {
|
||||
throw new BadRequestException("该编码code已存在,请校验!");
|
||||
}
|
||||
String now = DateUtil.now();
|
||||
json.put("update_optid", SecurityUtils.getCurrentUserId());
|
||||
json.put("update_id", SecurityUtils.getCurrentUserId());
|
||||
json.put("update_time", now);
|
||||
json.put("update_optname", SecurityUtils.getCurrentUsername());
|
||||
WQLObject.getWQLObject("sys_code_rule").update(json);
|
||||
|
||||
@@ -52,7 +52,7 @@ public class GridFieldServiceImpl implements GridFieldService {
|
||||
|
||||
dto.setId(IdUtil.simpleUUID());
|
||||
dto.setCreate_id(uid.toString());
|
||||
dto.setUpdate_optid(uid.toString());
|
||||
dto.setUpdate_id(uid.toString());
|
||||
dto.setCreate_name(currentUsername);
|
||||
dto.setUpdate_optname(currentUsername);
|
||||
dto.setUpdate_time(now);
|
||||
@@ -80,7 +80,7 @@ public class GridFieldServiceImpl implements GridFieldService {
|
||||
String currentUsername = SecurityUtils.getCurrentUsername();
|
||||
String now = DateUtil.now();
|
||||
dto.setUpdate_time(now);
|
||||
dto.setUpdate_optid(SecurityUtils.getCurrentUserId().toString());
|
||||
dto.setUpdate_id(SecurityUtils.getCurrentUserId().toString());
|
||||
dto.setUpdate_optname(currentUsername);
|
||||
|
||||
WQLObject wo = WQLObject.getWQLObject("sys_grid_field");
|
||||
@@ -118,7 +118,7 @@ public class GridFieldServiceImpl implements GridFieldService {
|
||||
fieldData.put("grid_id", grid_id);
|
||||
fieldData.put("id", IdUtil.simpleUUID());
|
||||
fieldData.put("create_id", currentUserId);
|
||||
fieldData.put("update_optid", currentUserId);
|
||||
fieldData.put("update_id", currentUserId);
|
||||
fieldData.put("create_name", currentUsername);
|
||||
fieldData.put("update_optname", currentUsername);
|
||||
fieldData.put("create_time", now);
|
||||
|
||||
@@ -49,7 +49,7 @@ public class GridServiceImpl implements GridService {
|
||||
|
||||
dto.setId(IdUtil.simpleUUID());
|
||||
dto.setCreate_id(uid.toString());
|
||||
dto.setUpdate_optid(uid.toString());
|
||||
dto.setUpdate_id(uid.toString());
|
||||
dto.setCreate_name(currentUsername);
|
||||
dto.setUpdate_optname(currentUsername);
|
||||
dto.setUpdate_time(now);
|
||||
@@ -76,7 +76,7 @@ public class GridServiceImpl implements GridService {
|
||||
|
||||
String currentUsername = SecurityUtils.getCurrentUsername();
|
||||
String now = DateUtil.now();
|
||||
dto.setUpdate_optid(SecurityUtils.getCurrentUserId().toString());
|
||||
dto.setUpdate_id(SecurityUtils.getCurrentUserId().toString());
|
||||
dto.setUpdate_time(now);
|
||||
dto.setUpdate_optname(currentUsername);
|
||||
|
||||
|
||||
@@ -81,7 +81,7 @@ public class ParamServiceImpl implements ParamService {
|
||||
|
||||
dto.setId(IdUtil.simpleUUID());
|
||||
dto.setCreate_id(currentId);
|
||||
dto.setUpdate_optid(currentId);
|
||||
dto.setUpdate_id(currentId);
|
||||
dto.setCreate_name(currentUsername.getPresonName());
|
||||
dto.setUpdate_optname(currentUsername.getPresonName());
|
||||
dto.setUpdate_time(now);
|
||||
@@ -100,7 +100,7 @@ public class ParamServiceImpl implements ParamService {
|
||||
|
||||
String now = DateUtil.now();
|
||||
|
||||
dto.setUpdate_optid(StpUtil.getLoginIdAsLong());
|
||||
dto.setUpdate_id(StpUtil.getLoginIdAsLong());
|
||||
dto.setUpdate_time(now);
|
||||
dto.setUpdate_optname(SecurityUtils.getCurrentNickName());
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ public class LocalStorage implements Serializable {
|
||||
private String create_time;
|
||||
|
||||
/** 修改人标识 */
|
||||
private String update_optid;
|
||||
private String update_id;
|
||||
|
||||
/** 修改人 */
|
||||
private String update_optname;
|
||||
@@ -67,7 +67,7 @@ public class LocalStorage implements Serializable {
|
||||
this.path = path;
|
||||
this.type = type;
|
||||
this.size = size;
|
||||
this.create_id = this.update_optid = SecurityUtils.getCurrentUserId().toString();
|
||||
this.create_id = this.update_id = SecurityUtils.getCurrentUserId().toString();
|
||||
this.create_name = this.update_optname = SecurityUtils.getCurrentNickName();
|
||||
this.create_time = this.update_time = DateUtil.now();
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ public class LocalStorageServiceImpl implements LocalStorageService {
|
||||
localStorage.put("type", type);
|
||||
localStorage.put("size", FileUtil.getSize(multipartFile.getSize()));
|
||||
localStorage.put("create_id", userId);
|
||||
localStorage.put("update_optid", userId);
|
||||
localStorage.put("update_id", userId);
|
||||
localStorage.put("create_name", nickName);
|
||||
localStorage.put("update_optname", nickName);
|
||||
localStorage.put("create_time", now);
|
||||
|
||||
@@ -67,7 +67,7 @@ public class DataPermissionDto implements Serializable {
|
||||
/**
|
||||
* 修改人标识
|
||||
*/
|
||||
private Long update_optid;
|
||||
private Long update_id;
|
||||
|
||||
/**
|
||||
* 修改人
|
||||
|
||||
@@ -81,7 +81,7 @@ public class DataPermissionServiceImpl implements DataPermissionService {
|
||||
dto.setPermission_id(IdUtil.getSnowflake(1, 1).nextId());
|
||||
dto.setCreate_id(currentUserId);
|
||||
dto.setCreate_name(nickName);
|
||||
dto.setUpdate_optid(currentUserId);
|
||||
dto.setUpdate_id(currentUserId);
|
||||
dto.setUpdate_optname(nickName);
|
||||
dto.setUpdate_time(now);
|
||||
dto.setCreate_time(now);
|
||||
@@ -102,7 +102,7 @@ public class DataPermissionServiceImpl implements DataPermissionService {
|
||||
|
||||
String now = DateUtil.now();
|
||||
dto.setUpdate_time(now);
|
||||
dto.setUpdate_optid(currentUserId);
|
||||
dto.setUpdate_id(currentUserId);
|
||||
dto.setUpdate_optname(nickName);
|
||||
|
||||
WQLObject wo = WQLObject.getWQLObject("sys_data_permission");
|
||||
@@ -122,7 +122,7 @@ public class DataPermissionServiceImpl implements DataPermissionService {
|
||||
JSONObject param = new JSONObject();
|
||||
param.put("permission_id", String.valueOf(permission_id));
|
||||
param.put("is_delete", "1");
|
||||
param.put("update_optid", currentUserId);
|
||||
param.put("update_id", currentUserId);
|
||||
param.put("update_optname", nickName);
|
||||
param.put("update_time", now);
|
||||
wo.update(param);
|
||||
|
||||
@@ -2,18 +2,24 @@ package org.nl.system.controller.menu;
|
||||
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import cn.dev33.satoken.annotation.SaMode;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.nl.common.TableDataInfo;
|
||||
import org.nl.modules.common.utils.SecurityUtils;
|
||||
import org.nl.modules.logging.annotation.Log;
|
||||
import org.nl.modules.system.service.dto.MenuDto;
|
||||
import org.nl.system.service.menu.ISysMenuService;
|
||||
import org.nl.system.service.menu.dao.SysMenu;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -33,8 +39,85 @@ public class SysMenuController {
|
||||
@ApiOperation("查询菜单")
|
||||
@SaCheckPermission("menu:list")
|
||||
public ResponseEntity<Object> pageQuery(@RequestParam Map param, Pageable page) throws Exception {
|
||||
return new ResponseEntity<>(baseService.queryAll(param),HttpStatus.OK);
|
||||
TableDataInfo data = TableDataInfo.build(baseService.queryAll(param));
|
||||
return new ResponseEntity<>(data, HttpStatus.OK);
|
||||
|
||||
}
|
||||
|
||||
@ApiOperation("返回全部的菜单")
|
||||
@GetMapping(value = "/lazy")//新增时候点击
|
||||
@SaCheckPermission(value = {"menu:list", "roles:list"}, mode = SaMode.AND)
|
||||
public ResponseEntity<Object> query(@RequestParam Long pid) {
|
||||
return new ResponseEntity<>(baseService.getMenus(pid), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@ApiOperation("查询菜单:根据ID获取同级与上级数据")
|
||||
@PostMapping("/superior")
|
||||
@SaCheckPermission("menu:list")
|
||||
public ResponseEntity<Object> getSuperior(@RequestBody List<Long> ids) {
|
||||
Set<MenuDto> menuDtos = new LinkedHashSet<>();
|
||||
if (CollectionUtil.isNotEmpty(ids)) {
|
||||
for (Long id : ids) {
|
||||
MenuDto menuDto = baseService.doToDto(baseService.findById(id));
|
||||
menuDtos.addAll(baseService.getSuperior(menuDto, new ArrayList<>()));
|
||||
}
|
||||
return new ResponseEntity<>(baseService.buildTree(new ArrayList<>(menuDtos)), HttpStatus.OK);
|
||||
}
|
||||
return new ResponseEntity<>(baseService.getMenus(null), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@GetMapping(value = "/build")
|
||||
@ApiOperation("根据用户获取菜单")
|
||||
public ResponseEntity<Object> buildMenus() {
|
||||
List<MenuDto> menuDtoList = baseService.findByUser(SecurityUtils.getCurrentUserId());
|
||||
List<MenuDto> menuDtos = baseService.buildTree(menuDtoList);
|
||||
return new ResponseEntity<>(baseService.buildMenus(menuDtos), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@ApiOperation("根据菜单ID返回所有子节点ID,包含自身ID")
|
||||
@GetMapping(value = "/child")
|
||||
@SaCheckPermission(value = {"menu:list", "roles:list"}, mode = SaMode.AND)
|
||||
public ResponseEntity<Object> child(@RequestParam Long id) {
|
||||
Set<SysMenu> menuSet = new HashSet<>();
|
||||
List<SysMenu> menuList = baseService.getMenus(id);
|
||||
menuSet.add(baseService.findById(id));
|
||||
menuSet = baseService.getChildMenus(menuList, menuSet);
|
||||
Set<Long> ids = menuSet.stream().map(SysMenu::getMenuId).collect(Collectors.toSet());
|
||||
return new ResponseEntity<>(ids, HttpStatus.OK);
|
||||
}
|
||||
|
||||
@Log("新增菜单")
|
||||
@ApiOperation("新增菜单")
|
||||
@PostMapping
|
||||
@SaCheckPermission("menu:add")
|
||||
public ResponseEntity<Object> create(@Validated @RequestBody SysMenu resources) {
|
||||
baseService.create(resources);
|
||||
return new ResponseEntity<>(HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
@Log("修改菜单")
|
||||
@ApiOperation("修改菜单")
|
||||
@PutMapping
|
||||
@SaCheckPermission("menu:edit")
|
||||
public ResponseEntity<Object> update(@RequestBody SysMenu resources) {
|
||||
baseService.update(resources);
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
@Log("删除菜单")
|
||||
@ApiOperation("删除菜单")
|
||||
@DeleteMapping
|
||||
@SaCheckPermission("menu:del")
|
||||
public ResponseEntity<Object> delete(@RequestBody Set<Long> ids) {
|
||||
Set<SysMenu> menuSet = new HashSet<>();
|
||||
for (Long id : ids) {
|
||||
//获取所有子节点
|
||||
List<SysMenu> menuList = baseService.getMenus(id);
|
||||
menuSet.add(baseService.findById(id));
|
||||
menuSet = baseService.getChildMenus(menuList, menuSet);
|
||||
}
|
||||
baseService.delete(menuSet);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -9,9 +9,7 @@ import org.nl.common.domain.query.PageQuery;
|
||||
import org.nl.modules.logging.annotation.Log;
|
||||
import org.nl.system.service.param.ISysParamService;
|
||||
import org.nl.system.service.param.dao.Param;
|
||||
import org.nl.system.service.param.dto.ParamQuery;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
@@ -73,11 +71,11 @@ class SysParamController {
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("/getValueByCode")
|
||||
@PostMapping("/getValueByCode/{code}")
|
||||
@Log("根据编码获取值")
|
||||
@ApiOperation("根据编码获取值")
|
||||
@SaIgnore
|
||||
public ResponseEntity<Object> getValueByCode(@RequestBody String code) {
|
||||
public ResponseEntity<Object> getValueByCode(@PathVariable String code) {
|
||||
return new ResponseEntity<>(paramService.findByCode(code), HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ public class SysRoleController {
|
||||
@PutMapping
|
||||
// @SaCheckPermission("roles:edit")
|
||||
public ResponseEntity<Object> update(@RequestBody JSONObject param) {
|
||||
roleService.update(param);
|
||||
// roleService.update(param);
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
|
||||
@@ -18,11 +18,8 @@ package org.nl.system.controller.user;
|
||||
import cn.dev33.satoken.secure.SaSecureUtil;
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.support.SFunction;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -43,9 +40,9 @@ import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.function.BiPredicate;
|
||||
|
||||
/**
|
||||
* @author Zheng Jie
|
||||
@@ -63,10 +60,9 @@ public class UserController {
|
||||
|
||||
@ApiOperation("查询用户")
|
||||
@GetMapping
|
||||
// @SaCheckPermission("user:list")
|
||||
public ResponseEntity<Object> query(UserQuery query, PageQuery page){
|
||||
Page<SysUser> pageable = userService.page(page.build(), query.build());
|
||||
return new ResponseEntity<>(TableDataInfo.build(pageable),HttpStatus.OK);
|
||||
List<Map<String, Object>> userDetail = userService.getUserDetail(query, page);
|
||||
return new ResponseEntity(TableDataInfo.build(userDetail),HttpStatus.OK);
|
||||
}
|
||||
|
||||
@Log("新增用户")
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="org.nl.system.service.dict.dao.mapper.SysDictMapper">
|
||||
|
||||
</mapper>
|
||||
@@ -1,11 +1,13 @@
|
||||
package org.nl.system.service.menu;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.nl.modules.system.domain.vo.MenuVo;
|
||||
import org.nl.modules.system.service.dto.MenuDto;
|
||||
import org.nl.system.service.menu.dao.SysMenu;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -25,13 +27,77 @@ public interface ISysMenuService extends IService<SysMenu> {
|
||||
*/
|
||||
List<MenuDto> queryAll(Map<String, Object> param) throws Exception;
|
||||
|
||||
|
||||
/**
|
||||
* 根据ID获取同级与上级数据
|
||||
* @param menuDto /
|
||||
* @param menus /
|
||||
* @return /
|
||||
*/
|
||||
List<MenuDto> getSuperior(MenuDto menuDto, List<SysMenu> menus);
|
||||
|
||||
/**
|
||||
* 根据ID查询
|
||||
* @param id /
|
||||
* @return /
|
||||
*/
|
||||
SysMenu findById(long id);
|
||||
List<SysMenu> findByPid(long pid);
|
||||
List<SysMenu> findByPidIsNull();
|
||||
|
||||
/**
|
||||
* 获取所有子节点,包含自身ID
|
||||
*
|
||||
* @param menuList /
|
||||
* @param menuSet /
|
||||
* @return /
|
||||
*/
|
||||
Set<SysMenu> getChildMenus(List<SysMenu> menuList, Set<SysMenu> menuSet);
|
||||
|
||||
/**
|
||||
* 创建
|
||||
* @param menu /
|
||||
*/
|
||||
void create(SysMenu menu);
|
||||
|
||||
/**
|
||||
* 删除
|
||||
* @param menuSet /
|
||||
*/
|
||||
void delete(Set<SysMenu> menuSet);
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
* @param menu /
|
||||
*/
|
||||
void update(SysMenu menu);
|
||||
|
||||
|
||||
List<MenuDto> findByUser(Long userId);
|
||||
|
||||
/**
|
||||
* 构建菜单树
|
||||
*
|
||||
* @param menuDtos /
|
||||
* @return /
|
||||
*/
|
||||
List<MenuVo> buildMenus(List<MenuDto> menuDtos);
|
||||
|
||||
|
||||
/**
|
||||
* 构建菜单树
|
||||
* @param menuDtos 原始数据
|
||||
* @return /
|
||||
*/
|
||||
List<MenuDto> buildTree(List<MenuDto> menuDtos);
|
||||
|
||||
/**
|
||||
* 懒加载菜单数据
|
||||
*
|
||||
* @param pid /
|
||||
* @return /
|
||||
*/
|
||||
List<MenuDto> getMenus(Long pid);
|
||||
List<SysMenu> getMenus(Long pid);
|
||||
|
||||
/**
|
||||
* @param sysMenu
|
||||
|
||||
@@ -1,8 +1,12 @@
|
||||
package org.nl.system.service.menu.dao.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
import org.nl.system.service.menu.dao.SysMenu;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 菜单表 Mapper 接口
|
||||
@@ -12,5 +16,18 @@ import org.nl.system.service.menu.dao.SysMenu;
|
||||
* @since 2022-12-15
|
||||
*/
|
||||
public interface SysMenuMapper extends BaseMapper<SysMenu> {
|
||||
@Select("select * from sys_menu where pid is null")
|
||||
List<SysMenu> findByPidIsNull();
|
||||
|
||||
@Select("select * from sys_menu where pid = #{pid}")
|
||||
List<SysMenu> findByPid(@Param("pid") Long pid);
|
||||
|
||||
/**
|
||||
* 根据用户获取菜单
|
||||
*
|
||||
* @param userId 用户标识
|
||||
* @return 当前用户拥有的菜单列表
|
||||
*/
|
||||
List<SysMenu> findByUser(@Param("userId") Long userId);
|
||||
|
||||
}
|
||||
|
||||
@@ -2,4 +2,20 @@
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="org.nl.system.service.menu.dao.mapper.SysMenuMapper">
|
||||
|
||||
<select id="findByUser" resultType="org.nl.system.service.menu.dao.SysMenu">
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
sys_menu
|
||||
WHERE
|
||||
type != '2'
|
||||
AND menu_id IN (
|
||||
SELECT
|
||||
menu_id
|
||||
FROM
|
||||
sys_roles_menus
|
||||
WHERE
|
||||
role_id IN ( SELECT role_id FROM sys_users_roles WHERE 1 = 1 and user_id=#{userId} ))
|
||||
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
@@ -1,16 +1,22 @@
|
||||
package org.nl.system.service.menu.impl;
|
||||
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.nl.modules.common.exception.BadRequestException;
|
||||
import org.nl.modules.system.domain.vo.MenuMetaVo;
|
||||
import org.nl.modules.system.domain.vo.MenuVo;
|
||||
import org.nl.modules.system.service.dto.MenuDto;
|
||||
import org.nl.system.service.menu.ISysMenuService;
|
||||
import org.nl.system.service.menu.dao.SysMenu;
|
||||
import org.nl.system.service.menu.dao.mapper.SysMenuMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@@ -28,20 +34,225 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
|
||||
|
||||
@Override
|
||||
public List<MenuDto> queryAll(Map<String, Object> param) throws Exception {
|
||||
Long pid = MapUtil.getLong(param, "pid");
|
||||
/*List<SysMenu> sysMenus = baseMapper.selectList(null);
|
||||
List<MenuDto> menus = sysMenus.stream().map(menu -> doToDto(menu)).collect(Collectors.toList());*/
|
||||
return getMenus(null);
|
||||
return getMenus(pid).stream().map(menu -> this.doToDto(menu)).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MenuDto> getMenus(Long pid) {
|
||||
public List<MenuDto> getSuperior(MenuDto menuDto, List<SysMenu> menus) {
|
||||
if (menuDto.getPid() == null) {
|
||||
menus.addAll(this.findByPidIsNull());
|
||||
return menus.stream().map(menu -> this.doToDto(menu)).collect(Collectors.toList());
|
||||
}
|
||||
menus.addAll(baseMapper.findByPid(menuDto.getPid()));
|
||||
|
||||
return getSuperior(this.doToDto(findById(menuDto.getPid())), menus);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SysMenu findById(long id) {
|
||||
return baseMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SysMenu> findByPid(long pid) {
|
||||
return baseMapper.findByPid(pid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SysMenu> findByPidIsNull() {
|
||||
return baseMapper.findByPidIsNull();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<SysMenu> getChildMenus(List<SysMenu> menuList, Set<SysMenu> menuSet) {
|
||||
for (SysMenu menu : menuList) {
|
||||
menuSet.add(menu);
|
||||
List<SysMenu> menus = this.findByPid(menu.getMenuId());
|
||||
if (menus != null && menus.size() != 0) {
|
||||
getChildMenus(menus, menuSet);
|
||||
}
|
||||
}
|
||||
return menuSet;
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public void create(SysMenu resources) {
|
||||
|
||||
if (resources.getPid().equals(0L)) {
|
||||
resources.setPid(null);
|
||||
}
|
||||
if (resources.getIFrame()) {
|
||||
String http = "http://", https = "https://";
|
||||
if (!(resources.getPath().toLowerCase().startsWith(http) || resources.getPath().toLowerCase().startsWith(https))) {
|
||||
throw new BadRequestException("外链必须以http://或者https://开头");
|
||||
}
|
||||
}
|
||||
baseMapper.insert(resources);
|
||||
// 计算子节点数目
|
||||
resources.setSubCount(0);
|
||||
// 更新父节点菜单数目
|
||||
updateSubCnt(resources.getPid());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void delete(Set<SysMenu> menuSet) {
|
||||
for (SysMenu menu : menuSet) {
|
||||
//解绑菜单
|
||||
// roleService.untiedMenu(menu.getId());
|
||||
baseMapper.deleteById(menu.getMenuId());
|
||||
updateSubCnt(menu.getPid());
|
||||
}
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public void update(SysMenu resources) {
|
||||
if (resources.getMenuId().equals(resources.getPid())) {
|
||||
throw new BadRequestException("上级不能为自己");
|
||||
}
|
||||
SysMenu menu = baseMapper.selectById(resources.getMenuId());
|
||||
if (resources.getIFrame()) {
|
||||
String http = "http://", https = "https://";
|
||||
if (!(resources.getPath().toLowerCase().startsWith(http) || resources.getPath().toLowerCase().startsWith(https))) {
|
||||
throw new BadRequestException("外链必须以http://或者https://开头");
|
||||
}
|
||||
}
|
||||
if (resources.getPid().equals(0L)) {
|
||||
resources.setPid(null);
|
||||
}
|
||||
|
||||
// 记录的父节点ID
|
||||
Long oldPid = menu.getPid();
|
||||
Long newPid = resources.getPid();
|
||||
menu.setTitle(resources.getTitle());
|
||||
menu.setComponent(resources.getComponent());
|
||||
menu.setPath(resources.getPath());
|
||||
menu.setIcon(resources.getIcon());
|
||||
menu.setIFrame(resources.getIFrame());
|
||||
menu.setPid(resources.getPid());
|
||||
menu.setMenuSort(resources.getMenuSort());
|
||||
menu.setCache(resources.getCache());
|
||||
menu.setHidden(resources.getHidden());
|
||||
menu.setComponentName(resources.getComponentName());
|
||||
menu.setPermission(resources.getPermission());
|
||||
menu.setType(resources.getType());
|
||||
baseMapper.updateById(menu);
|
||||
// 计算父级菜单节点数目
|
||||
updateSubCnt(oldPid);
|
||||
updateSubCnt(newPid);
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算菜单子节点数目
|
||||
*
|
||||
* @param menuId
|
||||
*/
|
||||
private void updateSubCnt(Long menuId) {
|
||||
if (menuId != null) {
|
||||
int count = baseMapper.findByPid(menuId).size();
|
||||
SysMenu sysMenu = baseMapper.selectById(menuId);
|
||||
if (ObjectUtil.isEmpty(sysMenu)) return;
|
||||
sysMenu.setSubCount(count);
|
||||
baseMapper.updateById(sysMenu);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MenuDto> findByUser(Long userId) {
|
||||
return baseMapper.findByUser(userId).stream().map(menu -> this.doToDto(menu)).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MenuVo> buildMenus(List<MenuDto> menuDtos) {
|
||||
List<MenuVo> list = new LinkedList<>();
|
||||
menuDtos.forEach(menuDTO -> {
|
||||
if (menuDTO != null) {
|
||||
List<MenuDto> menuDtoList = menuDTO.getChildren();
|
||||
MenuVo menuVo = new MenuVo();
|
||||
menuVo.setName(ObjectUtil.isNotEmpty(menuDTO.getComponentName()) ? menuDTO.getComponentName() : menuDTO.getTitle());
|
||||
// 一级目录需要加斜杠,不然会报警告
|
||||
menuVo.setPath(ObjectUtil.isEmpty(menuDTO.getPid()) ? "/" + menuDTO.getPath() : menuDTO.getPath());
|
||||
menuVo.setHidden(menuDTO.getHidden());
|
||||
// 如果不是外链
|
||||
if (!menuDTO.getIFrame()) {
|
||||
if (ObjectUtil.isEmpty(menuDTO.getPid())) {
|
||||
menuVo.setComponent(StrUtil.isEmpty(menuDTO.getComponent()) ? "Layout" : menuDTO.getComponent());
|
||||
} else if (!ObjectUtil.isEmpty(menuDTO.getPid()) && menuDTO.getType() == 0) {
|
||||
menuVo.setComponent(StrUtil.isEmpty(menuDTO.getComponent()) ? "ParentView" : menuDTO.getComponent());
|
||||
|
||||
} else if (!StrUtil.isEmpty(menuDTO.getComponent())) {
|
||||
menuVo.setComponent(menuDTO.getComponent());
|
||||
}
|
||||
}
|
||||
menuVo.setMeta(new MenuMetaVo(menuDTO.getTitle(), menuDTO.getIcon(), !menuDTO.getCache()));
|
||||
if (menuDtoList != null && menuDtoList.size() != 0) {
|
||||
menuVo.setAlwaysShow(true);
|
||||
menuVo.setRedirect("noredirect");
|
||||
menuVo.setChildren(buildMenus(menuDtoList));
|
||||
// 处理是一级菜单并且没有子菜单的情况
|
||||
} else if (ObjectUtil.isEmpty(menuDTO.getPid())) {
|
||||
MenuVo menuVo1 = new MenuVo();
|
||||
menuVo1.setMeta(menuVo.getMeta());
|
||||
// 非外链
|
||||
if (!menuDTO.getIFrame()) {
|
||||
menuVo1.setPath("index");
|
||||
menuVo1.setName(menuVo.getName());
|
||||
menuVo1.setComponent(menuVo.getComponent());
|
||||
} else {
|
||||
menuVo1.setPath(menuDTO.getPath());
|
||||
}
|
||||
menuVo.setName(null);
|
||||
menuVo.setMeta(null);
|
||||
menuVo.setComponent("Layout");
|
||||
List<MenuVo> list1 = new ArrayList<>();
|
||||
list1.add(menuVo1);
|
||||
menuVo.setChildren(list1);
|
||||
}
|
||||
list.add(menuVo);
|
||||
}
|
||||
}
|
||||
);
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MenuDto> buildTree(List<MenuDto> menuDtos) {
|
||||
List<MenuDto> trees = new ArrayList<>();
|
||||
Set<Long> ids = new HashSet<>();
|
||||
for (MenuDto menuDTO : menuDtos) {
|
||||
if (menuDTO.getPid() == null) {
|
||||
trees.add(menuDTO);
|
||||
}
|
||||
for (MenuDto it : menuDtos) {
|
||||
if (menuDTO.getMenuId().equals(it.getPid())) {
|
||||
if (menuDTO.getChildren() == null) {
|
||||
menuDTO.setChildren(new ArrayList<>());
|
||||
}
|
||||
menuDTO.getChildren().add(it);
|
||||
ids.add(it.getMenuId());
|
||||
}
|
||||
}
|
||||
}
|
||||
if (trees.size() == 0) {
|
||||
trees = menuDtos.stream().filter(s -> !ids.contains(s.getMenuId())).collect(Collectors.toList());
|
||||
}
|
||||
return trees;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SysMenu> getMenus(Long pid) {
|
||||
QueryWrapper<SysMenu> queryWrapper;
|
||||
if (pid != null && !pid.equals(0L)) {
|
||||
queryWrapper = new QueryWrapper<SysMenu>().eq("pid", pid);
|
||||
} else {
|
||||
queryWrapper = new QueryWrapper<SysMenu>().isNull("pid");
|
||||
}
|
||||
return baseMapper.selectList(queryWrapper).stream().map(menu -> doToDto(menu)).collect(Collectors.toList());
|
||||
return baseMapper.selectList(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -79,7 +79,10 @@ public class SysParamServiceImpl extends ServiceImpl<SysParamMapper, Param> impl
|
||||
|
||||
@Override
|
||||
public Param findByCode(String code) {
|
||||
List<Param> paramList = paramMapper.selectByMap(MapOf.of("code", code));
|
||||
return paramList.get(0);
|
||||
// List<Param> paramList = paramMapper.selectByMap(MapOf.of("code", code));
|
||||
QueryWrapper<Param> queryWrapper=new QueryWrapper<>();
|
||||
queryWrapper.eq("code",code);
|
||||
Param param = paramMapper.selectOne(queryWrapper);
|
||||
return param;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
package org.nl.system.service.user;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.nl.common.domain.query.PageQuery;
|
||||
import org.nl.system.service.user.dao.SysUser;
|
||||
import org.nl.system.service.user.dto.UserQuery;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
@@ -18,4 +22,6 @@ public interface ISysUserService extends IService<SysUser> {
|
||||
|
||||
Map<String, String> updateAvatar(MultipartFile avatar);
|
||||
|
||||
List<Map<String, Object>> getUserDetail(UserQuery query, PageQuery pageQuery);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,10 +1,15 @@
|
||||
package org.nl.system.service.user.dao.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
import org.nl.common.domain.query.PageQuery;
|
||||
import org.nl.system.service.user.dao.SysUser;
|
||||
import org.nl.system.service.user.dto.SysUserDetail;
|
||||
import org.nl.system.service.user.dto.UserQuery;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -16,8 +21,8 @@ import java.util.List;
|
||||
*/
|
||||
public interface SysUserMapper extends BaseMapper<SysUser> {
|
||||
|
||||
List<SysUser> selectAl();
|
||||
@Select("select * from sys_user")
|
||||
List<SysUser> selectAl2();
|
||||
List<SysUserDetail> getUserDetail(@Param("query") UserQuery query, @Param("page")PageQuery page);
|
||||
|
||||
List<Map<String,Object>> getDetailForMap(@Param("query") UserQuery query, @Param("page")PageQuery page);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,121 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="org.nl.system.service.user.dao.mapper.SysUserMapper">
|
||||
<sql id="Base_Column_List">
|
||||
sys_user.user_id as userId,
|
||||
sys_user.username as username,
|
||||
sys_user.person_name as personName,
|
||||
sys_user.gender,
|
||||
sys_user.phone,
|
||||
sys_user.email,
|
||||
sys_user.avatar_name as avatarName,
|
||||
sys_user.avatar_path as avatarPath,
|
||||
sys_user.password,
|
||||
sys_user.is_admin as isAdmin,
|
||||
sys_user.is_used as isUsed,
|
||||
sys_user.pwd_reset_user_id as pwdResetUserId,
|
||||
sys_user.pwd_reset_time as pwdResetTime,
|
||||
sys_user.create_id as createId,
|
||||
sys_user.create_name as createName,
|
||||
sys_user.create_time as createTime,
|
||||
sys_user.update_optid as updateOptid,
|
||||
sys_user.update_optname as updateOptname,
|
||||
sys_user.update_time as updateTime,
|
||||
sys_user.extperson_id as extpersonId,
|
||||
sys_user.extuser_id as extuserId
|
||||
</sql>
|
||||
<resultMap id="UserDetail" type="org.nl.system.service.user.dto.SysUserDetail" >
|
||||
<id column="user_id" property="userId" />
|
||||
<result column="username" property="username" />
|
||||
<result column="person_name" property="personName" />
|
||||
<result column="gender" property="gender" />
|
||||
<result column="phone" property="phone" />
|
||||
<result column="email" property="email" />
|
||||
<result column="avatar_name" property="avatarName" />
|
||||
<result column="avatar_path" property="avatarPath" />
|
||||
<result column="password" property="password" />
|
||||
<result column="is_admin" property="isAdmin" />
|
||||
<result column="is_used" property="isUsed" />
|
||||
<result column="pwd_reset_user_id" property="pwdResetUserId" />
|
||||
<result column="pwd_reset_time" property="pwdResetTime" />
|
||||
<result column="create_id" property="createId" />
|
||||
<result column="create_name" property="createName" />
|
||||
<result column="create_time" property="createTime" />
|
||||
<result column="update_optid" property="updateOptid" />
|
||||
<result column="update_optname" property="updateOptname" />
|
||||
<result column="update_tim" property="updateTime" />
|
||||
<result column="extperson_id" property="extpersonId" />
|
||||
<result column="extuser_i" property="extuserId" />
|
||||
<collection property="depts" ofType="org.nl.system.service.dept.dao.SysDept">
|
||||
<id property="dept_id" column="deptId"/>
|
||||
<result column="dept_name" property="name"/>
|
||||
</collection>
|
||||
<collection property="roles" ofType="org.nl.system.service.role.dao.SysRole">
|
||||
<id property="role_id" column="levelId"/>
|
||||
<result column="name" property="name"/>
|
||||
</collection>
|
||||
</resultMap>
|
||||
<select id="getUserDetail" resultMap="UserDetail">
|
||||
SELECT
|
||||
<include refid="Base_Column_List"/>
|
||||
,sys_dept.dept_id
|
||||
,sys_dept.name as dept_name
|
||||
,sys_role.role_id
|
||||
,sys_role.name as role_name
|
||||
FROM
|
||||
sys_user
|
||||
left join sys_user_dept on sys_user.user_id = sys_user_dept.user_id
|
||||
left join sys_users_roles on sys_users_roles.user_id = sys_user.user_id
|
||||
left join sys_dept on sys_user_dept.dept_id = sys_dept.dept_id
|
||||
left join sys_role on sys_users_roles.role_id = sys_role.role_id
|
||||
<where>
|
||||
<if test="query.deptId != null">
|
||||
and sys_dept.dept_id = #{query.deptId}
|
||||
</if>
|
||||
<if test="query.isUsed != null">
|
||||
and sys_user.is_used = #{query.isUsed}
|
||||
</if>
|
||||
<if test="query.startTime != null">
|
||||
and and sys_user.create_time >= #{query.startTime}
|
||||
</if>
|
||||
<if test="query.endTime != null">
|
||||
and #{query.endTime} >= sys_user.create_time
|
||||
</if>
|
||||
<if test="query.blurry != null">
|
||||
and (email like query.blurry or username like query.blurry or person_name like query.blurry)
|
||||
</if>
|
||||
</where>
|
||||
GROUP BY sys_user.user_id
|
||||
</select>
|
||||
|
||||
<select id="getDetailForMap" resultType="java.util.Map">
|
||||
SELECT
|
||||
<include refid="Base_Column_List"/>
|
||||
,GROUP_CONCAT(DISTINCT sys_dept.dept_id) as depts,
|
||||
GROUP_CONCAT(DISTINCT sys_dept.name) as deptnames,
|
||||
GROUP_CONCAT(DISTINCT role_id) as roles
|
||||
FROM
|
||||
sys_user
|
||||
left join sys_user_dept on sys_user.user_id = sys_user_dept.user_id
|
||||
left join sys_users_roles on sys_users_roles.user_id = sys_user.user_id
|
||||
left join sys_dept on sys_user_dept.dept_id = sys_dept.dept_id
|
||||
<where>
|
||||
<if test="query.deptId != null">
|
||||
and sys_dept.dept_id = #{query.deptId}
|
||||
</if>
|
||||
<if test="query.isUsed != null">
|
||||
and sys_user.is_used = #{query.isUsed}
|
||||
</if>
|
||||
<if test="query.startTime != null">
|
||||
and and sys_user.create_time >= #{query.startTime}
|
||||
</if>
|
||||
<if test="query.endTime != null">
|
||||
and #{query.endTime} >= sys_user.create_time
|
||||
</if>
|
||||
<if test="query.blurry != null">
|
||||
and (email like #{query.blurry} or username like #{query.blurry} or person_name like #{query.blurry})
|
||||
</if>
|
||||
</where>
|
||||
GROUP BY sys_user.user_id
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
package org.nl.system.service.user.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import org.nl.system.service.dept.dao.SysDept;
|
||||
import org.nl.system.service.role.dao.SysRole;
|
||||
import org.nl.system.service.user.dao.SysUser;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/*
|
||||
* @author ZZQ
|
||||
* @Date 2022/12/16 10:02 上午
|
||||
*/
|
||||
@Data
|
||||
public class SysUserDetail extends SysUser {
|
||||
|
||||
private List<SysDept> depts;
|
||||
|
||||
private List<SysRole> roles;
|
||||
}
|
||||
@@ -1,20 +1,26 @@
|
||||
package org.nl.system.service.user.impl;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.nl.common.domain.query.PageQuery;
|
||||
import org.nl.modules.common.config.FileProperties;
|
||||
import org.nl.modules.common.utils.FileUtil;
|
||||
import org.nl.modules.common.utils.SecurityUtils;
|
||||
import org.nl.system.service.user.ISysUserService;
|
||||
import org.nl.system.service.user.dao.SysUser;
|
||||
import org.nl.system.service.user.dao.mapper.SysUserMapper;
|
||||
import org.nl.system.service.user.dto.SysUserDetail;
|
||||
import org.nl.system.service.user.dto.UserQuery;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
@@ -31,6 +37,8 @@ public class ISysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> imp
|
||||
|
||||
@Autowired
|
||||
FileProperties properties;
|
||||
@Autowired
|
||||
SysUserMapper sysUserMapper;
|
||||
|
||||
@Override
|
||||
public Map<String, String> updateAvatar(MultipartFile multipartFile) {
|
||||
@@ -47,4 +55,10 @@ public class ISysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> imp
|
||||
put("avatar", file.getName());
|
||||
}};
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Map<String, Object>> getUserDetail(UserQuery query, PageQuery pageQuery) {
|
||||
List<Map<String, Object>> userDetail = sysUserMapper.getDetailForMap(query, pageQuery);
|
||||
return userDetail;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,7 +80,7 @@ public class ${className}ServiceImpl implements ${className}Service {
|
||||
dto.set${pkChangeColName ? cap_first }(IdUtil.getSnowflake(1, 1).nextId());
|
||||
dto.setCreate_id(currentUserId);
|
||||
dto.setCreate_name(nickName);
|
||||
dto.setUpdate_optid(currentUserId);
|
||||
dto.setUpdate_id(currentUserId);
|
||||
dto.setUpdate_optname(nickName);
|
||||
dto.setUpdate_time(now);
|
||||
dto.setCreate_time(now);
|
||||
@@ -101,7 +101,7 @@ public class ${className}ServiceImpl implements ${className}Service {
|
||||
|
||||
String now = DateUtil.now();
|
||||
dto.setUpdate_time(now);
|
||||
dto.setUpdate_optid(currentUserId);
|
||||
dto.setUpdate_id(currentUserId);
|
||||
dto.setUpdate_optname(nickName);
|
||||
|
||||
WQLObject wo = WQLObject.getWQLObject("${tableName}");
|
||||
@@ -121,7 +121,7 @@ public class ${className}ServiceImpl implements ${className}Service {
|
||||
JSONObject param = new JSONObject();
|
||||
param.put("${pkChangeColName}", String.valueOf(${pkChangeColName}));
|
||||
param.put("is_delete", "1");
|
||||
param.put("update_optid", currentUserId);
|
||||
param.put("update_id", currentUserId);
|
||||
param.put("update_optname", nickName);
|
||||
param.put("update_time", now);
|
||||
wo.update(param);
|
||||
|
||||
@@ -1,12 +1,9 @@
|
||||
package org.nl.sso;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.nl.AppRun;
|
||||
|
||||
import org.nl.system.service.user.ISysUserService;
|
||||
import org.nl.system.service.user.dao.SysUser;
|
||||
import org.nl.system.service.user.dao.mapper.SysUserMapper;
|
||||
import org.nl.system.service.menu.ISysMenuService;
|
||||
import org.nl.system.service.menu.dao.SysMenu;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
@@ -21,11 +18,11 @@ import java.util.List;
|
||||
public class MybatisTest {
|
||||
|
||||
@Resource
|
||||
SysUserMapper sysUserMapper;
|
||||
ISysMenuService iSysMenuService;
|
||||
@Test
|
||||
public void mybatisTest(){
|
||||
List<SysUser> sysUsers = sysUserMapper.selectAl();
|
||||
System.out.println(sysUsers.size());
|
||||
List<SysMenu> sysUsers = iSysMenuService.findByPid(1597878521852727297L);
|
||||
System.out.println(sysUsers);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -54,6 +54,7 @@
|
||||
"js-cookie": "2.2.0",
|
||||
"jsbarcode": "^3.11.5",
|
||||
"jsencrypt": "^3.0.0-rc.1",
|
||||
"json-bigint": "^1.0.0",
|
||||
"jszip": "3.1.5",
|
||||
"mavon-editor": "^2.9.0",
|
||||
"normalize.css": "7.0.0",
|
||||
|
||||
@@ -2,14 +2,14 @@ import request from '@/utils/request'
|
||||
|
||||
export function getMenusTree(pid) {
|
||||
return request({
|
||||
url: 'api/menus/lazy?pid=' + pid,
|
||||
url: 'api/sysMenu/lazy?pid=' + pid,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
export function getMenus(params) {
|
||||
return request({
|
||||
url: 'api/menus',
|
||||
url: 'api/sysMenu',
|
||||
method: 'get',
|
||||
params
|
||||
})
|
||||
@@ -17,19 +17,17 @@ export function getMenus(params) {
|
||||
|
||||
export function getMenusByRole(params) {
|
||||
return request({
|
||||
url: 'api/menus/getMenusByRole',
|
||||
url: 'api/sysMenu/getMenusByRole',
|
||||
method: 'post',
|
||||
data: params
|
||||
})
|
||||
}
|
||||
|
||||
export function getMenuSuperior(ids) {
|
||||
// const data = ids.length || ids.length === 0 ? ids : Array.of(ids)
|
||||
const data = {
|
||||
'ids': ids
|
||||
}
|
||||
const data = ids.length || ids.length === 0 ? ids : Array.of(ids)
|
||||
debugger
|
||||
return request({
|
||||
url: 'api/menus/superior',
|
||||
url: 'api/sysMenu/superior',
|
||||
method: 'post',
|
||||
data
|
||||
})
|
||||
@@ -37,21 +35,21 @@ export function getMenuSuperior(ids) {
|
||||
|
||||
export function getChild(id) {
|
||||
return request({
|
||||
url: 'api/menus/child?id=' + id,
|
||||
url: 'api/sysMenu/child?id=' + id,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
export function buildMenus(data) {
|
||||
return request({
|
||||
url: 'api/menus/build?system_type=' + data,
|
||||
url: 'api/sysMenu/build?system_type=' + data,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
export function add(data) {
|
||||
return request({
|
||||
url: 'api/menus',
|
||||
url: 'api/sysMenu',
|
||||
method: 'post',
|
||||
data
|
||||
})
|
||||
@@ -59,7 +57,7 @@ export function add(data) {
|
||||
|
||||
export function del(ids) {
|
||||
return request({
|
||||
url: 'api/menus',
|
||||
url: 'api/sysMenu',
|
||||
method: 'delete',
|
||||
data: ids
|
||||
})
|
||||
@@ -67,7 +65,7 @@ export function del(ids) {
|
||||
|
||||
export function edit(data) {
|
||||
return request({
|
||||
url: 'api/menus',
|
||||
url: 'api/sysMenu',
|
||||
method: 'put',
|
||||
data
|
||||
})
|
||||
|
||||
@@ -26,9 +26,8 @@ export function edit(data) {
|
||||
|
||||
export function getValueByCode(code) {
|
||||
return request({
|
||||
url: 'api/param/getValueByCode',
|
||||
method: 'post',
|
||||
data: code
|
||||
url: 'api/param/getValueByCode/' + code,
|
||||
method: 'post'
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
@keyup.enter.native="crud.toQuery"
|
||||
/>
|
||||
<el-select
|
||||
v-model="query.is_used"
|
||||
v-model="query.isUsed"
|
||||
clearable
|
||||
size="mini"
|
||||
placeholder="状态"
|
||||
@@ -63,7 +63,7 @@
|
||||
</el-form-item>
|
||||
<el-form-item label="状态" prop="is_uesd">
|
||||
<el-switch
|
||||
v-model="form.is_used"
|
||||
v-model="form.isUsed"
|
||||
active-color="#409EFF"
|
||||
inactive-color="#F56C6C"
|
||||
active-value="1"
|
||||
@@ -103,10 +103,10 @@
|
||||
<!-- <el-table-column label="编码" prop="code" />-->
|
||||
<el-table-column label="名称" prop="name" />
|
||||
<el-table-column label="排序" prop="dept_sort" />
|
||||
<el-table-column label="状态" align="center" prop="is_used">
|
||||
<el-table-column label="状态" align="center" prop="isUsed">
|
||||
<template slot-scope="scope">
|
||||
<el-switch
|
||||
v-model="scope.row.is_used"
|
||||
v-model="scope.row.isUsed"
|
||||
:disabled="scope.row.id === 1"
|
||||
active-color="#409EFF"
|
||||
inactive-color="#F56C6C"
|
||||
@@ -153,7 +153,7 @@ const defaultForm = {
|
||||
sub_count: 0,
|
||||
pid: null,
|
||||
dept_sort: 999,
|
||||
is_used: '1',
|
||||
isUsed: '1',
|
||||
ext_id: null
|
||||
}
|
||||
export default {
|
||||
@@ -203,7 +203,7 @@ export default {
|
||||
} else {
|
||||
form.isTop = '1'
|
||||
}
|
||||
form.is_used = `${form.is_used}`
|
||||
form.isUsed = `${form.isUsed}`
|
||||
if (form.pid != null) {
|
||||
this.getSupDepts(form.pid)
|
||||
} else {
|
||||
@@ -228,7 +228,7 @@ export default {
|
||||
})
|
||||
},
|
||||
getDepts() {
|
||||
crudDept.getDeptvo({ is_used: '1' }).then(res => {
|
||||
crudDept.getDeptvo({ isUsed: '1' }).then(res => {
|
||||
this.depts = res.content.map(function(obj) {
|
||||
if (obj.hasChildren) {
|
||||
obj.children = null
|
||||
@@ -240,7 +240,7 @@ export default {
|
||||
// 获取弹窗内部门数据
|
||||
loadDepts({ action, parentNode, callback }) {
|
||||
if (action === LOAD_CHILDREN_OPTIONS) {
|
||||
crudDept.getDeptvo({ is_used: '1', pid: parentNode.dept_id }).then(res => {
|
||||
crudDept.getDeptvo({ isUsed: '1', pid: parentNode.dept_id }).then(res => {
|
||||
parentNode.children = res.content.map(function(obj) {
|
||||
obj.children = null
|
||||
return obj
|
||||
|
||||
@@ -138,6 +138,8 @@
|
||||
>
|
||||
<el-table-column type="selection" width="55" />
|
||||
<el-table-column label="菜单标题" prop="title" :min-width="flexWidth('title',crud.data,'菜单标题')" />
|
||||
<el-table-column label="菜单标识" prop="menuId" :min-width="flexWidth('title',crud.data,'菜单标识')" />
|
||||
<el-table-column label="菜单标识" prop="menu_id" :min-width="flexWidth('title',crud.data,'菜单标识')" />
|
||||
<el-table-column label="子系统" prop="system_type" :min-width="flexWidth('system_type',crud.data,'子系统')" />
|
||||
<el-table-column prop="icon" label="图标" align="center" :min-width="flexWidth('icon',crud.data,'图标')">
|
||||
<template slot-scope="scope">
|
||||
@@ -185,7 +187,6 @@ import CRUD, { presenter, header, form, crud } from '@crud/crud'
|
||||
import rrOperation from '@crud/RR.operation'
|
||||
import crudOperation from '@crud/CRUD.operation'
|
||||
import udOperation from '@crud/UD.operation'
|
||||
import DateRangePicker from '@/components/DateRangePicker'
|
||||
|
||||
// crud交由presenter持有
|
||||
const defaultForm = {
|
||||
@@ -208,7 +209,7 @@ const defaultForm = {
|
||||
}
|
||||
export default {
|
||||
name: 'Menu',
|
||||
components: { Treeselect, IconSelect, crudOperation, rrOperation, udOperation, DateRangePicker },
|
||||
components: { Treeselect, IconSelect, crudOperation, rrOperation, udOperation },
|
||||
cruds() {
|
||||
return CRUD({ title: '菜单', idField: 'menuId', url: 'api/sysMenu', crudMethod: { ...crudMenu }})
|
||||
},
|
||||
@@ -260,6 +261,7 @@ export default {
|
||||
}, 100)
|
||||
},
|
||||
getSupDepts(menuId) {
|
||||
debugger
|
||||
crudMenu.getMenuSuperior(menuId).then(res => {
|
||||
const children = res.map(function(obj) {
|
||||
if (!obj.leaf && !obj.children) {
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
</el-col>
|
||||
<!--用户数据-->
|
||||
<el-col :span="20">
|
||||
<!--工具栏1-->
|
||||
<!--工具栏-->
|
||||
<div class="head-container">
|
||||
<div v-if="crud.props.searchToggle">
|
||||
<!-- 搜索 -->
|
||||
@@ -36,7 +36,7 @@
|
||||
@keyup.enter.native="crud.toQuery"
|
||||
/>
|
||||
<el-select
|
||||
v-model="query.is_used"
|
||||
v-model="query.isUsed"
|
||||
clearable
|
||||
size="mini"
|
||||
placeholder="状态"
|
||||
@@ -77,7 +77,8 @@
|
||||
<el-form-item label="邮箱" prop="email">
|
||||
<el-input v-model="form.email" style="width: 200px;" />
|
||||
</el-form-item>
|
||||
<el-form-item label="部门" prop="depts" :rules="[{ required: true, message: '请选择部门', trigger: 'change' }]">
|
||||
<br v-if="!crud.status.edit">
|
||||
<el-form-item v-if="crud.status.add" label="部门" prop="depts" :rules="[{ required: true, message: '请选择部门', trigger: 'change' }]">
|
||||
<treeselect
|
||||
v-model="form.depts"
|
||||
:load-options="loadDepts"
|
||||
@@ -101,14 +102,15 @@
|
||||
</el-form-item>
|
||||
<el-form-item label="状态" prop="is_uesd">
|
||||
<el-switch
|
||||
v-model="form.is_used"
|
||||
v-model="form.isUsed"
|
||||
active-color="#409EFF"
|
||||
inactive-color="#F56C6C"
|
||||
active-value="1"
|
||||
inactive-value="0"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item style="margin-bottom: 0;" label="角色" prop="roles">
|
||||
<br v-if="!crud.status.edit">
|
||||
<el-form-item v-if="crud.status.add" style="margin-bottom: 0;" label="角色" prop="roles">
|
||||
<el-select
|
||||
v-model="roleDatas"
|
||||
style="width: 512px"
|
||||
@@ -147,20 +149,18 @@
|
||||
<el-table-column
|
||||
prop="person_name"
|
||||
label="姓名"
|
||||
:min-width="flexWidth('person_name',crud.data,'姓名')"
|
||||
:min-width="flexWidth('personName',crud.data,'姓名')"
|
||||
/>
|
||||
<el-table-column prop="gender" label="性别" :min-width="flexWidth('person_name',crud.data,'性别')" />
|
||||
<el-table-column prop="phone" label="电话" :min-width="flexWidth('phone',crud.data,'电话')" />
|
||||
<el-table-column prop="email" label="邮箱" :min-width="flexWidth('email',crud.data,'邮箱')" />
|
||||
<el-table-column show-overflow-tooltip prop="deptnames" label="部门" />
|
||||
<el-table-column
|
||||
label="启用"
|
||||
align="center"
|
||||
prop="is_used"
|
||||
:formatter="crud.formatIsOrNot"
|
||||
:min-width="flexWidth('is_used',crud.data,'启用')"
|
||||
/>
|
||||
<el-table-column prop="create_time" label="创建日期" :min-width="flexWidth('create_time',crud.data,'创建日期')" />
|
||||
<el-table-column label="状态" align="center" prop="enabled">
|
||||
<template slot-scope="scope">
|
||||
<span :style="{'color': caseStatusColorFilter(scope.row.isUsed)}">{{ enabledTypeOptions.find(item => {return item.key == scope.row.isUsed}).display_name }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="createTime" label="创建日期" :min-width="flexWidth('createTime',crud.data,'创建日期')" />
|
||||
<el-table-column
|
||||
label="操作"
|
||||
fixed="right"
|
||||
@@ -168,16 +168,22 @@
|
||||
width="200"
|
||||
>
|
||||
<template v-if="scope.row.userId !== 1" slot-scope="scope">
|
||||
<el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)">修改</el-button>
|
||||
<el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)">删除</el-button>
|
||||
<el-dropdown v-hasPermi="['system:user:resetPwd', 'system:user:edit']" size="mini" @command="(command) => handleCommand(command, scope.row)">
|
||||
<el-button size="mini" type="text" icon="el-icon-edit" @click="crud.toEdit(scope.row)">修改</el-button>
|
||||
<el-button size="mini" type="text" icon="el-icon-delete" @click="handdeleted(scope.row)">删除</el-button>
|
||||
<el-dropdown v-hasPermi="['system:user:resetPwd', 'system:user:edit']" size="mini">
|
||||
<el-button size="mini" type="text" icon="el-icon-d-arrow-right">更多</el-button>
|
||||
<el-dropdown-menu slot="dropdown">
|
||||
<el-dropdown-item command="handleResetPwd" icon="el-icon-key">重置密码</el-dropdown-item>
|
||||
<el-dropdown-item command="handleResetPwd" icon="el-icon-key">部门权限</el-dropdown-item>
|
||||
<el-dropdown-item command="handleResetPwd" icon="el-icon-key">数据权限</el-dropdown-item>
|
||||
<el-dropdown-item command="handleResetPwd" icon="el-icon-key">锁定账号</el-dropdown-item>
|
||||
<el-dropdown-item command="handleAuthRole" icon="el-icon-circle-check">分配角色</el-dropdown-item>
|
||||
<el-dropdown-item icon="el-icon-refresh-right"><span @click="resetPassword(scope.row)">重置密码</span></el-dropdown-item>
|
||||
<el-dropdown-item icon="el-icon-key">
|
||||
<span @click="openDeptDrawer(scope.row)">部门权限</span>
|
||||
</el-dropdown-item>
|
||||
<!-- <el-dropdown-item icon="el-icon-key">-->
|
||||
<!-- <span @click="openDataDialog(scope.row)">数据权限</span>-->
|
||||
<!-- </el-dropdown-item>-->
|
||||
<el-dropdown-item icon="el-icon-lock"><span @click="changeEnabled(scope.row)">{{ enabledTypeOptions.find(item => {return item.key !== scope.row.isUsed}).display_name }}账号</span></el-dropdown-item>
|
||||
<el-dropdown-item icon="el-icon-circle-check">
|
||||
<span @click="openRoleDrawer(scope.row)">分配角色</span>
|
||||
</el-dropdown-item>
|
||||
</el-dropdown-menu>
|
||||
</el-dropdown>
|
||||
</template>
|
||||
@@ -187,12 +193,134 @@
|
||||
<pagination />
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-drawer
|
||||
:title="drawerTitle"
|
||||
:visible.sync="syncDrawer"
|
||||
direction="rtl"
|
||||
:before-close="handleClose"
|
||||
:wrapper-closable="false"
|
||||
size="35%"
|
||||
@close="clearCheck"
|
||||
>
|
||||
<div style="margin: 0 20px 0 20px; height: 100%">
|
||||
<div style="height: 90%">
|
||||
<el-tree
|
||||
v-if="flag"
|
||||
ref="deptUser"
|
||||
show-checkbox
|
||||
default-expand-all
|
||||
:data="deptsDatas"
|
||||
:default-checked-keys="depChecked"
|
||||
:props="deptProps"
|
||||
:node-key="nodeKey"
|
||||
highlight-current
|
||||
check-strictly
|
||||
@check="handCheck"
|
||||
@check-change="checkChange"
|
||||
@close="clearCheck"
|
||||
/>
|
||||
<el-table
|
||||
v-if="!flag"
|
||||
ref="roleTable"
|
||||
highlight-current-row
|
||||
style="width: 100%;"
|
||||
:data="rolesDatas"
|
||||
@selection-change="crud.selectionChangeHandler"
|
||||
>
|
||||
<el-table-column type="selection" width="55" />
|
||||
<el-table-column prop="name" label="角色名称" min-width="100" show-overflow-tooltip />
|
||||
</el-table>
|
||||
</div>
|
||||
<div style="height: 10%">
|
||||
<el-button @click="cancelForm">取 消</el-button>
|
||||
<el-button type="primary" @click="saveChecked">保 存</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</el-drawer>
|
||||
<el-dialog
|
||||
:close-on-click-modal="true"
|
||||
:visible.sync="dataPerm"
|
||||
:title="dataPermissionTitle"
|
||||
width="700px"
|
||||
>
|
||||
<el-form ref="form" :inline="true" :model="dataDialog" :rules="rules" size="mini" label-width="100px">
|
||||
<el-form-item label="用户名" prop="username">
|
||||
<el-input v-model="dataDialog.username" disabled style="width: 200px;" />
|
||||
</el-form-item>
|
||||
<el-form-item label="姓名" prop="preson_name">
|
||||
<el-input v-model="dataDialog.person_name" disabled style="width: 200px;" />
|
||||
</el-form-item>
|
||||
<el-table
|
||||
ref="dialogTable"
|
||||
:data="dataDialog.dataScopeType"
|
||||
style="width: 100%;"
|
||||
@selection-change="getRows"
|
||||
>
|
||||
<el-table-column :selectable="checkboxT" type="selection" width="55" />
|
||||
<el-table-column prop="label" label="权限范围" />
|
||||
<el-table-column label="数据权限">
|
||||
<template slot-scope="scope">
|
||||
<el-select
|
||||
v-model="scope.row.permission_id"
|
||||
placeholder="请选择"
|
||||
@change="openRelevance(scope.row, scope.$index)"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in permissions"
|
||||
:key="item.permission_id"
|
||||
:label="item.name"
|
||||
:value="item.permission_id"
|
||||
/>
|
||||
</el-select>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
label="操作"
|
||||
fixed="right"
|
||||
align="center"
|
||||
width="100"
|
||||
>
|
||||
<template slot-scope="scope">
|
||||
<el-button type="text" @click="showDatas(scope.row)">查看明细</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</el-form>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button @click="cancelDataPerm">取消</el-button>
|
||||
<el-button type="primary" @click="savePermise()">确认</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
<el-dialog
|
||||
:close-on-click-modal="true"
|
||||
:visible.sync="showData"
|
||||
:title="dataPermissionTitle"
|
||||
width="700px"
|
||||
>
|
||||
<el-table
|
||||
ref="dialogTable"
|
||||
:data="dataPermissions"
|
||||
style="width: 100%; max-height: 500px"
|
||||
>
|
||||
<el-table-column prop="permission_scope_type" label="权限类型" min-width="100" show-overflow-tooltip>
|
||||
<template slot-scope="scope">
|
||||
{{ dict.label.permission_scope_type[scope.row.permission_scope_type] }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="permission_name" label="权限范围" min-width="100" show-overflow-tooltip />
|
||||
<el-table-column prop="dept_name" label="部门名称" min-width="100" show-overflow-tooltip />
|
||||
<el-table-column prop="person_name" label="用户名称" min-width="100" show-overflow-tooltip />
|
||||
</el-table>
|
||||
</el-dialog>
|
||||
<relevance-user-dialog :dialog-show.sync="relevanceUser" :is-single="false" :users="userIds" @selectUsers="selectUsers" />
|
||||
<relevance-dept-dialog :dialog-show.sync="relevanceDept" :is-single="false" :depts="deptIds" @selectDepts="selectDepts" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import crudUser from '@/views/system/user'
|
||||
import crudDept from '@/api/system/dept'
|
||||
// import crudDataPermission from '@/views/system/permission/dataPermission'
|
||||
import { getAll, getLevel } from '@/api/system/role'
|
||||
import CRUD, { crud, form, header, presenter } from '@crud/crud'
|
||||
import rrOperation from '@crud/RR.operation'
|
||||
@@ -202,6 +330,8 @@ import pagination from '@crud/Pagination'
|
||||
import Treeselect, { LOAD_CHILDREN_OPTIONS } from '@riophae/vue-treeselect'
|
||||
import { mapGetters } from 'vuex'
|
||||
import '@riophae/vue-treeselect/dist/vue-treeselect.css'
|
||||
// import RelevanceUserDialog from '@/views/system/user/dialog/relevanceUserDialog'
|
||||
// import RelevanceDeptDialog from '@/views/system/user/dialog/relevanceDeptDialog'
|
||||
|
||||
let userRoles = []
|
||||
const defaultForm = {
|
||||
@@ -211,7 +341,7 @@ const defaultForm = {
|
||||
person_name: null,
|
||||
gender: '男',
|
||||
email: null,
|
||||
enabled: 'true',
|
||||
isUsed: '1',
|
||||
roles: [],
|
||||
phone: null,
|
||||
password: null
|
||||
@@ -224,13 +354,14 @@ export default {
|
||||
},
|
||||
mixins: [presenter(), header(), form(defaultForm), crud()],
|
||||
// 数据字典
|
||||
dicts: ['user_status'],
|
||||
dicts: ['user_status', 'permission_scope_type'],
|
||||
data() {
|
||||
return {
|
||||
height: document.documentElement.clientHeight - 180 + 'px;',
|
||||
deptName: '', depts: [], deptDatas: [], level: 3, roles: [],
|
||||
roleDatas: [], // 多选时使用
|
||||
defaultProps: { children: 'children', label: 'name' },
|
||||
deptProps: { children: 'children', label: 'name' },
|
||||
permission: {
|
||||
add: ['admin', 'user:add'],
|
||||
edit: ['admin', 'user:edit'],
|
||||
@@ -249,7 +380,28 @@ export default {
|
||||
{ required: true, message: '请输入用户姓名', trigger: 'blur' },
|
||||
{ min: 2, max: 20, message: '长度在 2 到 20 个字符', trigger: 'blur' }
|
||||
]
|
||||
}
|
||||
},
|
||||
syncDrawer: false,
|
||||
depChecked: [],
|
||||
depCheckedId: '',
|
||||
deptsDatas: [],
|
||||
rolesDatas: [],
|
||||
drawerTitle: '',
|
||||
nodeKey: 'dept_id',
|
||||
flag: true,
|
||||
dataPerm: false,
|
||||
dataDialog: {},
|
||||
permissions: [],
|
||||
permission_id: '',
|
||||
multipleSelection: [], // 选中
|
||||
relevanceUser: false, // 关联用户
|
||||
rowData: {}, // 当行数据
|
||||
relevanceDept: false, // 关联部门
|
||||
deptIds: [],
|
||||
userIds: [],
|
||||
showData: false,
|
||||
dataPermissions: [],
|
||||
dataPermissionTitle: '数据权限'
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
@@ -284,6 +436,23 @@ export default {
|
||||
}
|
||||
})
|
||||
},
|
||||
caseStatusColorFilter(isUsed) {
|
||||
if (isUsed === '1') {
|
||||
return '#378be2'
|
||||
}
|
||||
return '#F56C6C'
|
||||
},
|
||||
handdeleted(datas) {
|
||||
this.$confirm(`确认删除选中的1条数据?`, '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
this.crud.delAllLoading = true
|
||||
this.crud.doDelete(datas)
|
||||
}).catch(() => {
|
||||
})
|
||||
},
|
||||
// 新增与编辑前做的操作
|
||||
[CRUD.HOOK.afterToCU](crud, form) {
|
||||
this.getRoles()
|
||||
@@ -292,8 +461,8 @@ export default {
|
||||
} else {
|
||||
this.getSupDepts(form.dept_id)
|
||||
}
|
||||
this.getRoleLevel()
|
||||
form.is_used = form.enabled.toString()
|
||||
// this.getRoleLevel() 暂时不用
|
||||
form.isUsed = form.enabled.toString()
|
||||
},
|
||||
// 新增前将多选的值设置为空
|
||||
[CRUD.HOOK.beforeToAdd]() {
|
||||
@@ -302,15 +471,17 @@ export default {
|
||||
},
|
||||
// 初始化编辑时候的角色与岗位
|
||||
[CRUD.HOOK.beforeToEdit](crud, form) {
|
||||
crud.status.edit
|
||||
this.roleDatas = []
|
||||
userRoles = []
|
||||
const _this = this
|
||||
const arr = form.roles.split(',')
|
||||
arr.forEach(function(role, index) {
|
||||
_this.roleDatas.push(role.id)
|
||||
const rol = { id: role.id }
|
||||
userRoles.push(rol)
|
||||
})
|
||||
if (form.roles !== null && form.roles.length > 0) {
|
||||
form.roles.forEach(function(role, index) {
|
||||
_this.roleDatas.push(role)
|
||||
const rol = { id: role }
|
||||
userRoles.push(rol)
|
||||
})
|
||||
}
|
||||
},
|
||||
// 提交前做的操作
|
||||
[CRUD.HOOK.afterValidateCU](crud) {
|
||||
@@ -331,8 +502,7 @@ export default {
|
||||
userRoles.forEach(function(data, index) {
|
||||
roles.push(data.id)
|
||||
})
|
||||
crud.form.roles = roles.toString()
|
||||
crud.form.depts = crud.form.depts.toString()
|
||||
crud.form.roles = roles
|
||||
return true
|
||||
},
|
||||
// 获取左侧部门数据
|
||||
@@ -358,7 +528,7 @@ export default {
|
||||
},
|
||||
getDepts() {
|
||||
console.log('获取部门')
|
||||
crudDept.getDepts({ is_used: 1 }).then(res => {
|
||||
crudDept.getDepts({ isUsed: 1 }).then(res => {
|
||||
console.log('获取的部门信息', res)
|
||||
|
||||
this.depts = res.content.map(function(obj) {
|
||||
@@ -390,7 +560,7 @@ export default {
|
||||
// 获取弹窗内部门数据
|
||||
loadDepts({ action, parentNode, callback }) {
|
||||
if (action === LOAD_CHILDREN_OPTIONS) {
|
||||
crudDept.getDeptvo({ is_used: '1', pid: parentNode.dept_id }).then(res => {
|
||||
crudDept.getDeptvo({ isUsed: '1', pid: parentNode.dept_id }).then(res => {
|
||||
parentNode.children = res.content.map(function(obj) {
|
||||
obj.children = null
|
||||
return obj
|
||||
@@ -410,24 +580,23 @@ export default {
|
||||
},
|
||||
// 切换部门
|
||||
handleNodeClick(data) {
|
||||
this.query.deptId = data.dept_id
|
||||
this.query.deptId = data.deptId
|
||||
this.query.needAll = true
|
||||
this.crud.toQuery()
|
||||
},
|
||||
// 改变状态
|
||||
changeEnabled(data, val) {
|
||||
this.$confirm('此操作将 "' + this.dict.label.user_status[val] + '" ' + data.username + ', 是否继续?', '提示', {
|
||||
changeEnabled(row) {
|
||||
const satus = this.enabledTypeOptions.find(item => { return item.key !== row.isUsed })
|
||||
this.$confirm('此操作将' + satus.display_name + '账号:' + row.username + ', 是否继续?', '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
crudUser.edit(data).then(res => {
|
||||
this.crud.notify(this.dict.label.user_status[val] + '成功', CRUD.NOTIFICATION_TYPE.SUCCESS)
|
||||
}).catch(() => {
|
||||
data.enabled = !data.enabled
|
||||
row.isUsed = satus.key
|
||||
crudUser.edit(row).then(res => {
|
||||
this.crud.toQuery()
|
||||
this.crud.notify('账号' + row.username + '已' + satus.display_name)
|
||||
})
|
||||
}).catch(() => {
|
||||
data.enabled = !data.enabled
|
||||
})
|
||||
},
|
||||
// 获取弹窗内角色数据
|
||||
@@ -445,29 +614,245 @@ export default {
|
||||
})
|
||||
},
|
||||
checkboxT(row, rowIndex) {
|
||||
return row.id !== this.user.id
|
||||
// return row.id !== this.user.id
|
||||
return true
|
||||
},
|
||||
resetPassword(row) {
|
||||
row.password = null
|
||||
this.$prompt('', '重置密码', {
|
||||
this.$confirm(`确认重置密码?`, '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
inputPlaceholder: '请输入新的密码',
|
||||
inputPattern: /^[A-Z|a-z|0-9|(._~!@#$^&*)]{6,20}$/,
|
||||
inputErrorMessage: '密码格式不正确,只能是6-20位密码',
|
||||
closeOnClickModal: false
|
||||
}).then(({ value }) => {
|
||||
row.password = value
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
row.password = '123456'
|
||||
crudUser.edit(row).then(res => {
|
||||
this.crud.toQuery()
|
||||
this.crud.notify('密码重置成功', CRUD.NOTIFICATION_TYPE.SUCCESS)
|
||||
})
|
||||
}).catch(() => {
|
||||
this.$message({
|
||||
type: 'info',
|
||||
message: '取消输入'
|
||||
this.crud.notify('密码重置成功,密码:123456', CRUD.NOTIFICATION_TYPE.SUCCESS)
|
||||
})
|
||||
})
|
||||
},
|
||||
openDeptDrawer(row) {
|
||||
crudDept.getDeptTree().then(res => {
|
||||
this.deptsDatas = res.content
|
||||
})
|
||||
this.nodeKey = 'dept_id'
|
||||
this.openDrawer()
|
||||
this.drawerTitle = '分配部门权限'
|
||||
this.flag = true
|
||||
// 默认选中
|
||||
this.depChecked = row.depts
|
||||
this.giveValue(row)
|
||||
},
|
||||
openRoleDrawer(row) {
|
||||
this.rolesDatas = []
|
||||
getAll().then(res => {
|
||||
this.rolesDatas = res
|
||||
// 回显默认选中
|
||||
this.$nextTick(function() {
|
||||
for (let i = 0; i < this.rolesDatas.length; i++) {
|
||||
for (let j = 0; j < row.roles.length; j++) {
|
||||
if (this.rolesDatas[i].role_id == row.roles[j]) {
|
||||
this.$refs.roleTable.toggleRowSelection(this.rolesDatas[i], true)
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
this.openDrawer()
|
||||
this.drawerTitle = '分配角色权限'
|
||||
this.flag = false
|
||||
this.giveValue(row)
|
||||
},
|
||||
// openDataDialog(row) {
|
||||
// // 清空数据 应该需要初始化赋值
|
||||
// this.dataDialog = {}
|
||||
// this.multipleSelection = []
|
||||
// // 获取权限范围
|
||||
// crudDataPermission.getDataScopeType().then(res => {
|
||||
// this.dataDialog.dataScopeType = res
|
||||
// // permissions
|
||||
// crudDataPermission.getDataPermissionOption().then(res => {
|
||||
// this.permissions = res
|
||||
// this.dataDialog.person_name = row.person_name
|
||||
// this.dataDialog.username = row.username
|
||||
// this.dataDialog.user_id = row.user_id
|
||||
// this.dataPermissionTitle = '[' + row.person_name + '] 数据权限'
|
||||
// this.dataPerm = true
|
||||
// // 回显数据
|
||||
// crudDataPermission.getDataShow(row.user_id).then(res => {
|
||||
// this.$nextTick(function() {
|
||||
// for (var index = 0; index < res.length; index++) {
|
||||
// for (var i = 0; i < this.dataDialog.dataScopeType.length; i++) {
|
||||
// if (this.dataDialog.dataScopeType[i].value == res[index].permission_scope_type) {
|
||||
// this.dataDialog.dataScopeType[i].permission_id = res[index].permission_id
|
||||
// if (res[index].users) this.dataDialog.dataScopeType[i].users = res[index].users
|
||||
// if (res[index].depts) this.dataDialog.dataScopeType[i].depts = res[index].depts
|
||||
// // 选中
|
||||
// this.$refs.dialogTable.toggleRowSelection(this.dataDialog.dataScopeType[i], true)
|
||||
// break
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// })
|
||||
// })
|
||||
// })
|
||||
// })
|
||||
// },
|
||||
getRows(val) { // 获取行数据
|
||||
this.multipleSelection = val
|
||||
},
|
||||
// openRelevance(row, index) {
|
||||
// for (var i = 0; i < this.permissions.length; i++) {
|
||||
// if (this.permissions[i].permission_id != undefined && this.permissions[i].permission_id && this.permissions[i].permission_id != row.permission_id) {
|
||||
// this.$delete(this.dataDialog.dataScopeType[index], this.permissions[i].permission_id.toString())
|
||||
// }
|
||||
// }
|
||||
// this.$set(this.dataDialog.dataScopeType[index], this.dataDialog.dataScopeType[index].permission_id, row.permission_id)
|
||||
// this.rowData = {}
|
||||
// this.deptIds = []
|
||||
// this.userIds = []
|
||||
// if (row.permission_id == '1601040560293023744') { // 选择用户
|
||||
// this.userIds = this.dataDialog.dataScopeType[index].users
|
||||
// this.rowData = row
|
||||
// this.relevanceUser = true
|
||||
// } else if (row.permission_id == '1601040621190123520') { // 选择部门
|
||||
// this.deptIds = this.dataDialog.dataScopeType[index].depts
|
||||
// this.rowData = row
|
||||
// this.relevanceDept = true
|
||||
// } else if (row.permission_id == '1601038030326599680') { // 自身
|
||||
// const param = {
|
||||
// user_id: this.dataDialog.user_id
|
||||
// }
|
||||
// this.dataDialog.dataScopeType[index].users = []
|
||||
// this.dataDialog.dataScopeType[index].users.push(param)
|
||||
// } else { // 其他应该清空
|
||||
// this.dataDialog.dataScopeType[index].depts = []
|
||||
// this.dataDialog.dataScopeType[index].users = []
|
||||
// }
|
||||
// },
|
||||
selectUsers(row) { // row对话框传来的数据
|
||||
for (var i = 0; i < this.dataDialog.dataScopeType.length; i++) {
|
||||
if (this.dataDialog.dataScopeType[i].dict_id == this.rowData.dict_id) {
|
||||
if (this.dataDialog.dataScopeType[i].depts != undefined && this.dataDialog.dataScopeType[i].depts.length > 0) this.dataDialog.dataScopeType[i].depts = []
|
||||
this.dataDialog.dataScopeType[i].users = row
|
||||
break
|
||||
}
|
||||
}
|
||||
this.rowData = {}
|
||||
},
|
||||
selectDepts(row) {
|
||||
for (var i = 0; i < this.dataDialog.dataScopeType.length; i++) {
|
||||
if (this.dataDialog.dataScopeType[i].dict_id == this.rowData.dict_id) {
|
||||
if (this.dataDialog.dataScopeType[i].users != undefined && this.dataDialog.dataScopeType[i].users.length > 0) this.dataDialog.dataScopeType[i].users = []
|
||||
this.dataDialog.dataScopeType[i].depts = row
|
||||
break
|
||||
}
|
||||
}
|
||||
this.rowData = {}
|
||||
},
|
||||
cancelDataPerm() {
|
||||
this.dataPerm = false
|
||||
},
|
||||
// savePermise() {
|
||||
// const param = {
|
||||
// user_id: this.dataDialog.user_id,
|
||||
// datas: this.multipleSelection
|
||||
// }
|
||||
// crudDataPermission.saveDataPermission(param).then(res => {
|
||||
// this.dataPerm = false
|
||||
// this.crud.notify('添加数据权限成功', CRUD.NOTIFICATION_TYPE.SUCCESS)
|
||||
// this.crud.toQuery()
|
||||
// })
|
||||
// },
|
||||
openDrawer() {
|
||||
this.syncDrawer = true
|
||||
this.depCheckedId = ''
|
||||
this.depChecked = []
|
||||
},
|
||||
giveValue(row) {
|
||||
this.depCheckedId = row.user_id
|
||||
},
|
||||
clearCheck() {
|
||||
if (this.flag) this.$refs.deptUser.setCheckedKeys([])
|
||||
},
|
||||
handleClose(done) {
|
||||
this.$confirm('确认关闭?')
|
||||
.then(_ => {
|
||||
done()
|
||||
})
|
||||
.catch(_ => {})
|
||||
},
|
||||
cancelForm() { // 关闭
|
||||
this.syncDrawer = false
|
||||
if (this.flag) this.clearCheck()
|
||||
},
|
||||
saveChecked() {
|
||||
const user = {
|
||||
user_id: this.depCheckedId
|
||||
}
|
||||
if (this.flag) {
|
||||
user.depts = this.$refs.deptUser.getCheckedKeys()
|
||||
} else {
|
||||
user.roles = this.crud.selections.map(item => (item.role_id))
|
||||
}
|
||||
crudUser.edit(user).then(res => {
|
||||
this.cancelForm()
|
||||
this.crud.notify('保存成功', CRUD.NOTIFICATION_TYPE.SUCCESS)
|
||||
this.crud.toQuery()
|
||||
})
|
||||
},
|
||||
// 覆盖原有勾选功能,父与子关联,子与父不关联
|
||||
handCheck(data, node) {
|
||||
this.hanleCheck(data, node, 'deptUser')
|
||||
},
|
||||
hanleCheck(data, node, treeName) {
|
||||
const _this = this
|
||||
// 获取当前节点是否被选中
|
||||
const isChecked = _this.$refs[treeName].getNode(data).checked
|
||||
// 如果当前节点被选中,则遍历下级子节点并选中,如果当前节点取消选中,则遍历下级节点并取消
|
||||
if (isChecked) {
|
||||
// 判断该节点是否有下级节点,如果有那么遍历设置下级节点为选中
|
||||
data.children && data.children.length > 0 && setChildreChecked(data.children, true)
|
||||
} else {
|
||||
// 如果节点取消选中,则取消该节点下的子节点选中
|
||||
data.children && data.children.length > 0 && setChildreChecked(data.children, false)
|
||||
}
|
||||
function setChildreChecked(node, isChecked) {
|
||||
node.forEach(item => {
|
||||
item.children && item.children.length > 0 && setChildreChecked(item.children, isChecked)
|
||||
// 修改勾选状态
|
||||
_this.$refs[treeName].setChecked(item.name, isChecked)
|
||||
})
|
||||
}
|
||||
},
|
||||
checkChange(data, checked, indeterminate) {
|
||||
const _this = this
|
||||
// console.log(data, checked, indeterminate);
|
||||
// 选中全部子节点,父节点也默认选中,但是子节点再次取消勾选或者全部子节点取消勾选也不会影响父节点勾选状态
|
||||
const checkNode = _this.$refs.deptUser.getNode(data)// 获取当前节点
|
||||
// 勾选部分子节点,父节点变为半选状态
|
||||
if (checkNode.parent && checkNode.parent.childNodes.some(ele => ele.checked)) {
|
||||
checkNode.parent.indeterminate = true
|
||||
}
|
||||
// 勾选全部子节点,父节点变为全选状态
|
||||
if (checkNode.parent && checkNode.parent.childNodes.every(ele => ele.checked)) {
|
||||
checkNode.parent.checked = true
|
||||
checkNode.parent.indeterminate = false
|
||||
}
|
||||
// 如果取消所有第二节点的勾选状态,则第一层父节点也取消勾选
|
||||
if (checkNode.level == 2 && checkNode.parent.childNodes.every(ele => !ele.checked)) {
|
||||
checkNode.parent.checked = false
|
||||
checkNode.parent.indeterminate = false
|
||||
}
|
||||
},
|
||||
showDatas(row) {
|
||||
const param = {
|
||||
user_id: this.dataDialog.user_id,
|
||||
permission_scope_type: row.value
|
||||
}
|
||||
crudDataPermission.getDataDetail(param).then(res => {
|
||||
this.dataPermissions = res
|
||||
})
|
||||
this.showData = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user