Authored by tanling

接口

package com.yohoufo.order.controller;
import com.yohoufo.order.request.ShoppingRequest;
import com.yohoufo.order.response.ShoppingPaymentResponse;
import com.yohoufo.order.service.IShoppingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
@Controller
@RequestMapping(value = "/shopping")
public class ShoppingController {
@Autowired
IShoppingService shoppingService;
@RequestMapping("/payment")
@ResponseBody
public ShoppingPaymentResponse payment(@RequestBody ShoppingRequest shoppingRequest){
return null;
}
}
... ...
package com.yohoufo.order.request;
import lombok.Data;
@Data
public class ShoppingRequest {
private String skup;
private String uid;
}
... ...
package com.yohoufo.order.response;
import lombok.Data;
@Data
public class ShoppingPaymentResponse {
}
... ...
package com.yohoufo.order.service;
public interface IShoppingService {
}
... ...
package com.yohoufo.order.service.impl;
import com.yoho.error.ServiceError;
import com.yoho.error.exception.ServiceException;
import com.yohoufo.order.request.ShoppingRequest;
import com.yohoufo.order.response.ShoppingPaymentResponse;
import com.yohoufo.order.service.IShoppingService;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class ShoppingServiceImpl implements IShoppingService{
private final Logger logger = LoggerFactory.getLogger(getClass());
public ShoppingPaymentResponse payment(ShoppingRequest shoppingRequest){
// 入口参数检查
if (StringUtils.isEmpty(shoppingRequest.getUid())
|| StringUtils.isEmpty(shoppingRequest.getSkup())){
logger.warn("payment uid or skup is null");
// TODO
throw new ServiceException(ServiceError.ORDER_REQUEST_ERROR);
}
// skup是否是可售状态
return null;
}
}
... ...
... ... @@ -6,7 +6,7 @@
<parent>
<groupId>com.yoho</groupId>
<artifactId>parent</artifactId>
<version>1.4.4-SNAPSHOT</version>
<version>1.4.5-SNAPSHOT</version>
</parent>
<groupId>com.yohoufo.fore</groupId>
... ...
<?xml version="1.0" encoding="UTF-8"?>
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8" inherit-compiler-output="false">
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
<output url="file://$MODULE_DIR$/target/classes" />
<output-test url="file://$MODULE_DIR$/target/test-classes" />
<content url="file://$MODULE_DIR$">
... ...