-
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
hubin6
committed
Nov 1, 2017
1 parent
507e4fa
commit 5c83291
Showing
9 changed files
with
272 additions
and
0 deletions.
There are no files selected for viewing
17 changes: 17 additions & 0 deletions
17
dashboard-domain-service/src/main/java/com/jd/logistics/cloud/data/domain/Dim.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,17 @@ | ||
package com.jd.logistics.cloud.data.domain; | ||
|
||
import lombok.Data; | ||
|
||
import java.io.Serializable; | ||
|
||
/** | ||
* @Author hubin | ||
* @Description: | ||
* @Date 2017/10/31 14:38 | ||
*/ | ||
@Data | ||
public class Dim implements Serializable{ | ||
private static final long serialVersionUID = 8657041672009519925L; | ||
private long id; | ||
private String name; | ||
} |
19 changes: 19 additions & 0 deletions
19
dashboard-domain-service/src/main/java/com/jd/logistics/cloud/data/service/DimService.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,19 @@ | ||
package com.jd.logistics.cloud.data.service; | ||
|
||
import com.jd.logistics.cloud.data.domain.Dim; | ||
import com.jd.logistics.cloud.data.domain.DimQuery; | ||
import com.jd.logistics.cloud.data.domain.GenericRes; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* @Author hubin | ||
* @Description: | ||
* @Date 2017/10/31 14:39 | ||
*/ | ||
public interface DimService { | ||
List<Dim> getWarehouses(); | ||
|
||
List<Dim> getDateCycles(); | ||
|
||
} |
31 changes: 31 additions & 0 deletions
31
...oard-domain-service/src/main/java/com/jd/logistics/cloud/data/service/DimServiceImpl.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,31 @@ | ||
package com.jd.logistics.cloud.data.service; | ||
|
||
import com.jd.logistics.cloud.data.domain.Dim; | ||
import com.jd.logistics.cloud.data.domain.DimQuery; | ||
import com.jd.logistics.cloud.data.domain.GenericRes; | ||
import com.jd.logistics.cloud.data.repository.DimRepository; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Service; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* @Author hubin | ||
* @Description: | ||
* @Date 2017/10/31 14:40 | ||
*/ | ||
@Service | ||
public class DimServiceImpl implements DimService { | ||
@Autowired | ||
DimRepository dimRepository; | ||
@Override | ||
public List<Dim> getWarehouses() { | ||
return dimRepository.getWarehouses(); | ||
} | ||
|
||
@Override | ||
public List<Dim> getDateCycles() { | ||
return dimRepository.getDateCycles(); | ||
} | ||
|
||
} |
36 changes: 36 additions & 0 deletions
36
...ard-domain-service/src/main/java/com/jd/logistics/cloud/data/service/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,36 @@ | ||
package com.jd.logistics.cloud.data.service; | ||
|
||
import com.jd.logistics.cloud.data.domain.User; | ||
import com.jd.logistics.cloud.data.repository.UserRepository; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Service; | ||
|
||
/** | ||
* @Author hubin | ||
* @Description: | ||
* @Date 2017/10/31 9:13 | ||
*/ | ||
@Service | ||
public class UserServiceImpl implements UserService { | ||
@Autowired | ||
UserRepository userRepository; | ||
@Override | ||
public User getUserByName(String username) { | ||
return userRepository.getByName(username); | ||
} | ||
|
||
@Override | ||
public boolean checkPwd(String username, String pwd) { | ||
return pwd.equals(userRepository.getByName(username).getPassword()) ? true: false; | ||
} | ||
|
||
@Override | ||
public boolean checkUser(String username) { | ||
return null == getUserByName(username) ? false: true; | ||
} | ||
|
||
@Override | ||
public User getUserById(long id) { | ||
return userRepository.getById(id); | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
dashboard-web/src/main/java/com/jd/logistics/cloud/data/web/api/DimApi.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,33 @@ | ||
package com.jd.logistics.cloud.data.web.api; | ||
|
||
import com.jd.logistics.cloud.data.domain.Dim; | ||
import com.jd.logistics.cloud.data.domain.Function; | ||
import com.jd.logistics.cloud.data.domain.GenericRes; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.PathVariable; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RequestMethod; | ||
|
||
import javax.validation.Valid; | ||
import java.util.List; | ||
|
||
/** | ||
* @Author hubin | ||
* @Description: | ||
* @Date 2017/10/31 14:41 | ||
*/ | ||
@RequestMapping(value="/api/dim") | ||
public interface DimApi { | ||
|
||
@RequestMapping(value = "/warehouse", | ||
produces = {"application/json"}, | ||
method = RequestMethod.GET) | ||
List<Dim> getWarehouses(); | ||
|
||
@RequestMapping(value = "/datecycle", | ||
produces = {"application/json"}, | ||
method = RequestMethod.GET) | ||
List<Dim> getDateCycles(); | ||
|
||
} |
29 changes: 29 additions & 0 deletions
29
dashboard-web/src/main/java/com/jd/logistics/cloud/data/web/api/DimRestController.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,29 @@ | ||
package com.jd.logistics.cloud.data.web.api; | ||
|
||
import com.jd.logistics.cloud.data.domain.Dim; | ||
import com.jd.logistics.cloud.data.domain.GenericRes; | ||
import com.jd.logistics.cloud.data.service.DimService; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* @Author hubin | ||
* @Description: | ||
* @Date 2017/10/31 14:43 | ||
*/ | ||
@RestController | ||
public class DimRestController implements DimApi{ | ||
@Autowired | ||
DimService dimService; | ||
@Override | ||
public List<Dim> getWarehouses() { | ||
return dimService.getWarehouses(); | ||
} | ||
|
||
@Override | ||
public List<Dim> getDateCycles() { | ||
return dimService.getDateCycles(); | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
dashboard-web/src/main/java/com/jd/logistics/cloud/data/web/api/FuncApi.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,37 @@ | ||
package com.jd.logistics.cloud.data.web.api; | ||
|
||
import com.jd.logistics.cloud.data.domain.Function; | ||
import com.jd.logistics.cloud.data.domain.User; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.PathVariable; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RequestMethod; | ||
|
||
import javax.swing.text.html.parser.Entity; | ||
import javax.validation.Valid; | ||
import java.util.List; | ||
|
||
/** | ||
* @Author hubin | ||
* @Description: | ||
* @Date 2017/10/31 10:14 | ||
*/ | ||
@RequestMapping(value="/api/func") | ||
public interface FuncApi { | ||
|
||
@RequestMapping(value = "/{type}", | ||
produces = { "application/json" }, | ||
method = RequestMethod.GET) | ||
List<Function> getFuncByType(@PathVariable("type") int type); | ||
|
||
@RequestMapping(value = "", | ||
produces = { "application/json" }, | ||
method = RequestMethod.GET) | ||
List<Function> getFunc(); | ||
|
||
@RequestMapping(value = "", | ||
produces = { "application/json" }, | ||
method = RequestMethod.PUT) | ||
ResponseEntity updateFuncType(@Valid @RequestBody List<Function> functionList); | ||
} |
29 changes: 29 additions & 0 deletions
29
dashboard-web/src/main/java/com/jd/logistics/cloud/data/web/api/UserApi.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,29 @@ | ||
package com.jd.logistics.cloud.data.web.api; | ||
|
||
import com.jd.logistics.cloud.data.domain.User; | ||
import io.swagger.annotations.Api; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.PathVariable; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RequestMethod; | ||
|
||
import javax.validation.Valid; | ||
|
||
/** | ||
* @Author hubin | ||
* @Description: | ||
* @Date 2017/10/31 9:14 | ||
*/ | ||
@RequestMapping(value="/api/user") | ||
public interface UserApi { | ||
@RequestMapping(value = "/login", | ||
produces = { "application/json" }, | ||
method = RequestMethod.POST) | ||
ResponseEntity<?> login(@Valid @RequestBody User user); | ||
|
||
@RequestMapping(value = "/{id}", | ||
produces = { "application/json" }, | ||
method = RequestMethod.GET) | ||
User user(@PathVariable("id") long id); | ||
} |
41 changes: 41 additions & 0 deletions
41
dashboard-web/src/main/java/com/jd/logistics/cloud/data/web/api/UserRestController.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,41 @@ | ||
package com.jd.logistics.cloud.data.web.api; | ||
|
||
import com.jd.logistics.cloud.data.commons.validation.Errors; | ||
import com.jd.logistics.cloud.data.domain.User; | ||
import com.jd.logistics.cloud.data.service.UserService; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.PathVariable; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
/** | ||
* @Author hubin | ||
* @Description: | ||
* @Date 2017/10/31 9:14 | ||
*/ | ||
@RestController | ||
public class UserRestController implements UserApi { | ||
@Autowired | ||
UserService userService; | ||
@Override | ||
public ResponseEntity<?> login(@RequestBody User user) { | ||
Errors.Builder errorsBuilder = new Errors.Builder(); | ||
if(!userService.checkUser(user.getUsername())) { | ||
errorsBuilder.addFieldError("username", "账户不存在,请重新输入!"); | ||
return new ResponseEntity<>(errorsBuilder.build(), HttpStatus.OK); | ||
} | ||
if(!userService.checkPwd(user.getUsername(), user.getPassword())) { | ||
errorsBuilder.addFieldError("password", "密码不正确!"); | ||
return new ResponseEntity<>(errorsBuilder.build(), HttpStatus.OK); | ||
} | ||
|
||
return new ResponseEntity<>(HttpStatus.OK); | ||
} | ||
|
||
@Override | ||
public User user(@PathVariable("id") long id) { | ||
return userService.getUserById(id); | ||
} | ||
} |