Commit 87359b1f authored by hezhen's avatar hezhen

Merge branch 'master_activity' of...

Merge branch 'master_activity' of http://113.105.137.151:22280/youjj/cloud-platform into master_activity
parents daad9ea5 5a497965
......@@ -10,6 +10,7 @@ public class ActivityQuery extends Query {
private String title;
private Long startTime;
private Integer status;
/**
* 1.管理后台,2.h5页面
*/
......
package com.xxfc.platform.summit.pojo;
public enum SummitStatus {
ENROLL("报名中",1),IN_PROGRESS("进行中",2),End("已结束",3);
private String msg;
private Integer code;
SummitStatus(String msg, Integer code) {
this.msg = msg;
this.code = code;
}
public String getMsg() {
return msg;
}
public Integer getCode() {
return code;
}
}
......@@ -7,6 +7,7 @@ import com.xxfc.platform.summit.entity.Activity;
import com.xxfc.platform.summit.mapper.ActivityMapper;
import com.xxfc.platform.summit.pojo.AccessType;
import com.xxfc.platform.summit.pojo.ActivityQuery;
import com.xxfc.platform.summit.pojo.SummitStatus;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
......@@ -35,31 +36,41 @@ public class ActivityBiz extends BaseBiz<ActivityMapper, Activity> {
public Object getList(ActivityQuery query) {
Example exa = new Example(Activity.class);
Example.Criteria criteria = exa.createCriteria();
criteria.andEqualTo("isDel", NOT_DELETE);
if (StringUtils.isNotBlank(query.getTitle())) {
criteria.andLike("title", String.format("%%%s%%", query.getTitle().trim()));
}
if (query.getStartTime() != null) {
criteria.andLike("startTime", query.getStartTime()/(1000*60*60)+"%");
}
if (query.getStatus() != null) {
criteria.andEqualTo("status", query.getStatus());
}
if (query.getType() != null && AccessType.PUBLIC.getCode().equals(query.getType())) {
criteria.andEqualTo("isPublish", PUBLISHED);
}
exa.orderBy("rank").asc().orderBy("startTime").desc();
// if (AccessType.PUBLIC.getCode().equals(query.getType())) {
//// return mapper.selectByExample(exa);
//// }
// Example exa = new Example(Activity.class);
// Example.Criteria criteria = exa.createCriteria();
// criteria.andEqualTo("isDel", NOT_DELETE);
// if (StringUtils.isNotBlank(query.getTitle())) {
// criteria.andLike("title", String.format("%%%s%%", query.getTitle().trim()));
// }
// if (query.getStartTime() != null) {
// criteria.andLike("startTime", query.getStartTime() / (1000 * 60 * 60) + "%");
// }
// if (query.getStatus() != null) {
// criteria.andEqualTo("status", query.getStatus());
// switch (query.getStatus()) {
// case 1:
//
// criteria.orLessThan("startTime", System.currentTimeMillis());
// break;
// case 2:
// criteria.orBetween("startTime", System.currentTimeMillis(),"endTime");
// break;
// case 3:
// criteria.orGreaterThan("endTime", System.currentTimeMillis());
// break;
// default:
// throw new IllegalStateException("Unexpected value: " + query.getStatus());
// }
// }
//
// if (query.getType() != null && AccessType.PUBLIC.getCode().equals(query.getType())) {
// criteria.andEqualTo("isPublish", PUBLISHED);
// }
// exa.orderBy("rank").asc().orderBy("startTime").desc();
PageHelper.startPage(query.getPage(), query.getLimit());
List<Activity> activities = mapper.selectByExample(exa);
List<Activity> activities = mapper.selectByQuery (query);
return new PageInfo<Activity>(activities);
}
......
......@@ -15,7 +15,7 @@ import org.springframework.web.bind.annotation.*;
@RestController
@RequestMapping("/activityShow")
public class ActivityShowController extends BaseController<ActivityShowBiz, ActivityShow> {
@GetMapping("/one/{activityId}")
@GetMapping("/app/unauth/one/{activityId}")
public ObjectRestResponse getOne(@PathVariable Integer activityId){
return ObjectRestResponse.succ(baseBiz.getOne(activityId));
}
......@@ -28,4 +28,6 @@ public class ActivityShowController extends BaseController<ActivityShowBiz, Acti
}
return ObjectRestResponse.createDefaultFail();
}
}
......@@ -2,7 +2,11 @@ package com.xxfc.platform.summit.mapper;
import com.xxfc.platform.summit.entity.Activity;
import com.xxfc.platform.summit.pojo.ActivityQuery;
import tk.mybatis.mapper.common.Mapper;
import tk.mybatis.mapper.entity.Example;
import java.util.List;
/**
......@@ -10,4 +14,5 @@ import tk.mybatis.mapper.common.Mapper;
*/
public interface ActivityMapper extends Mapper<Activity> {
List<Activity> selectByQuery(ActivityQuery query);
}
......@@ -79,9 +79,11 @@ public class AccessTokenService {
* @return String accessToken
*/
public String getAccessTokenStr() {
return getAccessToken().getAccessToken();
// return getAccessToken().getAccessToken();
return null;
}
/**
* 强制更新 access token 值
*/
......@@ -100,7 +102,7 @@ public class AccessTokenService {
obj.put(wy_appid, result);
Boolean suc=summbitRedisTemplate.opsForValue().setIfAbsent(wy_appid, obj.toJSONString());
if (suc) {
summbitRedisTemplate.expire(wy_appid, result.getExpiresIn(), TimeUnit.MINUTES);
// summbitRedisTemplate.expire(wy_appid, result.getExpiresIn(), TimeUnit.MINUTES);
}
}
}
\ No newline at end of file
......@@ -2,4 +2,31 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.xxfc.platform.summit.mapper.ActivityMapper">
<select id="selectByQuery" resultType="com.xxfc.platform.summit.entity.Activity"
parameterType="com.xxfc.platform.summit.pojo.ActivityQuery">
select * from fc_activity
where
is_del=0
<if test="title != null and title.trim() != '' ">
and title like CONCAT('%',#{title},'%')
</if>
<if test="startTime != null">
and from_unixtime(start_time,'%Y-%m-%e %H')=from_unixtime(unix_timestamp(), '%Y-%m-%e %H')
</if>
<if test="status != null and status == 1">
and (status=#{status} or (status=0 and (start_time/1000) &gt;= unix_timestamp()) )
</if>
<if test="status != null and status == 2">
and (status=#{status} or (status=0 and (start_time/1000) &lt; unix_timestamp() and (end_time/1000)&gt;=unix_timestamp()))
</if>
<if test="status != null and status == 3">
and (status=#{status} or (status=0 and (end_time/1000)&lt;unix_timestamp()))
</if>
<if test="type ==2">
and is_publish=1
and is_show=1
</if>
order by rank asc , start_time desc
</select>
</mapper>
\ No newline at end of file
......@@ -98,4 +98,9 @@ public class RedisKey {
public static final String CACHE_DICTIONARY_ALL =CACHE_DICTIONARY_PREFIX + "all:";
public static final String CACHE_DICTIONARY_ALL_MAP =CACHE_DICTIONARY_ALL + "map:";
public static final String ILLEGAL_VEHICLE_ENQUIRIES ="cache:violation";
/**
* 服务器上传压缩包文件序号
*/
public static final String UPLOAD_ZIP_NO_PREFIX ="upload:zip:no:";
}
......@@ -8,7 +8,9 @@ import lombok.NoArgsConstructor;
@NoArgsConstructor
public enum FileTypeEnum {
FILE_TYPE_ZIP("application/zip", ".zip"),
FILE_TYPE_RAR("application/octet-stream", ".rar");
FILE_TYPE_RAR("application/octet-stream", ".rar"),
FILE_TYPE_X_ZIP("application/x-zip-compressed", ".zip");
public String type;
public String fileStufix;
......
......@@ -8,6 +8,7 @@ import com.xxfc.platform.universal.dto.ImgDTO;
import com.xxfc.platform.universal.dto.UploadImgDTO;
import com.xxfc.platform.universal.service.FileUploadService;
import com.xxfc.platform.universal.service.UploadService;
import com.xxfc.platform.universal.service.UploadZipService;
import com.xxfc.platform.universal.utils.ImgBase64Util;
import com.xxfc.platform.universal.utils.PublicMsg;
import com.xxfc.platform.universal.vo.Ueditor;
......@@ -42,6 +43,8 @@ public class UploadController{
UploadService uploadService;
@Autowired
FileUploadService fileUploadService;
@Autowired
UploadZipService uploadZipService;
private static Integer MAX_DRIVING_LICENSE_SIZE = 10 * 1024 * 1024;//10M
......@@ -180,9 +183,9 @@ public class UploadController{
@PostMapping(value="/app/unauth/pictureZip")
public ObjectRestResponse pictureZip(
@RequestParam("file")MultipartFile upfile,
@RequestParam(value = "prefix",defaultValue = "renovate")String prefix) throws Exception {
return fileUploadService.handlerUpload(upfile,null,prefix);
@RequestParam("file")MultipartFile file,
@RequestParam(value = "prefix",defaultValue = "summit")String prefix) throws Exception {
return uploadZipService.uploadPictureZip(file,prefix);
}
}
package com.xxfc.platform.universal.service;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import net.lingala.zip4j.exception.ZipException;
import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;
public interface UploadZipService {
ObjectRestResponse uploadPictureZip(MultipartFile file, String prefix) throws IOException;
}
......@@ -102,7 +102,4 @@ public class FileUploadServiceImpl implements FileUploadService {
zin.closeEntry();
return path;
}
}
package com.xxfc.platform.universal.service.impl;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.util.process.ResultCode;
import com.github.wxiaoqi.security.common.util.process.SystemConfig;
import com.xxfc.platform.universal.constant.RedisKey;
import com.xxfc.platform.universal.constant.enumerate.FileTypeEnum;
import com.xxfc.platform.universal.service.UploadZipService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.FileUtils;
import org.codehaus.plexus.util.IOUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import java.io.*;
import java.nio.charset.Charset;
import java.util.Enumeration;
import java.util.Objects;
import java.util.concurrent.TimeUnit;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
@Slf4j
@Service
public class UploadZipServiceImpl implements UploadZipService {
@Value("${universal.uploadPath}")
private String uploadPath ;
@Value("${universal.url}")
private String xx_url ;
@Value("${photo.format}")
private String PHOTO_FORMAT=".png/.jpg/.git/.bmp";
@Autowired
RedisTemplate redisTemplate;
@Override
public ObjectRestResponse uploadPictureZip(MultipartFile uFile, String prefix) throws IOException {
if (Objects.isNull(uFile)) {
return ObjectRestResponse.createFailedResult(ResultCode.FAILED_CODE,"请上传压缩文件!");
}
String fileContentType = uFile.getContentType();
//将压缩包保存在指定路径
String packFilePath = uploadPath + File.separator + uFile.getName();
if (FileTypeEnum.FILE_TYPE_ZIP.type.equals(fileContentType)||FileTypeEnum.FILE_TYPE_X_ZIP.type.equals(fileContentType)) {
//zip解压缩处理
packFilePath += FileTypeEnum.FILE_TYPE_ZIP.fileStufix;
} else {
return ObjectRestResponse.createFailedResult(ResultCode.FAILED_CODE,"上传的压缩包格式不正确,仅支持zip压缩文件!");
}
File file = new File(packFilePath);
try {
//保存压缩包
FileOutputStream os = new FileOutputStream(file);
IOUtil.copy(uFile.getInputStream(),os);
os.close();
} catch (IOException e) {
log.error("zip file save to " + uploadPath + " error", e.getMessage(), e);
return ObjectRestResponse.createFailedResult(ResultCode.FAILED_CODE,"保存压缩文件到:" + uploadPath + " 失败!");
}
//zip压缩包解压
return unPackZip(file, prefix);
}
public ObjectRestResponse<String> unPackZip(File file, String prefix) throws IOException {
ZipFile zipFile = new ZipFile(file, Charset.forName("GBK"));
Enumeration<? extends ZipEntry> entries = zipFile.entries();
long millis = System.currentTimeMillis();
String dirPathToday = prefix+ File.separator + millis;
String redisNoKey = RedisKey.UPLOAD_FILE_NO_PREFIX +millis;
StringBuffer result = new StringBuffer();
Integer index = 0;
while (entries.hasMoreElements()) {
ZipEntry entry = entries.nextElement();
if (entry.isDirectory() && index++ == 0) {
File dir = new File(uploadPath+dirPathToday);
dir.mkdir();
} else if (!entry.isDirectory()) {
Long no = redisTemplate.opsForValue().increment(redisNoKey);
if(no.equals(1l)){
redisTemplate.expire(redisNoKey,1, TimeUnit.DAYS);
}
String name = entry.getName();
String format = name.substring(name.lastIndexOf("."));
if (PHOTO_FORMAT.contains(format)) {
String realFileRelPath = dirPathToday + File.separator + no +format;
File targetFile = new File(uploadPath+realFileRelPath);
FileUtils.copyInputStreamToFile(zipFile.getInputStream(entry),targetFile);
realFileRelPath=xx_url+ SystemConfig.XXMP_URL+realFileRelPath;
result.append(realFileRelPath+",");
}
}
}
return ObjectRestResponse.succ(result.substring(0, result.length()-1));
}
}
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