Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 50 additions & 1 deletion README.md
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,53 @@ jdbc.driver = com.mysql.jdbc.Driver
4、浏览器访问

http://localhost:port/context



## Cola 开放数据
##### Cola-UI 测试与演示平台使用

提供的接口列表如下
* /service/company

* /service/company/find/:from/:limit

* /service/company/find?pageSize=5&pageNo=1

* /service/company/:id/depts

* /service/company/:id/employees

* /service/company/:id/find/depts?pageSize=5&pageNo=1

* /service/company/:id/find/employees?pageSize=5&pageNo=1

* /service/dept

* /service/dept/find/:from/:limit

* /service/dept/find?pageSize=5&pageNo=1

* /service/dept/:id/employees

* /service/dept/:id/find/employees?pageSize=5&pageNo=1

* /service/employee

* /service/employee/find/:from/:limit

* /service/employee/find?pageSize=5&pageNo=1

* /service/district/

* /service/district/provinces

* /service/district/children?parentId=2

* /service/district/:id/children

* /service/employee/exists?email=alex.tong007@gmail.com

* /service/dictionary?codes=10011,10012,10013,10014



64 changes: 64 additions & 0 deletions cola-ui-spring-rest-example.iml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<?xml version="1.0" encoding="UTF-8"?>
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="web" name="Web">
<configuration>
<descriptors>
<deploymentDescriptor name="web.xml" url="file://$MODULE_DIR$/src/main/webapp/WEB-INF/web.xml" />
</descriptors>
<webroots>
<root url="file://$MODULE_DIR$/src/main/webapp" relative="/" />
</webroots>
</configuration>
</facet>
<facet type="Spring" name="Spring">
<configuration />
</facet>
</component>
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_6" inherit-compiler-output="false">
<output url="file://$MODULE_DIR$/target/classes" />
<output-test url="file://$MODULE_DIR$/target/test-classes" />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Maven: org.springframework:spring-core:4.2.0.RELEASE" level="project" />
<orderEntry type="library" name="Maven: commons-logging:commons-logging:1.2" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-webmvc:4.2.0.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-beans:4.2.0.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-context:4.2.0.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-expression:4.2.0.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-web:4.2.0.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-jdbc:4.2.0.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-tx:4.2.0.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-aop:4.2.0.RELEASE" level="project" />
<orderEntry type="library" name="Maven: aopalliance:aopalliance:1.0" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-aspects:4.2.0.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.aspectj:aspectjweaver:1.8.6" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-orm:4.2.0.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.hibernate:hibernate-core:4.3.6.Final" level="project" />
<orderEntry type="library" name="Maven: org.jboss.logging:jboss-logging:3.1.3.GA" level="project" />
<orderEntry type="library" name="Maven: org.jboss.logging:jboss-logging-annotations:1.2.0.Beta1" level="project" />
<orderEntry type="library" name="Maven: org.jboss.spec.javax.transaction:jboss-transaction-api_1.2_spec:1.0.0.Final" level="project" />
<orderEntry type="library" name="Maven: dom4j:dom4j:1.6.1" level="project" />
<orderEntry type="library" name="Maven: xml-apis:xml-apis:1.0.b2" level="project" />
<orderEntry type="library" name="Maven: org.hibernate.common:hibernate-commons-annotations:4.0.5.Final" level="project" />
<orderEntry type="library" name="Maven: org.hibernate.javax.persistence:hibernate-jpa-2.1-api:1.0.0.Final" level="project" />
<orderEntry type="library" name="Maven: org.javassist:javassist:3.18.1-GA" level="project" />
<orderEntry type="library" name="Maven: antlr:antlr:2.7.7" level="project" />
<orderEntry type="library" name="Maven: org.jboss:jandex:1.1.0.Final" level="project" />
<orderEntry type="library" name="Maven: mysql:mysql-connector-java:5.1.31" level="project" />
<orderEntry type="library" name="Maven: javax.servlet:javax.servlet-api:3.1.0" level="project" />
<orderEntry type="library" name="Maven: javax.servlet.jsp:javax.servlet.jsp-api:2.3.1" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-databind:2.5.3" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-annotations:2.5.0" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-core:2.5.3" level="project" />
<orderEntry type="library" name="Maven: commons-lang:commons-lang:2.6" level="project" />
<orderEntry type="library" name="Maven: commons-dbcp:commons-dbcp:1.4" level="project" />
<orderEntry type="library" name="Maven: commons-pool:commons-pool:1.5.4" level="project" />
<orderEntry type="library" name="Maven: org.jsoup:jsoup:1.8.3" level="project" />
</component>
</module>
12 changes: 11 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,17 @@
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>

<finalName>cola-ui-spring-rest-example</finalName>
<finalName>cola-ui-spring-rest-example</finalName>
</build>
</project>
73 changes: 36 additions & 37 deletions src/main/java/com/colaui/example/controller/CategoryController.java
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -17,41 +17,40 @@
@RestController
@RequestMapping("category")
public class CategoryController {
@Autowired
CategoryService categoryService;

@RequestMapping(value = "/", method = RequestMethod.GET)
public Page<Category> paging(@RequestParam int pageSize,
@RequestParam int pageNo, @RequestParam(required=false) String contain) {
return categoryService.getPage(pageSize, pageNo, contain);
}

@RequestMapping(value = "/{id}/", method = RequestMethod.DELETE)
public void delete(@PathVariable("id") long id) {
System.out.println("Fetching & Deleting Employee with id " + id);
// categoryService.delete(id);
}

@RequestMapping(value = "/", method = RequestMethod.POST, produces = "application/json; charset=utf-8")
public void save(@RequestBody Category category) {
System.out.println(category.getCategoryName());
categoryService.save(category);
}

@RequestMapping(value = "/", method = RequestMethod.PUT, produces = "application/json; charset=utf-8")
public void update(@RequestBody Category category) {
System.out.println(category.getCategoryName());
categoryService.update(category);
}

@RequestMapping(value = "/{id}/", method = RequestMethod.GET)
public Category find(long id) {
return categoryService.find(id);
}

@RequestMapping(value = "/{from}/{limit}", method = RequestMethod.GET)
public List<Category> find(@PathVariable("from") int from,
@PathVariable("limit") int limit) {
return categoryService.find(from, limit);
}
@Autowired
CategoryService categoryService;

@RequestMapping(value = "/", method = RequestMethod.GET)
public Page<Category> paging(@RequestParam int pageSize,
@RequestParam int pageNo, @RequestParam(required = false) String contain) {
return categoryService.getPage(pageSize, pageNo, contain);
}

@RequestMapping(value = "/{id}/", method = RequestMethod.DELETE)
public void delete(@PathVariable("id") long id) {
categoryService.delete(id);
}

@RequestMapping(value = "/", method = RequestMethod.POST, produces = "application/json; charset=utf-8")
public void save(@RequestBody Category category) {
System.out.println(category.getCategoryName());
categoryService.save(category);
}

@RequestMapping(value = "/", method = RequestMethod.PUT, produces = "application/json; charset=utf-8")
public void update(@RequestBody Category category) {
System.out.println(category.getCategoryName());
categoryService.update(category);
}

@RequestMapping(value = "/{id}/", method = RequestMethod.GET)
public Category find(@PathVariable("id") long id) {
return categoryService.find(id);
}

@RequestMapping(value = "/{from}/{limit}", method = RequestMethod.GET)
public List<Category> find(@PathVariable("from") int from,
@PathVariable("limit") int limit) {
return categoryService.find(from, limit);
}
}
88 changes: 88 additions & 0 deletions src/main/java/com/colaui/example/controller/CompanyController.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
package com.colaui.example.controller;

import com.colaui.example.model.Company;
import com.colaui.example.model.Dept;
import com.colaui.example.model.Employee;
import com.colaui.example.service.CompanyService;
import com.colaui.example.service.DeptService;
import com.colaui.example.service.EmployeeService;
import com.colaui.provider.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("company")
public class CompanyController {
@Autowired
private CompanyService companyService;
@Autowired
private DeptService deptService;
@Autowired
private EmployeeService employeeService;

@RequestMapping(value = "", method = RequestMethod.GET)
public List<Company> getAll() {
return companyService.getAll();
}

@RequestMapping(value = "/find", method = RequestMethod.GET)
public Page<Company> paging(@RequestParam int pageSize,
@RequestParam int pageNo, @RequestParam(required = false) String contain) {
return companyService.getPage(pageSize, pageNo, contain);
}

@RequestMapping(value = "/", method = RequestMethod.POST, produces = "application/json; charset=utf-8")
public void save(@RequestBody Company Company) {
companyService.save(Company);
}

@RequestMapping(value = "/{id}/", method = RequestMethod.DELETE)
public void delete(@PathVariable("id") int id) {
companyService.delete(id);
}

@RequestMapping(value = "/", method = RequestMethod.PUT, produces = "application/json; charset=utf-8")
public void update(@RequestBody Company Company) {
companyService.update(Company);
}

@RequestMapping(value = "/{id}/", method = RequestMethod.GET)
public Company find(@PathVariable("id") int id) {
return companyService.find(id);
}

@RequestMapping(value = "/find/{from}/{limit}", method = RequestMethod.GET)
public List<Company> find(@PathVariable("from") int from,
@PathVariable("limit") int limit) {
return companyService.find(from, limit);
}

@RequestMapping(value = "/{id}/depts", method = RequestMethod.GET)
public List<Dept> findDept(@PathVariable("id") int id) {
return (List<Dept>) companyService.find(id).getDepts();
}

@RequestMapping(value = "/{id}/find/depts", method = RequestMethod.GET)
public Page<Dept> pageDept(@PathVariable("id") int id, @RequestParam int pageSize, @RequestParam int pageNo) {
Map<String, Object> param = new HashMap<String, Object>();
param.put("id", id);
return deptService.getPage(pageSize, pageNo, param);
}

@RequestMapping(value = "/{id}/employees", method = RequestMethod.GET)
public List<Employee> findEmployee(@PathVariable("id") int id) {
return (List<Employee>) companyService.find(id).getEmployees();
}

@RequestMapping(value = "/{id}/find/employees", method = RequestMethod.GET)
public Page<Employee> pageEmployee(@PathVariable("id") int id, @RequestParam int pageSize,
@RequestParam int pageNo) {
Map<String, Object> param = new HashMap<String, Object>();
param.put("companyId", id);
return employeeService.getPage(pageSize, pageNo, param);
}
}
74 changes: 74 additions & 0 deletions src/main/java/com/colaui/example/controller/DeptController.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
package com.colaui.example.controller;

import com.colaui.example.model.Dept;
import com.colaui.example.model.Employee;
import com.colaui.example.service.DeptService;
import com.colaui.example.service.EmployeeService;
import com.colaui.provider.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("dept")
public class DeptController {
@Autowired
private DeptService deptService;
@Autowired
private EmployeeService employeeService;

@RequestMapping(value = "", method = RequestMethod.GET)
public List<Dept> getAll() {
return deptService.getAll();
}

@RequestMapping(value = "/find", method = RequestMethod.GET)
public Page<Dept> paging(@RequestParam int pageSize,
@RequestParam int pageNo, @RequestParam(required = false) String contain) {
Map<String, Object> param = new HashMap<String, Object>();
param.put("contain", contain);
return deptService.getPage(pageSize, pageNo, param);
}

@RequestMapping(value = "/", method = RequestMethod.POST, produces = "application/json; charset=utf-8")
public void save(@RequestBody Dept employee) {
deptService.save(employee);
}

@RequestMapping(value = "/{id}/", method = RequestMethod.DELETE)
public void delete(@PathVariable("id") int id) {
deptService.delete(id);
}

@RequestMapping(value = "/", method = RequestMethod.PUT, produces = "application/json; charset=utf-8")
public void update(@RequestBody Dept employee) {
deptService.update(employee);
}

@RequestMapping(value = "/{id}/", method = RequestMethod.GET)
public Dept find(@PathVariable("id") int id) {
return deptService.find(id);
}

@RequestMapping(value = "/find/{from}/{limit}", method = RequestMethod.GET)
public List<Dept> find(@PathVariable("from") int from,
@PathVariable("limit") int limit) {
return deptService.find(from, limit);
}

@RequestMapping(value = "/{id}/employees", method = RequestMethod.GET)
public List<Employee> findEmployee(@PathVariable("id") int id) {
return (List<Employee>) deptService.find(id).getEmployees();
}

@RequestMapping(value = "/{id}/find/employees", method = RequestMethod.GET)
public Page<Employee> pageEmployee(@PathVariable("id") int id, @RequestParam int pageSize,
@RequestParam int pageNo) {
Map<String, Object> param = new HashMap<String, Object>();
param.put("deptId", id);
return employeeService.getPage(pageSize, pageNo, param);
}
}
Loading