Commit 31c45ee6 by 丁伟峰

订单创建接口实现

1 parent ac6441f3
package com.alibaba.cloud.integration.order.dao;
import com.alibaba.cloud.integration.order.entity.OrderRequestEntity;
import org.springframework.data.jpa.repository.JpaRepository;
public interface OrderReqeustDao extends JpaRepository <OrderRequestEntity, Long> {
}
...@@ -15,5 +15,5 @@ public class OrderCreateReqDTO { ...@@ -15,5 +15,5 @@ public class OrderCreateReqDTO {
private String expectEnd; private String expectEnd;
private String priority; private String priority;
private String orderTags; private String orderTags;
private String memo; private String description;
} }
...@@ -16,6 +16,8 @@ ...@@ -16,6 +16,8 @@
package com.alibaba.cloud.integration.order.entity; package com.alibaba.cloud.integration.order.entity;
import lombok.Data;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.GeneratedValue; import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType; import javax.persistence.GenerationType;
...@@ -23,7 +25,8 @@ import javax.persistence.Id; ...@@ -23,7 +25,8 @@ import javax.persistence.Id;
import java.io.Serializable; import java.io.Serializable;
@Entity @Entity
public class OrderRequestEntity implements Serializable { @Data
public class OrderRequestEntity {
@Id @Id
@GeneratedValue(strategy = GenerationType.IDENTITY) @GeneratedValue(strategy = GenerationType.IDENTITY)
......
...@@ -17,7 +17,10 @@ ...@@ -17,7 +17,10 @@
package com.alibaba.cloud.integration.order.service.impl; package com.alibaba.cloud.integration.order.service.impl;
import com.alibaba.cloud.integration.common.Result; import com.alibaba.cloud.integration.common.Result;
import com.alibaba.cloud.integration.order.dao.OrderReqeustDao;
import com.alibaba.cloud.integration.order.dto.LocationDTO;
import com.alibaba.cloud.integration.order.dto.OrderCreateReqDTO; import com.alibaba.cloud.integration.order.dto.OrderCreateReqDTO;
import com.alibaba.cloud.integration.order.entity.OrderRequestEntity;
import com.alibaba.cloud.integration.order.feign.AccountServiceFeignClient; import com.alibaba.cloud.integration.order.feign.AccountServiceFeignClient;
import com.alibaba.cloud.integration.order.feign.StorageServiceFeignClient; import com.alibaba.cloud.integration.order.feign.StorageServiceFeignClient;
import com.alibaba.cloud.integration.order.mapper.OrderMapper; import com.alibaba.cloud.integration.order.mapper.OrderMapper;
...@@ -33,22 +36,37 @@ import org.springframework.stereotype.Service; ...@@ -33,22 +36,37 @@ import org.springframework.stereotype.Service;
@Service @Service
public class OrderServiceImpl implements OrderService { public class OrderServiceImpl implements OrderService {
@Autowired @Autowired
private OrderMapper orderMapper; private OrderReqeustDao orderReqeustDao;
@Autowired @Override
private AccountServiceFeignClient accountService; @GlobalTransactional
public Result<?> createOrder(OrderCreateReqDTO req) {
@Autowired
private StorageServiceFeignClient storageService;
@Override
@GlobalTransactional
public Result<?> createOrder(OrderCreateReqDTO orderCreateReqDTO) {
log.info("[createOrder] current XID: {}", RootContext.getXID());
return null;
}
log.info("[createOrder] current XID: {}", RootContext.getXID());
OrderRequestEntity entity = new OrderRequestEntity();
entity.setName(req.getName());
entity.setPhone(req.getPhone());
entity.setAddress(req.getAddress());
entity.setBrand(req.getBrand());
entity.setCategoryId(req.getCatalogId());
entity.setFaultDescribe(req.getFaultDescribe());
entity.setExpectTimeBegin(req.getExpectBegin());
entity.setExpectTimeEnd(req.getExpectEnd());
entity.setDescription(req.getDescription());
// location
LocationDTO location = req.getLocation();
entity.setProvince(location.getProvince());
entity.setCity(location.getCity());
entity.setCounty(location.getCountry());
orderReqeustDao.save(entity);
// 根据orderTags, 解析保存到type、skill等字段
String[] l = req.getLocation().getLocation().split(",");
entity.setX(l[0]);
entity.setY(l[1]);
// todo 服务单状态、预约状态等
entity.setStatus("");
entity.setAppointmentStatus("");
return Result.success(null);
}
} }
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!