升级Spring Cloud Hoxton & Alibaba,认证授权改用Oauth2。
This commit is contained in:
@@ -3,11 +3,13 @@ package com.macro.mall;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
|
||||
import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||
|
||||
/**
|
||||
* 应用启动入口
|
||||
* Created by macro on 2018/4/26.
|
||||
*/
|
||||
@EnableFeignClients
|
||||
@EnableDiscoveryClient
|
||||
@SpringBootApplication
|
||||
public class MallAdminApplication {
|
||||
|
||||
@@ -1,62 +0,0 @@
|
||||
package com.macro.mall.bo;
|
||||
|
||||
import com.macro.mall.model.UmsAdmin;
|
||||
import com.macro.mall.model.UmsResource;
|
||||
import org.springframework.security.core.GrantedAuthority;
|
||||
import org.springframework.security.core.authority.SimpleGrantedAuthority;
|
||||
import org.springframework.security.core.userdetails.UserDetails;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* SpringSecurity需要的用户详情
|
||||
* Created by macro on 2018/4/26.
|
||||
*/
|
||||
public class AdminUserDetails implements UserDetails {
|
||||
private UmsAdmin umsAdmin;
|
||||
private List<UmsResource> resourceList;
|
||||
public AdminUserDetails(UmsAdmin umsAdmin,List<UmsResource> resourceList) {
|
||||
this.umsAdmin = umsAdmin;
|
||||
this.resourceList = resourceList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<? extends GrantedAuthority> getAuthorities() {
|
||||
//返回当前用户的角色
|
||||
return resourceList.stream()
|
||||
.map(role ->new SimpleGrantedAuthority(role.getId()+":"+role.getName()))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPassword() {
|
||||
return umsAdmin.getPassword();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUsername() {
|
||||
return umsAdmin.getUsername();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAccountNonExpired() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAccountNonLocked() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCredentialsNonExpired() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return umsAdmin.getStatus().equals(1);
|
||||
}
|
||||
}
|
||||
@@ -1,144 +0,0 @@
|
||||
package com.macro.mall.bo;
|
||||
|
||||
/**
|
||||
* Controller层的日志封装类
|
||||
* Created by macro on 2018/4/26.
|
||||
*/
|
||||
public class WebLog {
|
||||
/**
|
||||
* 操作描述
|
||||
*/
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* 操作用户
|
||||
*/
|
||||
private String username;
|
||||
|
||||
/**
|
||||
* 操作时间
|
||||
*/
|
||||
private Long startTime;
|
||||
|
||||
/**
|
||||
* 消耗时间
|
||||
*/
|
||||
private Integer spendTime;
|
||||
|
||||
/**
|
||||
* 根路径
|
||||
*/
|
||||
private String basePath;
|
||||
|
||||
/**
|
||||
* URI
|
||||
*/
|
||||
private String uri;
|
||||
|
||||
/**
|
||||
* URL
|
||||
*/
|
||||
private String url;
|
||||
|
||||
/**
|
||||
* 请求类型
|
||||
*/
|
||||
private String method;
|
||||
|
||||
/**
|
||||
* IP地址
|
||||
*/
|
||||
private String ip;
|
||||
|
||||
private Object parameter;
|
||||
|
||||
private Object result;
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public Long getStartTime() {
|
||||
return startTime;
|
||||
}
|
||||
|
||||
public void setStartTime(Long startTime) {
|
||||
this.startTime = startTime;
|
||||
}
|
||||
|
||||
public Integer getSpendTime() {
|
||||
return spendTime;
|
||||
}
|
||||
|
||||
public void setSpendTime(Integer spendTime) {
|
||||
this.spendTime = spendTime;
|
||||
}
|
||||
|
||||
public String getBasePath() {
|
||||
return basePath;
|
||||
}
|
||||
|
||||
public void setBasePath(String basePath) {
|
||||
this.basePath = basePath;
|
||||
}
|
||||
|
||||
public String getUri() {
|
||||
return uri;
|
||||
}
|
||||
|
||||
public void setUri(String uri) {
|
||||
this.uri = uri;
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
public void setUrl(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
public String getMethod() {
|
||||
return method;
|
||||
}
|
||||
|
||||
public void setMethod(String method) {
|
||||
this.method = method;
|
||||
}
|
||||
|
||||
public String getIp() {
|
||||
return ip;
|
||||
}
|
||||
|
||||
public void setIp(String ip) {
|
||||
this.ip = ip;
|
||||
}
|
||||
|
||||
public Object getParameter() {
|
||||
return parameter;
|
||||
}
|
||||
|
||||
public void setParameter(Object parameter) {
|
||||
this.parameter = parameter;
|
||||
}
|
||||
|
||||
public Object getResult() {
|
||||
return result;
|
||||
}
|
||||
|
||||
public void setResult(Object result) {
|
||||
this.result = result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.macro.mall.component;
|
||||
|
||||
import com.macro.mall.service.UmsResourceService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
|
||||
/**
|
||||
* 资源与角色访问对应关系操作组件
|
||||
* Created by macro on 2020/7/17.
|
||||
*/
|
||||
@Component
|
||||
public class ResourceRoleRulesHolder {
|
||||
|
||||
@Autowired
|
||||
private UmsResourceService resourceService;
|
||||
|
||||
@PostConstruct
|
||||
public void initResourceRolesMap(){
|
||||
resourceService.initResourceRolesMap();
|
||||
}
|
||||
}
|
||||
@@ -1,125 +0,0 @@
|
||||
package com.macro.mall.component;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.core.util.URLUtil;
|
||||
import cn.hutool.json.JSON;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.macro.mall.bo.WebLog;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import net.logstash.logback.marker.Markers;
|
||||
import org.aspectj.lang.JoinPoint;
|
||||
import org.aspectj.lang.ProceedingJoinPoint;
|
||||
import org.aspectj.lang.Signature;
|
||||
import org.aspectj.lang.annotation.*;
|
||||
import org.aspectj.lang.reflect.MethodSignature;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.context.request.RequestContextHolder;
|
||||
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Parameter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 统一日志处理切面
|
||||
* Created by macro on 2018/4/26.
|
||||
*/
|
||||
@Aspect
|
||||
@Component
|
||||
@Order(1)
|
||||
public class WebLogAspect {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(WebLogAspect.class);
|
||||
|
||||
@Pointcut("execution(public * com.macro.mall.controller.*.*(..))")
|
||||
public void webLog() {
|
||||
}
|
||||
|
||||
@Before("webLog()")
|
||||
public void doBefore(JoinPoint joinPoint) throws Throwable {
|
||||
}
|
||||
|
||||
@AfterReturning(value = "webLog()", returning = "ret")
|
||||
public void doAfterReturning(Object ret) throws Throwable {
|
||||
}
|
||||
|
||||
@Around("webLog()")
|
||||
public Object doAround(ProceedingJoinPoint joinPoint) throws Throwable {
|
||||
long startTime = System.currentTimeMillis();
|
||||
//获取当前请求对象
|
||||
ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
|
||||
HttpServletRequest request = attributes.getRequest();
|
||||
//记录请求信息(通过Logstash传入Elasticsearch)
|
||||
WebLog webLog = new WebLog();
|
||||
Object result = joinPoint.proceed();
|
||||
Signature signature = joinPoint.getSignature();
|
||||
MethodSignature methodSignature = (MethodSignature) signature;
|
||||
Method method = methodSignature.getMethod();
|
||||
if (method.isAnnotationPresent(ApiOperation.class)) {
|
||||
ApiOperation log = method.getAnnotation(ApiOperation.class);
|
||||
webLog.setDescription(log.value());
|
||||
}
|
||||
long endTime = System.currentTimeMillis();
|
||||
String urlStr = request.getRequestURL().toString();
|
||||
webLog.setBasePath(StrUtil.removeSuffix(urlStr, URLUtil.url(urlStr).getPath()));
|
||||
webLog.setIp(request.getRemoteUser());
|
||||
webLog.setMethod(request.getMethod());
|
||||
webLog.setParameter(getParameter(method, joinPoint.getArgs()));
|
||||
webLog.setResult(result);
|
||||
webLog.setSpendTime((int) (endTime - startTime));
|
||||
webLog.setStartTime(startTime);
|
||||
webLog.setUri(request.getRequestURI());
|
||||
webLog.setUrl(request.getRequestURL().toString());
|
||||
Map<String,Object> logMap = new HashMap<>();
|
||||
logMap.put("url",webLog.getUrl());
|
||||
logMap.put("method",webLog.getMethod());
|
||||
logMap.put("parameter",webLog.getParameter());
|
||||
logMap.put("spendTime",webLog.getSpendTime());
|
||||
logMap.put("description",webLog.getDescription());
|
||||
// LOGGER.info("{}", JSONUtil.parse(webLog));
|
||||
LOGGER.info(Markers.appendEntries(logMap), JSONUtil.parse(webLog).toString());
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据方法和传入的参数获取请求参数
|
||||
*/
|
||||
private Object getParameter(Method method, Object[] args) {
|
||||
List<Object> argList = new ArrayList<>();
|
||||
Parameter[] parameters = method.getParameters();
|
||||
for (int i = 0; i < parameters.length; i++) {
|
||||
//将RequestBody注解修饰的参数作为请求参数
|
||||
RequestBody requestBody = parameters[i].getAnnotation(RequestBody.class);
|
||||
if (requestBody != null) {
|
||||
argList.add(args[i]);
|
||||
}
|
||||
//将RequestParam注解修饰的参数作为请求参数
|
||||
RequestParam requestParam = parameters[i].getAnnotation(RequestParam.class);
|
||||
if (requestParam != null) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
String key = parameters[i].getName();
|
||||
if (!StringUtils.isEmpty(requestParam.value())) {
|
||||
key = requestParam.value();
|
||||
}
|
||||
map.put(key, args[i]);
|
||||
argList.add(map);
|
||||
}
|
||||
}
|
||||
if (argList.size() == 0) {
|
||||
return null;
|
||||
} else if (argList.size() == 1) {
|
||||
return argList.get(0);
|
||||
} else {
|
||||
return argList;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
package com.macro.mall.config;
|
||||
|
||||
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;
|
||||
|
||||
/**
|
||||
* 全局跨域配置
|
||||
* 注意:前端从网关进行调用时不需要配置
|
||||
* Created by macro on 2019/7/27.
|
||||
*/
|
||||
//@Configuration
|
||||
public class GlobalCorsConfig {
|
||||
|
||||
/**
|
||||
* 允许跨域调用的过滤器
|
||||
*/
|
||||
@Bean
|
||||
public CorsFilter corsFilter() {
|
||||
CorsConfiguration config = new CorsConfiguration();
|
||||
//允许所有域名进行跨域调用
|
||||
config.addAllowedOrigin("*");
|
||||
//允许跨越发送cookie
|
||||
config.setAllowCredentials(true);
|
||||
//放行全部原始头信息
|
||||
config.addAllowedHeader("*");
|
||||
//允许所有请求方法跨域调用
|
||||
config.addAllowedMethod("*");
|
||||
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
|
||||
source.registerCorsConfiguration("/**", config);
|
||||
return new CorsFilter(source);
|
||||
}
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
package com.macro.mall.config;
|
||||
|
||||
import com.macro.mall.model.UmsResource;
|
||||
import com.macro.mall.security.component.DynamicSecurityService;
|
||||
import com.macro.mall.security.config.SecurityConfig;
|
||||
import com.macro.mall.service.UmsAdminService;
|
||||
import com.macro.mall.service.UmsResourceService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.security.access.ConfigAttribute;
|
||||
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
|
||||
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
|
||||
import org.springframework.security.core.userdetails.UserDetailsService;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
/**
|
||||
* mall-security模块相关配置
|
||||
* Created by macro on 2019/11/9.
|
||||
*/
|
||||
@Configuration
|
||||
@EnableWebSecurity
|
||||
@EnableGlobalMethodSecurity(prePostEnabled = true)
|
||||
public class MallSecurityConfig extends SecurityConfig {
|
||||
|
||||
@Autowired
|
||||
private UmsAdminService adminService;
|
||||
@Autowired
|
||||
private UmsResourceService resourceService;
|
||||
|
||||
@Bean
|
||||
public UserDetailsService userDetailsService() {
|
||||
//获取登录用户信息
|
||||
return username -> adminService.loadUserByUsername(username);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public DynamicSecurityService dynamicSecurityService() {
|
||||
return new DynamicSecurityService() {
|
||||
@Override
|
||||
public Map<String, ConfigAttribute> loadDataSource() {
|
||||
Map<String, ConfigAttribute> map = new ConcurrentHashMap<>();
|
||||
List<UmsResource> resourceList = resourceService.listAll();
|
||||
for (UmsResource resource : resourceList) {
|
||||
map.put(resource.getUrl(), new org.springframework.security.access.SecurityConfig(resource.getId() + ":" + resource.getName()));
|
||||
}
|
||||
return map;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,7 @@ import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||
|
||||
/**
|
||||
* MyBatis配置类
|
||||
* MyBatis相关配置
|
||||
* Created by macro on 2019/4/8.
|
||||
*/
|
||||
@Configuration
|
||||
|
||||
@@ -6,6 +6,7 @@ import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* OSS对象存储相关配置
|
||||
* Created by macro on 2018/5/17.
|
||||
*/
|
||||
@Configuration
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.macro.mall.config;
|
||||
|
||||
import com.macro.mall.common.config.BaseRedisConfig;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.data.redis.connection.RedisConnectionFactory;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.data.redis.repository.configuration.EnableRedisRepositories;
|
||||
import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
|
||||
import org.springframework.data.redis.serializer.StringRedisSerializer;
|
||||
|
||||
/**
|
||||
* Redis相关配置
|
||||
* Created by macro on 2020/6/19.
|
||||
*/
|
||||
@Configuration
|
||||
public class RedisConfig extends BaseRedisConfig {
|
||||
|
||||
}
|
||||
@@ -1,80 +0,0 @@
|
||||
package com.macro.mall.config;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import springfox.documentation.builders.ApiInfoBuilder;
|
||||
import springfox.documentation.builders.PathSelectors;
|
||||
import springfox.documentation.builders.RequestHandlerSelectors;
|
||||
import springfox.documentation.service.ApiInfo;
|
||||
import springfox.documentation.service.ApiKey;
|
||||
import springfox.documentation.service.AuthorizationScope;
|
||||
import springfox.documentation.service.SecurityReference;
|
||||
import springfox.documentation.spi.DocumentationType;
|
||||
import springfox.documentation.spi.service.contexts.SecurityContext;
|
||||
import springfox.documentation.spring.web.plugins.Docket;
|
||||
import springfox.documentation.swagger2.annotations.EnableSwagger2;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Swagger2API文档的配置
|
||||
* Created by macro on 2018/4/26.
|
||||
*/
|
||||
@Configuration
|
||||
@EnableSwagger2
|
||||
public class Swagger2Config {
|
||||
@Bean
|
||||
public Docket createRestApi(){
|
||||
return new Docket(DocumentationType.SWAGGER_2)
|
||||
.apiInfo(apiInfo())
|
||||
.select()
|
||||
.apis(RequestHandlerSelectors.basePackage("com.macro.mall.controller"))
|
||||
.paths(PathSelectors.any())
|
||||
.build()
|
||||
.securitySchemes(securitySchemes())
|
||||
.securityContexts(securityContexts());
|
||||
}
|
||||
|
||||
private ApiInfo apiInfo() {
|
||||
return new ApiInfoBuilder()
|
||||
.title("mall后台系统")
|
||||
.description("mall后台模块")
|
||||
.contact("macro")
|
||||
.version("1.0")
|
||||
.build();
|
||||
}
|
||||
|
||||
private List<ApiKey> securitySchemes() {
|
||||
//设置请求头信息
|
||||
List<ApiKey> result = new ArrayList<>();
|
||||
ApiKey apiKey = new ApiKey("Authorization", "Authorization", "header");
|
||||
result.add(apiKey);
|
||||
return result;
|
||||
}
|
||||
|
||||
private List<SecurityContext> securityContexts() {
|
||||
//设置需要登录认证的路径
|
||||
List<SecurityContext> result = new ArrayList<>();
|
||||
result.add(getContextByPath("/brand/.*"));
|
||||
result.add(getContextByPath("/product/.*"));
|
||||
result.add(getContextByPath("/productCategory/.*"));
|
||||
return result;
|
||||
}
|
||||
|
||||
private SecurityContext getContextByPath(String pathRegex){
|
||||
return SecurityContext.builder()
|
||||
.securityReferences(defaultAuth())
|
||||
.forPaths(PathSelectors.regex(pathRegex))
|
||||
.build();
|
||||
}
|
||||
|
||||
private List<SecurityReference> defaultAuth() {
|
||||
List<SecurityReference> result = new ArrayList<>();
|
||||
AuthorizationScope authorizationScope = new AuthorizationScope("global", "accessEverything");
|
||||
AuthorizationScope[] authorizationScopes = new AuthorizationScope[1];
|
||||
authorizationScopes[0] = authorizationScope;
|
||||
result.add(new SecurityReference("Authorization", authorizationScopes));
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.macro.mall.config;
|
||||
|
||||
import com.macro.mall.common.config.BaseSwaggerConfig;
|
||||
import com.macro.mall.common.domain.SwaggerProperties;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import springfox.documentation.builders.ApiInfoBuilder;
|
||||
import springfox.documentation.builders.PathSelectors;
|
||||
import springfox.documentation.builders.RequestHandlerSelectors;
|
||||
import springfox.documentation.service.ApiInfo;
|
||||
import springfox.documentation.service.ApiKey;
|
||||
import springfox.documentation.service.AuthorizationScope;
|
||||
import springfox.documentation.service.SecurityReference;
|
||||
import springfox.documentation.spi.DocumentationType;
|
||||
import springfox.documentation.spi.service.contexts.SecurityContext;
|
||||
import springfox.documentation.spring.web.plugins.Docket;
|
||||
import springfox.documentation.swagger2.annotations.EnableSwagger2;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Swagger API文档相关配置
|
||||
* Created by macro on 2018/4/26.
|
||||
*/
|
||||
@Configuration
|
||||
@EnableSwagger2
|
||||
public class SwaggerConfig extends BaseSwaggerConfig {
|
||||
|
||||
@Override
|
||||
public SwaggerProperties swaggerProperties() {
|
||||
return SwaggerProperties.builder()
|
||||
.apiBasePackage("com.macro.mall.controller")
|
||||
.title("mall后台系统")
|
||||
.description("mall后台相关接口文档")
|
||||
.contactName("macro")
|
||||
.version("1.0")
|
||||
.enableSecurity(true)
|
||||
.build();
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,11 @@
|
||||
package com.macro.mall.controller;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.macro.mall.common.api.CommonResult;
|
||||
import com.macro.mall.dto.BucketPolicyConfigDto;
|
||||
import com.macro.mall.dto.MinioUploadDto;
|
||||
import io.minio.MinioClient;
|
||||
import io.minio.policy.PolicyType;
|
||||
import io.minio.*;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.slf4j.Logger;
|
||||
@@ -20,6 +22,7 @@ import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* MinIO对象存储管理
|
||||
* Created by macro on 2019/12/25.
|
||||
*/
|
||||
@Api(tags = "MinioController", description = "MinIO对象存储管理")
|
||||
@@ -43,39 +46,68 @@ public class MinioController {
|
||||
public CommonResult upload(@RequestParam("file") MultipartFile file) {
|
||||
try {
|
||||
//创建一个MinIO的Java客户端
|
||||
MinioClient minioClient = new MinioClient(ENDPOINT, ACCESS_KEY, SECRET_KEY);
|
||||
boolean isExist = minioClient.bucketExists(BUCKET_NAME);
|
||||
MinioClient minioClient =MinioClient.builder()
|
||||
.endpoint(ENDPOINT)
|
||||
.credentials(ACCESS_KEY,SECRET_KEY)
|
||||
.build();
|
||||
boolean isExist = minioClient.bucketExists(BucketExistsArgs.builder().bucket(BUCKET_NAME).build());
|
||||
if (isExist) {
|
||||
LOGGER.info("存储桶已经存在!");
|
||||
} else {
|
||||
//创建存储桶并设置只读权限
|
||||
minioClient.makeBucket(BUCKET_NAME);
|
||||
minioClient.setBucketPolicy(BUCKET_NAME, "*.*", PolicyType.READ_ONLY);
|
||||
minioClient.makeBucket(MakeBucketArgs.builder().bucket(BUCKET_NAME).build());
|
||||
BucketPolicyConfigDto bucketPolicyConfigDto = createBucketPolicyConfigDto(BUCKET_NAME);
|
||||
SetBucketPolicyArgs setBucketPolicyArgs = SetBucketPolicyArgs.builder()
|
||||
.bucket(BUCKET_NAME)
|
||||
.config(JSONUtil.toJsonStr(bucketPolicyConfigDto))
|
||||
.build();
|
||||
minioClient.setBucketPolicy(setBucketPolicyArgs);
|
||||
}
|
||||
String filename = file.getOriginalFilename();
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
|
||||
// 设置存储对象名称
|
||||
String objectName = sdf.format(new Date()) + "/" + filename;
|
||||
// 使用putObject上传一个文件到存储桶中
|
||||
minioClient.putObject(BUCKET_NAME, objectName, file.getInputStream(), file.getContentType());
|
||||
PutObjectArgs putObjectArgs = PutObjectArgs.builder()
|
||||
.bucket(BUCKET_NAME)
|
||||
.object(objectName)
|
||||
.contentType(file.getContentType())
|
||||
.stream(file.getInputStream(), file.getSize(), ObjectWriteArgs.MIN_MULTIPART_SIZE).build();
|
||||
minioClient.putObject(putObjectArgs);
|
||||
LOGGER.info("文件上传成功!");
|
||||
MinioUploadDto minioUploadDto = new MinioUploadDto();
|
||||
minioUploadDto.setName(filename);
|
||||
minioUploadDto.setUrl(ENDPOINT + "/" + BUCKET_NAME + "/" + objectName);
|
||||
return CommonResult.success(minioUploadDto);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
LOGGER.info("上传发生错误: {}!", e.getMessage());
|
||||
}
|
||||
return CommonResult.failed();
|
||||
}
|
||||
|
||||
private BucketPolicyConfigDto createBucketPolicyConfigDto(String bucketName) {
|
||||
BucketPolicyConfigDto.Statement statement = BucketPolicyConfigDto.Statement.builder()
|
||||
.Effect("Allow")
|
||||
.Principal("*")
|
||||
.Action("s3:GetObject")
|
||||
.Resource("arn:aws:s3:::"+bucketName+"/*.**").build();
|
||||
return BucketPolicyConfigDto.builder()
|
||||
.Version("2012-10-17")
|
||||
.Statement(CollUtil.toList(statement))
|
||||
.build();
|
||||
}
|
||||
|
||||
@ApiOperation("文件删除")
|
||||
@RequestMapping(value = "/delete", method = RequestMethod.POST)
|
||||
@ResponseBody
|
||||
public CommonResult delete(@RequestParam("objectName") String objectName) {
|
||||
try {
|
||||
MinioClient minioClient = new MinioClient(ENDPOINT, ACCESS_KEY, SECRET_KEY);
|
||||
minioClient.removeObject(BUCKET_NAME, objectName);
|
||||
MinioClient minioClient = MinioClient.builder()
|
||||
.endpoint(ENDPOINT)
|
||||
.credentials(ACCESS_KEY,SECRET_KEY)
|
||||
.build();
|
||||
minioClient.removeObject(RemoveObjectArgs.builder().bucket(BUCKET_NAME).object(objectName).build());
|
||||
return CommonResult.success(null);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
package com.macro.mall.controller;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.macro.mall.common.api.CommonPage;
|
||||
import com.macro.mall.common.api.CommonResult;
|
||||
import com.macro.mall.common.domain.UserDto;
|
||||
import com.macro.mall.dto.UmsAdminLoginParam;
|
||||
import com.macro.mall.dto.UmsAdminParam;
|
||||
import com.macro.mall.dto.UpdateAdminPasswordParam;
|
||||
@@ -13,16 +15,14 @@ import com.macro.mall.service.UmsRoleService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.validation.BindingResult;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.security.Principal;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 后台用户管理
|
||||
@@ -32,10 +32,6 @@ import java.util.Map;
|
||||
@Api(tags = "UmsAdminController", description = "后台用户管理")
|
||||
@RequestMapping("/admin")
|
||||
public class UmsAdminController {
|
||||
@Value("${jwt.tokenHeader}")
|
||||
private String tokenHeader;
|
||||
@Value("${jwt.tokenHead}")
|
||||
private String tokenHead;
|
||||
@Autowired
|
||||
private UmsAdminService adminService;
|
||||
@Autowired
|
||||
@@ -56,45 +52,23 @@ public class UmsAdminController {
|
||||
@RequestMapping(value = "/login", method = RequestMethod.POST)
|
||||
@ResponseBody
|
||||
public CommonResult login(@RequestBody UmsAdminLoginParam umsAdminLoginParam, BindingResult result) {
|
||||
String token = adminService.login(umsAdminLoginParam.getUsername(), umsAdminLoginParam.getPassword());
|
||||
if (token == null) {
|
||||
return CommonResult.validateFailed("用户名或密码错误");
|
||||
}
|
||||
Map<String, String> tokenMap = new HashMap<>();
|
||||
tokenMap.put("token", token);
|
||||
tokenMap.put("tokenHead", tokenHead);
|
||||
return CommonResult.success(tokenMap);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "刷新token")
|
||||
@RequestMapping(value = "/refreshToken", method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
public CommonResult refreshToken(HttpServletRequest request) {
|
||||
String token = request.getHeader(tokenHeader);
|
||||
String refreshToken = adminService.refreshToken(token);
|
||||
if (refreshToken == null) {
|
||||
return CommonResult.failed("token已经过期!");
|
||||
}
|
||||
Map<String, String> tokenMap = new HashMap<>();
|
||||
tokenMap.put("token", refreshToken);
|
||||
tokenMap.put("tokenHead", tokenHead);
|
||||
return CommonResult.success(tokenMap);
|
||||
return adminService.login(umsAdminLoginParam.getUsername(),umsAdminLoginParam.getPassword());
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取当前登录用户信息")
|
||||
@RequestMapping(value = "/info", method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
public CommonResult getAdminInfo(Principal principal) {
|
||||
if(principal==null){
|
||||
return CommonResult.unauthorized(null);
|
||||
}
|
||||
String username = principal.getName();
|
||||
UmsAdmin umsAdmin = adminService.getAdminByUsername(username);
|
||||
public CommonResult getAdminInfo() {
|
||||
UmsAdmin umsAdmin = adminService.getCurrentAdmin();
|
||||
Map<String, Object> data = new HashMap<>();
|
||||
data.put("username", umsAdmin.getUsername());
|
||||
data.put("roles", new String[]{"TEST"});
|
||||
data.put("menus", roleService.getMenuList(umsAdmin.getId()));
|
||||
data.put("icon", umsAdmin.getIcon());
|
||||
List<UmsRole> roleList = adminService.getRoleList(umsAdmin.getId());
|
||||
if(CollUtil.isNotEmpty(roleList)){
|
||||
List<String> roles = roleList.stream().map(UmsRole::getName).collect(Collectors.toList());
|
||||
data.put("roles",roles);
|
||||
}
|
||||
return CommonResult.success(data);
|
||||
}
|
||||
|
||||
@@ -215,4 +189,12 @@ public class UmsAdminController {
|
||||
List<UmsPermission> permissionList = adminService.getPermissionList(adminId);
|
||||
return CommonResult.success(permissionList);
|
||||
}
|
||||
|
||||
@ApiOperation("根据用户名获取通用用户信息")
|
||||
@RequestMapping(value = "/loadByUsername", method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
public UserDto loadUserByUsername(@RequestParam String username) {
|
||||
UserDto userDTO = adminService.loadUserByUsername(username);
|
||||
return userDTO;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ package com.macro.mall.controller;
|
||||
import com.macro.mall.common.api.CommonPage;
|
||||
import com.macro.mall.common.api.CommonResult;
|
||||
import com.macro.mall.model.UmsResource;
|
||||
import com.macro.mall.security.component.DynamicSecurityMetadataSource;
|
||||
import com.macro.mall.service.UmsResourceService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
@@ -12,6 +11,7 @@ import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 后台资源管理Controller
|
||||
@@ -24,15 +24,12 @@ public class UmsResourceController {
|
||||
|
||||
@Autowired
|
||||
private UmsResourceService resourceService;
|
||||
@Autowired
|
||||
private DynamicSecurityMetadataSource dynamicSecurityMetadataSource;
|
||||
|
||||
@ApiOperation("添加后台资源")
|
||||
@RequestMapping(value = "/create", method = RequestMethod.POST)
|
||||
@ResponseBody
|
||||
public CommonResult create(@RequestBody UmsResource umsResource) {
|
||||
int count = resourceService.create(umsResource);
|
||||
dynamicSecurityMetadataSource.clearDataSource();
|
||||
if (count > 0) {
|
||||
return CommonResult.success(count);
|
||||
} else {
|
||||
@@ -46,7 +43,6 @@ public class UmsResourceController {
|
||||
public CommonResult update(@PathVariable Long id,
|
||||
@RequestBody UmsResource umsResource) {
|
||||
int count = resourceService.update(id, umsResource);
|
||||
dynamicSecurityMetadataSource.clearDataSource();
|
||||
if (count > 0) {
|
||||
return CommonResult.success(count);
|
||||
} else {
|
||||
@@ -67,7 +63,6 @@ public class UmsResourceController {
|
||||
@ResponseBody
|
||||
public CommonResult delete(@PathVariable Long id) {
|
||||
int count = resourceService.delete(id);
|
||||
dynamicSecurityMetadataSource.clearDataSource();
|
||||
if (count > 0) {
|
||||
return CommonResult.success(count);
|
||||
} else {
|
||||
@@ -94,4 +89,12 @@ public class UmsResourceController {
|
||||
List<UmsResource> resourceList = resourceService.listAll();
|
||||
return CommonResult.success(resourceList);
|
||||
}
|
||||
|
||||
@ApiOperation("初始化资源角色关联数据")
|
||||
@RequestMapping(value = "/initResourceRolesMap", method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
public CommonResult initResourceRolesMap() {
|
||||
Map<String, List<String>> resourceRolesMap = resourceService.initResourceRolesMap();
|
||||
return CommonResult.success(resourceRolesMap);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ import org.apache.ibatis.annotations.Param;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 自定义优选和商品关系操作
|
||||
* 自定义优选和商品关系操作Dao
|
||||
* Created by macro on 2018/4/26.
|
||||
*/
|
||||
public interface CmsPrefrenceAreaProductRelationDao {
|
||||
|
||||
@@ -6,7 +6,7 @@ import org.apache.ibatis.annotations.Param;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 自定义商品和专题关系操作
|
||||
* 自定义商品和专题关系操作Dao
|
||||
* Created by macro on 2018/4/26.
|
||||
*/
|
||||
public interface CmsSubjectProductRelationDao {
|
||||
|
||||
@@ -10,7 +10,7 @@ import java.util.List;
|
||||
*/
|
||||
public interface PmsProductAttributeCategoryDao {
|
||||
/**
|
||||
* 获取商品属性分类,包括属性
|
||||
* 获取包含属性的商品属性分类
|
||||
*/
|
||||
List<PmsProductAttributeCategoryItem> getListWithAttr();
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ import java.util.List;
|
||||
*/
|
||||
public interface PmsProductCategoryDao {
|
||||
/**
|
||||
* 获取商品分类包括子分类
|
||||
* 获取商品分类及其子分类
|
||||
*/
|
||||
List<PmsProductCategoryWithChildrenItem> listWithChildren();
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import org.apache.ibatis.annotations.Param;
|
||||
|
||||
|
||||
/**
|
||||
* 商品自定义Dao
|
||||
* 自定义商品管理Dao
|
||||
* Created by macro on 2018/4/26.
|
||||
*/
|
||||
public interface PmsProductDao {
|
||||
|
||||
@@ -10,5 +10,8 @@ import java.util.List;
|
||||
* Created by macro on 2018/4/26.
|
||||
*/
|
||||
public interface PmsProductLadderDao {
|
||||
/**
|
||||
* 批量创建
|
||||
*/
|
||||
int insertList(@Param("list") List<PmsProductLadder> productLadderList);
|
||||
}
|
||||
|
||||
@@ -6,9 +6,12 @@ import org.apache.ibatis.annotations.Param;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 商品审核日志自定义Dao
|
||||
* 自定义商品审核日志管理Dao
|
||||
* Created by macro on 2018/4/27.
|
||||
*/
|
||||
public interface PmsProductVertifyRecordDao {
|
||||
/**
|
||||
* 批量创建
|
||||
*/
|
||||
int insertList(@Param("list") List<PmsProductVertifyRecord> list);
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ import org.apache.ibatis.annotations.Param;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 自定义商品sku库存Dao
|
||||
* 自定义商品SKU管理Dao
|
||||
* Created by macro on 2018/4/26.
|
||||
*/
|
||||
public interface PmsSkuStockDao {
|
||||
|
||||
@@ -4,9 +4,12 @@ import com.macro.mall.dto.SmsCouponParam;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* 优惠券管理自定义查询Dao
|
||||
* 自定义优惠券管理Dao
|
||||
* Created by macro on 2018/8/29.
|
||||
*/
|
||||
public interface SmsCouponDao {
|
||||
/**
|
||||
* 获取优惠券详情包括绑定关系
|
||||
*/
|
||||
SmsCouponParam getItem(@Param("id") Long id);
|
||||
}
|
||||
|
||||
@@ -6,9 +6,12 @@ import org.apache.ibatis.annotations.Param;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 优惠券和商品分类关系自定义Dao
|
||||
* 自定义优惠券和商品分类关系管理Dao
|
||||
* Created by macro on 2018/8/28.
|
||||
*/
|
||||
public interface SmsCouponProductCategoryRelationDao {
|
||||
/**
|
||||
* 批量创建
|
||||
*/
|
||||
int insertList(@Param("list")List<SmsCouponProductCategoryRelation> productCategoryRelationList);
|
||||
}
|
||||
|
||||
@@ -6,9 +6,12 @@ import org.apache.ibatis.annotations.Param;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 优惠券和产品关系自定义Dao
|
||||
* 自定义优惠券和商品关系关系Dao
|
||||
* Created by macro on 2018/8/28.
|
||||
*/
|
||||
public interface SmsCouponProductRelationDao {
|
||||
/**
|
||||
* 批量创建
|
||||
*/
|
||||
int insertList(@Param("list")List<SmsCouponProductRelation> productRelationList);
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ import org.apache.ibatis.annotations.Param;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 限时购商品关联自定义Dao
|
||||
* 自定义限时购商品关系管理Dao
|
||||
* Created by macro on 2018/11/16.
|
||||
*/
|
||||
public interface SmsFlashPromotionProductRelationDao {
|
||||
|
||||
@@ -6,9 +6,12 @@ import org.apache.ibatis.annotations.Param;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 用户权限自定义Dao
|
||||
* 自定义用户权限关系管理Dao
|
||||
* Created by macro on 2018/10/8.
|
||||
*/
|
||||
public interface UmsAdminPermissionRelationDao {
|
||||
/**
|
||||
* 批量创建
|
||||
*/
|
||||
int insertList(@Param("list") List<UmsAdminPermissionRelation> list);
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ import org.apache.ibatis.annotations.Param;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 后台用户与角色管理自定义Dao
|
||||
* 自定义后台用户与角色管理Dao
|
||||
* Created by macro on 2018/10/8.
|
||||
*/
|
||||
public interface UmsAdminRoleRelationDao {
|
||||
@@ -37,4 +37,9 @@ public interface UmsAdminRoleRelationDao {
|
||||
* 获取用户所有可访问资源
|
||||
*/
|
||||
List<UmsResource> getResourceList(@Param("adminId") Long adminId);
|
||||
|
||||
/**
|
||||
* 获取资源相关用户ID列表
|
||||
*/
|
||||
List<Long> getAdminIdList(@Param("resourceId") Long resourceId);
|
||||
}
|
||||
|
||||
@@ -7,13 +7,20 @@ import org.apache.ibatis.annotations.Param;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 后台用户角色自定义Dao
|
||||
* 自定义后台角色管理Dao
|
||||
* Created by macro on 2020/2/2.
|
||||
*/
|
||||
public interface UmsRoleDao {
|
||||
/**
|
||||
* 根据后台用户ID获取菜单
|
||||
*/
|
||||
List<UmsMenu> getMenuList(@Param("adminId") Long adminId);
|
||||
|
||||
/**
|
||||
* 根据角色ID获取菜单
|
||||
*/
|
||||
List<UmsMenu> getMenuListByRoleId(@Param("roleId") Long roleId);
|
||||
|
||||
/**
|
||||
* 根据角色ID获取资源
|
||||
*/
|
||||
List<UmsResource> getResourceListByRoleId(@Param("roleId") Long roleId);
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import org.apache.ibatis.annotations.Param;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 后台用户角色管理自定义Dao
|
||||
* 自定义角色权限关系管理Dao
|
||||
* Created by macro on 2018/9/30.
|
||||
*/
|
||||
public interface UmsRolePermissionRelationDao {
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.macro.mall.dto;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Minio Bucket访问策略配置
|
||||
* Created by macro on 2020/8/11.
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Builder
|
||||
public class BucketPolicyConfigDto {
|
||||
|
||||
private String Version;
|
||||
private List<Statement> Statement;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Builder
|
||||
public static class Statement {
|
||||
private String Effect;
|
||||
private String Principal;
|
||||
private String Action;
|
||||
private String Resource;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.macro.mall.dto;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
@@ -10,6 +11,8 @@ import lombok.EqualsAndHashCode;
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class MinioUploadDto {
|
||||
@ApiModelProperty("文件访问URL")
|
||||
private String url;
|
||||
@ApiModelProperty("文件名称")
|
||||
private String name;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.macro.mall.dto;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@@ -12,8 +13,12 @@ import java.math.BigDecimal;
|
||||
@Getter
|
||||
@Setter
|
||||
public class OmsMoneyInfoParam {
|
||||
@ApiModelProperty("订单ID")
|
||||
private Long orderId;
|
||||
@ApiModelProperty("运费金额")
|
||||
private BigDecimal freightAmount;
|
||||
@ApiModelProperty("管理员后台调整订单使用的折扣金额")
|
||||
private BigDecimal discountAmount;
|
||||
@ApiModelProperty("订单状态:0->待付款;1->待发货;2->已发货;3->已完成;4->已关闭;5->无效订单")
|
||||
private Integer status;
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.macro.mall.dto;
|
||||
import com.macro.mall.model.OmsOrder;
|
||||
import com.macro.mall.model.OmsOrderItem;
|
||||
import com.macro.mall.model.OmsOrderOperateHistory;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@@ -15,8 +16,10 @@ import java.util.List;
|
||||
public class OmsOrderDetail extends OmsOrder {
|
||||
@Getter
|
||||
@Setter
|
||||
@ApiModelProperty("订单商品列表")
|
||||
private List<OmsOrderItem> orderItemList;
|
||||
@Getter
|
||||
@Setter
|
||||
@ApiModelProperty("订单操作记录列表")
|
||||
private List<OmsOrderOperateHistory> historyList;
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.macro.mall.dto;
|
||||
|
||||
import com.macro.mall.model.OmsCompanyAddress;
|
||||
import com.macro.mall.model.OmsOrderReturnApply;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@@ -12,5 +13,6 @@ import lombok.Setter;
|
||||
public class OmsOrderReturnApplyResult extends OmsOrderReturnApply {
|
||||
@Getter
|
||||
@Setter
|
||||
@ApiModelProperty(value = "公司收货地址")
|
||||
private OmsCompanyAddress companyAddress;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.macro.mall.dto;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@@ -10,13 +11,22 @@ import lombok.Setter;
|
||||
@Getter
|
||||
@Setter
|
||||
public class OmsReceiverInfoParam {
|
||||
@ApiModelProperty(value = "订单ID")
|
||||
private Long orderId;
|
||||
@ApiModelProperty(value = "收货人姓名")
|
||||
private String receiverName;
|
||||
@ApiModelProperty(value = "收货人电话")
|
||||
private String receiverPhone;
|
||||
@ApiModelProperty(value = "收货人邮编")
|
||||
private String receiverPostCode;
|
||||
@ApiModelProperty(value = "详细地址")
|
||||
private String receiverDetailAddress;
|
||||
@ApiModelProperty(value = "省份/直辖市")
|
||||
private String receiverProvince;
|
||||
@ApiModelProperty(value = "城市")
|
||||
private String receiverCity;
|
||||
@ApiModelProperty(value = "区")
|
||||
private String receiverRegion;
|
||||
@ApiModelProperty(value = "订单状态:0->待付款;1->待发货;2->已发货;3->已完成;4->已关闭;5->无效订单")
|
||||
private Integer status;
|
||||
}
|
||||
|
||||
@@ -1,11 +1,15 @@
|
||||
package com.macro.mall.dto;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* oss上传成功后的回调参数
|
||||
* Created by macro on 2018/5/17.
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class OssCallbackParam {
|
||||
@ApiModelProperty("请求的回调地址")
|
||||
private String callbackUrl;
|
||||
@@ -13,28 +17,4 @@ public class OssCallbackParam {
|
||||
private String callbackBody;
|
||||
@ApiModelProperty("回调时传入参数的格式,比如表单提交形式")
|
||||
private String callbackBodyType;
|
||||
|
||||
public String getCallbackUrl() {
|
||||
return callbackUrl;
|
||||
}
|
||||
|
||||
public void setCallbackUrl(String callbackUrl) {
|
||||
this.callbackUrl = callbackUrl;
|
||||
}
|
||||
|
||||
public String getCallbackBody() {
|
||||
return callbackBody;
|
||||
}
|
||||
|
||||
public void setCallbackBody(String callbackBody) {
|
||||
this.callbackBody = callbackBody;
|
||||
}
|
||||
|
||||
public String getCallbackBodyType() {
|
||||
return callbackBodyType;
|
||||
}
|
||||
|
||||
public void setCallbackBodyType(String callbackBodyType) {
|
||||
this.callbackBodyType = callbackBodyType;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,15 @@
|
||||
package com.macro.mall.dto;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* oss上传文件的回调结果
|
||||
* Created by macro on 2018/5/17.
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class OssCallbackResult {
|
||||
@ApiModelProperty("文件名称")
|
||||
private String filename;
|
||||
@@ -17,44 +21,4 @@ public class OssCallbackResult {
|
||||
private String width;
|
||||
@ApiModelProperty("图片文件的高")
|
||||
private String height;
|
||||
|
||||
public String getFilename() {
|
||||
return filename;
|
||||
}
|
||||
|
||||
public void setFilename(String filename) {
|
||||
this.filename = filename;
|
||||
}
|
||||
|
||||
public String getSize() {
|
||||
return size;
|
||||
}
|
||||
|
||||
public void setSize(String size) {
|
||||
this.size = size;
|
||||
}
|
||||
|
||||
public String getMimeType() {
|
||||
return mimeType;
|
||||
}
|
||||
|
||||
public void setMimeType(String mimeType) {
|
||||
this.mimeType = mimeType;
|
||||
}
|
||||
|
||||
public String getWidth() {
|
||||
return width;
|
||||
}
|
||||
|
||||
public void setWidth(String width) {
|
||||
this.width = width;
|
||||
}
|
||||
|
||||
public String getHeight() {
|
||||
return height;
|
||||
}
|
||||
|
||||
public void setHeight(String height) {
|
||||
this.height = height;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,15 @@
|
||||
package com.macro.mall.dto;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* 获取OSS上传文件授权返回结果
|
||||
* Created by macro on 2018/5/17.
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class OssPolicyResult {
|
||||
@ApiModelProperty("访问身份验证中用到用户标识")
|
||||
private String accessKeyId;
|
||||
@@ -19,52 +23,4 @@ public class OssPolicyResult {
|
||||
private String host;
|
||||
@ApiModelProperty("上传成功后的回调设置")
|
||||
private String callback;
|
||||
|
||||
public String getAccessKeyId() {
|
||||
return accessKeyId;
|
||||
}
|
||||
|
||||
public void setAccessKeyId(String accessKeyId) {
|
||||
this.accessKeyId = accessKeyId;
|
||||
}
|
||||
|
||||
public String getPolicy() {
|
||||
return policy;
|
||||
}
|
||||
|
||||
public void setPolicy(String policy) {
|
||||
this.policy = policy;
|
||||
}
|
||||
|
||||
public String getSignature() {
|
||||
return signature;
|
||||
}
|
||||
|
||||
public void setSignature(String signature) {
|
||||
this.signature = signature;
|
||||
}
|
||||
|
||||
public String getDir() {
|
||||
return dir;
|
||||
}
|
||||
|
||||
public void setDir(String dir) {
|
||||
this.dir = dir;
|
||||
}
|
||||
|
||||
public String getHost() {
|
||||
return host;
|
||||
}
|
||||
|
||||
public void setHost(String host) {
|
||||
this.host = host;
|
||||
}
|
||||
|
||||
public String getCallback() {
|
||||
return callback;
|
||||
}
|
||||
|
||||
public void setCallback(String callback) {
|
||||
this.callback = callback;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,8 @@ package com.macro.mall.dto;
|
||||
|
||||
import com.macro.mall.validator.FlagValidator;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import javax.validation.constraints.Min;
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
@@ -10,6 +12,8 @@ import javax.validation.constraints.NotEmpty;
|
||||
* 品牌传递参数
|
||||
* Created by macro on 2018/4/26.
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class PmsBrandParam {
|
||||
@ApiModelProperty(value = "品牌名称",required = true)
|
||||
@NotEmpty(message = "名称不能为空")
|
||||
@@ -32,68 +36,4 @@ public class PmsBrandParam {
|
||||
private String bigPic;
|
||||
@ApiModelProperty(value = "品牌故事")
|
||||
private String brandStory;
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getFirstLetter() {
|
||||
return firstLetter;
|
||||
}
|
||||
|
||||
public void setFirstLetter(String firstLetter) {
|
||||
this.firstLetter = firstLetter;
|
||||
}
|
||||
|
||||
public Integer getSort() {
|
||||
return sort;
|
||||
}
|
||||
|
||||
public void setSort(Integer sort) {
|
||||
this.sort = sort;
|
||||
}
|
||||
|
||||
public Integer getFactoryStatus() {
|
||||
return factoryStatus;
|
||||
}
|
||||
|
||||
public void setFactoryStatus(Integer factoryStatus) {
|
||||
this.factoryStatus = factoryStatus;
|
||||
}
|
||||
|
||||
public Integer getShowStatus() {
|
||||
return showStatus;
|
||||
}
|
||||
|
||||
public void setShowStatus(Integer showStatus) {
|
||||
this.showStatus = showStatus;
|
||||
}
|
||||
|
||||
public String getLogo() {
|
||||
return logo;
|
||||
}
|
||||
|
||||
public void setLogo(String logo) {
|
||||
this.logo = logo;
|
||||
}
|
||||
|
||||
public String getBigPic() {
|
||||
return bigPic;
|
||||
}
|
||||
|
||||
public void setBigPic(String bigPic) {
|
||||
this.bigPic = bigPic;
|
||||
}
|
||||
|
||||
public String getBrandStory() {
|
||||
return brandStory;
|
||||
}
|
||||
|
||||
public void setBrandStory(String brandStory) {
|
||||
this.brandStory = brandStory;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,10 @@ package com.macro.mall.dto;
|
||||
|
||||
import com.macro.mall.model.PmsProductAttribute;
|
||||
import com.macro.mall.model.PmsProductAttributeCategory;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -10,13 +14,8 @@ import java.util.List;
|
||||
* Created by macro on 2018/5/24.
|
||||
*/
|
||||
public class PmsProductAttributeCategoryItem extends PmsProductAttributeCategory {
|
||||
@Getter
|
||||
@Setter
|
||||
@ApiModelProperty(value = "商品属性列表")
|
||||
private List<PmsProductAttribute> productAttributeList;
|
||||
|
||||
public List<PmsProductAttribute> getProductAttributeList() {
|
||||
return productAttributeList;
|
||||
}
|
||||
|
||||
public void setProductAttributeList(List<PmsProductAttribute> productAttributeList) {
|
||||
this.productAttributeList = productAttributeList;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,8 @@ package com.macro.mall.dto;
|
||||
|
||||
import com.macro.mall.validator.FlagValidator;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
|
||||
@@ -9,6 +11,8 @@ import javax.validation.constraints.NotEmpty;
|
||||
* 商品属性参数
|
||||
* Created by macro on 2018/4/26.
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class PmsProductAttributeParam {
|
||||
@ApiModelProperty("属性分类ID")
|
||||
@NotEmpty(message = "属性分类不能为空")
|
||||
@@ -41,92 +45,4 @@ public class PmsProductAttributeParam {
|
||||
@ApiModelProperty("属性的类型;0->规格;1->参数")
|
||||
@FlagValidator({"0","1"})
|
||||
private Integer type;
|
||||
|
||||
public Long getProductAttributeCategoryId() {
|
||||
return productAttributeCategoryId;
|
||||
}
|
||||
|
||||
public void setProductAttributeCategoryId(Long productAttributeCategoryId) {
|
||||
this.productAttributeCategoryId = productAttributeCategoryId;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public Integer getSelectType() {
|
||||
return selectType;
|
||||
}
|
||||
|
||||
public void setSelectType(Integer selectType) {
|
||||
this.selectType = selectType;
|
||||
}
|
||||
|
||||
public Integer getInputType() {
|
||||
return inputType;
|
||||
}
|
||||
|
||||
public void setInputType(Integer inputType) {
|
||||
this.inputType = inputType;
|
||||
}
|
||||
|
||||
public String getInputList() {
|
||||
return inputList;
|
||||
}
|
||||
|
||||
public void setInputList(String inputList) {
|
||||
this.inputList = inputList;
|
||||
}
|
||||
|
||||
public Integer getSort() {
|
||||
return sort;
|
||||
}
|
||||
|
||||
public void setSort(Integer sort) {
|
||||
this.sort = sort;
|
||||
}
|
||||
|
||||
public Integer getFilterType() {
|
||||
return filterType;
|
||||
}
|
||||
|
||||
public void setFilterType(Integer filterType) {
|
||||
this.filterType = filterType;
|
||||
}
|
||||
|
||||
public Integer getSearchType() {
|
||||
return searchType;
|
||||
}
|
||||
|
||||
public void setSearchType(Integer searchType) {
|
||||
this.searchType = searchType;
|
||||
}
|
||||
|
||||
public Integer getRelatedStatus() {
|
||||
return relatedStatus;
|
||||
}
|
||||
|
||||
public void setRelatedStatus(Integer relatedStatus) {
|
||||
this.relatedStatus = relatedStatus;
|
||||
}
|
||||
|
||||
public Integer getHandAddStatus() {
|
||||
return handAddStatus;
|
||||
}
|
||||
|
||||
public void setHandAddStatus(Integer handAddStatus) {
|
||||
this.handAddStatus = handAddStatus;
|
||||
}
|
||||
|
||||
public Integer getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(Integer type) {
|
||||
this.type = type;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,8 @@ package com.macro.mall.dto;
|
||||
|
||||
import com.macro.mall.validator.FlagValidator;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import javax.validation.constraints.Min;
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
@@ -11,6 +13,8 @@ import java.util.List;
|
||||
* 添加更新产品分类的参数
|
||||
* Created by macro on 2018/4/26.
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class PmsProductCategoryParam {
|
||||
@ApiModelProperty("父分类的编号")
|
||||
private Long parentId;
|
||||
@@ -36,84 +40,4 @@ public class PmsProductCategoryParam {
|
||||
private String description;
|
||||
@ApiModelProperty("产品相关筛选属性集合")
|
||||
private List<Long> productAttributeIdList;
|
||||
|
||||
public Long getParentId() {
|
||||
return parentId;
|
||||
}
|
||||
|
||||
public void setParentId(Long parentId) {
|
||||
this.parentId = parentId;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getProductUnit() {
|
||||
return productUnit;
|
||||
}
|
||||
|
||||
public void setProductUnit(String productUnit) {
|
||||
this.productUnit = productUnit;
|
||||
}
|
||||
|
||||
public Integer getNavStatus() {
|
||||
return navStatus;
|
||||
}
|
||||
|
||||
public void setNavStatus(Integer navStatus) {
|
||||
this.navStatus = navStatus;
|
||||
}
|
||||
|
||||
public Integer getShowStatus() {
|
||||
return showStatus;
|
||||
}
|
||||
|
||||
public void setShowStatus(Integer showStatus) {
|
||||
this.showStatus = showStatus;
|
||||
}
|
||||
|
||||
public Integer getSort() {
|
||||
return sort;
|
||||
}
|
||||
|
||||
public void setSort(Integer sort) {
|
||||
this.sort = sort;
|
||||
}
|
||||
|
||||
public String getIcon() {
|
||||
return icon;
|
||||
}
|
||||
|
||||
public void setIcon(String icon) {
|
||||
this.icon = icon;
|
||||
}
|
||||
|
||||
public String getKeywords() {
|
||||
return keywords;
|
||||
}
|
||||
|
||||
public void setKeywords(String keywords) {
|
||||
this.keywords = keywords;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public List<Long> getProductAttributeIdList() {
|
||||
return productAttributeIdList;
|
||||
}
|
||||
|
||||
public void setProductAttributeIdList(List<Long> productAttributeIdList) {
|
||||
this.productAttributeIdList = productAttributeIdList;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
package com.macro.mall.dto;
|
||||
|
||||
import com.macro.mall.model.PmsProductCategory;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -8,13 +11,8 @@ import java.util.List;
|
||||
* Created by macro on 2018/5/25.
|
||||
*/
|
||||
public class PmsProductCategoryWithChildrenItem extends PmsProductCategory {
|
||||
@Getter
|
||||
@Setter
|
||||
@ApiModelProperty("子级分类")
|
||||
private List<PmsProductCategory> children;
|
||||
|
||||
public List<PmsProductCategory> getChildren() {
|
||||
return children;
|
||||
}
|
||||
|
||||
public void setChildren(List<PmsProductCategory> children) {
|
||||
this.children = children;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,8 @@ package com.macro.mall.dto;
|
||||
|
||||
import com.macro.mall.model.*;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -9,6 +11,8 @@ import java.util.List;
|
||||
* 创建和修改商品时使用的参数
|
||||
* Created by macro on 2018/4/26.
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class PmsProductParam extends PmsProduct{
|
||||
@ApiModelProperty("商品阶梯价格设置")
|
||||
private List<PmsProductLadder> productLadderList;
|
||||
@@ -24,60 +28,4 @@ public class PmsProductParam extends PmsProduct{
|
||||
private List<CmsSubjectProductRelation> subjectProductRelationList;
|
||||
@ApiModelProperty("优选专区和商品的关系")
|
||||
private List<CmsPrefrenceAreaProductRelation> prefrenceAreaProductRelationList;
|
||||
|
||||
public List<PmsProductLadder> getProductLadderList() {
|
||||
return productLadderList;
|
||||
}
|
||||
|
||||
public void setProductLadderList(List<PmsProductLadder> productLadderList) {
|
||||
this.productLadderList = productLadderList;
|
||||
}
|
||||
|
||||
public List<PmsProductFullReduction> getProductFullReductionList() {
|
||||
return productFullReductionList;
|
||||
}
|
||||
|
||||
public void setProductFullReductionList(List<PmsProductFullReduction> productFullReductionList) {
|
||||
this.productFullReductionList = productFullReductionList;
|
||||
}
|
||||
|
||||
public List<PmsMemberPrice> getMemberPriceList() {
|
||||
return memberPriceList;
|
||||
}
|
||||
|
||||
public void setMemberPriceList(List<PmsMemberPrice> memberPriceList) {
|
||||
this.memberPriceList = memberPriceList;
|
||||
}
|
||||
|
||||
public List<PmsSkuStock> getSkuStockList() {
|
||||
return skuStockList;
|
||||
}
|
||||
|
||||
public void setSkuStockList(List<PmsSkuStock> skuStockList) {
|
||||
this.skuStockList = skuStockList;
|
||||
}
|
||||
|
||||
public List<PmsProductAttributeValue> getProductAttributeValueList() {
|
||||
return productAttributeValueList;
|
||||
}
|
||||
|
||||
public void setProductAttributeValueList(List<PmsProductAttributeValue> productAttributeValueList) {
|
||||
this.productAttributeValueList = productAttributeValueList;
|
||||
}
|
||||
|
||||
public List<CmsSubjectProductRelation> getSubjectProductRelationList() {
|
||||
return subjectProductRelationList;
|
||||
}
|
||||
|
||||
public void setSubjectProductRelationList(List<CmsSubjectProductRelation> subjectProductRelationList) {
|
||||
this.subjectProductRelationList = subjectProductRelationList;
|
||||
}
|
||||
|
||||
public List<CmsPrefrenceAreaProductRelation> getPrefrenceAreaProductRelationList() {
|
||||
return prefrenceAreaProductRelationList;
|
||||
}
|
||||
|
||||
public void setPrefrenceAreaProductRelationList(List<CmsPrefrenceAreaProductRelation> prefrenceAreaProductRelationList) {
|
||||
this.prefrenceAreaProductRelationList = prefrenceAreaProductRelationList;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,15 @@
|
||||
package com.macro.mall.dto;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* 产品查询参数
|
||||
* Created by macro on 2018/4/27.
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class PmsProductQueryParam {
|
||||
@ApiModelProperty("上架状态")
|
||||
private Integer publishStatus;
|
||||
@@ -19,52 +23,4 @@ public class PmsProductQueryParam {
|
||||
private Long productCategoryId;
|
||||
@ApiModelProperty("商品品牌编号")
|
||||
private Long brandId;
|
||||
|
||||
public Integer getPublishStatus() {
|
||||
return publishStatus;
|
||||
}
|
||||
|
||||
public void setPublishStatus(Integer publishStatus) {
|
||||
this.publishStatus = publishStatus;
|
||||
}
|
||||
|
||||
public Integer getVerifyStatus() {
|
||||
return verifyStatus;
|
||||
}
|
||||
|
||||
public void setVerifyStatus(Integer verifyStatus) {
|
||||
this.verifyStatus = verifyStatus;
|
||||
}
|
||||
|
||||
public String getKeyword() {
|
||||
return keyword;
|
||||
}
|
||||
|
||||
public void setKeyword(String keyword) {
|
||||
this.keyword = keyword;
|
||||
}
|
||||
|
||||
public String getProductSn() {
|
||||
return productSn;
|
||||
}
|
||||
|
||||
public void setProductSn(String productSn) {
|
||||
this.productSn = productSn;
|
||||
}
|
||||
|
||||
public Long getProductCategoryId() {
|
||||
return productCategoryId;
|
||||
}
|
||||
|
||||
public void setProductCategoryId(Long productCategoryId) {
|
||||
this.productCategoryId = productCategoryId;
|
||||
}
|
||||
|
||||
public Long getBrandId() {
|
||||
return brandId;
|
||||
}
|
||||
|
||||
public void setBrandId(Long brandId) {
|
||||
this.brandId = brandId;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,18 +1,16 @@
|
||||
package com.macro.mall.dto;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* 查询单个产品进行修改时返回的结果
|
||||
* Created by macro on 2018/4/26.
|
||||
*/
|
||||
public class PmsProductResult extends PmsProductParam {
|
||||
//商品所选分类的父id
|
||||
@Getter
|
||||
@Setter
|
||||
@ApiModelProperty("商品所选分类的父id")
|
||||
private Long cateParentId;
|
||||
|
||||
public Long getCateParentId() {
|
||||
return cateParentId;
|
||||
}
|
||||
|
||||
public void setCateParentId(Long cateParentId) {
|
||||
this.cateParentId = cateParentId;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,27 +1,19 @@
|
||||
package com.macro.mall.dto;
|
||||
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* 商品分类对应属性信息
|
||||
* Created by macro on 2018/5/23.
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class ProductAttrInfo {
|
||||
@ApiModelProperty("商品属性ID")
|
||||
private Long attributeId;
|
||||
@ApiModelProperty("商品属性分类ID")
|
||||
private Long attributeCategoryId;
|
||||
|
||||
public Long getAttributeId() {
|
||||
return attributeId;
|
||||
}
|
||||
|
||||
public void setAttributeId(Long attributeId) {
|
||||
this.attributeId = attributeId;
|
||||
}
|
||||
|
||||
public Long getAttributeCategoryId() {
|
||||
return attributeCategoryId;
|
||||
}
|
||||
|
||||
public void setAttributeCategoryId(Long attributeCategoryId) {
|
||||
this.attributeCategoryId = attributeCategoryId;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,9 @@ package com.macro.mall.dto;
|
||||
import com.macro.mall.model.SmsCoupon;
|
||||
import com.macro.mall.model.SmsCouponProductCategoryRelation;
|
||||
import com.macro.mall.model.SmsCouponProductRelation;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -11,24 +14,12 @@ import java.util.List;
|
||||
* Created by macro on 2018/8/28.
|
||||
*/
|
||||
public class SmsCouponParam extends SmsCoupon {
|
||||
//优惠券绑定的商品
|
||||
@Getter
|
||||
@Setter
|
||||
@ApiModelProperty("优惠券绑定的商品")
|
||||
private List<SmsCouponProductRelation> productRelationList;
|
||||
//优惠券绑定的商品分类
|
||||
@Getter
|
||||
@Setter
|
||||
@ApiModelProperty("优惠券绑定的商品分类")
|
||||
private List<SmsCouponProductCategoryRelation> productCategoryRelationList;
|
||||
|
||||
public List<SmsCouponProductRelation> getProductRelationList() {
|
||||
return productRelationList;
|
||||
}
|
||||
|
||||
public void setProductRelationList(List<SmsCouponProductRelation> productRelationList) {
|
||||
this.productRelationList = productRelationList;
|
||||
}
|
||||
|
||||
public List<SmsCouponProductCategoryRelation> getProductCategoryRelationList() {
|
||||
return productCategoryRelationList;
|
||||
}
|
||||
|
||||
public void setProductCategoryRelationList(List<SmsCouponProductCategoryRelation> productCategoryRelationList) {
|
||||
this.productCategoryRelationList = productCategoryRelationList;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.macro.mall.dto;
|
||||
|
||||
import com.macro.mall.model.PmsProduct;
|
||||
import com.macro.mall.model.SmsFlashPromotionProductRelation;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@@ -12,5 +13,6 @@ import lombok.Setter;
|
||||
public class SmsFlashPromotionProduct extends SmsFlashPromotionProductRelation{
|
||||
@Getter
|
||||
@Setter
|
||||
@ApiModelProperty("关联商品")
|
||||
private PmsProduct product;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.macro.mall.dto;
|
||||
|
||||
import com.macro.mall.model.SmsFlashPromotionSession;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@@ -11,5 +12,6 @@ import lombok.Setter;
|
||||
public class SmsFlashPromotionSessionDetail extends SmsFlashPromotionSession {
|
||||
@Setter
|
||||
@Getter
|
||||
@ApiModelProperty("商品数量")
|
||||
private Long productCount;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package com.macro.mall.dto;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
|
||||
@@ -8,6 +10,8 @@ import javax.validation.constraints.NotEmpty;
|
||||
* 用户登录参数
|
||||
* Created by macro on 2018/4/26.
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class UmsAdminLoginParam {
|
||||
@ApiModelProperty(value = "用户名", required = true)
|
||||
@NotEmpty(message = "用户名不能为空")
|
||||
@@ -15,20 +19,4 @@ public class UmsAdminLoginParam {
|
||||
@ApiModelProperty(value = "密码", required = true)
|
||||
@NotEmpty(message = "密码不能为空")
|
||||
private String password;
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.macro.mall.dto;
|
||||
|
||||
import com.macro.mall.model.UmsMenu;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@@ -13,5 +14,6 @@ import java.util.List;
|
||||
@Getter
|
||||
@Setter
|
||||
public class UmsMenuNode extends UmsMenu {
|
||||
@ApiModelProperty(value = "子级菜单")
|
||||
private List<UmsMenuNode> children;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.macro.mall.dto;
|
||||
|
||||
import com.macro.mall.model.UmsPermission;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@@ -13,5 +14,6 @@ import java.util.List;
|
||||
public class UmsPermissionNode extends UmsPermission {
|
||||
@Getter
|
||||
@Setter
|
||||
@ApiModelProperty(value = "子级权限")
|
||||
private List<UmsPermissionNode> children;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.macro.mall.service;
|
||||
|
||||
import com.macro.mall.common.api.CommonResult;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 认证服务远程调用
|
||||
* Created by macro on 2020/7/19.
|
||||
*/
|
||||
@FeignClient("mall-auth")
|
||||
public interface AuthService {
|
||||
|
||||
@PostMapping(value = "/oauth/token")
|
||||
CommonResult getAccessToken(@RequestParam Map<String, String> parameters);
|
||||
|
||||
}
|
||||
@@ -14,8 +14,7 @@ import java.util.List;
|
||||
public interface PmsProductAttributeService {
|
||||
/**
|
||||
* 根据分类分页获取商品属性
|
||||
*
|
||||
* @param cid 分类id
|
||||
* @param cid 分类id
|
||||
* @param type 0->属性;2->参数
|
||||
*/
|
||||
List<PmsProductAttribute> getList(Long cid, Integer type, Integer pageSize, Integer pageNum);
|
||||
@@ -36,14 +35,8 @@ public interface PmsProductAttributeService {
|
||||
*/
|
||||
PmsProductAttribute getItem(Long id);
|
||||
|
||||
/**
|
||||
* 批量删除商品属性
|
||||
*/
|
||||
@Transactional
|
||||
int delete(List<Long> ids);
|
||||
|
||||
/**
|
||||
* 获取和分类相关的商品属性
|
||||
*/
|
||||
List<ProductAttrInfo> getProductAttrInfo(Long productCategoryId);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.macro.mall.service;
|
||||
|
||||
import com.macro.mall.model.UmsAdmin;
|
||||
import com.macro.mall.model.UmsResource;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 后台用户缓存操作类
|
||||
* Created by macro on 2020/3/13.
|
||||
*/
|
||||
public interface UmsAdminCacheService {
|
||||
/**
|
||||
* 删除后台用户缓存
|
||||
*/
|
||||
void delAdmin(Long adminId);
|
||||
|
||||
/**
|
||||
* 获取缓存后台用户信息
|
||||
*/
|
||||
UmsAdmin getAdmin(Long adminId);
|
||||
|
||||
/**
|
||||
* 设置缓存后台用户信息
|
||||
*/
|
||||
void setAdmin(UmsAdmin admin);
|
||||
}
|
||||
@@ -1,12 +1,10 @@
|
||||
package com.macro.mall.service;
|
||||
|
||||
import com.macro.mall.common.api.CommonResult;
|
||||
import com.macro.mall.common.domain.UserDto;
|
||||
import com.macro.mall.dto.UmsAdminParam;
|
||||
import com.macro.mall.dto.UpdateAdminPasswordParam;
|
||||
import com.macro.mall.model.UmsAdmin;
|
||||
import com.macro.mall.model.UmsPermission;
|
||||
import com.macro.mall.model.UmsResource;
|
||||
import com.macro.mall.model.UmsRole;
|
||||
import org.springframework.security.core.userdetails.UserDetails;
|
||||
import com.macro.mall.model.*;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
@@ -30,15 +28,9 @@ public interface UmsAdminService {
|
||||
* 登录功能
|
||||
* @param username 用户名
|
||||
* @param password 密码
|
||||
* @return 生成的JWT的token
|
||||
* @return 调用认证中心返回结果
|
||||
*/
|
||||
String login(String username,String password);
|
||||
|
||||
/**
|
||||
* 刷新token的功能
|
||||
* @param oldToken 旧的token
|
||||
*/
|
||||
String refreshToken(String oldToken);
|
||||
CommonResult login(String username, String password);
|
||||
|
||||
/**
|
||||
* 根据用户id获取用户
|
||||
@@ -95,5 +87,10 @@ public interface UmsAdminService {
|
||||
/**
|
||||
* 获取用户信息
|
||||
*/
|
||||
UserDetails loadUserByUsername(String username);
|
||||
UserDto loadUserByUsername(String username);
|
||||
|
||||
/**
|
||||
* 获取当前登录后台用户
|
||||
*/
|
||||
UmsAdmin getCurrentAdmin();
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.macro.mall.service;
|
||||
import com.macro.mall.model.UmsResource;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 后台资源管理Service
|
||||
@@ -38,4 +39,9 @@ public interface UmsResourceService {
|
||||
* 查询全部资源
|
||||
*/
|
||||
List<UmsResource> listAll();
|
||||
|
||||
/**
|
||||
* 初始化资源角色规则
|
||||
*/
|
||||
Map<String,List<String>> initResourceRolesMap();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.macro.mall.service.impl;
|
||||
|
||||
import com.macro.mall.common.service.RedisService;
|
||||
import com.macro.mall.model.UmsAdmin;
|
||||
import com.macro.mall.service.UmsAdminCacheService;
|
||||
import com.macro.mall.service.UmsAdminService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* UmsAdminCacheService实现类
|
||||
* Created by macro on 2020/3/13.
|
||||
*/
|
||||
@Service
|
||||
public class UmsAdminCacheServiceImpl implements UmsAdminCacheService {
|
||||
@Autowired
|
||||
private UmsAdminService adminService;
|
||||
@Autowired
|
||||
private RedisService redisService;
|
||||
@Value("${redis.database}")
|
||||
private String REDIS_DATABASE;
|
||||
@Value("${redis.expire.common}")
|
||||
private Long REDIS_EXPIRE;
|
||||
@Value("${redis.key.admin}")
|
||||
private String REDIS_KEY_ADMIN;
|
||||
|
||||
@Override
|
||||
public void delAdmin(Long adminId) {
|
||||
String key = REDIS_DATABASE + ":" + REDIS_KEY_ADMIN + ":" + adminId;
|
||||
redisService.del(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public UmsAdmin getAdmin(Long adminId) {
|
||||
String key = REDIS_DATABASE + ":" + REDIS_KEY_ADMIN + ":" + adminId;
|
||||
return (UmsAdmin) redisService.get(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAdmin(UmsAdmin admin) {
|
||||
String key = REDIS_DATABASE + ":" + REDIS_KEY_ADMIN + ":" + admin.getId();
|
||||
redisService.set(key, admin, REDIS_EXPIRE);
|
||||
}
|
||||
}
|
||||
@@ -2,8 +2,14 @@ package com.macro.mall.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.crypto.digest.BCrypt;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.macro.mall.bo.AdminUserDetails;
|
||||
import com.macro.mall.common.api.CommonResult;
|
||||
import com.macro.mall.common.api.ResultCode;
|
||||
import com.macro.mall.common.constant.AuthConstant;
|
||||
import com.macro.mall.common.domain.UserDto;
|
||||
import com.macro.mall.common.exception.Asserts;
|
||||
import com.macro.mall.dao.UmsAdminPermissionRelationDao;
|
||||
import com.macro.mall.dao.UmsAdminRoleRelationDao;
|
||||
import com.macro.mall.dto.UmsAdminParam;
|
||||
@@ -13,19 +19,13 @@ import com.macro.mall.mapper.UmsAdminMapper;
|
||||
import com.macro.mall.mapper.UmsAdminPermissionRelationMapper;
|
||||
import com.macro.mall.mapper.UmsAdminRoleRelationMapper;
|
||||
import com.macro.mall.model.*;
|
||||
import com.macro.mall.security.util.JwtTokenUtil;
|
||||
import com.macro.mall.service.AuthService;
|
||||
import com.macro.mall.service.UmsAdminCacheService;
|
||||
import com.macro.mall.service.UmsAdminService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.authentication.BadCredentialsException;
|
||||
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
||||
import org.springframework.security.core.AuthenticationException;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
import org.springframework.security.core.userdetails.UserDetails;
|
||||
import org.springframework.security.core.userdetails.UsernameNotFoundException;
|
||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
@@ -33,9 +33,7 @@ import org.springframework.web.context.request.RequestContextHolder;
|
||||
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@@ -46,10 +44,6 @@ import java.util.stream.Collectors;
|
||||
public class UmsAdminServiceImpl implements UmsAdminService {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(UmsAdminServiceImpl.class);
|
||||
@Autowired
|
||||
private JwtTokenUtil jwtTokenUtil;
|
||||
@Autowired
|
||||
private PasswordEncoder passwordEncoder;
|
||||
@Autowired
|
||||
private UmsAdminMapper adminMapper;
|
||||
@Autowired
|
||||
private UmsAdminRoleRelationMapper adminRoleRelationMapper;
|
||||
@@ -61,6 +55,12 @@ public class UmsAdminServiceImpl implements UmsAdminService {
|
||||
private UmsAdminPermissionRelationDao adminPermissionRelationDao;
|
||||
@Autowired
|
||||
private UmsAdminLoginLogMapper loginLogMapper;
|
||||
@Autowired
|
||||
private AuthService authService;
|
||||
@Autowired
|
||||
private UmsAdminCacheService adminCacheService;
|
||||
@Autowired
|
||||
private HttpServletRequest request;
|
||||
|
||||
@Override
|
||||
public UmsAdmin getAdminByUsername(String username) {
|
||||
@@ -87,30 +87,29 @@ public class UmsAdminServiceImpl implements UmsAdminService {
|
||||
return null;
|
||||
}
|
||||
//将密码进行加密操作
|
||||
String encodePassword = passwordEncoder.encode(umsAdmin.getPassword());
|
||||
String encodePassword = BCrypt.hashpw(umsAdmin.getPassword());
|
||||
umsAdmin.setPassword(encodePassword);
|
||||
adminMapper.insert(umsAdmin);
|
||||
return umsAdmin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String login(String username, String password) {
|
||||
String token = null;
|
||||
//密码需要客户端加密后传递
|
||||
try {
|
||||
UserDetails userDetails = loadUserByUsername(username);
|
||||
if(!passwordEncoder.matches(password,userDetails.getPassword())){
|
||||
throw new BadCredentialsException("密码不正确");
|
||||
}
|
||||
UsernamePasswordAuthenticationToken authentication = new UsernamePasswordAuthenticationToken(userDetails, null, userDetails.getAuthorities());
|
||||
SecurityContextHolder.getContext().setAuthentication(authentication);
|
||||
token = jwtTokenUtil.generateToken(userDetails);
|
||||
public CommonResult login(String username, String password) {
|
||||
if(StrUtil.isEmpty(username)||StrUtil.isEmpty(password)){
|
||||
Asserts.fail("用户名或密码不能为空!");
|
||||
}
|
||||
Map<String, String> params = new HashMap<>();
|
||||
params.put("client_id", AuthConstant.ADMIN_CLIENT_ID);
|
||||
params.put("client_secret","123456");
|
||||
params.put("grant_type","password");
|
||||
params.put("username",username);
|
||||
params.put("password",password);
|
||||
CommonResult restResult = authService.getAccessToken(params);
|
||||
if(ResultCode.SUCCESS.getCode()==restResult.getCode()&&restResult.getData()!=null){
|
||||
// updateLoginTimeByUsername(username);
|
||||
insertLoginLog(username);
|
||||
} catch (AuthenticationException e) {
|
||||
LOGGER.warn("登录异常:{}", e.getMessage());
|
||||
}
|
||||
return token;
|
||||
return restResult;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -119,6 +118,7 @@ public class UmsAdminServiceImpl implements UmsAdminService {
|
||||
*/
|
||||
private void insertLoginLog(String username) {
|
||||
UmsAdmin admin = getAdminByUsername(username);
|
||||
if(admin==null) return;
|
||||
UmsAdminLoginLog loginLog = new UmsAdminLoginLog();
|
||||
loginLog.setAdminId(admin.getId());
|
||||
loginLog.setCreateTime(new Date());
|
||||
@@ -139,11 +139,6 @@ public class UmsAdminServiceImpl implements UmsAdminService {
|
||||
adminMapper.updateByExampleSelective(record, example);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String refreshToken(String oldToken) {
|
||||
return jwtTokenUtil.refreshHeadToken(oldToken);
|
||||
}
|
||||
|
||||
@Override
|
||||
public UmsAdmin getItem(Long id) {
|
||||
return adminMapper.selectByPrimaryKey(id);
|
||||
@@ -173,15 +168,19 @@ public class UmsAdminServiceImpl implements UmsAdminService {
|
||||
if(StrUtil.isEmpty(admin.getPassword())){
|
||||
admin.setPassword(null);
|
||||
}else{
|
||||
admin.setPassword(passwordEncoder.encode(admin.getPassword()));
|
||||
admin.setPassword(BCrypt.hashpw(admin.getPassword()));
|
||||
}
|
||||
}
|
||||
return adminMapper.updateByPrimaryKeySelective(admin);
|
||||
int count = adminMapper.updateByPrimaryKeySelective(admin);
|
||||
adminCacheService.delAdmin(id);
|
||||
return count;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int delete(Long id) {
|
||||
return adminMapper.deleteByPrimaryKey(id);
|
||||
int count = adminMapper.deleteByPrimaryKey(id);
|
||||
adminCacheService.delAdmin(id);
|
||||
return count;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -271,22 +270,46 @@ public class UmsAdminServiceImpl implements UmsAdminService {
|
||||
return -2;
|
||||
}
|
||||
UmsAdmin umsAdmin = adminList.get(0);
|
||||
if(!passwordEncoder.matches(param.getOldPassword(),umsAdmin.getPassword())){
|
||||
if(!BCrypt.checkpw(param.getOldPassword(),umsAdmin.getPassword())){
|
||||
return -3;
|
||||
}
|
||||
umsAdmin.setPassword(passwordEncoder.encode(param.getNewPassword()));
|
||||
umsAdmin.setPassword(BCrypt.hashpw(param.getNewPassword()));
|
||||
adminMapper.updateByPrimaryKey(umsAdmin);
|
||||
adminCacheService.delAdmin(umsAdmin.getId());
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserDetails loadUserByUsername(String username){
|
||||
public UserDto loadUserByUsername(String username){
|
||||
//获取用户信息
|
||||
UmsAdmin admin = getAdminByUsername(username);
|
||||
if (admin != null) {
|
||||
List<UmsResource> resourceList = getResourceList(admin.getId());
|
||||
return new AdminUserDetails(admin,resourceList);
|
||||
List<UmsRole> roleList = getRoleList(admin.getId());
|
||||
UserDto userDTO = new UserDto();
|
||||
BeanUtils.copyProperties(admin,userDTO);
|
||||
if(CollUtil.isNotEmpty(roleList)){
|
||||
List<String> roleStrList = roleList.stream().map(item -> item.getId() + "_" + item.getName()).collect(Collectors.toList());
|
||||
userDTO.setRoles(roleStrList);
|
||||
}
|
||||
return userDTO;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UmsAdmin getCurrentAdmin() {
|
||||
String userStr = request.getHeader(AuthConstant.USER_TOKEN_HEADER);
|
||||
if(StrUtil.isEmpty(userStr)){
|
||||
Asserts.fail(ResultCode.UNAUTHORIZED);
|
||||
}
|
||||
UserDto userDto = JSONUtil.toBean(userStr, UserDto.class);
|
||||
UmsAdmin admin = adminCacheService.getAdmin(userDto.getId());
|
||||
if(admin!=null){
|
||||
return admin;
|
||||
}else{
|
||||
admin = adminMapper.selectByPrimaryKey(userDto.getId());
|
||||
adminCacheService.setAdmin(admin);
|
||||
return admin;
|
||||
}
|
||||
throw new UsernameNotFoundException("用户名或密码错误");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,15 +2,20 @@ package com.macro.mall.service.impl;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.macro.mall.common.constant.AuthConstant;
|
||||
import com.macro.mall.common.service.RedisService;
|
||||
import com.macro.mall.mapper.UmsResourceMapper;
|
||||
import com.macro.mall.model.UmsResource;
|
||||
import com.macro.mall.model.UmsResourceExample;
|
||||
import com.macro.mall.mapper.UmsRoleMapper;
|
||||
import com.macro.mall.mapper.UmsRoleResourceRelationMapper;
|
||||
import com.macro.mall.model.*;
|
||||
import com.macro.mall.service.UmsAdminCacheService;
|
||||
import com.macro.mall.service.UmsResourceService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 后台资源管理Service实现类
|
||||
@@ -20,16 +25,28 @@ import java.util.List;
|
||||
public class UmsResourceServiceImpl implements UmsResourceService {
|
||||
@Autowired
|
||||
private UmsResourceMapper resourceMapper;
|
||||
@Autowired
|
||||
private UmsRoleMapper roleMapper;
|
||||
@Autowired
|
||||
private UmsRoleResourceRelationMapper roleResourceRelationMapper;
|
||||
@Autowired
|
||||
private RedisService redisService;
|
||||
@Value("${spring.application.name}")
|
||||
private String applicationName;
|
||||
@Override
|
||||
public int create(UmsResource umsResource) {
|
||||
umsResource.setCreateTime(new Date());
|
||||
return resourceMapper.insert(umsResource);
|
||||
int count = resourceMapper.insert(umsResource);
|
||||
initResourceRolesMap();
|
||||
return count;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int update(Long id, UmsResource umsResource) {
|
||||
umsResource.setId(id);
|
||||
return resourceMapper.updateByPrimaryKeySelective(umsResource);
|
||||
int count = resourceMapper.updateByPrimaryKeySelective(umsResource);
|
||||
initResourceRolesMap();
|
||||
return count;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -39,7 +56,9 @@ public class UmsResourceServiceImpl implements UmsResourceService {
|
||||
|
||||
@Override
|
||||
public int delete(Long id) {
|
||||
return resourceMapper.deleteByPrimaryKey(id);
|
||||
int count = resourceMapper.deleteByPrimaryKey(id);
|
||||
initResourceRolesMap();
|
||||
return count;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -63,4 +82,21 @@ public class UmsResourceServiceImpl implements UmsResourceService {
|
||||
public List<UmsResource> listAll() {
|
||||
return resourceMapper.selectByExample(new UmsResourceExample());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String,List<String>> initResourceRolesMap() {
|
||||
Map<String,List<String>> resourceRoleMap = new TreeMap<>();
|
||||
List<UmsResource> resourceList = resourceMapper.selectByExample(new UmsResourceExample());
|
||||
List<UmsRole> roleList = roleMapper.selectByExample(new UmsRoleExample());
|
||||
List<UmsRoleResourceRelation> relationList = roleResourceRelationMapper.selectByExample(new UmsRoleResourceRelationExample());
|
||||
for (UmsResource resource : resourceList) {
|
||||
Set<Long> roleIds = relationList.stream().filter(item -> item.getResourceId().equals(resource.getId())).map(UmsRoleResourceRelation::getRoleId).collect(Collectors.toSet());
|
||||
List<String> roleNames = roleList.stream().filter(item -> roleIds.contains(item.getId())).map(item -> item.getId() + "_" + item.getName()).collect(Collectors.toList());
|
||||
resourceRoleMap.put("/"+applicationName+resource.getUrl(),roleNames);
|
||||
}
|
||||
redisService.del(AuthConstant.RESOURCE_ROLES_MAP_KEY);
|
||||
redisService.hSetAll(AuthConstant.RESOURCE_ROLES_MAP_KEY, resourceRoleMap);
|
||||
return resourceRoleMap;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,8 @@ import com.macro.mall.mapper.UmsRoleMenuRelationMapper;
|
||||
import com.macro.mall.mapper.UmsRolePermissionRelationMapper;
|
||||
import com.macro.mall.mapper.UmsRoleResourceRelationMapper;
|
||||
import com.macro.mall.model.*;
|
||||
import com.macro.mall.service.UmsAdminCacheService;
|
||||
import com.macro.mall.service.UmsResourceService;
|
||||
import com.macro.mall.service.UmsRoleService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -35,6 +37,8 @@ public class UmsRoleServiceImpl implements UmsRoleService {
|
||||
private UmsRolePermissionRelationDao rolePermissionRelationDao;
|
||||
@Autowired
|
||||
private UmsRoleDao roleDao;
|
||||
@Autowired
|
||||
private UmsResourceService resourceService;
|
||||
@Override
|
||||
public int create(UmsRole role) {
|
||||
role.setCreateTime(new Date());
|
||||
@@ -53,7 +57,9 @@ public class UmsRoleServiceImpl implements UmsRoleService {
|
||||
public int delete(List<Long> ids) {
|
||||
UmsRoleExample example = new UmsRoleExample();
|
||||
example.createCriteria().andIdIn(ids);
|
||||
return roleMapper.deleteByExample(example);
|
||||
int count = roleMapper.deleteByExample(example);
|
||||
resourceService.initResourceRolesMap();
|
||||
return count;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -137,6 +143,7 @@ public class UmsRoleServiceImpl implements UmsRoleService {
|
||||
relation.setResourceId(resourceId);
|
||||
roleResourceRelationMapper.insert(relation);
|
||||
}
|
||||
resourceService.initResourceRolesMap();
|
||||
return resourceIds.size();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user