Commit 45e02a77 authored by 周健威's avatar 周健威

Merge remote-tracking branch 'origin/dev' into dev

parents ec10d672 746f44e3
...@@ -20,4 +20,14 @@ public class RandomListDto { ...@@ -20,4 +20,14 @@ public class RandomListDto {
*/ */
private Integer location; private Integer location;
/**
* 新闻类型
*/
private Integer newsType;
/**
* 新闻id
*/
private Integer newsId;
} }
...@@ -24,7 +24,7 @@ public class ArticleBiz extends BaseBiz<ArticleMapper, Article> { ...@@ -24,7 +24,7 @@ public class ArticleBiz extends BaseBiz<ArticleMapper, Article> {
/** /**
* 随机文章条数 * 随机文章条数
*/ */
private final Integer RANDOM_NUMBER = 3; private final Integer RANDOM_NUMBER = 2;
/** /**
* 首页文章条数 * 首页文章条数
...@@ -77,18 +77,18 @@ public class ArticleBiz extends BaseBiz<ArticleMapper, Article> { ...@@ -77,18 +77,18 @@ public class ArticleBiz extends BaseBiz<ArticleMapper, Article> {
* @param id * @param id
* @return * @return
*/ */
public List getThree( Integer type,Integer id) { public List getThree( Integer type, Integer number, Integer id) {
number = number == null ? RANDOM_NUMBER : number;
List<Article> articleList = mapper.getArticleList(type,null,id); List<Article> articleList = mapper.getArticleList(type,null,id);
if (!Objects.isNull(articleList)) { if (!Objects.isNull(articleList)) {
int size = articleList.size(); int size = articleList.size();
if (RANDOM_NUMBER >= size) { if (number >= size) {
return articleList; return articleList;
} else { } else {
Random random = new Random(); Random random = new Random();
int r = random.nextInt(size - RANDOM_NUMBER + 1); int r = random.nextInt(size - number + 1);
List<Article> result = new ArrayList<>(); List<Article> result = new ArrayList<>();
for (int i = 0; i < RANDOM_NUMBER.intValue(); i++) { for (int i = 0; i < number.intValue(); i++) {
int index = i + r; int index = i + r;
result.add(articleList.get(index)); result.add(articleList.get(index));
} }
......
...@@ -37,7 +37,7 @@ public class RandomListBiz { ...@@ -37,7 +37,7 @@ public class RandomListBiz {
* @param number 随机数,默认是2 * @param number 随机数,默认是2
* @return * @return
*/ */
public ObjectRestResponse getRandomList(Integer type, Integer number, Integer location) { public ObjectRestResponse getRandomList(Integer type, Integer number, Integer location, Integer id, Integer newsType) {
if(type != null) { if(type != null) {
number = number == null ? 2 : number; number = number == null ? 2 : number;
switch (TypeEnum.getByValue(type)) { switch (TypeEnum.getByValue(type)) {
...@@ -50,7 +50,7 @@ public class RandomListBiz { ...@@ -50,7 +50,7 @@ public class RandomListBiz {
case ACTIVITY: case ACTIVITY:
return ObjectRestResponse.succ(summitActivityBiz.getHostWithSummitActivity(number, location)); return ObjectRestResponse.succ(summitActivityBiz.getHostWithSummitActivity(number, location));
case NEWS: case NEWS:
return ObjectRestResponse.succ(articleBiz.getThree(type, number, id));
} }
} }
return ObjectRestResponse.succ(); return ObjectRestResponse.succ();
......
...@@ -37,15 +37,19 @@ public class ArticleController extends BaseController<ArticleBiz, Article> { ...@@ -37,15 +37,19 @@ public class ArticleController extends BaseController<ArticleBiz, Article> {
} }
/** /**
* * 随机获取三条数据
* @param type * @param type
* @param id 当前文章id * @param number
* @param id
* @return * @return
*/ */
@GetMapping("/app/unauth/three/{type}/{id}") @GetMapping("/app/unauth/three")
@ApiOperation(value = "随机获取三条数据") @ApiOperation(value = "随机获取三条数据")
public ObjectRestResponse randomAccessToThreeData(@PathVariable Integer type,@PathVariable Integer id){ public ObjectRestResponse randomAccessToThreeData(@RequestParam("type") Integer type,
return ObjectRestResponse.succ(baseBiz.getThree(type,id)); @RequestParam("number") Integer number,
@RequestParam("id") Integer id
){
return ObjectRestResponse.succ(baseBiz.getThree(type,number,id));
} }
@GetMapping("/app/unauth/homePage/{type}") @GetMapping("/app/unauth/homePage/{type}")
......
...@@ -19,7 +19,7 @@ public class RandomListController { ...@@ -19,7 +19,7 @@ public class RandomListController {
if(randomListDto == null) { if(randomListDto == null) {
return ObjectRestResponse.paramIsEmpty(); return ObjectRestResponse.paramIsEmpty();
} }
return randomListBiz.getRandomList(randomListDto.getType(), randomListDto.getNumber(), randomListDto.getLocation()); return randomListBiz.getRandomList(randomListDto.getType(), randomListDto.getNumber(), randomListDto.getLocation(), randomListDto.getNewsId(), randomListDto.getNewsType());
} }
} }
...@@ -195,21 +195,26 @@ public class SmsService { ...@@ -195,21 +195,26 @@ public class SmsService {
try { try {
JSONObject jsonParams=new JSONObject(); JSONObject jsonParams=new JSONObject();
for (int i=0;i<params.length;i++){ for (int i=0;i<params.length;i++){
jsonParams.put(param+(i+1),params[i]); String para=params[i];
if (para.contains("【")){
para=para.replaceAll("【","");
}
if (para.contains("】")){
para=para.replaceAll("】","");
}
jsonParams.put(param+(i+1),para);
} }
sendTemplate(PhoneNumbers,jsonParams.toJSONString(),templateCode); sendTemplate(PhoneNumbers,jsonParams.toJSONString(),templateCode);
}catch (Exception e){ }catch (Exception e){
e.printStackTrace(); e.printStackTrace();
} }
} }
public static void main(String[] args) throws ClientException, InterruptedException { public static void main(String[] args) throws ClientException, InterruptedException {
SmsService smsService=new SmsService(); SmsService smsService=new SmsService();
//发短信 //发短信
String[] params={"1","2","3","2019-08-29","松山湖"}; String[] params={"1","2","3","2019-08-29","【松山湖】"};
SmsService.sendTemplateToJson("13612688539,13265487972",params,"SMS_169904346"); SmsService.sendTemplateToJson("13612688539,13265487972",params,"SMS_169904346");
/*System.out.println("短信接口返回的数据----------------"); /*System.out.println("短信接口返回的数据----------------");
System.out.println("Code=" + response.getCode()); System.out.println("Code=" + response.getCode());
......
...@@ -27,6 +27,9 @@ public class FileUploadServiceImpl implements FileUploadService { ...@@ -27,6 +27,9 @@ public class FileUploadServiceImpl implements FileUploadService {
@Value("${universal.url}") @Value("${universal.url}")
private String xx_url ; private String xx_url ;
private static final String APK_SUFFIX=".apk";
private static final String APK_NAME="xxfc.apk";
@Override @Override
public ObjectRestResponse handlerUpload(MultipartFile zipFile,String password,String prefix)throws Exception { public ObjectRestResponse handlerUpload(MultipartFile zipFile,String password,String prefix)throws Exception {
if (null == zipFile) { if (null == zipFile) {
...@@ -63,7 +66,18 @@ public class FileUploadServiceImpl implements FileUploadService { ...@@ -63,7 +66,18 @@ public class FileUploadServiceImpl implements FileUploadService {
String path=readZipFile(packFilePath); String path=readZipFile(packFilePath);
if (StringUtils.isNotBlank(path)){ if (StringUtils.isNotBlank(path)){
String filename = path;
path=xx_url+"/"+prefix+"/"+path; path=xx_url+"/"+prefix+"/"+path;
log.info("文件名:{}",path);
if (filename.contains(APK_SUFFIX)){
Runtime runtime = Runtime.getRuntime();
log.info("执行删除xxfc.apk");
//删除包
runtime.exec("rm -rf "+uploadPath+"/"+APK_NAME);
log.info("执行复制上传包为xxfc.apk");
//复制包
runtime.exec("cp -f "+uploadPath+"/"+filename+" "+uploadPath+"/"+APK_NAME);
}
return ObjectRestResponse.succ(path); return ObjectRestResponse.succ(path);
}else { }else {
return ObjectRestResponse.createDefaultFail(); return ObjectRestResponse.createDefaultFail();
......
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