Skip to content

Commit

Permalink
modify ui and api bug
Browse files Browse the repository at this point in the history
  • Loading branch information
flyer1212 committed May 15, 2019
1 parent 5ba33c1 commit 0be53ee
Show file tree
Hide file tree
Showing 64 changed files with 883 additions and 760 deletions.
2 changes: 1 addition & 1 deletion docker-compose.yml
Expand Up @@ -415,7 +415,7 @@ services:
networks:
- my-network

ts-voucher-service:
ts-voucher-service:userName
build: ts-voucher-service
image: ts/ts-voucher-service
restart: always
Expand Down
2 changes: 1 addition & 1 deletion ts-auth-service/src/main/java/auth/dto/BasicAuthDto.java
Expand Up @@ -18,5 +18,5 @@ public class BasicAuthDto implements Serializable {
private static final long serialVersionUID = 5505144168320447022L;
private String username;
private String password;
private String verifyCode;
private String verificationCode;
}
Expand Up @@ -43,10 +43,10 @@ public class TokenServiceImpl implements TokenService {
public Response getToken(BasicAuthDto dto, HttpHeaders headers) {
String username = dto.getUsername();
String password = dto.getPassword();
String verifyCode = dto.getVerifyCode();
// if verifycode is not empty ,is not admin , common user need verify
if (!StringUtils.isEmpty(verifyCode)) {
String verifyCode = dto.getVerificationCode();
log.info("LOGIN USER :" + username + " __ " + password + " __ " + verifyCode);

if (!StringUtils.isEmpty(verifyCode)) {
HttpEntity requestEntity = new HttpEntity(headers);
ResponseEntity<Boolean> re = restTemplate.exchange(
"http://ts-verification-code-service:15678/api/v1/verifycode/verify/" + verifyCode,
Expand All @@ -55,10 +55,10 @@ public Response getToken(BasicAuthDto dto, HttpHeaders headers) {
Boolean.class);
boolean id = re.getBody();
if (!id) { // failed code
return new Response<>(0, "verifycode failed", null);
return new Response<>(0, "verify code failed", null);
}

}

// verify username and password
UsernamePasswordAuthenticationToken upat = new UsernamePasswordAuthenticationToken(username, password);
authenticationManager.authenticate(upat);
Expand All @@ -68,8 +68,8 @@ public Response getToken(BasicAuthDto dto, HttpHeaders headers) {
InfoConstant.USER_NAME_NOT_FOUND_1, username
)));
String token = jwtProvider.createToken(user);
log.info(token + "USER TOKEN");
log.info(user.getUserId() +" USER ID");
return new Response<>(1, "login success", new TokenDto(user.getUserId(),username, token));
log.info(token + "USER TOKEN");
log.info(user.getUserId() + " USER ID");
return new Response<>(1, "login success", new TokenDto(user.getUserId(), username, token));
}
}
Expand Up @@ -29,7 +29,7 @@ public PasswordEncoder passwordEncoder() {
}

/**
* allow cors domain
* allow cors domain
* header 在默认的情况下只能从头部取出6个字段,想要其他字段只能自己在头里指定
* credentials 默认不发送Cookie, 如果需要Cookie,这个值只能为true
* 本次请求检查的有效期
Expand Down Expand Up @@ -61,7 +61,7 @@ protected void configure(HttpSecurity httpSecurity) throws Exception {
.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS)
.and()
.authorizeRequests()
.antMatchers("/api/v1/basicservice/**").hasAnyRole("ADMIN", "USER")
.antMatchers("/api/v1/basicservice/**").permitAll()
.antMatchers("/swagger-ui.html", "/webjars/**", "/images/**",
"/configuration/**", "/swagger-resources/**", "/v2/**").permitAll()
.anyRequest().authenticated()
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

29 changes: 29 additions & 0 deletions ts-cancel-service/src/main/java/cancel/entity/User.java
@@ -0,0 +1,29 @@
package cancel.entity;


import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.UUID;

@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class User {

private UUID userId;
private String userName;
private String password;

private int gender;

private int documentType;

private String documentNum;

private String email;

}
Expand Up @@ -23,8 +23,7 @@ public class CancelServiceImpl implements CancelService {

@Override
public Response cancelOrder(String orderId, String loginId, HttpHeaders headers) throws Exception {
GetOrderByIdInfo getFromOrderInfo = new GetOrderByIdInfo();
getFromOrderInfo.setOrderId(orderId);

Response<Order> orderResult = getOrderByIdFromOrder(orderId, headers);
if (orderResult.getStatus() == 1) {
System.out.println("[Cancel Order Service][Cancel Order] Order found G|H");
Expand All @@ -45,19 +44,18 @@ public Response cancelOrder(String orderId, String loginId, HttpHeaders headers)
if (status) {
System.out.println("[Cancel Order Service][Draw Back Money] Success.");

GetAccountByIdInfo getAccountByIdInfo = new GetAccountByIdInfo();
getAccountByIdInfo.setAccountId(order.getAccountId().toString());

// todo
GetAccountByIdResult result = getAccount(getAccountByIdInfo, headers);
if (result.isStatus() == false) {
return null;
Response<User> result = getAccount(order.getAccountId().toString(), headers);
if (result.getStatus() == 0) {
return new Response<>(0, "Cann't find userinfo by user id.", null);
}
NotifyInfo notifyInfo = new NotifyInfo();
notifyInfo.setDate(new Date().toString());
notifyInfo.setEmail(result.getAccount().getEmail());
notifyInfo.setEmail(result.getData().getEmail());
notifyInfo.setStartingPlace(order.getFrom());
notifyInfo.setEndPlace(order.getTo());
notifyInfo.setUsername(result.getAccount().getName());
notifyInfo.setUsername(result.getData().getUserName());
notifyInfo.setSeatNumber(order.getSeatNumber());
notifyInfo.setOrderNumber(order.getId().toString());
notifyInfo.setPrice(order.getPrice());
Expand Down Expand Up @@ -152,8 +150,7 @@ public Response calculateRefund(String orderId, HttpHeaders headers) {
return new Response<>(0, "Order Status Cancel Not Permitted, Refound error", null);
}
} else {
GetOrderByIdInfo getFromOtherOrderInfo = new GetOrderByIdInfo();
getFromOtherOrderInfo.setOrderId(orderId);

Response<Order> orderOtherResult = getOrderByIdFromOrderOther(orderId, headers);
if (orderOtherResult.getStatus() == 1) {
Order order = orderOtherResult.getData();
Expand Down Expand Up @@ -218,7 +215,6 @@ private String calculateRefund(Order order) {
private Response cancelFromOrder(Order order, HttpHeaders headers) {
System.out.println("[Cancel Order Service][Change Order Status] Changing....");

// ChangeOrderResult result = restTemplate.postForObject("http://ts-order-service:12031/order/update",info,ChangeOrderResult.class);
HttpEntity requestEntity = new HttpEntity(order, headers);
ResponseEntity<Response> re = restTemplate.exchange(
"http://ts-order-service:12031/api/v1/orderservice/order",
Expand All @@ -239,7 +235,7 @@ private Response cancelFromOtherOrder(Order info, HttpHeaders headers) {
requestEntity,
Response.class);
Response result = re.getBody();
// ChangeOrderResult result = restTemplate.postForObject("http://ts-order-other-service:12032/orderOther/update",info,ChangeOrderResult.class);

return result;
}

Expand All @@ -253,23 +249,24 @@ public boolean drawbackMoney(String money, String userId, HttpHeaders headers) {
requestEntity,
Response.class);
Response result = re.getBody();
// String result = restTemplate.postForObject("http://ts-inside-payment-service:18673/inside_payment/drawBack",info,String.class);

if (result.getStatus() == 1) {
return true;
} else {
return false;
}
}

public GetAccountByIdResult getAccount(GetAccountByIdInfo info, HttpHeaders headers) {
public Response<User> getAccount(String orderId, HttpHeaders headers) {
System.out.println("[Cancel Order Service][Get By Id]");
HttpEntity requestEntity = new HttpEntity(info, headers);
ResponseEntity<GetAccountByIdResult> re = restTemplate.exchange(
"http://ts-sso-service:12349/account/findById",
HttpMethod.POST,
HttpEntity requestEntity = new HttpEntity( headers);
ResponseEntity<Response<User>> re = restTemplate.exchange(
"http://ts-user-service:12342/api/v1/userservice/users/id/" + orderId,
HttpMethod.GET,
requestEntity,
GetAccountByIdResult.class);
GetAccountByIdResult result = re.getBody();
new ParameterizedTypeReference<Response<User>>() {
});
Response<User> result = re.getBody();
return result;
}

Expand Down
6 changes: 5 additions & 1 deletion ts-config-service/src/main/java/config/SecurityConfig.java
Expand Up @@ -3,6 +3,7 @@
import edu.fudan.common.security.jwt.JWTFilter;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpMethod;
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
Expand Down Expand Up @@ -61,7 +62,10 @@ protected void configure(HttpSecurity httpSecurity) throws Exception {
.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS)
.and()
.authorizeRequests()
.antMatchers("/api/v1/configservice/**").hasAnyRole("ADMIN", "USER")
.antMatchers("/api/v1/configservice/**").permitAll()
.antMatchers(HttpMethod.POST, "/api/v1/configservice/configs").hasAnyRole("ADMIN")
.antMatchers(HttpMethod.PUT, "/api/v1/configservice/configs").hasAnyRole("ADMIN")
.antMatchers(HttpMethod.DELETE, "/api/v1/configservice/configs/*").hasAnyRole("ADMIN")
.antMatchers("/swagger-ui.html", "/webjars/**", "/images/**",
"/configuration/**", "/swagger-resources/**", "/v2/**").permitAll()
.anyRequest().authenticated()
Expand Down
Expand Up @@ -23,20 +23,6 @@ public String home(@RequestHeader HttpHeaders headers) {
return "Welcome to [ Consign Service ] !";
}


// {
// "accountId": "f150e530-9142-4cd8-80f1-695693dc704f",
// "consignee": "string",
// "from": "string",
// "handleDate": "Fri Apr 12 13:29:40 CST 2019",
// "id": "f150e530-9142-4cd8-80f1-695693dc704f",
// "phone": "string",
// "targetDate": "Fri Apr 12 13:29:40 CST 2019",
// "to": "string",
// "weight": 12.3,
// "within": true
// }
//
@PostMapping(value = "/consigns")
public HttpEntity insertConsign(@RequestBody Consign request,
@RequestHeader HttpHeaders headers) {
Expand All @@ -54,6 +40,13 @@ public HttpEntity findByAccountId(@PathVariable String id, @RequestHeader HttpHe
return ok(service.queryByAccountId(newid, headers));
}

@GetMapping(value = "/consigns/order/{id}")
public HttpEntity findByOrderId(@PathVariable String id, @RequestHeader HttpHeaders headers) {
UUID newid = UUID.fromString(id);
return ok(service.queryByOrderId(newid, headers));
}


@GetMapping(value = "/consigns/{consignee}")
public HttpEntity findByConsignee(@PathVariable String consignee, @RequestHeader HttpHeaders headers) {
return ok(service.queryByConsignee(consignee, headers));
Expand Down

0 comments on commit 0be53ee

Please sign in to comment.