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 ...@@ -193,6 +193,7 @@ public class BaseUserMemberBiz extends BaseBiz<BaseUserMemberMapper,BaseUserMemb
* @return * @return
*/ */
public BaseUserMemberVO findOneByUserId(Integer userId) { public BaseUserMemberVO findOneByUserId(Integer userId) {
BaseUserMemberVO baseUserMemberVO= mapper.getBaseUserMemberVOByUserId(userId); BaseUserMemberVO baseUserMemberVO= mapper.getBaseUserMemberVOByUserId(userId);
if (baseUserMemberVO!=null) { if (baseUserMemberVO!=null) {
return baseUserMemberVO; return baseUserMemberVO;
...@@ -218,23 +219,38 @@ public class BaseUserMemberBiz extends BaseBiz<BaseUserMemberMapper,BaseUserMemb ...@@ -218,23 +219,38 @@ public class BaseUserMemberBiz extends BaseBiz<BaseUserMemberMapper,BaseUserMemb
BaseUserMember baseUserMember = new BaseUserMember(); BaseUserMember baseUserMember = new BaseUserMember();
BeanUtilsBean.getInstance().copyProperties(baseUserMember,baseUserMemberVO); BeanUtilsBean.getInstance().copyProperties(baseUserMember,baseUserMemberVO);
if (baseUserMembers==null||baseUserMembers.size()==0) { if (baseUserMembers==null||baseUserMembers.size()==0) {
if (baseUserMemberVO.getMemberLevel()==null||baseUserMember.getValidTime()==null) return;
baseUserMember.setCrtTime(System.currentTimeMillis()); if (baseUserMemberVO.getMemberLevel() == null || baseUserMember.getValidTime() == null ) return;
baseUserMember.setIsDel(0); baseUserMember.setCrtTime(System.currentTimeMillis());
baseUserMember.setPayCount(0); baseUserMember.setIsDel(0);
baseUserMember.setCardLeave(1); baseUserMember.setPayCount(0);
baseUserMember.setRecentRecharge(System.currentTimeMillis()); baseUserMember.setCardLeave(1);
Integer buyCount = baseUserMember.getBuyCount()==null? 0:baseUserMember.getBuyCount(); baseUserMember.setRecentRecharge(System.currentTimeMillis());
baseUserMember.setBuyCount(buyCount+1); Integer buyCount = baseUserMember.getBuyCount() == null ? 0 : baseUserMember.getBuyCount();
insertSelective(baseUserMember); baseUserMember.setBuyCount(buyCount + 1);
return; insertSelective(baseUserMember);
return;
}else if (baseUserMembers.size()==1){ }else if (baseUserMembers.size()==1){
baseUserMember.setUpdTime(System.currentTimeMillis()); if (baseUserMemberVO.getMemberLevel() == null || baseUserMember.getValidTime() == null ){
getMyBiz().updateSelectiveById(baseUserMember); baseUserMember.setIsDel(1);
}else {
baseUserMember.setIsDel(0);
}
baseUserMember.setUpdTime(System.currentTimeMillis());
baseUserMember.setBuyCount(baseUserMembers.get(0).getBuyCount()+1);
baseUserMember.setId(baseUserMembers.get(0).getId());
mapper.updateByPrimaryKeySelective(baseUserMember);
}else { }else {
throw new BaseException("Member purchase repeat!"); throw new BaseException("Member purchase repeat!");
} }
} }
} }
\ No newline at end of file
...@@ -54,7 +54,7 @@ public class MemberLevelController extends BaseController<UserMemberLevelBiz, Ba ...@@ -54,7 +54,7 @@ public class MemberLevelController extends BaseController<UserMemberLevelBiz, Ba
return null; return null;
} }
@GetMapping("/Manage/getMembers") @GetMapping("/manage/getMembers")
public ObjectRestResponse getMembers(){ public ObjectRestResponse getMembers(){
Example exa = Example.builder(BaseUserMemberLevel.class).where( Example exa = Example.builder(BaseUserMemberLevel.class).where(
WeekendSqls.<BaseUserMemberLevel>custom() WeekendSqls.<BaseUserMemberLevel>custom()
...@@ -66,7 +66,7 @@ public class MemberLevelController extends BaseController<UserMemberLevelBiz, Ba ...@@ -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){ public ObjectRestResponse delMembershipGrade(@PathVariable Integer id){
BaseUserMemberLevel baseUserMemberLevel = new BaseUserMemberLevel(); BaseUserMemberLevel baseUserMemberLevel = new BaseUserMemberLevel();
baseUserMemberLevel.setId(id); baseUserMemberLevel.setId(id);
......
...@@ -95,10 +95,7 @@ ...@@ -95,10 +95,7 @@
) m ) m
on on
l.id = m.user_id l.id = m.user_id
and m.is_del=0
where 1=1
<if test="mobile !=null"> <if test="mobile !=null">
and l.username like CONCAT('%',#{mobile},'%') and l.username like CONCAT('%',#{mobile},'%')
...@@ -118,6 +115,8 @@ ...@@ -118,6 +115,8 @@
<if test="source !=null"> <if test="source !=null">
and d.source = #{source} and d.source = #{source}
</if> </if>
order by l.id ASC order by l.id ASC
</select> </select>
......
...@@ -97,7 +97,7 @@ public class AppVersionBiz extends BaseBiz<AppVersionMapper,AppVersion> { ...@@ -97,7 +97,7 @@ public class AppVersionBiz extends BaseBiz<AppVersionMapper,AppVersion> {
return ObjectRestResponse.succ(); return ObjectRestResponse.succ();
} }
public RestResponse uploadDrivingLicense(MultipartFile file) throws IOException { public ObjectRestResponse uploadDrivingLicense(MultipartFile file) throws IOException {
DateTime now = DateTime.now(); DateTime now = DateTime.now();
String dirPathToday = File.separator + now.toString(DEFAULT_DATE_TIME_FORMATTER); String dirPathToday = File.separator + now.toString(DEFAULT_DATE_TIME_FORMATTER);
String redisNoKey = RedisKey.UPLOAD_FILE_NO_PREFIX + 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> { ...@@ -111,7 +111,7 @@ public class AppVersionBiz extends BaseBiz<AppVersionMapper,AppVersion> {
String filePath = uploadPath + realFileRelPath; String filePath = uploadPath + realFileRelPath;
FileUtils.copyInputStreamToFile(file.getInputStream(), new File(filePath)); 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; package com.xxfc.platform.app.rest;
import com.github.pagehelper.PageInfo; 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.IgnoreClientToken;
import com.github.wxiaoqi.security.auth.client.annotation.IgnoreUserToken; import com.github.wxiaoqi.security.auth.client.annotation.IgnoreUserToken;
import com.github.wxiaoqi.security.common.exception.BaseException; import com.github.wxiaoqi.security.common.exception.BaseException;
...@@ -17,6 +18,7 @@ import com.xxfc.platform.vehicle.constant.ResCode.ResCode; ...@@ -17,6 +18,7 @@ import com.xxfc.platform.vehicle.constant.ResCode.ResCode;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.Data; import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.FileUtils; import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.ibatis.annotations.Delete; import org.apache.ibatis.annotations.Delete;
...@@ -36,6 +38,7 @@ import java.util.List; ...@@ -36,6 +38,7 @@ import java.util.List;
@RestController @RestController
@RequestMapping("version") @RequestMapping("version")
@IgnoreClientToken @IgnoreClientToken
@Slf4j
public class AppVersionController extends BaseController<AppVersionBiz,AppVersion> { public class AppVersionController extends BaseController<AppVersionBiz,AppVersion> {
//最大上传500MB //最大上传500MB
private Long MAX_DRIVING_LICENSE_SIZE =1024*1024*500L; private Long MAX_DRIVING_LICENSE_SIZE =1024*1024*500L;
...@@ -68,7 +71,7 @@ public class AppVersionController extends BaseController<AppVersionBiz,AppVersio ...@@ -68,7 +71,7 @@ public class AppVersionController extends BaseController<AppVersionBiz,AppVersio
} }
@ApiOperation("查询") @ApiOperation("查询一条")
@RequestMapping(value = "/background/getAppVersion/{id}",method = RequestMethod.GET) @RequestMapping(value = "/background/getAppVersion/{id}",method = RequestMethod.GET)
public ObjectRestResponse<AppVersion> getAppVersion(@PathVariable Integer id){ public ObjectRestResponse<AppVersion> getAppVersion(@PathVariable Integer id){
return ObjectRestResponse.succ(baseBiz.get(id)); return ObjectRestResponse.succ(baseBiz.get(id));
...@@ -82,7 +85,7 @@ public class AppVersionController extends BaseController<AppVersionBiz,AppVersio ...@@ -82,7 +85,7 @@ public class AppVersionController extends BaseController<AppVersionBiz,AppVersio
@Override @Override
@ApiOperation("修改") @ApiOperation("修改")
@RequestMapping(value = "/background/update/{id}",method = RequestMethod.PUT) @RequestMapping(value = "/background/update",method = RequestMethod.PUT)
public ObjectRestResponse<AppVersion> update(@RequestBody AppVersion appVersion){ public ObjectRestResponse<AppVersion> update(@RequestBody AppVersion appVersion){
baseBiz.updateAppVersionById(appVersion); baseBiz.updateAppVersionById(appVersion);
return new ObjectRestResponse<AppVersion>(); return new ObjectRestResponse<AppVersion>();
...@@ -99,17 +102,17 @@ public class AppVersionController extends BaseController<AppVersionBiz,AppVersio ...@@ -99,17 +102,17 @@ public class AppVersionController extends BaseController<AppVersionBiz,AppVersio
@PostMapping(value = "/upload/installationPackage") @PostMapping(value = "/upload/installationPackage")
@ApiOperation(value = "上传app安装包") @ApiOperation(value = "上传app安装包")
public RestResponse uploadInstallationPackage(@RequestParam("file") MultipartFile file) public ObjectRestResponse uploadInstallationPackage(@RequestParam("file") MultipartFile file)
throws Exception { throws Exception {
Assert.notNull(file); Assert.notNull(file);
String contentType = file.getContentType(); //文件类型 //文件类型
//// String fileName = file.getOriginalFilename(); //文件名 String contentType = file.getContentType();
if (!contentType.equals("apk") && !contentType.equals("ipa")) { log.debug("contentType"+contentType);
return RestResponse.code(ResCode.INVALID_REST_REQ_PARAM.getCode()); //判断上传的文件格式
} if (!judgeFormat(contentType)||file.getSize() > MAX_DRIVING_LICENSE_SIZE) {
if (file.getSize() > MAX_DRIVING_LICENSE_SIZE) { return ObjectRestResponse.createDefaultFail();
return RestResponse.code(ResCode.INVALID_REST_REQ_PARAM.getCode());
} }
return baseBiz.uploadDrivingLicense(file); return baseBiz.uploadDrivingLicense(file);
} }
...@@ -123,4 +126,21 @@ public class AppVersionController extends BaseController<AppVersionBiz,AppVersio ...@@ -123,4 +126,21 @@ public class AppVersionController extends BaseController<AppVersionBiz,AppVersio
return baseBiz.downloadInstallationPackage(realFileRelPath); 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
...@@ -4,4 +4,14 @@ logging: ...@@ -4,4 +4,14 @@ logging:
com.xxfc.platform.universal: com.xxfc.platform.universal:
debug debug
com.xxfc.platform.common: com.xxfc.platform.common:
debug debug
\ 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
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