forked from houko/SpringBootUnity
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
75 changed files
with
6,877 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
*.js linguist-language=java | ||
*.css linguist-language=java | ||
*.html linguist-language=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,4 @@ | ||
.idea | ||
*.iml | ||
node_modules | ||
target |
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 @@ | ||
API接口 |
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,3 @@ | ||
*.js linguist-language=java | ||
*.css linguist-language=java | ||
*.html linguist-language=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,4 @@ | ||
.idea | ||
*.iml | ||
node_modules | ||
target |
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 @@ | ||
小莫APP |
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,3 @@ | ||
*.js linguist-language=java | ||
*.css linguist-language=java | ||
*.html linguist-language=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,4 @@ | ||
.idea | ||
*.iml | ||
node_modules | ||
target |
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 @@ | ||
校园APP |
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,41 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<parent> | ||
<artifactId>xiaomo</artifactId> | ||
<groupId>info.xiaomo</groupId> | ||
<version>1.0.0-SNAPSHOT</version> | ||
</parent> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<artifactId>aries</artifactId> | ||
<dependencies> | ||
<dependency> | ||
<groupId>info.xiaomo</groupId> | ||
<artifactId>core</artifactId> | ||
<version>1.0.0-SNAPSHOT</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-data-jpa</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.springfox</groupId> | ||
<artifactId>springfox-swagger-ui</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.springfox</groupId> | ||
<artifactId>springfox-swagger2</artifactId> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-maven-plugin</artifactId> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
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,64 @@ | ||
package info.xiaomo.aries; | ||
|
||
import io.swagger.annotations.ApiOperation; | ||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; | ||
import org.springframework.boot.autoconfigure.domain.EntityScan; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.ComponentScan; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RequestMethod; | ||
import org.springframework.web.bind.annotation.RestController; | ||
import org.springframework.web.servlet.ModelAndView; | ||
import springfox.documentation.annotations.ApiIgnore; | ||
import springfox.documentation.builders.ApiInfoBuilder; | ||
import springfox.documentation.builders.PathSelectors; | ||
import springfox.documentation.builders.RequestHandlerSelectors; | ||
import springfox.documentation.service.ApiInfo; | ||
import springfox.documentation.spi.DocumentationType; | ||
import springfox.documentation.spring.web.plugins.Docket; | ||
import springfox.documentation.swagger2.annotations.EnableSwagger2; | ||
|
||
/** | ||
* @author 小莫 (https://xiaomo.info) (https://github.com/syoubaku) | ||
* @version : 2017/1/11 16:34 | ||
*/ | ||
@Configuration | ||
@EnableAutoConfiguration | ||
@ComponentScan("info.xiaomo") | ||
@EntityScan("info.xiaomo.*.model") | ||
@RestController | ||
@EnableSwagger2 | ||
public class AriesMain { | ||
public static void main(String[] args) throws Exception { | ||
SpringApplication.run(AriesMain.class, args); | ||
} | ||
|
||
@RequestMapping(value = "/", method = RequestMethod.GET) | ||
@ApiIgnore() | ||
@ApiOperation(value = "重定向到api首页") | ||
public ModelAndView index() { | ||
return new ModelAndView("redirect:/swagger-ui.html"); | ||
} | ||
|
||
@Bean | ||
public Docket createRestApi() { | ||
return new Docket(DocumentationType.SWAGGER_2) | ||
.apiInfo(apiInfo()) | ||
.select() | ||
.apis(RequestHandlerSelectors.basePackage("info.xiaomo.aries")) | ||
.paths(PathSelectors.any()) | ||
.build(); | ||
} | ||
|
||
private ApiInfo apiInfo() { | ||
return new ApiInfoBuilder() | ||
.title("Spring Boot中使用Swagger2构建RESTful APIs") | ||
.description("使用mongodb构建api接口") | ||
.termsOfServiceUrl("http://xiaomo.info/") | ||
.contact("小莫") | ||
.version("1.0") | ||
.build(); | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
aries/src/main/java/info/xiaomo/aries/base/BaseController.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,8 @@ | ||
package info.xiaomo.aries.base; | ||
|
||
/** | ||
* @author 小莫 (https://xiaomo.info) (https://github.com/syoubaku) | ||
* @version : 2017/1/11 16:41 | ||
*/ | ||
public class BaseController { | ||
} |
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,42 @@ | ||
package info.xiaomo.aries.base; | ||
|
||
import com.fasterxml.jackson.databind.annotation.JsonSerialize; | ||
import info.xiaomo.core.filter.CustomDateSerializer; | ||
import io.swagger.annotations.ApiModel; | ||
import io.swagger.annotations.ApiModelProperty; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
import javax.persistence.*; | ||
import java.util.Date; | ||
|
||
/** | ||
* @author 小莫 (https://xiaomo.info) (https://github.com/syoubaku) | ||
* @version : 2017/1/11 16:41 | ||
*/ | ||
|
||
@MappedSuperclass | ||
@Data | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
@ApiModel("基类") | ||
public class BaseModel { | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.AUTO) | ||
@Column(name = "Id") | ||
@ApiModelProperty(value = "id") | ||
private long id; | ||
|
||
@JsonSerialize(using = CustomDateSerializer.class) | ||
@Column(name = "CreateTime") | ||
@ApiModelProperty(value = "创建时间") | ||
private Date createTime; | ||
|
||
@JsonSerialize(using = CustomDateSerializer.class) | ||
@Column(name = "UpdateTime") | ||
@ApiModelProperty(value = "更新时间") | ||
private Date updateTime; | ||
|
||
} |
28 changes: 28 additions & 0 deletions
28
aries/src/main/java/info/xiaomo/aries/base/BaseService.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,28 @@ | ||
package info.xiaomo.aries.base; | ||
|
||
import org.springframework.data.domain.Page; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* @author 小莫 (https://xiaomo.info) (https://github.com/syoubaku) | ||
* @version : 2017/1/11 16:42 | ||
*/ | ||
public interface BaseService<T> { | ||
|
||
T findById(Long id); | ||
|
||
T findByName(String name); | ||
|
||
List<T> findAll(); | ||
|
||
Page<T> findAll(int start, int pageSize); | ||
|
||
void delById(Long id); | ||
|
||
void delByName(String name); | ||
|
||
void add(T model); | ||
|
||
void update(T model); | ||
} |
16 changes: 16 additions & 0 deletions
16
aries/src/main/java/info/xiaomo/aries/controller/UserController.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,16 @@ | ||
package info.xiaomo.aries.controller; | ||
|
||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
/** | ||
* @author 小莫 (https://xiaomo.info) (https://github.com/syoubaku) | ||
* @version : 2017/1/11 16:40 | ||
*/ | ||
@RestController | ||
@RequestMapping("/user") | ||
public class UserController { | ||
|
||
|
||
|
||
} |
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,16 @@ | ||
package info.xiaomo.aries.dao; | ||
|
||
import info.xiaomo.aries.model.UserModel; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
/** | ||
* @author 小莫 (https://xiaomo.info) (https://github.com/syoubaku) | ||
* @version : 2017/1/11 16:39 | ||
*/ | ||
public interface UserDao extends JpaRepository<Long, UserModel> { | ||
|
||
UserModel findById(Long id); | ||
|
||
UserModel findByName(String name); | ||
|
||
} |
26 changes: 26 additions & 0 deletions
26
aries/src/main/java/info/xiaomo/aries/model/UserModel.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,26 @@ | ||
package info.xiaomo.aries.model; | ||
|
||
import info.xiaomo.aries.base.BaseModel; | ||
import io.swagger.annotations.ApiModel; | ||
import lombok.*; | ||
|
||
import javax.persistence.Entity; | ||
import javax.persistence.Table; | ||
import java.io.Serializable; | ||
|
||
/** | ||
* @author 小莫 (https://xiaomo.info) (https://github.com/syoubaku) | ||
* @version : 2017/1/11 16:40 | ||
*/ | ||
@Entity | ||
@Table(name = "user") | ||
@Data | ||
@ToString(callSuper = true) | ||
@EqualsAndHashCode(callSuper = false) | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
@ApiModel(value = "用户实体类") | ||
public class UserModel extends BaseModel implements Serializable { | ||
|
||
|
||
} |
11 changes: 11 additions & 0 deletions
11
aries/src/main/java/info/xiaomo/aries/service/UserService.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,11 @@ | ||
package info.xiaomo.aries.service; | ||
|
||
import info.xiaomo.aries.base.BaseService; | ||
import info.xiaomo.aries.model.UserModel; | ||
|
||
/** | ||
* @author 小莫 (https://xiaomo.info) (https://github.com/syoubaku) | ||
* @version : 2017/1/11 16:39 | ||
*/ | ||
public interface UserService extends BaseService<UserModel> { | ||
} |
64 changes: 64 additions & 0 deletions
64
aries/src/main/java/info/xiaomo/aries/service/impl/UserServiceImpl.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,64 @@ | ||
package info.xiaomo.aries.service.impl; | ||
|
||
import info.xiaomo.aries.dao.UserDao; | ||
import info.xiaomo.aries.model.UserModel; | ||
import info.xiaomo.aries.service.UserService; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.data.domain.Page; | ||
import org.springframework.stereotype.Service; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* @author 小莫 (https://xiaomo.info) (https://github.com/syoubaku) | ||
* @version : 2017/1/11 16:39 | ||
*/ | ||
@Service | ||
public class UserServiceImpl implements UserService { | ||
|
||
private final UserDao userDao; | ||
|
||
@Autowired | ||
public UserServiceImpl(UserDao userDao) { | ||
this.userDao = userDao; | ||
} | ||
|
||
@Override | ||
public UserModel findById(Long id) { | ||
return userDao.findById(id); | ||
} | ||
|
||
@Override | ||
public UserModel findByName(String name) { | ||
return userDao.findByName(name); | ||
} | ||
|
||
@Override | ||
public List<UserModel> findAll() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public Page<UserModel> findAll(int start, int pageSize) { | ||
return null; | ||
} | ||
|
||
@Override | ||
public void delById(Long id) { | ||
userDao.delete(id); | ||
} | ||
|
||
@Override | ||
public void delByName(String name) { | ||
userDao.findByName(name); | ||
} | ||
|
||
@Override | ||
public void add(UserModel model) { | ||
|
||
} | ||
|
||
@Override | ||
public void update(UserModel model) { | ||
} | ||
} |
Oops, something went wrong.