commit
27efe772ab
@ -7,6 +7,7 @@
|
||||
<springProperty scope="context" name="APP_NAME" source="spring.application.name"/>
|
||||
<!--日志文件保存路径-->
|
||||
<springProperty scope="context" name="LOG_FILE_PATH" source="logging.file.path"/>
|
||||
<springProperty scope="context" name="LOGSTASH_SERVER" source="lili.data.logstash.server"/>
|
||||
<contextName>${APP_NAME}</contextName>
|
||||
|
||||
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
@ -22,7 +23,7 @@
|
||||
<!--输出到elk的LOGSTASH-->
|
||||
<appender name="LOGSTASH" class="net.logstash.logback.appender.LogstashTcpSocketAppender">
|
||||
<!-- 配置elk日志收集 配饰的是 LOGSTASH 的地址-->
|
||||
<destination>127.0.0.1:4560</destination>
|
||||
<destination>${LOGSTASH_SERVER}</destination>
|
||||
<encoder charset="UTF-8" class="net.logstash.logback.encoder.LogstashEncoder">
|
||||
<providers>
|
||||
<timestamp>
|
||||
|
@ -1,8 +1,6 @@
|
||||
package cn.lili.controller.passport;
|
||||
|
||||
import cn.lili.common.enums.ResultCode;
|
||||
import cn.lili.common.enums.ResultUtil;
|
||||
import cn.lili.common.exception.ServiceException;
|
||||
import cn.lili.common.vo.ResultMessage;
|
||||
import cn.lili.modules.member.entity.dos.Member;
|
||||
import cn.lili.modules.member.entity.dto.MemberEditDTO;
|
||||
|
@ -46,8 +46,7 @@ spring:
|
||||
# mongodb
|
||||
data:
|
||||
mongodb:
|
||||
host: 127.0.0.1
|
||||
port: 27017
|
||||
uri: 127.0.0.1:27017
|
||||
database: lilishop
|
||||
username: root
|
||||
password: lilishop
|
||||
|
@ -7,6 +7,7 @@
|
||||
<springProperty scope="context" name="APP_NAME" source="spring.application.name"/>
|
||||
<!--日志文件保存路径-->
|
||||
<springProperty scope="context" name="LOG_FILE_PATH" source="logging.file.path"/>
|
||||
<springProperty scope="context" name="LOGSTASH_SERVER" source="lili.data.logstash.server"/>
|
||||
<contextName>${APP_NAME}</contextName>
|
||||
|
||||
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
@ -22,7 +23,7 @@
|
||||
<!--输出到elk的LOGSTASH-->
|
||||
<appender name="LOGSTASH" class="net.logstash.logback.appender.LogstashTcpSocketAppender">
|
||||
<!-- 配置elk日志收集 配饰的是 LOGSTASH 的地址-->
|
||||
<destination>127.0.0.1:4560</destination>
|
||||
<destination>${LOGSTASH_SERVER}</destination>
|
||||
<encoder charset="UTF-8" class="net.logstash.logback.encoder.LogstashEncoder">
|
||||
<providers>
|
||||
<timestamp>
|
||||
|
@ -1,12 +1,10 @@
|
||||
package cn.lili.controller.common;
|
||||
|
||||
import cn.lili.cache.limit.annotation.LimitPoint;
|
||||
import cn.lili.common.enums.ResultCode;
|
||||
import cn.lili.common.exception.ServiceException;
|
||||
import cn.lili.common.enums.ResultUtil;
|
||||
import cn.lili.common.vo.ResultMessage;
|
||||
import cn.lili.modules.verification.enums.VerificationEnums;
|
||||
import cn.lili.modules.verification.service.VerificationService;
|
||||
import cn.lili.common.vo.ResultMessage;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
@ -2,12 +2,11 @@ package cn.lili.controller.common;
|
||||
|
||||
import cn.lili.cache.limit.annotation.LimitPoint;
|
||||
import cn.lili.common.enums.ResultCode;
|
||||
import cn.lili.common.exception.ServiceException;
|
||||
import cn.lili.modules.system.sms.SmsUtil;
|
||||
import cn.lili.common.enums.ResultUtil;
|
||||
import cn.lili.common.vo.ResultMessage;
|
||||
import cn.lili.modules.system.sms.SmsUtil;
|
||||
import cn.lili.modules.verification.enums.VerificationEnums;
|
||||
import cn.lili.modules.verification.service.VerificationService;
|
||||
import cn.lili.common.vo.ResultMessage;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
|
@ -32,8 +32,7 @@ spring:
|
||||
# mongodb
|
||||
data:
|
||||
mongodb:
|
||||
host: 127.0.0.1
|
||||
port: 27017
|
||||
uri: 127.0.0.1:27017
|
||||
database: lilishop
|
||||
username: root
|
||||
password: lilishop
|
||||
|
@ -7,6 +7,7 @@
|
||||
<springProperty scope="context" name="APP_NAME" source="spring.application.name"/>
|
||||
<!--日志文件保存路径-->
|
||||
<springProperty scope="context" name="LOG_FILE_PATH" source="logging.file.path"/>
|
||||
<springProperty scope="context" name="LOGSTASH_SERVER" source="lili.data.logstash.server"/>
|
||||
<contextName>${APP_NAME}</contextName>
|
||||
|
||||
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
@ -22,7 +23,7 @@
|
||||
<!--输出到elk的LOGSTASH-->
|
||||
<appender name="LOGSTASH" class="net.logstash.logback.appender.LogstashTcpSocketAppender">
|
||||
<!-- 配置elk日志收集 配饰的是 LOGSTASH 的地址-->
|
||||
<destination>127.0.0.1:4560</destination>
|
||||
<destination>${LOGSTASH_SERVER}</destination>
|
||||
<encoder charset="UTF-8" class="net.logstash.logback.encoder.LogstashEncoder">
|
||||
<providers>
|
||||
<timestamp>
|
||||
|
@ -28,8 +28,7 @@ spring:
|
||||
# mongodb
|
||||
data:
|
||||
mongodb:
|
||||
host: 192.168.0.116
|
||||
port: 27017
|
||||
uri: 192.168.0.116:27017
|
||||
database: lilishop
|
||||
username: root
|
||||
password: lilishop
|
||||
|
@ -35,8 +35,7 @@ spring:
|
||||
# mongodb
|
||||
data:
|
||||
mongodb:
|
||||
host: 127.0.0.1
|
||||
port: 27017
|
||||
uri: 127.0.0.1:27017
|
||||
database: lilishop
|
||||
username: root
|
||||
password: lilishop
|
||||
|
@ -7,6 +7,7 @@
|
||||
<springProperty scope="context" name="APP_NAME" source="spring.application.name"/>
|
||||
<!--日志文件保存路径-->
|
||||
<springProperty scope="context" name="LOG_FILE_PATH" source="logging.file.path"/>
|
||||
<springProperty scope="context" name="LOGSTASH_SERVER" source="lili.data.logstash.server"/>
|
||||
<contextName>${APP_NAME}</contextName>
|
||||
|
||||
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
@ -22,7 +23,7 @@
|
||||
<!--输出到elk的LOGSTASH-->
|
||||
<appender name="LOGSTASH" class="net.logstash.logback.appender.LogstashTcpSocketAppender">
|
||||
<!-- 配置elk日志收集 配饰的是 LOGSTASH 的地址-->
|
||||
<destination>127.0.0.1:4560</destination>
|
||||
<destination>${LOGSTASH_SERVER}</destination>
|
||||
<encoder charset="UTF-8" class="net.logstash.logback.encoder.LogstashEncoder">
|
||||
<providers>
|
||||
<timestamp>
|
||||
|
@ -1,7 +1,7 @@
|
||||
package cn.lili.cache;
|
||||
|
||||
import cn.lili.common.security.enums.UserEnums;
|
||||
import cn.lili.common.enums.PromotionTypeEnum;
|
||||
import cn.lili.common.security.enums.UserEnums;
|
||||
|
||||
/**
|
||||
* 缓存前缀
|
||||
@ -469,6 +469,14 @@ public enum CachePrefix {
|
||||
* 店铺分类
|
||||
*/
|
||||
STORE_CATEGORY,
|
||||
/**
|
||||
* 用户菜单
|
||||
*/
|
||||
MENU_USER_ID,
|
||||
/**
|
||||
* 用户菜单
|
||||
*/
|
||||
USER_MENU,
|
||||
/**
|
||||
* 订单暂时缓存
|
||||
*/
|
||||
|
@ -8,7 +8,8 @@ import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.data.mongodb.config.AbstractMongoClientConfiguration;
|
||||
import org.springframework.data.mongodb.repository.config.EnableMongoRepositories;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author paulG
|
||||
@ -21,11 +22,8 @@ public class MongoConfig extends AbstractMongoClientConfiguration {
|
||||
@Value("${spring.data.mongodb.database}")
|
||||
private String databaseName;
|
||||
|
||||
@Value("${spring.data.mongodb.host}")
|
||||
private String host;
|
||||
|
||||
@Value("${spring.data.mongodb.port}")
|
||||
private Integer port;
|
||||
@Value("${spring.data.mongodb.uri}")
|
||||
private List<String> uri = new ArrayList<>();
|
||||
|
||||
@Value("${spring.data.mongodb.username}")
|
||||
private String username;
|
||||
@ -44,7 +42,14 @@ public class MongoConfig extends AbstractMongoClientConfiguration {
|
||||
@Override
|
||||
protected void configureClientSettings(MongoClientSettings.Builder builder) {
|
||||
builder.credential(MongoCredential.createCredential(username, authenticationDatabase, password.toCharArray()))
|
||||
.applyToClusterSettings(settings -> settings.hosts(Collections.singletonList(new ServerAddress(host, port))));
|
||||
.applyToClusterSettings(settings -> {
|
||||
List<ServerAddress> serverAddresses = new ArrayList<>();
|
||||
for (String s : uri) {
|
||||
String[] node = s.split(":");
|
||||
serverAddresses.add(new ServerAddress(node[0], Integer.parseInt(node[1])));
|
||||
}
|
||||
settings.hosts(serverAddresses);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2,16 +2,20 @@ package cn.lili.common.exception;
|
||||
|
||||
import cn.lili.common.enums.ResultCode;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* 全局业务异常类
|
||||
*
|
||||
* @author Chopper
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class ServiceException extends RuntimeException {
|
||||
|
||||
public static String DEFAULT_MESSAGE = "网络错误,请稍后重试!";
|
||||
private static final long serialVersionUID = 3447728300174142127L;
|
||||
|
||||
public static final String DEFAULT_MESSAGE = "网络错误,请稍后重试!";
|
||||
|
||||
/**
|
||||
* 异常消息
|
||||
|
@ -16,6 +16,7 @@ import java.io.InputStreamReader;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
@ -39,7 +40,10 @@ public class XssHttpServletRequestWrapper extends HttpServletRequestWrapper {
|
||||
public String[] getParameterValues(String name) {
|
||||
String[] values = super.getParameterValues(name);
|
||||
if (values == null) {
|
||||
return null;
|
||||
return new String[0];
|
||||
}
|
||||
if (ignoreXss(name)) {
|
||||
return values;
|
||||
}
|
||||
int count = values.length;
|
||||
String[] encodedValues = new String[count];
|
||||
@ -58,7 +62,7 @@ public class XssHttpServletRequestWrapper extends HttpServletRequestWrapper {
|
||||
if (value == null) {
|
||||
return null;
|
||||
}
|
||||
return cleanXSS(value);
|
||||
return ignoreXss(name) ? value : cleanXSS(value);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -67,6 +71,9 @@ public class XssHttpServletRequestWrapper extends HttpServletRequestWrapper {
|
||||
@Override
|
||||
public Object getAttribute(String name) {
|
||||
Object value = super.getAttribute(name);
|
||||
if (ignoreXss(name)) {
|
||||
return value;
|
||||
}
|
||||
if (value instanceof String) {
|
||||
value = cleanXSS((String) value);
|
||||
}
|
||||
@ -82,7 +89,7 @@ public class XssHttpServletRequestWrapper extends HttpServletRequestWrapper {
|
||||
if (value == null) {
|
||||
return null;
|
||||
}
|
||||
return cleanXSS(value);
|
||||
return ignoreXss(name) ? value : cleanXSS(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -96,12 +103,14 @@ public class XssHttpServletRequestWrapper extends HttpServletRequestWrapper {
|
||||
for (Map.Entry<String, String[]> entry : parameterMap.entrySet()) {
|
||||
//根据key获取value
|
||||
String[] values = entry.getValue();
|
||||
//遍历数组
|
||||
for (int i = 0; i < values.length; i++) {
|
||||
String value = values[i];
|
||||
value = cleanXSS(value);
|
||||
//将转义后的数据放回数组中
|
||||
values[i] = value;
|
||||
if (!ignoreXss(entry.getKey())) {
|
||||
//遍历数组
|
||||
for (int i = 0; i < values.length; i++) {
|
||||
String value = values[i];
|
||||
value = cleanXSS(value);
|
||||
//将转义后的数据放回数组中
|
||||
values[i] = value;
|
||||
}
|
||||
}
|
||||
//将转义后的数组put到linkMap当中
|
||||
params.put(entry.getKey(), values);
|
||||
@ -113,8 +122,8 @@ public class XssHttpServletRequestWrapper extends HttpServletRequestWrapper {
|
||||
/**
|
||||
* 获取输入流
|
||||
*
|
||||
* @return
|
||||
* @throws IOException
|
||||
* @return 过滤后的输入流
|
||||
* @throws IOException 异常信息
|
||||
*/
|
||||
@Override
|
||||
public ServletInputStream getInputStream() throws IOException {
|
||||
@ -145,7 +154,7 @@ public class XssHttpServletRequestWrapper extends HttpServletRequestWrapper {
|
||||
//遍历数组
|
||||
for (Map.Entry<String, Object> entry : map.entrySet()) {
|
||||
//如果map.get(key)获取到的是字符串就需要进行转义,如果不是直接存储resultMap
|
||||
if (map.get(entry.getKey()) instanceof String) {
|
||||
if (map.get(entry.getKey()) instanceof String && !ignoreXss(entry.getKey())) {
|
||||
resultMap.put(entry.getKey(), cleanXSS(entry.getValue().toString()));
|
||||
} else {
|
||||
resultMap.put(entry.getKey(), entry.getValue());
|
||||
@ -171,7 +180,6 @@ public class XssHttpServletRequestWrapper extends HttpServletRequestWrapper {
|
||||
|
||||
@Override
|
||||
public void setReadListener(ReadListener readListener) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -215,4 +223,9 @@ public class XssHttpServletRequestWrapper extends HttpServletRequestWrapper {
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
private boolean ignoreXss(String name) {
|
||||
return CharSequenceUtil.containsAny(name.toLowerCase(Locale.ROOT), "logo", "url", "photo", "intro");
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -78,22 +78,14 @@ public class SensitiveJsonSerializer extends JsonSerializer<String>
|
||||
//如果是店铺
|
||||
if (authUser.getRole().equals(UserEnums.STORE)) {
|
||||
//店铺需要进行脱敏,则脱敏处理
|
||||
if (systemSettingProperties.getSensitiveLevel() == 2) {
|
||||
return true;
|
||||
}
|
||||
//默认不需要
|
||||
return false;
|
||||
return systemSettingProperties.getSensitiveLevel() == 2;
|
||||
}
|
||||
|
||||
|
||||
//如果是店铺
|
||||
if (authUser.getRole().equals(UserEnums.MANAGER)) {
|
||||
//店铺需要进行脱敏,则脱敏处理
|
||||
if (systemSettingProperties.getSensitiveLevel() >= 1) {
|
||||
return true;
|
||||
}
|
||||
//默认不需要
|
||||
return false;
|
||||
return systemSettingProperties.getSensitiveLevel() >= 1;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -7,7 +7,6 @@ import cn.hutool.json.JSONUtil;
|
||||
import cn.lili.common.enums.ResultCode;
|
||||
import cn.lili.common.exception.ServiceException;
|
||||
import cn.lili.modules.goods.entity.dto.GoodsOperationDTO;
|
||||
import cn.lili.modules.goods.entity.enums.GoodsAuthEnum;
|
||||
import cn.lili.modules.goods.entity.enums.GoodsStatusEnum;
|
||||
import cn.lili.mybatis.BaseEntity;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
|
@ -23,7 +23,6 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
@ -7,8 +7,6 @@ import cn.lili.modules.goods.service.CategoryBrandService;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
|
@ -43,7 +43,6 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.apache.rocketmq.spring.core.RocketMQTemplate;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
|
@ -1,14 +1,14 @@
|
||||
package cn.lili.modules.order.cart.entity.dto;
|
||||
|
||||
import cn.lili.modules.member.entity.dos.MemberAddress;
|
||||
import cn.lili.modules.order.cart.entity.enums.SuperpositionPromotionEnum;
|
||||
import cn.lili.modules.order.order.entity.dto.PriceDetailDTO;
|
||||
import cn.lili.modules.order.order.entity.vo.OrderVO;
|
||||
import cn.lili.modules.order.order.entity.vo.ReceiptVO;
|
||||
import cn.lili.modules.order.cart.entity.enums.CartTypeEnum;
|
||||
import cn.lili.modules.order.cart.entity.enums.SuperpositionPromotionEnum;
|
||||
import cn.lili.modules.order.cart.entity.vo.CartSkuVO;
|
||||
import cn.lili.modules.order.cart.entity.vo.CartVO;
|
||||
import cn.lili.modules.order.cart.entity.vo.PriceDetailVO;
|
||||
import cn.lili.modules.order.order.entity.dto.PriceDetailDTO;
|
||||
import cn.lili.modules.order.order.entity.vo.OrderVO;
|
||||
import cn.lili.modules.order.order.entity.vo.ReceiptVO;
|
||||
import cn.lili.modules.promotion.entity.dos.MemberCoupon;
|
||||
import cn.lili.modules.promotion.entity.vos.MemberCouponVO;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
@ -7,7 +7,6 @@ import cn.lili.modules.page.entity.vos.PageDataListVO;
|
||||
import cn.lili.modules.page.entity.vos.PageDataVO;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.springframework.cache.annotation.CacheConfig;
|
||||
|
||||
/**
|
||||
* 页面业务层
|
||||
|
@ -1,7 +1,7 @@
|
||||
package cn.lili.modules.permission.service;
|
||||
|
||||
import cn.lili.modules.permission.entity.dto.MenuSearchParams;
|
||||
import cn.lili.modules.permission.entity.dos.Menu;
|
||||
import cn.lili.modules.permission.entity.dto.MenuSearchParams;
|
||||
import cn.lili.modules.permission.entity.vo.MenuVO;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.springframework.cache.annotation.CacheConfig;
|
||||
@ -63,4 +63,12 @@ public interface MenuService extends IService<Menu> {
|
||||
*/
|
||||
void deleteIds(List<String> ids);
|
||||
|
||||
/**
|
||||
* 添加更新菜单
|
||||
*
|
||||
* @param menu 菜单数据
|
||||
* @return 是否成功
|
||||
*/
|
||||
boolean saveOrUpdateMenu(Menu menu);
|
||||
|
||||
}
|
||||
|
@ -1,11 +1,12 @@
|
||||
package cn.lili.modules.permission.serviceimpl;
|
||||
|
||||
import cn.hutool.core.text.CharSequenceUtil;
|
||||
import cn.lili.cache.Cache;
|
||||
import cn.lili.cache.CachePrefix;
|
||||
import cn.lili.common.enums.ResultCode;
|
||||
import cn.lili.common.exception.ServiceException;
|
||||
import cn.lili.common.security.AuthUser;
|
||||
import cn.lili.common.security.context.UserContext;
|
||||
import cn.lili.mybatis.util.PageUtil;
|
||||
import cn.lili.common.utils.StringUtils;
|
||||
import cn.lili.common.vo.SearchVO;
|
||||
import cn.lili.modules.permission.entity.dos.Menu;
|
||||
import cn.lili.modules.permission.entity.dos.RoleMenu;
|
||||
@ -14,15 +15,14 @@ import cn.lili.modules.permission.entity.vo.MenuVO;
|
||||
import cn.lili.modules.permission.mapper.MenuMapper;
|
||||
import cn.lili.modules.permission.service.MenuService;
|
||||
import cn.lili.modules.permission.service.RoleMenuService;
|
||||
import cn.lili.mybatis.util.PageUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 权限业务层实现
|
||||
@ -39,6 +39,9 @@ public class MenuServiceImpl extends ServiceImpl<MenuMapper, Menu> implements Me
|
||||
@Autowired
|
||||
private RoleMenuService roleMenuService;
|
||||
|
||||
@Autowired
|
||||
private Cache<List<Menu>> cache;
|
||||
|
||||
@Override
|
||||
public void deleteIds(List<String> ids) {
|
||||
QueryWrapper<RoleMenu> queryWrapper = new QueryWrapper<>();
|
||||
@ -53,8 +56,8 @@ public class MenuServiceImpl extends ServiceImpl<MenuMapper, Menu> implements Me
|
||||
|
||||
@Override
|
||||
public List<MenuVO> findUserTree() {
|
||||
AuthUser authUser = UserContext.getCurrentUser();
|
||||
if (authUser.getIsSuper()) {
|
||||
AuthUser authUser = Objects.requireNonNull(UserContext.getCurrentUser());
|
||||
if (Boolean.TRUE.equals(authUser.getIsSuper())) {
|
||||
return this.tree();
|
||||
}
|
||||
List<Menu> userMenus = this.baseMapper.findByUserId(authUser.getId());
|
||||
@ -63,7 +66,28 @@ public class MenuServiceImpl extends ServiceImpl<MenuMapper, Menu> implements Me
|
||||
|
||||
@Override
|
||||
public List<Menu> findUserList(String userId) {
|
||||
return this.baseMapper.findByUserId(userId);
|
||||
String cacheKey = CachePrefix.MENU_USER_ID.getPrefix() + userId;
|
||||
List<Menu> menuList = cache.get(cacheKey);
|
||||
if (menuList == null) {
|
||||
menuList = this.baseMapper.findByUserId(userId);
|
||||
cache.put(cacheKey, menuList);
|
||||
}
|
||||
return menuList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加更新菜单
|
||||
*
|
||||
* @param menu 菜单数据
|
||||
* @return 是否成功
|
||||
*/
|
||||
@Override
|
||||
public boolean saveOrUpdateMenu(Menu menu) {
|
||||
if (CharSequenceUtil.isNotEmpty(menu.getId())) {
|
||||
cache.vagueDel(CachePrefix.MENU_USER_ID.getPrefix());
|
||||
cache.vagueDel(CachePrefix.USER_MENU.getPrefix());
|
||||
}
|
||||
return this.saveOrUpdate(menu);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -77,12 +101,12 @@ public class MenuServiceImpl extends ServiceImpl<MenuMapper, Menu> implements Me
|
||||
public List<Menu> searchList(MenuSearchParams menuSearchParams) {
|
||||
//title 需要特殊处理
|
||||
String title = null;
|
||||
if (StringUtils.isNotEmpty(menuSearchParams.getTitle())) {
|
||||
if (CharSequenceUtil.isNotEmpty(menuSearchParams.getTitle())) {
|
||||
title = menuSearchParams.getTitle();
|
||||
menuSearchParams.setTitle(null);
|
||||
}
|
||||
QueryWrapper queryWrapper = PageUtil.initWrapper(menuSearchParams, new SearchVO());
|
||||
if (StringUtils.isNotEmpty(title)) {
|
||||
QueryWrapper<Menu> queryWrapper = PageUtil.initWrapper(menuSearchParams, new SearchVO());
|
||||
if (CharSequenceUtil.isNotEmpty(title)) {
|
||||
queryWrapper.like("title", title);
|
||||
}
|
||||
queryWrapper.orderByDesc("sort_order");
|
||||
@ -98,14 +122,14 @@ public class MenuServiceImpl extends ServiceImpl<MenuMapper, Menu> implements Me
|
||||
} catch (Exception e) {
|
||||
log.error("菜单树错误", e);
|
||||
}
|
||||
return null;
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
/**
|
||||
* 传入自定义菜单集合
|
||||
*
|
||||
* @param menus
|
||||
* @return
|
||||
* @param menus 自定义菜单集合
|
||||
* @return 修改后的自定义菜单集合
|
||||
*/
|
||||
private List<MenuVO> tree(List<Menu> menus) {
|
||||
List<MenuVO> tree = new ArrayList<>();
|
||||
@ -117,12 +141,7 @@ public class MenuServiceImpl extends ServiceImpl<MenuMapper, Menu> implements Me
|
||||
}
|
||||
});
|
||||
//对一级菜单排序
|
||||
tree.sort(new Comparator<MenuVO>() {
|
||||
@Override
|
||||
public int compare(MenuVO o1, MenuVO o2) {
|
||||
return o1.getSortOrder().compareTo(o2.getSortOrder());
|
||||
}
|
||||
});
|
||||
tree.sort(Comparator.comparing(Menu::getSortOrder));
|
||||
return tree;
|
||||
}
|
||||
|
||||
|
@ -1,13 +1,17 @@
|
||||
package cn.lili.modules.permission.serviceimpl;
|
||||
|
||||
import cn.lili.cache.Cache;
|
||||
import cn.lili.cache.CachePrefix;
|
||||
import cn.lili.modules.permission.entity.dos.RoleMenu;
|
||||
import cn.lili.modules.permission.entity.vo.UserMenuVO;
|
||||
import cn.lili.modules.permission.mapper.MenuMapper;
|
||||
import cn.lili.modules.permission.mapper.RoleMenuMapper;
|
||||
import cn.lili.modules.permission.service.RoleMenuService;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import groovy.util.logging.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@ -31,16 +35,26 @@ public class RoleMenuServiceImpl extends ServiceImpl<RoleMenuMapper, RoleMenu> i
|
||||
@Resource
|
||||
private MenuMapper menuMapper;
|
||||
|
||||
|
||||
@Autowired
|
||||
private Cache<Object> cache;
|
||||
|
||||
@Override
|
||||
public List<RoleMenu> findByRoleId(String roleId) {
|
||||
QueryWrapper<RoleMenu> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("role_id", roleId);
|
||||
LambdaQueryWrapper<RoleMenu> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(RoleMenu::getRoleId, roleId);
|
||||
return this.baseMapper.selectList(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UserMenuVO> findAllMenu(String userId) {
|
||||
return menuMapper.getUserRoleMenu(userId);
|
||||
String cacheKey = CachePrefix.USER_MENU.getPrefix() + userId;
|
||||
List<UserMenuVO> menuList = (List<UserMenuVO>) cache.get(cacheKey);
|
||||
if (menuList == null) {
|
||||
menuList = menuMapper.getUserRoleMenu(userId);
|
||||
cache.put(cacheKey, menuList);
|
||||
}
|
||||
return menuList;
|
||||
}
|
||||
|
||||
|
||||
@ -51,8 +65,10 @@ public class RoleMenuServiceImpl extends ServiceImpl<RoleMenuMapper, RoleMenu> i
|
||||
this.deleteRoleMenu(roleId);
|
||||
//重新保存角色菜单关系
|
||||
this.saveBatch(roleMenus);
|
||||
cache.vagueDel(CachePrefix.MENU_USER_ID.getPrefix());
|
||||
cache.vagueDel(CachePrefix.USER_MENU.getPrefix());
|
||||
} catch (Exception e) {
|
||||
log.error("修改用户权限错误",e);
|
||||
log.error("修改用户权限错误", e);
|
||||
}
|
||||
}
|
||||
|
||||
@ -62,12 +78,17 @@ public class RoleMenuServiceImpl extends ServiceImpl<RoleMenuMapper, RoleMenu> i
|
||||
QueryWrapper<RoleMenu> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("role_id", roleId);
|
||||
this.remove(queryWrapper);
|
||||
cache.vagueDel(CachePrefix.MENU_USER_ID.getPrefix());
|
||||
cache.vagueDel(CachePrefix.USER_MENU.getPrefix());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteRoleMenu(List<String> roleId) {
|
||||
//删除
|
||||
QueryWrapper<RoleMenu> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.in("role_id", roleId);
|
||||
this.remove(queryWrapper);
|
||||
cache.vagueDel(CachePrefix.MENU_USER_ID.getPrefix());
|
||||
cache.vagueDel(CachePrefix.USER_MENU.getPrefix());
|
||||
}
|
||||
}
|
@ -12,7 +12,6 @@ import cn.lili.cache.Cache;
|
||||
import cn.lili.cache.CachePrefix;
|
||||
import cn.lili.common.enums.PromotionTypeEnum;
|
||||
import cn.lili.common.enums.ResultCode;
|
||||
import cn.lili.common.enums.ResultUtil;
|
||||
import cn.lili.common.exception.ServiceException;
|
||||
import cn.lili.elasticsearch.BaseElasticsearchService;
|
||||
import cn.lili.elasticsearch.EsSuffix;
|
||||
@ -652,8 +651,10 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements
|
||||
goodsWords.setSort(0);
|
||||
goodsWordsService.save(goodsWords);
|
||||
}
|
||||
} catch (MyBatisSystemException e) {
|
||||
} catch (MyBatisSystemException me) {
|
||||
log.error(words + "关键字已存在!");
|
||||
} catch (Exception e) {
|
||||
log.error("关键字入库异常!", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,41 +1,15 @@
|
||||
package cn.lili.controller.other;
|
||||
|
||||
import cn.hutool.core.text.CharSequenceUtil;
|
||||
import cn.hutool.core.thread.ThreadUtil;
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import cn.lili.cache.Cache;
|
||||
import cn.lili.cache.CachePrefix;
|
||||
import cn.lili.common.enums.ResultCode;
|
||||
import cn.lili.common.enums.ResultUtil;
|
||||
import cn.lili.common.vo.ResultMessage;
|
||||
import cn.lili.modules.goods.entity.dos.Brand;
|
||||
import cn.lili.modules.goods.entity.dos.Category;
|
||||
import cn.lili.modules.goods.entity.dos.Goods;
|
||||
import cn.lili.modules.goods.entity.dos.GoodsSku;
|
||||
import cn.lili.modules.goods.entity.dto.GoodsParamsDTO;
|
||||
import cn.lili.modules.goods.entity.enums.GoodsAuthEnum;
|
||||
import cn.lili.modules.goods.entity.enums.GoodsStatusEnum;
|
||||
import cn.lili.modules.goods.service.BrandService;
|
||||
import cn.lili.modules.goods.service.CategoryService;
|
||||
import cn.lili.modules.goods.service.GoodsService;
|
||||
import cn.lili.modules.goods.service.GoodsSkuService;
|
||||
import cn.lili.modules.promotion.service.PromotionService;
|
||||
import cn.lili.modules.search.entity.dos.EsGoodsIndex;
|
||||
import cn.lili.modules.search.service.EsGoodsIndexService;
|
||||
import cn.lili.modules.store.entity.dos.StoreGoodsLabel;
|
||||
import cn.lili.modules.store.service.StoreGoodsLabelService;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import io.swagger.annotations.Api;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
|
@ -2,7 +2,6 @@ package cn.lili.controller.permission;
|
||||
|
||||
import cn.lili.common.enums.ResultUtil;
|
||||
import cn.lili.common.vo.ResultMessage;
|
||||
import cn.lili.modules.system.aspect.annotation.DemoSite;
|
||||
import cn.lili.modules.permission.entity.dos.Menu;
|
||||
import cn.lili.modules.permission.entity.dto.MenuSearchParams;
|
||||
import cn.lili.modules.permission.entity.vo.MenuVO;
|
||||
@ -29,6 +28,7 @@ import java.util.List;
|
||||
@Api(tags = "管理端,菜单管理接口")
|
||||
@RequestMapping("/manager/menu")
|
||||
public class MenuManagerController {
|
||||
|
||||
@Autowired
|
||||
private MenuService menuService;
|
||||
|
||||
@ -43,9 +43,9 @@ public class MenuManagerController {
|
||||
@DemoSite
|
||||
public ResultMessage<Menu> add(Menu menu) {
|
||||
try {
|
||||
menuService.save(menu);
|
||||
menuService.saveOrUpdateMenu(menu);
|
||||
} catch (Exception e) {
|
||||
log.error("添加菜单错误",e);
|
||||
log.error("添加菜单错误", e);
|
||||
}
|
||||
return ResultUtil.data(menu);
|
||||
}
|
||||
@ -57,7 +57,7 @@ public class MenuManagerController {
|
||||
@DemoSite
|
||||
public ResultMessage<Menu> edit(@PathVariable String id, Menu menu) {
|
||||
menu.setId(id);
|
||||
menuService.updateById(menu);
|
||||
menuService.saveOrUpdateMenu(menu);
|
||||
return ResultUtil.data(menu);
|
||||
}
|
||||
|
||||
|
@ -32,8 +32,7 @@ spring:
|
||||
# mongodb
|
||||
data:
|
||||
mongodb:
|
||||
host: 127.0.0.1
|
||||
port: 27017
|
||||
uri: 127.0.0.1:27017
|
||||
database: lilishop
|
||||
username: root
|
||||
password: lilishop
|
||||
|
@ -7,6 +7,7 @@
|
||||
<springProperty scope="context" name="APP_NAME" source="spring.application.name"/>
|
||||
<!--日志文件保存路径-->
|
||||
<springProperty scope="context" name="LOG_FILE_PATH" source="logging.file.path"/>
|
||||
<springProperty scope="context" name="LOGSTASH_SERVER" source="lili.data.logstash.server"/>
|
||||
<contextName>${APP_NAME}</contextName>
|
||||
|
||||
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
@ -22,7 +23,7 @@
|
||||
<!--输出到elk的LOGSTASH-->
|
||||
<appender name="LOGSTASH" class="net.logstash.logback.appender.LogstashTcpSocketAppender">
|
||||
<!-- 配置elk日志收集 配饰的是 LOGSTASH 的地址-->
|
||||
<destination>127.0.0.1:4560</destination>
|
||||
<destination>${LOGSTASH_SERVER}</destination>
|
||||
<encoder charset="UTF-8" class="net.logstash.logback.encoder.LogstashEncoder">
|
||||
<providers>
|
||||
<timestamp>
|
||||
|
@ -23,7 +23,6 @@ import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.data.elasticsearch.core.SearchPage;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
@ -32,8 +32,7 @@ spring:
|
||||
# mongodb
|
||||
data:
|
||||
mongodb:
|
||||
host: 127.0.0.1
|
||||
port: 27017
|
||||
uri: 127.0.0.1:27017
|
||||
database: lilishop
|
||||
username: root
|
||||
password: lilishop
|
||||
|
@ -7,6 +7,7 @@
|
||||
<springProperty scope="context" name="APP_NAME" source="spring.application.name"/>
|
||||
<!--日志文件保存路径-->
|
||||
<springProperty scope="context" name="LOG_FILE_PATH" source="logging.file.path"/>
|
||||
<springProperty scope="context" name="LOGSTASH_SERVER" source="lili.data.logstash.server"/>
|
||||
<contextName>${APP_NAME}</contextName>
|
||||
|
||||
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
@ -22,7 +23,7 @@
|
||||
<!--输出到elk的LOGSTASH-->
|
||||
<appender name="LOGSTASH" class="net.logstash.logback.appender.LogstashTcpSocketAppender">
|
||||
<!-- 配置elk日志收集 配饰的是 LOGSTASH 的地址-->
|
||||
<destination>127.0.0.1:4560</destination>
|
||||
<destination>${LOGSTASH_SERVER}</destination>
|
||||
<encoder charset="UTF-8" class="net.logstash.logback.encoder.LogstashEncoder">
|
||||
<providers>
|
||||
<timestamp>
|
||||
|
Loading…
x
Reference in New Issue
Block a user