Commit 716a5455 authored by hezhen's avatar hezhen

Merge branch 'base-modify' of http://113.105.137.151:22280/youjj/cloud-platform into base-modify

parents 6ec5877f 4a4fd268
package com.github.wxiaoqi.security.admin.constant;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
public class AppFormat {
private static final String[] format = {"ipa", "apk","pxl"};
private static final Set formatSet= new HashSet(Arrays.asList(format));
public static Set<String> getFormatSet() {
return formatSet;
}
}
......@@ -193,6 +193,7 @@ public class BaseUserMemberBiz extends BaseBiz<BaseUserMemberMapper,BaseUserMemb
* @return
*/
public BaseUserMemberVO findOneByUserId(Integer userId) {
BaseUserMemberVO baseUserMemberVO= mapper.getBaseUserMemberVOByUserId(userId);
if (baseUserMemberVO!=null) {
return baseUserMemberVO;
......@@ -218,23 +219,38 @@ public class BaseUserMemberBiz extends BaseBiz<BaseUserMemberMapper,BaseUserMemb
BaseUserMember baseUserMember = new BaseUserMember();
BeanUtilsBean.getInstance().copyProperties(baseUserMember,baseUserMemberVO);
if (baseUserMembers==null||baseUserMembers.size()==0) {
if (baseUserMemberVO.getMemberLevel()==null||baseUserMember.getValidTime()==null) return;
if (baseUserMemberVO.getMemberLevel() == null || baseUserMember.getValidTime() == null ) return;
baseUserMember.setCrtTime(System.currentTimeMillis());
baseUserMember.setIsDel(0);
baseUserMember.setPayCount(0);
baseUserMember.setCardLeave(1);
baseUserMember.setRecentRecharge(System.currentTimeMillis());
Integer buyCount = baseUserMember.getBuyCount()==null? 0:baseUserMember.getBuyCount();
baseUserMember.setBuyCount(buyCount+1);
Integer buyCount = baseUserMember.getBuyCount() == null ? 0 : baseUserMember.getBuyCount();
baseUserMember.setBuyCount(buyCount + 1);
insertSelective(baseUserMember);
return;
}else if (baseUserMembers.size()==1){
if (baseUserMemberVO.getMemberLevel() == null || baseUserMember.getValidTime() == null ){
baseUserMember.setIsDel(1);
}else {
baseUserMember.setIsDel(0);
}
baseUserMember.setUpdTime(System.currentTimeMillis());
getMyBiz().updateSelectiveById(baseUserMember);
baseUserMember.setBuyCount(baseUserMembers.get(0).getBuyCount()+1);
baseUserMember.setId(baseUserMembers.get(0).getId());
mapper.updateByPrimaryKeySelective(baseUserMember);
}else {
throw new BaseException("Member purchase repeat!");
}
}
}
\ No newline at end of file
......@@ -54,7 +54,7 @@ public class MemberLevelController extends BaseController<UserMemberLevelBiz, Ba
return null;
}
@GetMapping("/Manage/getMembers")
@GetMapping("/manage/getMembers")
public ObjectRestResponse getMembers(){
Example exa = Example.builder(BaseUserMemberLevel.class).where(
WeekendSqls.<BaseUserMemberLevel>custom()
......@@ -66,7 +66,7 @@ public class MemberLevelController extends BaseController<UserMemberLevelBiz, Ba
@DeleteMapping("/Manage/delMembershipGrade/{id}")
@DeleteMapping("/manage/delMembershipGrade/{id}")
public ObjectRestResponse delMembershipGrade(@PathVariable Integer id){
BaseUserMemberLevel baseUserMemberLevel = new BaseUserMemberLevel();
baseUserMemberLevel.setId(id);
......
......@@ -95,10 +95,7 @@
) m
on
l.id = m.user_id
where 1=1
and m.is_del=0
<if test="mobile !=null">
and l.username like CONCAT('%',#{mobile},'%')
......@@ -118,6 +115,8 @@
<if test="source !=null">
and d.source = #{source}
</if>
order by l.id ASC
</select>
......
......@@ -97,7 +97,7 @@ public class AppVersionBiz extends BaseBiz<AppVersionMapper,AppVersion> {
return ObjectRestResponse.succ();
}
public RestResponse uploadDrivingLicense(MultipartFile file) throws IOException {
public ObjectRestResponse uploadDrivingLicense(MultipartFile file) throws IOException {
DateTime now = DateTime.now();
String dirPathToday = File.separator + now.toString(DEFAULT_DATE_TIME_FORMATTER);
String redisNoKey = RedisKey.UPLOAD_FILE_NO_PREFIX + now.toString(DEFAULT_DATE_TIME_FORMATTER);
......@@ -111,7 +111,7 @@ public class AppVersionBiz extends BaseBiz<AppVersionMapper,AppVersion> {
String filePath = uploadPath + realFileRelPath;
FileUtils.copyInputStreamToFile(file.getInputStream(), new File(filePath));
return RestResponse.suc(filePath);
return ObjectRestResponse.succ(filePath);
}
......
package com.xxfc.platform.app.config;
import org.springframework.boot.web.servlet.MultipartConfigFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import javax.servlet.MultipartConfigElement;
@Configuration
public class FileUploadConfig {
@Bean
public MultipartConfigElement multipartConfigElement() {
MultipartConfigFactory factory = new MultipartConfigFactory();
// 单个数据大小
factory.setMaxFileSize("51200KB");
/// 总上传数据大小
factory.setMaxRequestSize("51200KB");
return factory.createMultipartConfig();
}
}
package com.xxfc.platform.app.rest;
import com.github.pagehelper.PageInfo;
import com.github.wxiaoqi.security.admin.constant.AppFormat;
import com.github.wxiaoqi.security.auth.client.annotation.IgnoreClientToken;
import com.github.wxiaoqi.security.auth.client.annotation.IgnoreUserToken;
import com.github.wxiaoqi.security.common.exception.BaseException;
......@@ -17,6 +18,7 @@ import com.xxfc.platform.vehicle.constant.ResCode.ResCode;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.ibatis.annotations.Delete;
......@@ -36,6 +38,7 @@ import java.util.List;
@RestController
@RequestMapping("version")
@IgnoreClientToken
@Slf4j
public class AppVersionController extends BaseController<AppVersionBiz,AppVersion> {
//最大上传500MB
private Long MAX_DRIVING_LICENSE_SIZE =1024*1024*500L;
......@@ -68,7 +71,7 @@ public class AppVersionController extends BaseController<AppVersionBiz,AppVersio
}
@ApiOperation("查询")
@ApiOperation("查询一条")
@RequestMapping(value = "/background/getAppVersion/{id}",method = RequestMethod.GET)
public ObjectRestResponse<AppVersion> getAppVersion(@PathVariable Integer id){
return ObjectRestResponse.succ(baseBiz.get(id));
......@@ -82,7 +85,7 @@ public class AppVersionController extends BaseController<AppVersionBiz,AppVersio
@Override
@ApiOperation("修改")
@RequestMapping(value = "/background/update/{id}",method = RequestMethod.PUT)
@RequestMapping(value = "/background/update",method = RequestMethod.PUT)
public ObjectRestResponse<AppVersion> update(@RequestBody AppVersion appVersion){
baseBiz.updateAppVersionById(appVersion);
return new ObjectRestResponse<AppVersion>();
......@@ -99,17 +102,17 @@ public class AppVersionController extends BaseController<AppVersionBiz,AppVersio
@PostMapping(value = "/upload/installationPackage")
@ApiOperation(value = "上传app安装包")
public RestResponse uploadInstallationPackage(@RequestParam("file") MultipartFile file)
public ObjectRestResponse uploadInstallationPackage(@RequestParam("file") MultipartFile file)
throws Exception {
Assert.notNull(file);
String contentType = file.getContentType(); //文件类型
//// String fileName = file.getOriginalFilename(); //文件名
if (!contentType.equals("apk") && !contentType.equals("ipa")) {
return RestResponse.code(ResCode.INVALID_REST_REQ_PARAM.getCode());
}
if (file.getSize() > MAX_DRIVING_LICENSE_SIZE) {
return RestResponse.code(ResCode.INVALID_REST_REQ_PARAM.getCode());
//文件类型
String contentType = file.getContentType();
log.debug("contentType"+contentType);
//判断上传的文件格式
if (!judgeFormat(contentType)||file.getSize() > MAX_DRIVING_LICENSE_SIZE) {
return ObjectRestResponse.createDefaultFail();
}
return baseBiz.uploadDrivingLicense(file);
}
......@@ -123,4 +126,21 @@ public class AppVersionController extends BaseController<AppVersionBiz,AppVersio
return baseBiz.downloadInstallationPackage(realFileRelPath);
}
/**
* 判断上传的文件格式
* @param contentType
* @return
*/
private boolean judgeFormat(String contentType){
if (AppFormat.getFormatSet().size()==0) {
return true;
}
for (String format : AppFormat.getFormatSet()) {
if (format.equals(contentType)) {
return true;
}
}
return false;
}
}
\ No newline at end of file
servlet:
multipart:
# 启用上传处理,默认是true
enabled: true
# 当上传文件达到1MB的时候进行磁盘写入
file-size-threshold: 20MB
# 设置最大的请求文件的大小
max-request-size: 50MB
# 设置单个文件的最大长度
max-file-size: 50MB
\ No newline at end of file
......@@ -5,3 +5,13 @@ logging:
debug
com.xxfc.platform.common:
debug
servlet:
multipart:
# 启用上传处理,默认是true
enabled: true
# 当上传文件达到1MB的时候进行磁盘写入
file-size-threshold: 20MB
# 设置最大的请求文件的大小
max-request-size: 50MB
# 设置单个文件的最大长度
max-file-size: 50MB
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment