Skip to content

Commit 92781cf

Browse files
committed
搭建order模块
1 parent ece8408 commit 92781cf

File tree

7 files changed

+256
-1
lines changed

7 files changed

+256
-1
lines changed

order/pom.xml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<parent>
6+
<artifactId>xiaomo</artifactId>
7+
<groupId>info.xiaomo</groupId>
8+
<version>2017.2</version>
9+
</parent>
10+
<modelVersion>4.0.0</modelVersion>
11+
12+
<artifactId>order</artifactId>
13+
<dependencies>
14+
<dependency>
15+
<groupId>info.xiaomo</groupId>
16+
<artifactId>core</artifactId>
17+
<version>2017.2</version>
18+
</dependency>
19+
<dependency>
20+
<groupId>org.springframework.boot</groupId>
21+
<artifactId>spring-boot-devtools</artifactId>
22+
<optional>true</optional>
23+
</dependency>
24+
<dependency>
25+
<groupId>io.springfox</groupId>
26+
<artifactId>springfox-swagger2</artifactId>
27+
</dependency>
28+
<dependency>
29+
<groupId>io.springfox</groupId>
30+
<artifactId>springfox-swagger-ui</artifactId>
31+
</dependency>
32+
<dependency>
33+
<groupId>com.github.xiaoymin</groupId>
34+
<artifactId>swagger-bootstrap-ui</artifactId>
35+
<version>1.5</version>
36+
</dependency>
37+
</dependencies>
38+
39+
<build>
40+
<plugins>
41+
<plugin>
42+
<groupId>org.springframework.boot</groupId>
43+
<artifactId>spring-boot-maven-plugin</artifactId>
44+
<executions>
45+
<execution>
46+
<goals>
47+
<goal>repackage</goal>
48+
</goals>
49+
</execution>
50+
</executions>
51+
</plugin>
52+
</plugins>
53+
</build>
54+
55+
</project>
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
package info.xiaomo.order;
2+
3+
import io.swagger.annotations.ApiOperation;
4+
import org.springframework.boot.SpringApplication;
5+
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
6+
import org.springframework.boot.autoconfigure.domain.EntityScan;
7+
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
8+
import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration;
9+
import org.springframework.cache.annotation.EnableCaching;
10+
import org.springframework.context.annotation.Bean;
11+
import org.springframework.context.annotation.ComponentScan;
12+
import org.springframework.context.annotation.Configuration;
13+
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
14+
import org.springframework.stereotype.Controller;
15+
import org.springframework.transaction.annotation.EnableTransactionManagement;
16+
import org.springframework.web.bind.annotation.RequestMapping;
17+
import org.springframework.web.bind.annotation.RequestMethod;
18+
import org.springframework.web.servlet.ModelAndView;
19+
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
20+
import springfox.documentation.annotations.ApiIgnore;
21+
import springfox.documentation.builders.ApiInfoBuilder;
22+
import springfox.documentation.builders.PathSelectors;
23+
import springfox.documentation.builders.RequestHandlerSelectors;
24+
import springfox.documentation.service.ApiInfo;
25+
import springfox.documentation.spi.DocumentationType;
26+
import springfox.documentation.spring.web.plugins.Docket;
27+
import springfox.documentation.swagger2.annotations.EnableSwagger2;
28+
29+
30+
/**
31+
* @author xiaomo
32+
*/
33+
@Configuration
34+
@ComponentScan("info.xiaomo")
35+
@EntityScan("info.xiaomo.*.model")
36+
@EnableSwagger2
37+
@Controller
38+
@EnableAutoConfiguration(exclude = {DataSourceAutoConfiguration.class, HibernateJpaAutoConfiguration.class})
39+
public class OrderMain implements WebMvcConfigurer {
40+
41+
public static void main(String[] args) {
42+
SpringApplication.run(OrderMain.class, args);
43+
}
44+
45+
@RequestMapping(value = "/", method = RequestMethod.GET)
46+
public String index() {
47+
return "swagger-ui.html";
48+
}
49+
50+
/**
51+
* 接口
52+
*
53+
* @return 接口
54+
*/
55+
@RequestMapping(value = "/api", method = RequestMethod.GET)
56+
@ApiIgnore()
57+
@ApiOperation(value = "重定向到api首页")
58+
public ModelAndView api() {
59+
return new ModelAndView("redirect:/swagger-ui.html");
60+
}
61+
62+
63+
@Bean
64+
public Docket createRestApi() {
65+
return new Docket(DocumentationType.SWAGGER_2)
66+
.apiInfo(apiInfo())
67+
.select()
68+
.apis(RequestHandlerSelectors.basePackage("info.xiaomo.order"))
69+
.paths(PathSelectors.any())
70+
.build();
71+
}
72+
73+
private ApiInfo apiInfo() {
74+
return new ApiInfoBuilder()
75+
.title("Spring Boot中使用Swagger2构建RESTful APIs")
76+
.contact("小莫")
77+
.version("1.0")
78+
.build();
79+
}
80+
81+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
package info.xiaomo.order.controller;
2+
3+
import info.xiaomo.core.base.Result;
4+
import info.xiaomo.order.service.OrderService;
5+
import io.swagger.annotations.*;
6+
import org.springframework.beans.factory.annotation.Autowired;
7+
import org.springframework.http.MediaType;
8+
import org.springframework.web.bind.annotation.PathVariable;
9+
import org.springframework.web.bind.annotation.RequestMapping;
10+
import org.springframework.web.bind.annotation.RequestMethod;
11+
import org.springframework.web.bind.annotation.RestController;
12+
13+
14+
/**
15+
* @author xiaomo
16+
*/
17+
@RestController
18+
@RequestMapping("/order")
19+
@Api(value = "识别订单")
20+
public class OrderController {
21+
22+
private final OrderService service;
23+
24+
@Autowired
25+
public OrderController(OrderService orderService) {
26+
this.service = orderService;
27+
}
28+
29+
30+
@RequestMapping(value = "forbid/{id}", method = RequestMethod.GET)
31+
@ApiOperation(value = "封号", notes = "根据传入的id对修改对应帐号状态", httpMethod = "GET", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
32+
@ApiImplicitParams({
33+
@ApiImplicitParam(name = "id", value = "后台用户唯一id", required = true, dataType = "Long", paramType = "path")
34+
})
35+
@ApiResponses(value = {
36+
@ApiResponse(code = 404, message = "Not Found"),
37+
@ApiResponse(code = 400, message = "No Name Provided"),
38+
})
39+
public Result forbid(@PathVariable("id") Long id) {
40+
return new Result<>(null);
41+
}
42+
}
43+
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
package info.xiaomo.order.model;
2+
3+
4+
import info.xiaomo.core.base.BaseModel;
5+
import lombok.*;
6+
7+
import javax.persistence.Column;
8+
import javax.persistence.Entity;
9+
import javax.persistence.Table;
10+
import java.io.Serializable;
11+
12+
/**
13+
* │\__╭╭╭╭╭__/│
14+
* │         │
15+
* │         │
16+
* │ -      -│
17+
* │≡    o ≡ │
18+
* │         │
19+
* ╰——┬O◤▽◥O┬——╯
20+
* |  o  |
21+
* |╭---╮把今天最好的表现当作明天最新的起点..~
22+
* いま 最高の表現 として 明日最新の始発..~
23+
* Today the best performance as tomorrow newest starter!
24+
25+
*
26+
* @author : xiaomo
27+
* github: https://github.com/houko
28+
* email: xiaomo@xiaomo.info
29+
* <p>
30+
* Date: 16/4/2 12:39
31+
* Copyright(©) 2015 by xiaomo.
32+
*/
33+
@Entity
34+
@Table(name = "adminUser")
35+
@Data
36+
@ToString(callSuper = true)
37+
@EqualsAndHashCode(callSuper = false)
38+
@AllArgsConstructor
39+
@NoArgsConstructor
40+
public class OrderModel extends BaseModel implements Serializable {
41+
42+
@Column(name = "UserName")
43+
private String userName;
44+
45+
@Column(name = "Password")
46+
private String password;
47+
48+
@Column(name = "Status")
49+
private int status = 1;
50+
51+
@Column(name = "Salt")
52+
private String salt;
53+
54+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package info.xiaomo.order.service;
2+
3+
/**
4+
* @author xiaomo
5+
*/
6+
public interface OrderService {
7+
8+
9+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package info.xiaomo.order.service.impl;
2+
3+
import info.xiaomo.order.service.OrderService;
4+
import org.springframework.stereotype.Service;
5+
6+
/**
7+
* @author xiaomo
8+
*/
9+
@Service
10+
public class OrderServiceImpl implements OrderService {
11+
12+
}

pom.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
<!-- 爬虫 -->
3838
<module>crawler</module>
3939
<module>javase</module>
40+
<module>order</module>
4041
</modules>
4142
<packaging>pom</packaging>
4243

@@ -260,4 +261,4 @@
260261
</plugin>
261262
</plugins>
262263
</build>
263-
</project>
264+
</project>

0 commit comments

Comments
 (0)