Skip to content

Commit 4d5b35d

Browse files
committed
sync from oschina and isuue version v1.0
1 parent b9dede9 commit 4d5b35d

File tree

118 files changed

+22601
-164
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

118 files changed

+22601
-164
lines changed

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
# oss-server
1+
![](https://static.oschina.net/uploads/img/201806/18222124_VR9L.png)
2+
3+
**项目文档地址:http://oss-server.mydoc.io**
4+
5+
**oss-server项目交流群:608374991**
26

37
## 项目介绍
48

oss-server/pom.xml

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
<groupId>com.xiaominfo.oss</groupId>
77
<artifactId>oss-server</artifactId>
8-
<version>0.0.1-SNAPSHOT</version>
8+
<version>1.0</version>
99
<packaging>jar</packaging>
1010
<name>oss-server</name>
1111
<description>oss-server上传组件,该组件为项目服务,可单独部署迁移</description>
@@ -43,7 +43,10 @@
4343
<groupId>org.springframework.boot</groupId>
4444
<artifactId>spring-boot-starter-web</artifactId>
4545
</dependency>
46-
46+
<dependency>
47+
<groupId>org.springframework.boot</groupId>
48+
<artifactId>spring-boot-starter-aop</artifactId>
49+
</dependency>
4750
<dependency>
4851
<groupId>org.springframework.boot</groupId>
4952
<artifactId>spring-boot-starter-test</artifactId>
@@ -134,6 +137,31 @@
134137
<artifactId>hutool-all</artifactId>
135138
<version>4.0.7</version>
136139
</dependency>
140+
<!-- https://mvnrepository.com/artifact/com.alibaba/druid -->
141+
<dependency>
142+
<groupId>com.alibaba</groupId>
143+
<artifactId>druid</artifactId>
144+
<version>1.1.9</version>
145+
</dependency>
146+
<!-- https://mvnrepository.com/artifact/org.xerial/sqlite-jdbc -->
147+
<dependency>
148+
<groupId>org.xerial</groupId>
149+
<artifactId>sqlite-jdbc</artifactId>
150+
<version>3.21.0.1</version>
151+
</dependency>
152+
<!-- https://mvnrepository.com/artifact/com.baomidou/mybatisplus-spring-boot-starter -->
153+
<dependency>
154+
<groupId>com.baomidou</groupId>
155+
<artifactId>mybatisplus-spring-boot-starter</artifactId>
156+
<version>1.0.5</version>
157+
</dependency>
158+
159+
<!-- https://mvnrepository.com/artifact/com.baomidou/mybatis-plus -->
160+
<dependency>
161+
<groupId>com.baomidou</groupId>
162+
<artifactId>mybatis-plus</artifactId>
163+
<version>2.1.9</version>
164+
</dependency>
137165
</dependencies>
138166

139167
<build>
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
/*
2+
* Copyright (C) 2018 Zhejiang xiaominfo Technology CO.,LTD.
3+
* All rights reserved.
4+
* Official Web Site: http://www.xiaominfo.com.
5+
* Developer Web Site: http://open.xiaominfo.com.
6+
*/
7+
8+
package com.xiaominfo.oss.api;
9+
10+
import cn.hutool.core.util.ReUtil;
11+
import cn.hutool.core.util.StrUtil;
12+
import com.google.common.collect.Lists;
13+
import com.xiaominfo.oss.common.pojo.Pagination;
14+
import com.xiaominfo.oss.common.pojo.RestfulMessage;
15+
import com.xiaominfo.oss.exception.AssemblerException;
16+
import com.xiaominfo.oss.exception.ErrorCable;
17+
import com.xiaominfo.oss.exception.ErrorConstant;
18+
import com.xiaominfo.oss.module.model.OSSAppInfo;
19+
import com.xiaominfo.oss.service.OSSAppInfoService;
20+
import org.joda.time.DateTime;
21+
import org.springframework.beans.factory.annotation.Autowired;
22+
import org.springframework.web.bind.annotation.*;
23+
24+
/***
25+
*
26+
* @since:oss-server 1.0
27+
* @author <a href="mailto:[email protected]">[email protected]</a>
28+
* 2018/06/17 19:53
29+
*/
30+
@RestController
31+
@RequestMapping("/oss/app")
32+
public class AppInfoApplication extends RootApis{
33+
34+
@Autowired
35+
OSSAppInfoService ossAppInfoService;
36+
37+
@GetMapping("/queryByPage")
38+
public Pagination<OSSAppInfo> queryByPage(OSSAppInfo ossAppInfo,
39+
@RequestParam(value = "page",defaultValue = "1") Integer current_page,
40+
@RequestParam(value = "rows",defaultValue = "10") Integer page_size){
41+
return ossAppInfoService.queryByPage(ossAppInfo,current_page,page_size);
42+
43+
}
44+
45+
@PostMapping("/queryById")
46+
public RestfulMessage queryById(String id){
47+
RestfulMessage restfulMessage=new RestfulMessage();
48+
try{
49+
assertArgumentNotEmpty(id,"项目id不能为空");
50+
restfulMessage.setData(ossAppInfoService.selectById(id));
51+
successResultCode(restfulMessage);
52+
}catch (Exception e){
53+
restfulMessage=wrapperException(e);
54+
}
55+
return restfulMessage;
56+
}
57+
58+
@PostMapping("/delete")
59+
public RestfulMessage delete(String id){
60+
RestfulMessage restfulMessage=new RestfulMessage();
61+
try{
62+
//验证邮箱
63+
assertArgumentNotEmpty(id,"项目id不能为空");
64+
String[] ids= StrUtil.split(id,",");
65+
ossAppInfoService.deleteBatchIds(Lists.newArrayList(ids));
66+
successResultCode(restfulMessage);
67+
}catch (Exception e){
68+
restfulMessage=wrapperException(e);
69+
}
70+
return restfulMessage;
71+
}
72+
73+
74+
@PostMapping("/merge")
75+
public RestfulMessage merge(OSSAppInfo ossAppInfo){
76+
RestfulMessage restfulMessage=new RestfulMessage();
77+
try{
78+
//验证邮箱
79+
assertArgumentNotEmpty(ossAppInfo.getName(),"项目名称不能为空");
80+
assertArgumentNotEmpty(ossAppInfo.getCode(),"项目code不能为空");
81+
assertArgumentNotEmpty(ossAppInfo.getDevId(),"开发者不能为空");
82+
String regex="^.*?(\\\\|\\/|\\:|\\*|\\?|\\?|\\\"|\\“|\\”|\\>|\\<|\\|).*";
83+
if (ReUtil.isMatch(regex,ossAppInfo.getCode())){
84+
throw new AssemblerException(new ErrorCable(ErrorConstant.REQUEST_PARAMS_NOT_VALID,"项目code不能包含以下字符: / /: *?<>|"));
85+
}
86+
//不能包含\s字符
87+
//不能包含中文
88+
regex=".*?[\\u4e00-\\u9fa5\\s].*";
89+
if (ReUtil.isMatch(regex,ossAppInfo.getCode())){
90+
throw new AssemblerException(new ErrorCable(ErrorConstant.REQUEST_PARAMS_NOT_VALID,"项目code不能包含中文"));
91+
}
92+
//判断是否存在
93+
if (ossAppInfoService.queryByCode(ossAppInfo.getCode())>0){
94+
throw new AssemblerException(new ErrorCable(ErrorConstant.REQUEST_PARAMS_NOT_VALID,"项目code已经存在"));
95+
}
96+
if (StrUtil.isEmpty(ossAppInfo.getId())){
97+
//insert
98+
ossAppInfo.setCreateTime(DateTime.now().toString("yyyy-MM-dd HH:mm:ss"));
99+
ossAppInfo.setUseSpace(0L);
100+
ossAppInfo.setUseSpaceStr("0kb");
101+
ossAppInfoService.insert(ossAppInfo);
102+
}else{
103+
ossAppInfoService.updateById(ossAppInfo);
104+
}
105+
successResultCode(restfulMessage);
106+
}catch (Exception e){
107+
restfulMessage=wrapperException(e);
108+
}
109+
return restfulMessage;
110+
}
111+
112+
}
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
/*
2+
* Copyright (C) 2018 Zhejiang xiaominfo Technology CO.,LTD.
3+
* All rights reserved.
4+
* Official Web Site: http://www.xiaominfo.com.
5+
* Developer Web Site: http://open.xiaominfo.com.
6+
*/
7+
8+
package com.xiaominfo.oss.api;
9+
10+
import cn.hutool.core.lang.PatternPool;
11+
import cn.hutool.core.util.ReUtil;
12+
import cn.hutool.core.util.StrUtil;
13+
import com.google.common.collect.Lists;
14+
import com.xiaominfo.oss.common.pojo.Pagination;
15+
import com.xiaominfo.oss.common.pojo.RestfulMessage;
16+
import com.xiaominfo.oss.module.model.OSSDeveloper;
17+
import com.xiaominfo.oss.service.OSSDeveloperService;
18+
import com.xiaominfo.oss.utils.RandomUtils;
19+
import org.joda.time.DateTime;
20+
import org.springframework.beans.factory.annotation.Autowired;
21+
import org.springframework.web.bind.annotation.*;
22+
23+
/***
24+
*
25+
* @since:oss-server 1.0
26+
* @author <a href="mailto:[email protected]">[email protected]</a>
27+
* 2018/06/17 12:01
28+
*/
29+
@RestController
30+
@RequestMapping("/oss/developer")
31+
public class DeveloperApplication extends RootApis{
32+
33+
@Autowired
34+
OSSDeveloperService ossDeveloperService;
35+
36+
37+
@GetMapping("/queryByPage")
38+
public Pagination<OSSDeveloper> queryByPage(OSSDeveloper ossDeveloper,
39+
@RequestParam(value = "page",defaultValue = "1") Integer current_page,
40+
@RequestParam(value = "rows",defaultValue = "10") Integer page_size){
41+
return ossDeveloperService.queryByPage(ossDeveloper,current_page,page_size);
42+
43+
}
44+
45+
@PostMapping("/queryById")
46+
public RestfulMessage queryById(String id){
47+
RestfulMessage restfulMessage=new RestfulMessage();
48+
try{
49+
//验证邮箱
50+
assertArgumentNotEmpty(id,"id不能为空");
51+
restfulMessage.setData(ossDeveloperService.selectById(id));
52+
successResultCode(restfulMessage);
53+
}catch (Exception e){
54+
restfulMessage=wrapperException(e);
55+
}
56+
return restfulMessage;
57+
}
58+
59+
@PostMapping("/delete")
60+
public RestfulMessage delete(String id){
61+
RestfulMessage restfulMessage=new RestfulMessage();
62+
try{
63+
//验证邮箱
64+
assertArgumentNotEmpty(id,"id不能为空");
65+
String[] ids=StrUtil.split(id,",");
66+
ossDeveloperService.deleteBatchIds(Lists.newArrayList(ids));
67+
successResultCode(restfulMessage);
68+
}catch (Exception e){
69+
restfulMessage=wrapperException(e);
70+
}
71+
return restfulMessage;
72+
}
73+
74+
75+
@PostMapping("/merge")
76+
public RestfulMessage merge(OSSDeveloper ossDeveloper){
77+
RestfulMessage restfulMessage=new RestfulMessage();
78+
try{
79+
//验证邮箱
80+
assertArgumentNotEmpty(ossDeveloper.getName(),"开发者名称不能为空");
81+
assertArgumentNotEmpty(ossDeveloper.getTel(),"手机号不能为空");
82+
assertArgumentNotEmpty(ossDeveloper.getEmail(),"邮箱不能为空");
83+
isTrue(ReUtil.isMatch(PatternPool.EMAIL,ossDeveloper.getEmail()),"邮箱格式非法");
84+
if (StrUtil.isEmpty(ossDeveloper.getId())){
85+
//insert
86+
ossDeveloper.setAppid("oss"+ RandomUtils.random(6));
87+
ossDeveloper.setAppsecret(RandomUtils.random(8));
88+
ossDeveloper.setStatus("0");
89+
ossDeveloper.setCreateTime(DateTime.now().toString("yyyy-MM-dd HH:mm:ss"));
90+
ossDeveloper.setUseSpace(0L);
91+
ossDeveloper.setUseSpaceStr("0kb");
92+
ossDeveloperService.insert(ossDeveloper);
93+
}else{
94+
ossDeveloperService.updateById(ossDeveloper);
95+
}
96+
successResultCode(restfulMessage);
97+
}catch (Exception e){
98+
restfulMessage=wrapperException(e);
99+
}
100+
return restfulMessage;
101+
}
102+
}

oss-server/src/main/java/com/xiaominfo/oss/api/IndexApplication.java

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,16 @@
99

1010
import cn.hutool.core.util.StrUtil;
1111
import com.google.common.collect.ImmutableMap;
12+
import com.xiaominfo.oss.common.annotation.NotLogin;
13+
import com.xiaominfo.oss.common.conf.Consts;
14+
import com.xiaominfo.oss.common.pojo.RestfulMessage;
15+
import com.xiaominfo.oss.exception.ErrorConstant;
1216
import org.springframework.beans.factory.annotation.Value;
1317
import org.springframework.stereotype.Controller;
1418
import org.springframework.ui.Model;
1519
import org.springframework.web.bind.annotation.GetMapping;
1620
import org.springframework.web.bind.annotation.PostMapping;
21+
import org.springframework.web.bind.annotation.ResponseBody;
1722

1823
import javax.servlet.http.HttpServletRequest;
1924

@@ -24,7 +29,7 @@
2429
* 2018/06/11 14:25
2530
*/
2631
@Controller
27-
public class IndexApplication {
32+
public class IndexApplication extends RootApis{
2833

2934
@Value(value = "${oss.security.userName}")
3035
private String userN;
@@ -35,22 +40,34 @@ public class IndexApplication {
3540

3641
@GetMapping(value = {"/","/index"})
3742
public String index(){
38-
return "redirect:/oss/list/";
43+
return "index";
3944
}
4045

4146

47+
@NotLogin
4248
@GetMapping("/login")
4349
public String login(){
4450
return "login";
4551
}
4652

53+
@GetMapping("/exit")
54+
public String exit(HttpServletRequest request){
55+
request.getSession().removeAttribute(Consts.Admin_User_Session);
56+
return "login";
57+
}
58+
59+
@NotLogin
4760
@PostMapping("/login")
48-
public String loginValidate(String username, String password, Model model, HttpServletRequest request){
61+
@ResponseBody
62+
public RestfulMessage loginValidate(String username, String password, Model model, HttpServletRequest request){
63+
RestfulMessage r=new RestfulMessage();
4964
if (StrUtil.equalsIgnoreCase(username,userN)&&StrUtil.equalsIgnoreCase(password,passwd)){
50-
request.getSession().setAttribute("USER", ImmutableMap.of("userName",username));
51-
return "redirect:/oss/list/";
65+
request.getSession().setAttribute(Consts.Admin_User_Session, ImmutableMap.of("userName",username));
66+
successResultCode(r);
67+
}else{
68+
r.setCode(ErrorConstant.REQUEST_PARAMS_NOT_VALID);
69+
r.setMessage("用户名或密码错误");
5270
}
53-
model.addAttribute("message","用户名或密码错误");
54-
return "login";
71+
return r;
5572
}
5673
}

0 commit comments

Comments
 (0)