初始化代码 2022-02-11前 最新版本
33
common-api/pom.xml
Normal file
@@ -0,0 +1,33 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>cn.lili</groupId>
|
||||
<artifactId>lili-shop-parent</artifactId>
|
||||
<version>${revision}</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<artifactId>common-api</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>cn.lili</groupId>
|
||||
<artifactId>framework</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
||||
21
common-api/src/main/java/cn/lili/CommonApiApplication.java
Normal file
@@ -0,0 +1,21 @@
|
||||
package cn.lili;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.cache.annotation.EnableCaching;
|
||||
|
||||
/**
|
||||
* 基础API
|
||||
*
|
||||
* @author Chopper
|
||||
* @since 2020/11/17 3:38 下午
|
||||
*/
|
||||
@EnableCaching
|
||||
@SpringBootApplication
|
||||
public class CommonApiApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(CommonApiApplication.class, args);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
package cn.lili.controller.common;
|
||||
|
||||
import cn.lili.cache.Cache;
|
||||
import cn.lili.common.enums.ResultCode;
|
||||
import cn.lili.common.enums.ResultUtil;
|
||||
import cn.lili.common.exception.ServiceException;
|
||||
import cn.lili.common.security.AuthUser;
|
||||
import cn.lili.common.security.context.UserContext;
|
||||
import cn.lili.common.security.enums.UserEnums;
|
||||
import cn.lili.common.vo.PageVO;
|
||||
import cn.lili.common.vo.ResultMessage;
|
||||
import cn.lili.common.vo.SearchVO;
|
||||
import cn.lili.modules.file.entity.File;
|
||||
import cn.lili.modules.file.entity.dto.FileOwnerDTO;
|
||||
import cn.lili.modules.file.service.FileService;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* 文件管理管理接口
|
||||
*
|
||||
* @author Chopper
|
||||
* @since 2020/11/26 15:41
|
||||
*/
|
||||
@RestController
|
||||
@Api(tags = "文件管理管理接口")
|
||||
@RequestMapping("/common/file")
|
||||
public class FileController {
|
||||
|
||||
@Autowired
|
||||
private FileService fileService;
|
||||
|
||||
@Autowired
|
||||
private Cache cache;
|
||||
|
||||
@ApiOperation(value = "获取自己的图片资源")
|
||||
@GetMapping
|
||||
@ApiImplicitParam(name = "title", value = "名称模糊匹配")
|
||||
public ResultMessage<IPage<File>> getFileList(@RequestHeader String accessToken, File file, SearchVO searchVO, PageVO pageVo) {
|
||||
|
||||
AuthUser authUser = UserContext.getAuthUser(cache, accessToken);
|
||||
FileOwnerDTO fileOwnerDTO = new FileOwnerDTO();
|
||||
//只有买家才写入自己id
|
||||
if (authUser.getRole().equals(UserEnums.MEMBER)) {
|
||||
fileOwnerDTO.setOwnerId(authUser.getId());
|
||||
}//如果是店铺,则写入店铺id
|
||||
else if (authUser.getRole().equals(UserEnums.STORE)) {
|
||||
fileOwnerDTO.setOwnerId(authUser.getStoreId());
|
||||
}
|
||||
fileOwnerDTO.setUserEnums(authUser.getRole().name());
|
||||
return ResultUtil.data(fileService.customerPageOwner(fileOwnerDTO, file, searchVO, pageVo));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "文件重命名")
|
||||
@PostMapping(value = "/rename")
|
||||
public ResultMessage<File> upload(@RequestHeader String accessToken, String id, String newName) {
|
||||
|
||||
AuthUser authUser = UserContext.getAuthUser(cache, accessToken);
|
||||
File file = fileService.getById(id);
|
||||
file.setName(newName);
|
||||
//操作图片属性判定
|
||||
switch (authUser.getRole()) {
|
||||
case MEMBER:
|
||||
if (file.getOwnerId().equals(authUser.getId()) && file.getUserEnums().equals(authUser.getRole().name())) {
|
||||
break;
|
||||
}
|
||||
throw new ServiceException(ResultCode.USER_AUTHORITY_ERROR);
|
||||
case STORE:
|
||||
if (file.getOwnerId().equals(authUser.getStoreId()) && file.getUserEnums().equals(authUser.getRole().name())) {
|
||||
break;
|
||||
}
|
||||
throw new ServiceException(ResultCode.USER_AUTHORITY_ERROR);
|
||||
case MANAGER:
|
||||
break;
|
||||
default:
|
||||
throw new ServiceException(ResultCode.USER_AUTHORITY_ERROR);
|
||||
}
|
||||
fileService.updateById(file);
|
||||
return ResultUtil.data(file);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "文件删除")
|
||||
@DeleteMapping(value = "/delete/{ids}")
|
||||
public ResultMessage delete(@RequestHeader String accessToken, @PathVariable List<String> ids) {
|
||||
|
||||
AuthUser authUser = UserContext.getAuthUser(cache, accessToken);
|
||||
fileService.batchDelete(ids, authUser);
|
||||
return ResultUtil.success();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package cn.lili.controller.common;
|
||||
|
||||
|
||||
import cn.hutool.json.JSONUtil;
|
||||
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.system.entity.dos.Setting;
|
||||
import cn.lili.modules.system.entity.dto.ImSetting;
|
||||
import cn.lili.modules.system.entity.enums.SettingEnum;
|
||||
import cn.lili.modules.system.service.SettingService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* IM控制器
|
||||
*
|
||||
* @author Chopper
|
||||
* @version v1.0
|
||||
* 2021-09-16 15:32
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/common/IM")
|
||||
@Api(tags = "IM 中心")
|
||||
public class IMController {
|
||||
|
||||
@Autowired
|
||||
private SettingService settingService;
|
||||
|
||||
@ApiOperation(value = "获取IM接口前缀")
|
||||
@GetMapping
|
||||
public ResultMessage<String> getUrl() {
|
||||
String imUrl;
|
||||
try {
|
||||
Setting imSettingVal = settingService.get(SettingEnum.IM_SETTING.name());
|
||||
ImSetting imSetting = JSONUtil.toBean(imSettingVal.getSettingValue(), ImSetting.class);
|
||||
imUrl = imSetting.getHttpUrl() + "?tenant_id=" + imSetting.getTenantId()+"&merchant_euid=";
|
||||
} catch (Exception e) {
|
||||
throw new ServiceException(ResultCode.PLATFORM_NOT_SUPPORTED_IM);
|
||||
}
|
||||
return ResultUtil.data(imUrl);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package cn.lili.controller.common;
|
||||
|
||||
import cn.lili.common.enums.ResultUtil;
|
||||
import cn.lili.common.utils.IpHelper;
|
||||
import cn.lili.common.vo.ResultMessage;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
/**
|
||||
* 管理端,IP接口
|
||||
*
|
||||
* @author Chopper
|
||||
* @since 2020-02-25 14:10:16
|
||||
*/
|
||||
@RestController
|
||||
@Api(tags = "获取IP信息以及天气")
|
||||
@RequestMapping("/common/ip")
|
||||
public class IpInfoManagerController {
|
||||
@Autowired
|
||||
private IpHelper ipHelper;
|
||||
|
||||
@RequestMapping(value = "/info", method = RequestMethod.GET)
|
||||
@ApiOperation(value = "IP及天气相关信息")
|
||||
public ResultMessage<Object> upload(HttpServletRequest request) {
|
||||
String result = ipHelper.getIpCity(request);
|
||||
return ResultUtil.data(result);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package cn.lili.controller.common;
|
||||
|
||||
import cn.lili.common.enums.ResultUtil;
|
||||
import cn.lili.common.vo.ResultMessage;
|
||||
import cn.lili.modules.system.entity.enums.SettingEnum;
|
||||
import cn.lili.modules.system.service.SettingService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
|
||||
/**
|
||||
* 文件管理管理接口
|
||||
*
|
||||
* @author Chopper
|
||||
* @since 2020/11/26 15:41
|
||||
*/
|
||||
@RestController
|
||||
@Api(tags = "文件管理管理接口")
|
||||
@RequestMapping("/common/logo")
|
||||
public class LogoController {
|
||||
|
||||
@Autowired
|
||||
private SettingService settingService;
|
||||
|
||||
@ApiOperation(value = "获取logo")
|
||||
@GetMapping
|
||||
public ResultMessage<Object> getFileList() {
|
||||
return ResultUtil.data(settingService.get(SettingEnum.BASE_SETTING.name()));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package cn.lili.controller.common;
|
||||
|
||||
import cn.lili.common.enums.ResultUtil;
|
||||
import cn.lili.common.vo.ResultMessage;
|
||||
import cn.lili.modules.system.service.RegionService;
|
||||
import cn.lili.modules.system.entity.dos.Region;
|
||||
import cn.lili.modules.system.entity.vo.RegionVO;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* 地址信息接口
|
||||
*
|
||||
* @author Chopper
|
||||
*/
|
||||
@RestController
|
||||
@Api(tags = "地址信息接口")
|
||||
@RequestMapping("/common/region")
|
||||
public class RegionController {
|
||||
|
||||
@Autowired
|
||||
private RegionService regionService;
|
||||
|
||||
@ApiOperation(value = "点地图获取地址信息")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "cityCode", value = "城市code", dataType = "String", paramType = "query"),
|
||||
@ApiImplicitParam(name = "townName", value = "镇名称", dataType = "Long", paramType = "query")
|
||||
})
|
||||
@GetMapping(value = "/region")
|
||||
public ResultMessage<Object> getRegion(@RequestParam String cityCode,@RequestParam String townName) {
|
||||
return ResultUtil.data(regionService.getRegion(cityCode,townName));
|
||||
}
|
||||
|
||||
|
||||
@GetMapping(value = "/item/{id}")
|
||||
@ApiImplicitParam(name = "id", value = "地区ID", required = true, dataType = "String", paramType = "path")
|
||||
@ApiOperation(value = "通过id获取子地区")
|
||||
public ResultMessage<List<Region>> getItem(@PathVariable String id) {
|
||||
return ResultUtil.data(regionService.getItem(id));
|
||||
}
|
||||
|
||||
@GetMapping(value = "/allCity")
|
||||
@ApiOperation(value = "获取所有的省-市")
|
||||
public ResultMessage<List<RegionVO>> getAllCity() {
|
||||
return ResultUtil.data(regionService.getAllCity());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package cn.lili.controller.common;
|
||||
|
||||
import cn.lili.cache.limit.annotation.LimitPoint;
|
||||
import cn.lili.common.aop.annotation.PreventDuplicateSubmissions;
|
||||
import cn.lili.common.enums.ResultUtil;
|
||||
import cn.lili.common.vo.ResultMessage;
|
||||
import cn.lili.modules.verification.entity.enums.VerificationEnums;
|
||||
import cn.lili.modules.verification.service.VerificationService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
/**
|
||||
* 滑块验证码接口
|
||||
*
|
||||
* @author Chopper
|
||||
* @since 2020/11/26 15:41
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/common/slider")
|
||||
@Api(tags = "滑块验证码接口")
|
||||
public class SliderImageController {
|
||||
|
||||
@Autowired
|
||||
private VerificationService verificationService;
|
||||
|
||||
@LimitPoint(name = "slider_image", key = "verification")
|
||||
@GetMapping("/{verificationEnums}")
|
||||
@ApiOperation(value = "获取校验接口,一分钟同一个ip请求10次")
|
||||
public ResultMessage getSliderImage(@RequestHeader String uuid, @PathVariable VerificationEnums verificationEnums) {
|
||||
return ResultUtil.data(verificationService.createVerification(verificationEnums, uuid));
|
||||
|
||||
}
|
||||
|
||||
@LimitPoint(name = "slider_image", key = "verification_pre_check", limit = 600)
|
||||
@PostMapping("/{verificationEnums}")
|
||||
@ApiOperation(value = "验证码预校验")
|
||||
public ResultMessage verificationImage(Integer xPos, @RequestHeader String uuid, @PathVariable VerificationEnums verificationEnums) {
|
||||
return ResultUtil.data(verificationService.preCheck(xPos, uuid, verificationEnums));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package cn.lili.controller.common;
|
||||
|
||||
import cn.lili.cache.limit.annotation.LimitPoint;
|
||||
import cn.lili.common.enums.ResultCode;
|
||||
import cn.lili.common.enums.ResultUtil;
|
||||
import cn.lili.common.vo.ResultMessage;
|
||||
import cn.lili.modules.sms.SmsUtil;
|
||||
import cn.lili.modules.verification.entity.enums.VerificationEnums;
|
||||
import cn.lili.modules.verification.service.VerificationService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
/**
|
||||
* 短信验证码接口
|
||||
*
|
||||
* @author Chopper
|
||||
* @since 2020/11/26 15:41
|
||||
*/
|
||||
@RestController
|
||||
@Api(tags = "短信验证码接口")
|
||||
@RequestMapping("/common/sms")
|
||||
public class SmsController {
|
||||
|
||||
@Autowired
|
||||
private SmsUtil smsUtil;
|
||||
@Autowired
|
||||
private VerificationService verificationService;
|
||||
|
||||
@LimitPoint(name = "sms_send", key = "sms")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(paramType = "path", dataType = "String", name = "mobile", value = "手机号"),
|
||||
@ApiImplicitParam(paramType = "header", dataType = "String", name = "uuid", value = "uuid"),
|
||||
})
|
||||
@GetMapping("/{verificationEnums}/{mobile}")
|
||||
@ApiOperation(value = "发送短信验证码,一分钟同一个ip请求1次")
|
||||
public ResultMessage getSmsCode(
|
||||
@RequestHeader String uuid,
|
||||
@PathVariable String mobile,
|
||||
@PathVariable VerificationEnums verificationEnums) {
|
||||
verificationService.check(uuid, verificationEnums);
|
||||
smsUtil.sendSmsCode(mobile, verificationEnums, uuid);
|
||||
return ResultUtil.success(ResultCode.VERIFICATION_SEND_SUCCESS);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
package cn.lili.controller.common;
|
||||
|
||||
import cn.hutool.core.text.CharSequenceUtil;
|
||||
import cn.lili.cache.Cache;
|
||||
import cn.lili.common.enums.ResultCode;
|
||||
import cn.lili.common.enums.ResultUtil;
|
||||
import cn.lili.common.exception.ServiceException;
|
||||
import cn.lili.common.properties.SystemSettingProperties;
|
||||
import cn.lili.common.security.AuthUser;
|
||||
import cn.lili.common.security.context.UserContext;
|
||||
import cn.lili.common.security.enums.UserEnums;
|
||||
import cn.lili.common.utils.Base64DecodeMultipartFile;
|
||||
import cn.lili.common.utils.CommonUtil;
|
||||
import cn.lili.common.vo.ResultMessage;
|
||||
import cn.lili.modules.file.entity.File;
|
||||
import cn.lili.modules.file.plugin.QiNiuManagerPlugin;
|
||||
import cn.lili.modules.file.service.FileService;
|
||||
import cn.lili.modules.system.entity.dos.Setting;
|
||||
import cn.lili.modules.system.entity.enums.SettingEnum;
|
||||
import cn.lili.modules.system.service.SettingService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestHeader;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 文件上传接口
|
||||
*
|
||||
* @author Chopper
|
||||
* @since 2020/11/26 15:41
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@Api(tags = "文件上传接口")
|
||||
@RequestMapping("/common/upload")
|
||||
public class UploadController {
|
||||
|
||||
@Autowired
|
||||
private FileService fileService;
|
||||
@Autowired
|
||||
private SettingService settingService;
|
||||
@Autowired
|
||||
private QiNiuManagerPlugin fileManagerPlugin;
|
||||
@Autowired
|
||||
private Cache cache;
|
||||
|
||||
@ApiOperation(value = "文件上传")
|
||||
@PostMapping(value = "/file")
|
||||
public ResultMessage<Object> upload(MultipartFile file,
|
||||
String base64,
|
||||
@RequestHeader String accessToken) {
|
||||
|
||||
|
||||
AuthUser authUser = UserContext.getAuthUser(cache, accessToken);
|
||||
//如果用户未登录,则无法上传图片
|
||||
if (authUser == null) {
|
||||
throw new ServiceException(ResultCode.USER_AUTHORITY_ERROR);
|
||||
}
|
||||
Setting setting = settingService.get(SettingEnum.OSS_SETTING.name());
|
||||
if (setting == null || CharSequenceUtil.isBlank(setting.getSettingValue())) {
|
||||
throw new ServiceException(ResultCode.OSS_NOT_EXIST);
|
||||
}
|
||||
if (file == null || CharSequenceUtil.isEmpty(file.getContentType())) {
|
||||
throw new ServiceException(ResultCode.IMAGE_FILE_EXT_ERROR);
|
||||
}
|
||||
|
||||
|
||||
if (!CharSequenceUtil.containsAny(file.getContentType().toLowerCase(), "image")) {
|
||||
throw new ServiceException(ResultCode.FILE_TYPE_NOT_SUPPORT);
|
||||
}
|
||||
|
||||
if (CharSequenceUtil.isNotBlank(base64)) {
|
||||
//base64上传
|
||||
file = Base64DecodeMultipartFile.base64Convert(base64);
|
||||
}
|
||||
String result;
|
||||
String fileKey = CommonUtil.rename(Objects.requireNonNull(file.getOriginalFilename()));
|
||||
File newFile = new File();
|
||||
try {
|
||||
InputStream inputStream = file.getInputStream();
|
||||
//上传至第三方云服务或服务器
|
||||
result = fileManagerPlugin.inputStreamUpload(inputStream, fileKey);
|
||||
//保存数据信息至数据库
|
||||
newFile.setName(file.getOriginalFilename());
|
||||
newFile.setFileSize(file.getSize());
|
||||
newFile.setFileType(file.getContentType());
|
||||
newFile.setFileKey(fileKey);
|
||||
newFile.setUrl(result);
|
||||
newFile.setCreateBy(authUser.getUsername());
|
||||
newFile.setUserEnums(authUser.getRole().name());
|
||||
//如果是店铺,则记录店铺id
|
||||
if (authUser.getRole().equals(UserEnums.STORE)) {
|
||||
newFile.setOwnerId(authUser.getStoreId());
|
||||
} else {
|
||||
newFile.setOwnerId(authUser.getId());
|
||||
}
|
||||
fileService.save(newFile);
|
||||
} catch (Exception e) {
|
||||
log.error("文件上传失败", e);
|
||||
throw new ServiceException(ResultCode.OSS_EXCEPTION_ERROR);
|
||||
}
|
||||
return ResultUtil.data(result);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
package cn.lili.controller.security;
|
||||
|
||||
import cn.lili.cache.Cache;
|
||||
import cn.lili.common.security.CustomAccessDeniedHandler;
|
||||
import cn.lili.common.properties.IgnoredUrlsProperties;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
|
||||
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
|
||||
import org.springframework.security.config.annotation.web.configurers.ExpressionUrlAuthorizationConfigurer;
|
||||
import org.springframework.web.cors.CorsConfigurationSource;
|
||||
|
||||
/**
|
||||
* spring Security 核心配置类 通用安全
|
||||
*
|
||||
* @author Chopper
|
||||
* @version v4.0
|
||||
* @since 2020/11/14 16:20
|
||||
*/
|
||||
@Slf4j
|
||||
@Configuration
|
||||
@EnableGlobalMethodSecurity(prePostEnabled = true)
|
||||
public class CommonSecurityConfig extends WebSecurityConfigurerAdapter {
|
||||
|
||||
|
||||
/**
|
||||
* 忽略验权配置
|
||||
*/
|
||||
@Autowired
|
||||
private IgnoredUrlsProperties ignoredUrlsProperties;
|
||||
/**
|
||||
* spring security -》 权限不足处理
|
||||
*/
|
||||
@Autowired
|
||||
private CustomAccessDeniedHandler accessDeniedHandler;
|
||||
@Autowired
|
||||
private Cache<String> cache;
|
||||
@Autowired
|
||||
private CorsConfigurationSource corsConfigurationSource;
|
||||
|
||||
@Override
|
||||
protected void configure(HttpSecurity http) throws Exception {
|
||||
|
||||
ExpressionUrlAuthorizationConfigurer<HttpSecurity>.ExpressionInterceptUrlRegistry registry = http
|
||||
.authorizeRequests();
|
||||
registry
|
||||
.and()
|
||||
//禁止网页iframe
|
||||
.headers().frameOptions().disable()
|
||||
.and()
|
||||
.authorizeRequests()
|
||||
//任何请求
|
||||
.anyRequest()
|
||||
//需要身份认证
|
||||
.permitAll()
|
||||
.and()
|
||||
//允许跨域
|
||||
.cors().configurationSource(corsConfigurationSource).and()
|
||||
//关闭跨站请求防护
|
||||
.csrf().disable();
|
||||
}
|
||||
|
||||
}
|
||||
309
common-api/src/main/resources/application.yml
Normal file
@@ -0,0 +1,309 @@
|
||||
server:
|
||||
port: 8890
|
||||
|
||||
servlet:
|
||||
context-path: /
|
||||
|
||||
tomcat:
|
||||
uri-encoding: UTF-8
|
||||
threads:
|
||||
min-spare: 50
|
||||
max: 1000
|
||||
|
||||
# 与Spring Boot 2一样,默认情况下,大多数端点都不通过http公开,我们公开了所有端点。对于生产,您应该仔细选择要公开的端点。
|
||||
management:
|
||||
# health:
|
||||
# elasticsearch:
|
||||
# enabled: false
|
||||
# datasource:
|
||||
# enabled: false
|
||||
endpoints:
|
||||
web:
|
||||
exposure:
|
||||
include: '*'
|
||||
spring:
|
||||
# 要在其中注册的Spring Boot Admin Server的URL。
|
||||
boot:
|
||||
admin:
|
||||
client:
|
||||
url: http://127.0.0.1:8000
|
||||
# mongodb
|
||||
data:
|
||||
mongodb:
|
||||
host: 192.168.2.126
|
||||
port: 27017
|
||||
database: rx-shop
|
||||
username: goboo
|
||||
password: Gb84505016
|
||||
authentication-database: admin
|
||||
# replica-set-name: mongoreplset
|
||||
cache:
|
||||
type: redis
|
||||
# Redis
|
||||
redis:
|
||||
host: 192.168.2.126
|
||||
port: 6379
|
||||
password: Gb84505016
|
||||
lettuce:
|
||||
pool:
|
||||
# 连接池最大连接数(使用负值表示没有限制) 默认 8
|
||||
max-active: 200
|
||||
# 连接池最大阻塞等待时间(使用负值表示没有限制) 默认 -1
|
||||
max-wait: 20
|
||||
# 连接池中的最大空闲连接 默认 8
|
||||
max-idle: 10
|
||||
# 连接池中的最小空闲连接 默认 8
|
||||
min-idle: 8
|
||||
# 文件大小上传配置
|
||||
servlet:
|
||||
multipart:
|
||||
max-file-size: 20MB
|
||||
max-request-size: 20MB
|
||||
jackson:
|
||||
time-zone: GMT+8
|
||||
serialization:
|
||||
#关闭jackson 对json做解析
|
||||
fail-on-empty-beans: false
|
||||
|
||||
shardingsphere:
|
||||
datasource:
|
||||
# 数据库名称,可自定义,可以为多个,以逗号隔开,每个在这里定义的库,都要在下面定义连接属性
|
||||
names: default-datasource
|
||||
default-datasource:
|
||||
type: com.alibaba.druid.pool.DruidDataSource
|
||||
driverClassName: com.mysql.cj.jdbc.Driver
|
||||
url: jdbc:mysql://192.168.2.126:3306/rx-shop?useUnicode=true&characterEncoding=UTF-8&serverTimezone=UTC&allowPublicKeyRetrieval=true&verifyServerCertificate=false&useSSL=false
|
||||
username: rx-shop
|
||||
password: J2xEZ42HwPXrDXt3
|
||||
maxActive: 20
|
||||
initialSize: 5
|
||||
maxWait: 60000
|
||||
minIdle: 5
|
||||
timeBetweenEvictionRunsMillis: 60000
|
||||
minEvictableIdleTimeMillis: 300000
|
||||
validationQuery: SELECT 1 FROM DUAL
|
||||
testWhileIdle: true
|
||||
testOnBorrow: false
|
||||
testOnReturn: false
|
||||
#是否缓存preparedStatement,也就是PSCache。在mysql下建议关闭。 PSCache对支持游标的数据库性能提升巨大,比如说oracle。
|
||||
poolPreparedStatements: false
|
||||
#要启用PSCache,-1为关闭 必须配置大于0,当大于0时,poolPreparedStatements自动触发修改为true 可以把这个数值配置大一些,比如说100
|
||||
maxOpenPreparedStatements: -1
|
||||
#配置监控统计拦截的filters,去掉后监控界面sql无法统计,'wall'用于防火墙
|
||||
filters: stat,wall,log4j2
|
||||
#通过connectProperties属性来打开mergeSql功能;慢SQL记录
|
||||
connectionProperties: druid.stat.mergeSql=true;druid.stat.slowSqlMillis=5000
|
||||
#合并多个DruidDataSource的监控数据
|
||||
useGlobalDataSourceStat: true
|
||||
loginUsername: druid
|
||||
loginPassword: druid
|
||||
# sharding:
|
||||
# default-data-source-name: default-datasource
|
||||
# #需要拆分的表,可以设置多个 在 li_order 级别即可
|
||||
# tables:
|
||||
# #需要进行分表的逻辑表名
|
||||
# li_order:
|
||||
# #实际的表结点,下面代表的是li_order_为开头的所有表,如果能确定表的范围例如按月份分表,这里的写法是data2020.li_order_$->{2020..2021}_$->{01..12} 表示例如 li_order_2020_01 li_order_2020_03 li_order_2021_01
|
||||
# actual-data-nodes: data2020.li_order_$->{2019..2021}_$->{01..12}
|
||||
# table-strategy:
|
||||
# # 分表策略,根据创建日期
|
||||
# standard:
|
||||
# sharding-column: create_time
|
||||
# #分表策略
|
||||
# precise-algorithm-class-name: cn.lili.mybatis.sharding.CreateTimeShardingTableAlgorithm
|
||||
# #范围查询实现
|
||||
# range-algorithm-class-name: cn.lili.mybatis.sharding.CreateTimeShardingTableAlgorithm
|
||||
props:
|
||||
#是否打印逻辑SQL语句和实际SQL语句,建议调试时打印,在生产环境关闭
|
||||
sql:
|
||||
show: true
|
||||
|
||||
# 忽略鉴权url
|
||||
ignored:
|
||||
urls:
|
||||
- /editor-app/**
|
||||
- /actuator**
|
||||
- /actuator/**
|
||||
- /MP_verify_qSyvBPhDsPdxvOhC.txt
|
||||
- /weixin/**
|
||||
- /source/**
|
||||
- /buyer/mini-program/**
|
||||
- /buyer/cashier/**
|
||||
- /buyer/pageData/**
|
||||
- /buyer/article/**
|
||||
- /buyer/goods/**
|
||||
- /buyer/category/**
|
||||
- /buyer/shop/**
|
||||
- /buyer/connect/**
|
||||
- /buyer/members/smsLogin
|
||||
- /buyer/members/refresh/*
|
||||
- /buyer/members/refresh**
|
||||
- /buyer/promotion/pintuan
|
||||
- /buyer/promotion/seckill
|
||||
- /buyer/memberEvaluation/**/goodsEvaluation
|
||||
- /buyer/memberEvaluation/**/evaluationNumber
|
||||
- /store/login/**
|
||||
- /manager/user/login
|
||||
- /manager/user/refresh/**
|
||||
- /druid/**
|
||||
- /swagger-ui.html
|
||||
- /doc.html
|
||||
- /swagger-resources/**
|
||||
- /swagger/**
|
||||
- /webjars/**
|
||||
- /v2/api-docs
|
||||
- /configuration/ui
|
||||
- /boot-admin
|
||||
- /**/*.js
|
||||
- /**/*.css
|
||||
- /**/*.png
|
||||
- /**/*.ico
|
||||
|
||||
# Swagger界面内容配置
|
||||
swagger:
|
||||
title: API接口文档
|
||||
description: Api Documentation
|
||||
version: 1.0.0
|
||||
termsOfServiceUrl:
|
||||
contact:
|
||||
name: rx
|
||||
url:
|
||||
email:
|
||||
|
||||
# Mybatis-plus
|
||||
mybatis-plus:
|
||||
mapper-locations: classpath*:mapper/*.xml
|
||||
configuration:
|
||||
#缓存开启
|
||||
cache-enabled: true
|
||||
#日志
|
||||
# log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
|
||||
|
||||
# 日志
|
||||
logging:
|
||||
# 输出级别
|
||||
level:
|
||||
cn.lili: info
|
||||
# org.hibernate: debug
|
||||
# org.springframework: debug
|
||||
# org.springframework.data.mongodb.core: debug
|
||||
file:
|
||||
# 指定路径
|
||||
path: lili-logs
|
||||
# 最大保存天数
|
||||
max-history: 7
|
||||
# 每个文件最大大小
|
||||
max-size: 5MB
|
||||
#加密参数
|
||||
jasypt:
|
||||
encryptor:
|
||||
password: lili
|
||||
|
||||
lili:
|
||||
#验证码设置
|
||||
verification-code:
|
||||
#图形验证码有效时间 秒 包含滑块验证码有效时间, 以及验证通过之后,缓存中存储的验证结果有效时间
|
||||
effectiveTime: 300
|
||||
#水印
|
||||
watermark:
|
||||
#干扰项数量 最大2 默认0
|
||||
interfereNum: 0
|
||||
#允许误差像素
|
||||
faultTolerant: 3
|
||||
#短信模版配置
|
||||
sms:
|
||||
#登录
|
||||
LOGIN: SMS_205755300
|
||||
#注册
|
||||
REGISTER: SMS_205755298
|
||||
#找回密码
|
||||
FIND_USER: SMS_205755301
|
||||
#设置密码
|
||||
UPDATE_PASSWORD: SMS_205755297
|
||||
#支付密码
|
||||
WALLET_PASSWORD: SMS_205755301
|
||||
system:
|
||||
isTestModel: true
|
||||
statistics:
|
||||
# 在线人数统计 X 小时。这里设置48,即统计过去48小时每小时在线人数
|
||||
onlineMember: 48
|
||||
# 当前在线人数刷新时间间隔,单位秒,设置为600,则每10分钟刷新一次
|
||||
currentOnlineUpdate: 600
|
||||
#qq lbs 申请
|
||||
lbs:
|
||||
key: 4BYBZ-7MT6S-PUAOA-6BNWL-FJUD7-UUFXT
|
||||
sk: zhNKVrJK6UPOhqIjn8AQvG37b9sz6
|
||||
#域名
|
||||
domain:
|
||||
pc: https://pc.b2b2c.pickmall.cn
|
||||
wap: https://m.b2b2c.pickmall.cn
|
||||
store: https://store.b2b2c.pickmall.cn
|
||||
admin: https://admin.b2b2c.pickmall.cn
|
||||
#api地址
|
||||
api:
|
||||
buyer: https://buyer-api.pickmall.cn
|
||||
common: https://common-api.pickmall.cn
|
||||
manager: https://admin-api.pickmall.cn
|
||||
store: https://store-api.pickmall.cn
|
||||
|
||||
# jwt 细节设定
|
||||
jwt-setting:
|
||||
# token过期时间(分钟)
|
||||
tokenExpireTime: 60
|
||||
|
||||
# 使用Spring @Cacheable注解失效时间
|
||||
cache:
|
||||
# 过期时间 单位秒 永久不过期设为-1
|
||||
timeout: 1500
|
||||
#多线程配置
|
||||
thread:
|
||||
corePoolSize: 5
|
||||
maxPoolSize: 50
|
||||
queueCapacity: 50
|
||||
data:
|
||||
elasticsearch:
|
||||
cluster-name: elasticsearch
|
||||
cluster-nodes: 192.168.2.126:9200
|
||||
index:
|
||||
number-of-replicas: 0
|
||||
number-of-shards: 3
|
||||
index-prefix: lili
|
||||
schema: http
|
||||
# account:
|
||||
# username: elastic
|
||||
# password: LiLiShopES
|
||||
|
||||
rocketmq:
|
||||
promotion-topic: lili_promotion_topic
|
||||
promotion-group: lili_promotion_group
|
||||
msg-ext-topic: lili_msg_topic
|
||||
msg-ext-group: lili_msg_group
|
||||
goods-topic: lili_goods_topic
|
||||
goods-group: lili_goods_group
|
||||
order-topic: lili_order_topic
|
||||
order-group: lili_order_group
|
||||
member-topic: lili_member_topic
|
||||
member-group: lili_member_group
|
||||
other-topic: lili_other_topic
|
||||
other-group: lili_other_group
|
||||
notice-topic: lili_notice_topic
|
||||
notice-group: lili_notice_group
|
||||
notice-send-topic: lili_send_notice_topic
|
||||
notice-send-group: lili_send_notice_group
|
||||
rocketmq:
|
||||
name-server: 192.168.2.126:9876
|
||||
producer:
|
||||
group: lili_group
|
||||
send-message-timeout: 30000
|
||||
|
||||
xxl:
|
||||
job:
|
||||
admin:
|
||||
addresses: http://192.168.2.126:9001/xxl-job-admin
|
||||
executor:
|
||||
appname: xxl-job-executor-lilishop
|
||||
address:
|
||||
ip:
|
||||
port: 8891
|
||||
logpath: ./xxl-job/executor
|
||||
logretentiondays: 7
|
||||
43
common-api/src/main/resources/logback-spring.xml
Normal file
@@ -0,0 +1,43 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE configuration>
|
||||
<configuration>
|
||||
<include resource="org/springframework/boot/logging/logback/defaults.xml"/>
|
||||
<include resource="org/springframework/boot/logging/logback/console-appender.xml"/>
|
||||
<!--应用名称-->
|
||||
<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">
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<fileNamePattern>${LOG_FILE_PATH}/${APP_NAME}-%d{yyyy-MM-dd}.log</fileNamePattern>
|
||||
<maxHistory>30</maxHistory>
|
||||
</rollingPolicy>
|
||||
<encoder>
|
||||
<pattern>${FILE_LOG_PATTERN}</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<!--输出到elk的LOGSTASH-->
|
||||
<appender name="LOGSTASH" class="net.logstash.logback.appender.LogstashTcpSocketAppender">
|
||||
<!-- 配置elk日志收集 配饰的是 LOGSTASH 的地址-->
|
||||
<destination>${LOGSTASH_SERVER}</destination>
|
||||
<encoder charset="UTF-8" class="net.logstash.logback.encoder.LogstashEncoder">
|
||||
<providers>
|
||||
<timestamp>
|
||||
<timeZone>UTC</timeZone>
|
||||
</timestamp>
|
||||
</providers>
|
||||
<!--自定义字段 区分项目-->
|
||||
<customFields>{"appName":"${APP_NAME}"}</customFields>
|
||||
</encoder>
|
||||
</appender>
|
||||
<!-- <root level="INFO">-->
|
||||
<root>
|
||||
<appender-ref ref="CONSOLE"/>
|
||||
<appender-ref ref="FILE"/>
|
||||
<appender-ref ref="LOGSTASH"/>
|
||||
</root>
|
||||
</configuration>
|
||||
BIN
common-api/src/main/resources/slider/images/1.jpg
Normal file
|
After Width: | Height: | Size: 12 KiB |
BIN
common-api/src/main/resources/slider/images/10.jpg
Normal file
|
After Width: | Height: | Size: 7.3 KiB |
BIN
common-api/src/main/resources/slider/images/11.jpg
Normal file
|
After Width: | Height: | Size: 12 KiB |
BIN
common-api/src/main/resources/slider/images/12.jpg
Normal file
|
After Width: | Height: | Size: 11 KiB |
BIN
common-api/src/main/resources/slider/images/13.jpg
Normal file
|
After Width: | Height: | Size: 6.1 KiB |
BIN
common-api/src/main/resources/slider/images/14.jpg
Normal file
|
After Width: | Height: | Size: 7.2 KiB |
BIN
common-api/src/main/resources/slider/images/15.jpg
Normal file
|
After Width: | Height: | Size: 8.9 KiB |
BIN
common-api/src/main/resources/slider/images/16.jpg
Normal file
|
After Width: | Height: | Size: 10 KiB |
BIN
common-api/src/main/resources/slider/images/17.jpg
Normal file
|
After Width: | Height: | Size: 11 KiB |
BIN
common-api/src/main/resources/slider/images/18.jpg
Normal file
|
After Width: | Height: | Size: 9.2 KiB |
BIN
common-api/src/main/resources/slider/images/19.jpg
Normal file
|
After Width: | Height: | Size: 10 KiB |
BIN
common-api/src/main/resources/slider/images/2.jpg
Normal file
|
After Width: | Height: | Size: 14 KiB |
BIN
common-api/src/main/resources/slider/images/20.jpg
Normal file
|
After Width: | Height: | Size: 11 KiB |
BIN
common-api/src/main/resources/slider/images/21.jpg
Normal file
|
After Width: | Height: | Size: 5.2 KiB |
BIN
common-api/src/main/resources/slider/images/22.jpg
Normal file
|
After Width: | Height: | Size: 7.0 KiB |
BIN
common-api/src/main/resources/slider/images/23.jpg
Normal file
|
After Width: | Height: | Size: 6.5 KiB |
BIN
common-api/src/main/resources/slider/images/3.jpg
Normal file
|
After Width: | Height: | Size: 8.0 KiB |
BIN
common-api/src/main/resources/slider/images/4.jpg
Normal file
|
After Width: | Height: | Size: 8.4 KiB |
BIN
common-api/src/main/resources/slider/images/5.jpg
Normal file
|
After Width: | Height: | Size: 10 KiB |
BIN
common-api/src/main/resources/slider/images/6.jpg
Normal file
|
After Width: | Height: | Size: 5.5 KiB |
BIN
common-api/src/main/resources/slider/images/7.jpg
Normal file
|
After Width: | Height: | Size: 7.3 KiB |
BIN
common-api/src/main/resources/slider/images/8.jpg
Normal file
|
After Width: | Height: | Size: 4.0 KiB |
BIN
common-api/src/main/resources/slider/images/9.jpg
Normal file
|
After Width: | Height: | Size: 6.6 KiB |
BIN
common-api/src/main/resources/slider/slider/1-w.png
Normal file
|
After Width: | Height: | Size: 3.5 KiB |
BIN
common-api/src/main/resources/slider/slider/2-w.png
Normal file
|
After Width: | Height: | Size: 18 KiB |
BIN
common-api/src/main/resources/slider/slider/3-w.png
Normal file
|
After Width: | Height: | Size: 17 KiB |
BIN
common-api/src/main/resources/slider/slider/4-w.png
Normal file
|
After Width: | Height: | Size: 18 KiB |
BIN
common-api/src/main/resources/slider/slider/5-w.png
Normal file
|
After Width: | Height: | Size: 17 KiB |
BIN
common-api/src/main/resources/slider/slider/6-w.png
Normal file
|
After Width: | Height: | Size: 18 KiB |