-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
sync from oschina and isuue version v1.0
- Loading branch information
Showing
118 changed files
with
22,601 additions
and
164 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
112 changes: 112 additions & 0 deletions
112
oss-server/src/main/java/com/xiaominfo/oss/api/AppInfoApplication.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
/* | ||
* Copyright (C) 2018 Zhejiang xiaominfo Technology CO.,LTD. | ||
* All rights reserved. | ||
* Official Web Site: http://www.xiaominfo.com. | ||
* Developer Web Site: http://open.xiaominfo.com. | ||
*/ | ||
|
||
package com.xiaominfo.oss.api; | ||
|
||
import cn.hutool.core.util.ReUtil; | ||
import cn.hutool.core.util.StrUtil; | ||
import com.google.common.collect.Lists; | ||
import com.xiaominfo.oss.common.pojo.Pagination; | ||
import com.xiaominfo.oss.common.pojo.RestfulMessage; | ||
import com.xiaominfo.oss.exception.AssemblerException; | ||
import com.xiaominfo.oss.exception.ErrorCable; | ||
import com.xiaominfo.oss.exception.ErrorConstant; | ||
import com.xiaominfo.oss.module.model.OSSAppInfo; | ||
import com.xiaominfo.oss.service.OSSAppInfoService; | ||
import org.joda.time.DateTime; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
/*** | ||
* | ||
* @since:oss-server 1.0 | ||
* @author <a href="mailto:[email protected]">[email protected]</a> | ||
* 2018/06/17 19:53 | ||
*/ | ||
@RestController | ||
@RequestMapping("/oss/app") | ||
public class AppInfoApplication extends RootApis{ | ||
|
||
@Autowired | ||
OSSAppInfoService ossAppInfoService; | ||
|
||
@GetMapping("/queryByPage") | ||
public Pagination<OSSAppInfo> queryByPage(OSSAppInfo ossAppInfo, | ||
@RequestParam(value = "page",defaultValue = "1") Integer current_page, | ||
@RequestParam(value = "rows",defaultValue = "10") Integer page_size){ | ||
return ossAppInfoService.queryByPage(ossAppInfo,current_page,page_size); | ||
|
||
} | ||
|
||
@PostMapping("/queryById") | ||
public RestfulMessage queryById(String id){ | ||
RestfulMessage restfulMessage=new RestfulMessage(); | ||
try{ | ||
assertArgumentNotEmpty(id,"项目id不能为空"); | ||
restfulMessage.setData(ossAppInfoService.selectById(id)); | ||
successResultCode(restfulMessage); | ||
}catch (Exception e){ | ||
restfulMessage=wrapperException(e); | ||
} | ||
return restfulMessage; | ||
} | ||
|
||
@PostMapping("/delete") | ||
public RestfulMessage delete(String id){ | ||
RestfulMessage restfulMessage=new RestfulMessage(); | ||
try{ | ||
//验证邮箱 | ||
assertArgumentNotEmpty(id,"项目id不能为空"); | ||
String[] ids= StrUtil.split(id,","); | ||
ossAppInfoService.deleteBatchIds(Lists.newArrayList(ids)); | ||
successResultCode(restfulMessage); | ||
}catch (Exception e){ | ||
restfulMessage=wrapperException(e); | ||
} | ||
return restfulMessage; | ||
} | ||
|
||
|
||
@PostMapping("/merge") | ||
public RestfulMessage merge(OSSAppInfo ossAppInfo){ | ||
RestfulMessage restfulMessage=new RestfulMessage(); | ||
try{ | ||
//验证邮箱 | ||
assertArgumentNotEmpty(ossAppInfo.getName(),"项目名称不能为空"); | ||
assertArgumentNotEmpty(ossAppInfo.getCode(),"项目code不能为空"); | ||
assertArgumentNotEmpty(ossAppInfo.getDevId(),"开发者不能为空"); | ||
String regex="^.*?(\\\\|\\/|\\:|\\*|\\?|\\?|\\\"|\\“|\\”|\\>|\\<|\\|).*"; | ||
if (ReUtil.isMatch(regex,ossAppInfo.getCode())){ | ||
throw new AssemblerException(new ErrorCable(ErrorConstant.REQUEST_PARAMS_NOT_VALID,"项目code不能包含以下字符: / /: *?<>|")); | ||
} | ||
//不能包含\s字符 | ||
//不能包含中文 | ||
regex=".*?[\\u4e00-\\u9fa5\\s].*"; | ||
if (ReUtil.isMatch(regex,ossAppInfo.getCode())){ | ||
throw new AssemblerException(new ErrorCable(ErrorConstant.REQUEST_PARAMS_NOT_VALID,"项目code不能包含中文")); | ||
} | ||
//判断是否存在 | ||
if (ossAppInfoService.queryByCode(ossAppInfo.getCode())>0){ | ||
throw new AssemblerException(new ErrorCable(ErrorConstant.REQUEST_PARAMS_NOT_VALID,"项目code已经存在")); | ||
} | ||
if (StrUtil.isEmpty(ossAppInfo.getId())){ | ||
//insert | ||
ossAppInfo.setCreateTime(DateTime.now().toString("yyyy-MM-dd HH:mm:ss")); | ||
ossAppInfo.setUseSpace(0L); | ||
ossAppInfo.setUseSpaceStr("0kb"); | ||
ossAppInfoService.insert(ossAppInfo); | ||
}else{ | ||
ossAppInfoService.updateById(ossAppInfo); | ||
} | ||
successResultCode(restfulMessage); | ||
}catch (Exception e){ | ||
restfulMessage=wrapperException(e); | ||
} | ||
return restfulMessage; | ||
} | ||
|
||
} |
102 changes: 102 additions & 0 deletions
102
oss-server/src/main/java/com/xiaominfo/oss/api/DeveloperApplication.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
/* | ||
* Copyright (C) 2018 Zhejiang xiaominfo Technology CO.,LTD. | ||
* All rights reserved. | ||
* Official Web Site: http://www.xiaominfo.com. | ||
* Developer Web Site: http://open.xiaominfo.com. | ||
*/ | ||
|
||
package com.xiaominfo.oss.api; | ||
|
||
import cn.hutool.core.lang.PatternPool; | ||
import cn.hutool.core.util.ReUtil; | ||
import cn.hutool.core.util.StrUtil; | ||
import com.google.common.collect.Lists; | ||
import com.xiaominfo.oss.common.pojo.Pagination; | ||
import com.xiaominfo.oss.common.pojo.RestfulMessage; | ||
import com.xiaominfo.oss.module.model.OSSDeveloper; | ||
import com.xiaominfo.oss.service.OSSDeveloperService; | ||
import com.xiaominfo.oss.utils.RandomUtils; | ||
import org.joda.time.DateTime; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
/*** | ||
* | ||
* @since:oss-server 1.0 | ||
* @author <a href="mailto:[email protected]">[email protected]</a> | ||
* 2018/06/17 12:01 | ||
*/ | ||
@RestController | ||
@RequestMapping("/oss/developer") | ||
public class DeveloperApplication extends RootApis{ | ||
|
||
@Autowired | ||
OSSDeveloperService ossDeveloperService; | ||
|
||
|
||
@GetMapping("/queryByPage") | ||
public Pagination<OSSDeveloper> queryByPage(OSSDeveloper ossDeveloper, | ||
@RequestParam(value = "page",defaultValue = "1") Integer current_page, | ||
@RequestParam(value = "rows",defaultValue = "10") Integer page_size){ | ||
return ossDeveloperService.queryByPage(ossDeveloper,current_page,page_size); | ||
|
||
} | ||
|
||
@PostMapping("/queryById") | ||
public RestfulMessage queryById(String id){ | ||
RestfulMessage restfulMessage=new RestfulMessage(); | ||
try{ | ||
//验证邮箱 | ||
assertArgumentNotEmpty(id,"id不能为空"); | ||
restfulMessage.setData(ossDeveloperService.selectById(id)); | ||
successResultCode(restfulMessage); | ||
}catch (Exception e){ | ||
restfulMessage=wrapperException(e); | ||
} | ||
return restfulMessage; | ||
} | ||
|
||
@PostMapping("/delete") | ||
public RestfulMessage delete(String id){ | ||
RestfulMessage restfulMessage=new RestfulMessage(); | ||
try{ | ||
//验证邮箱 | ||
assertArgumentNotEmpty(id,"id不能为空"); | ||
String[] ids=StrUtil.split(id,","); | ||
ossDeveloperService.deleteBatchIds(Lists.newArrayList(ids)); | ||
successResultCode(restfulMessage); | ||
}catch (Exception e){ | ||
restfulMessage=wrapperException(e); | ||
} | ||
return restfulMessage; | ||
} | ||
|
||
|
||
@PostMapping("/merge") | ||
public RestfulMessage merge(OSSDeveloper ossDeveloper){ | ||
RestfulMessage restfulMessage=new RestfulMessage(); | ||
try{ | ||
//验证邮箱 | ||
assertArgumentNotEmpty(ossDeveloper.getName(),"开发者名称不能为空"); | ||
assertArgumentNotEmpty(ossDeveloper.getTel(),"手机号不能为空"); | ||
assertArgumentNotEmpty(ossDeveloper.getEmail(),"邮箱不能为空"); | ||
isTrue(ReUtil.isMatch(PatternPool.EMAIL,ossDeveloper.getEmail()),"邮箱格式非法"); | ||
if (StrUtil.isEmpty(ossDeveloper.getId())){ | ||
//insert | ||
ossDeveloper.setAppid("oss"+ RandomUtils.random(6)); | ||
ossDeveloper.setAppsecret(RandomUtils.random(8)); | ||
ossDeveloper.setStatus("0"); | ||
ossDeveloper.setCreateTime(DateTime.now().toString("yyyy-MM-dd HH:mm:ss")); | ||
ossDeveloper.setUseSpace(0L); | ||
ossDeveloper.setUseSpaceStr("0kb"); | ||
ossDeveloperService.insert(ossDeveloper); | ||
}else{ | ||
ossDeveloperService.updateById(ossDeveloper); | ||
} | ||
successResultCode(restfulMessage); | ||
}catch (Exception e){ | ||
restfulMessage=wrapperException(e); | ||
} | ||
return restfulMessage; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.