Commit 662eef7a authored by hanfeng's avatar hanfeng

修改app管理和app上传

parent 4a4fd268
...@@ -88,6 +88,16 @@ auth: ...@@ -88,6 +88,16 @@ auth:
token-header: x-client-token token-header: x-client-token
id: ace-gate #不填则默认读取spring.application.name id: ace-gate #不填则默认读取spring.application.name
secret: 123456 secret: 123456
servlet:
multipart:
# 启用上传处理,默认是true
enabled: true
# 当上传文件达到20MB的时候进行磁盘写入
file-size-threshold: 20MB
# 设置最大的请求文件的大小
max-request-size: 50MB
# 设置单个文件的最大长度
max-file-size: 50MB
# #
# #
#ribbon: #ribbon:
......
...@@ -6,7 +6,7 @@ import java.util.List; ...@@ -6,7 +6,7 @@ import java.util.List;
import java.util.Set; import java.util.Set;
public class AppFormat { public class AppFormat {
private static final String[] format = {"ipa", "apk","pxl"}; private static final String[] format = {".ipa", ".apk",".pxl"};
private static final Set formatSet= new HashSet(Arrays.asList(format)); private static final Set formatSet= new HashSet(Arrays.asList(format));
public static Set<String> getFormatSet() { public static Set<String> getFormatSet() {
return formatSet; return formatSet;
......
...@@ -52,10 +52,10 @@ public class AppUserManageDTO { ...@@ -52,10 +52,10 @@ public class AppUserManageDTO {
*/ */
private Integer source; private Integer source;
/** // /**
* 接收前台时间范围 // * 接收前台时间范围
*/ // */
private String[] registrationDate; // private String[] registrationDate;
} }
...@@ -57,7 +57,7 @@ public class AppUserManageBiz extends BaseBiz<AppUserDetailMapper, AppUserDetail ...@@ -57,7 +57,7 @@ public class AppUserManageBiz extends BaseBiz<AppUserDetailMapper, AppUserDetail
List<AppUserManageVo> appUserManageVos = mapper.selectAppUserManage(appUserManageDTO); List<AppUserManageVo> appUserManageVos = mapper.selectAppUserManage(appUserManageDTO);
PageInfo<AppUserManageVo> pageInfo = PageInfo.of(appUserManageVos); PageInfo<AppUserManageVo> pageInfo = PageInfo.of(appUserManageVos);
if (pageInfo.getList()==null||pageInfo.getList().size()==0) { if (pageInfo.getList()==null||pageInfo.getList().size()==0) {
return null; return pageInfo;
} }
List<Integer> Citys = pageInfo.getList().parallelStream().map(AppUserManageVo::getCityCode).collect(Collectors.toList()); List<Integer> Citys = pageInfo.getList().parallelStream().map(AppUserManageVo::getCityCode).collect(Collectors.toList());
HashSet<Integer> set = new HashSet<>(); HashSet<Integer> set = new HashSet<>();
......
...@@ -235,9 +235,9 @@ public class BaseUserMemberBiz extends BaseBiz<BaseUserMemberMapper,BaseUserMemb ...@@ -235,9 +235,9 @@ public class BaseUserMemberBiz extends BaseBiz<BaseUserMemberMapper,BaseUserMemb
}else if (baseUserMembers.size()==1){ }else if (baseUserMembers.size()==1){
if (baseUserMemberVO.getMemberLevel() == null || baseUserMember.getValidTime() == null ){ if (baseUserMemberVO.getMemberLevel() == null || baseUserMember.getValidTime() == null ){
baseUserMember.setIsDel(1); baseUserMember.setTotalNumber(0);
baseUserMember.setRentFreeDays(0);
}else { }else {
baseUserMember.setIsDel(0);
} }
baseUserMember.setUpdTime(System.currentTimeMillis()); baseUserMember.setUpdTime(System.currentTimeMillis());
baseUserMember.setBuyCount(baseUserMembers.get(0).getBuyCount()+1); baseUserMember.setBuyCount(baseUserMembers.get(0).getBuyCount()+1);
......
...@@ -95,8 +95,7 @@ ...@@ -95,8 +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},'%')
</if> </if>
...@@ -115,8 +114,6 @@ ...@@ -115,8 +114,6 @@
<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>
......
...@@ -100,16 +100,14 @@ public class AppVersionBiz extends BaseBiz<AppVersionMapper,AppVersion> { ...@@ -100,16 +100,14 @@ public class AppVersionBiz extends BaseBiz<AppVersionMapper,AppVersion> {
public ObjectRestResponse 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);
// Long no = redisTemplate.opsForValue().increment(redisNoKey); // Long no = redisTemplate.opsForValue().increment(redisNoKey);
// if(no.equals(1L)){ // if(no.equals(1L)){
// redisTemplate.expire(redisNoKey,1, TimeUnit.DAYS); // redisTemplate.expire(redisNoKey,1, TimeUnit.DAYS);
// } // }
String fileName = file.getOriginalFilename(); String fileName = file.getOriginalFilename();
String realFileRelPath = dirPathToday + File.separator+fileName.substring(fileName.lastIndexOf("/")); String realFileRelPath = dirPathToday + File.separator+fileName;
String filePath = uploadPath + realFileRelPath; String filePath = uploadPath + realFileRelPath;
FileUtils.copyInputStreamToFile(file.getInputStream(), new File(filePath)); FileUtils.copyInputStreamToFile(file.getInputStream(), new File(filePath));
return ObjectRestResponse.succ(filePath); return ObjectRestResponse.succ(filePath);
} }
......
...@@ -33,83 +33,87 @@ import org.springframework.web.multipart.MultipartFile; ...@@ -33,83 +33,87 @@ import org.springframework.web.multipart.MultipartFile;
import java.io.File; import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.List; import java.util.List;
@RestController @RestController
@RequestMapping("version") @RequestMapping("version")
@IgnoreClientToken @IgnoreClientToken
@Slf4j @Slf4j
public class AppVersionController extends BaseController<AppVersionBiz,AppVersion> { public class AppVersionController extends BaseController<AppVersionBiz, AppVersion> {
//最大上传500MB /**
private Long MAX_DRIVING_LICENSE_SIZE =1024*1024*500L; * 最大上传500MB
private int id; */
private Long MAX_DRIVING_LICENSE_SIZE = 1024 * 1024 * 500L;
@ApiModelProperty("app自动更新") @ApiModelProperty("app自动更新")
@RequestMapping(value ="/app/unauth/info",method = RequestMethod.GET) @RequestMapping(value = "/app/unauth/info", method = RequestMethod.GET)
@IgnoreUserToken @IgnoreUserToken
public ObjectRestResponse info( public ObjectRestResponse info(
@RequestParam(value = "type",defaultValue = "0") Integer type, @RequestParam(value = "type", defaultValue = "0") Integer type,
@RequestParam(value = "version",defaultValue = "") String version, @RequestParam(value = "version", defaultValue = "") String version,
@RequestParam(value = "isH5",defaultValue = "0") Integer isH5 @RequestParam(value = "isH5", defaultValue = "0") Integer isH5
){ ) {
ObjectRestResponse restResponse=null; ObjectRestResponse restResponse = null;
if (isH5!=null&&isH5==1){ if (isH5 != null && isH5 == 1) {
restResponse= baseBiz.getVersionH5(type); restResponse = baseBiz.getVersionH5(type);
}else { } else {
restResponse=baseBiz.getVersion(version,type); restResponse = baseBiz.getVersion(version, type);
} }
return restResponse; return restResponse;
} }
@Override @Override
@ApiOperation("添加") @ApiOperation("添加")
@RequestMapping(value = "/background/add",method = RequestMethod.POST) @RequestMapping(value = "/background/add", method = RequestMethod.POST)
public ObjectRestResponse<AppVersion> add(@RequestBody AppVersion appVersion){ public ObjectRestResponse<AppVersion> add(@RequestBody AppVersion appVersion) {
baseBiz.insertAppVersion(appVersion); baseBiz.insertAppVersion(appVersion);
return new ObjectRestResponse<AppVersion>(); return new ObjectRestResponse<AppVersion>();
} }
@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));
} }
@ApiOperation("查询所有") @ApiOperation("查询所有")
@RequestMapping(value = "/background/getAppVersions",method = RequestMethod.POST) @RequestMapping(value = "/background/getAppVersions", method = RequestMethod.POST)
public ObjectRestResponse<PageInfo<AppVersion>> getAppVersions(@RequestBody appVersionQuery query){ public ObjectRestResponse<PageInfo<AppVersion>> getAppVersions(@RequestBody appVersionQuery query) {
return ObjectRestResponse.succ(baseBiz.getAll(query)); return ObjectRestResponse.succ(baseBiz.getAll(query));
} }
@Override @Override
@ApiOperation("修改") @ApiOperation("修改")
@RequestMapping(value = "/background/update",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>();
} }
@ApiOperation("删除") @ApiOperation("删除")
@DeleteMapping(value = "/background/remove/{id}") @DeleteMapping(value = "/background/remove/{id}")
public ObjectRestResponse<AppVersion> remove(@PathVariable Integer id){ public ObjectRestResponse<AppVersion> remove(@PathVariable Integer id) {
baseBiz.remove(id); baseBiz.remove(id);
return new ObjectRestResponse<AppVersion>(); return new ObjectRestResponse<AppVersion>();
} }
@PostMapping(value = "/upload/installationPackage") @PostMapping(value = "/upload/installationPackage")
@ApiOperation(value = "上传app安装包") @ApiOperation(value = "上传app安装包")
public ObjectRestResponse uploadInstallationPackage(@RequestParam("file") MultipartFile file) public ObjectRestResponse uploadInstallationPackage(@RequestParam MultipartFile file)
throws Exception { throws Exception {
Assert.notNull(file);
//文件类型 //文件类型
String contentType = file.getContentType(); String contentType = file.getContentType();
log.debug("contentType"+contentType); String name = file.getOriginalFilename();
//判断上传的文件格式 String content = name.substring(name.lastIndexOf("."));
if (!judgeFormat(contentType)||file.getSize() > MAX_DRIVING_LICENSE_SIZE) { System.out.println("file.getSize()" + file.getSize());
System.out.println("content"+content);
System.out.println("contentType" + contentType);
//判断上传的文件格式
if (!judgeFormat(content) || file.getSize() > MAX_DRIVING_LICENSE_SIZE) {
return ObjectRestResponse.createDefaultFail(); return ObjectRestResponse.createDefaultFail();
} }
...@@ -117,8 +121,6 @@ public class AppVersionController extends BaseController<AppVersionBiz,AppVersio ...@@ -117,8 +121,6 @@ public class AppVersionController extends BaseController<AppVersionBiz,AppVersio
} }
@IgnoreUserToken @IgnoreUserToken
@GetMapping(value = "/download/installationPackage/{realFileRelPath}") //匹配的是href中的download请求 @GetMapping(value = "/download/installationPackage/{realFileRelPath}") //匹配的是href中的download请求
@ApiOperation(value = "下载app安装包") @ApiOperation(value = "下载app安装包")
...@@ -128,11 +130,12 @@ public class AppVersionController extends BaseController<AppVersionBiz,AppVersio ...@@ -128,11 +130,12 @@ public class AppVersionController extends BaseController<AppVersionBiz,AppVersio
/** /**
* 判断上传的文件格式 * 判断上传的文件格式
*
* @param contentType * @param contentType
* @return * @return
*/ */
private boolean judgeFormat(String contentType){ private boolean judgeFormat(String contentType) {
if (AppFormat.getFormatSet().size()==0) { if (AppFormat.getFormatSet().size() == 0) {
return true; return true;
} }
for (String format : AppFormat.getFormatSet()) { for (String format : AppFormat.getFormatSet()) {
......
...@@ -2,7 +2,7 @@ servlet: ...@@ -2,7 +2,7 @@ servlet:
multipart: multipart:
# 启用上传处理,默认是true # 启用上传处理,默认是true
enabled: true enabled: true
# 当上传文件达到1MB的时候进行磁盘写入 # 当上传文件达到20MB的时候进行磁盘写入
file-size-threshold: 20MB file-size-threshold: 20MB
# 设置最大的请求文件的大小 # 设置最大的请求文件的大小
max-request-size: 50MB max-request-size: 50MB
......
...@@ -9,7 +9,7 @@ servlet: ...@@ -9,7 +9,7 @@ servlet:
multipart: multipart:
# 启用上传处理,默认是true # 启用上传处理,默认是true
enabled: true enabled: true
# 当上传文件达到1MB的时候进行磁盘写入 # 当上传文件达到20MB的时候进行磁盘写入
file-size-threshold: 20MB file-size-threshold: 20MB
# 设置最大的请求文件的大小 # 设置最大的请求文件的大小
max-request-size: 50MB max-request-size: 50MB
......
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