Browse Source

订单

master
xyiege 4 years ago
parent
commit
253359f405
  1. 13
      src/main/java/cn/chjyj/szwh/controller/admin/AdminOrderController.java
  2. 7
      src/main/java/cn/chjyj/szwh/mapper/OrderGoodsDetailMapper.java
  3. 15
      src/main/java/cn/chjyj/szwh/service/OrderGoodsDetailService.java
  4. 17
      src/main/java/cn/chjyj/szwh/service/impl/OrderGoodsDetailServiceImpl.java
  5. 6
      src/main/resources/mapper/szwh/OrderGoodsDetailMapper.xml
  6. 23
      src/test/java/cn/chjyj/szwh/mapper/OrderGoodsDetailMapperTest.java

13
src/main/java/cn/chjyj/szwh/controller/admin/AdminOrderController.java

@ -3,6 +3,7 @@ package cn.chjyj.szwh.controller.admin;
import cn.chjyj.szwh.bean.Order;
import cn.chjyj.szwh.bean.OrderGoodsDetail;
import cn.chjyj.szwh.controller.BaseController;
import cn.chjyj.szwh.service.OrderGoodsDetailService;
import cn.chjyj.szwh.service.OrderService;
import com.alibaba.fastjson.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
@ -21,6 +22,8 @@ import java.util.Map;
public class AdminOrderController extends BaseController {
@Autowired
private OrderService orderService;
@Autowired
private OrderGoodsDetailService orderGoodsDetailService;
/**
* 订单列列表
@ -77,4 +80,14 @@ public class AdminOrderController extends BaseController {
jsonObject.put("data",order);
return jsonObject;
}
@PostMapping("/orderGoodsDetail")
public JSONObject orderGoodsDetail(String id){
Integer sid = Integer.valueOf(id);
OrderGoodsDetail orderGoodsDetail = orderGoodsDetailService.getOrderGoodsById(sid);
jsonObject.put("data",orderGoodsDetail);
jsonObject.put("code",200);
jsonObject.put("msg","操作成功");
return jsonObject;
}
}

7
src/main/java/cn/chjyj/szwh/mapper/OrderGoodsDetailMapper.java

@ -1,5 +1,6 @@
package cn.chjyj.szwh.mapper;
import cn.chjyj.szwh.bean.OrderGoodsDetail;
import org.springframework.stereotype.Component;
/**
@ -7,4 +8,10 @@ import org.springframework.stereotype.Component;
*/
@Component
public interface OrderGoodsDetailMapper {
/**
* 根据id查询
* @param id
* @return
*/
OrderGoodsDetail getOrderGoodsDetailById(Integer id);
}

15
src/main/java/cn/chjyj/szwh/service/OrderGoodsDetailService.java

@ -0,0 +1,15 @@
package cn.chjyj.szwh.service;
import cn.chjyj.szwh.bean.OrderGoodsDetail;
/**
* 订单产品服务接口
*/
public interface OrderGoodsDetailService {
/**
* 查询明细
* @param id
* @return
*/
OrderGoodsDetail getOrderGoodsById(Integer id);
}

17
src/main/java/cn/chjyj/szwh/service/impl/OrderGoodsDetailServiceImpl.java

@ -0,0 +1,17 @@
package cn.chjyj.szwh.service.impl;
import cn.chjyj.szwh.bean.OrderGoodsDetail;
import cn.chjyj.szwh.mapper.OrderGoodsDetailMapper;
import cn.chjyj.szwh.service.OrderGoodsDetailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class OrderGoodsDetailServiceImpl implements OrderGoodsDetailService {
@Autowired
private OrderGoodsDetailMapper orderGoodsDetailMapper;
@Override
public OrderGoodsDetail getOrderGoodsById(Integer id) {
return orderGoodsDetailMapper.getOrderGoodsDetailById(id);
}
}

6
src/main/resources/mapper/szwh/OrderGoodsDetailMapper.xml

@ -29,11 +29,11 @@
)SELECT * FROM mm ORDER BY id DESC;
</select>
<!--根据uid查询用户-->
<select id="getUserByUid" parameterType="java.lang.Integer" resultType="cn.chjyj.szwh.bean.Goods">
<!--根据id查询-->
<select id="getOrderGoodsDetailById" parameterType="java.lang.Integer" resultType="cn.chjyj.szwh.bean.OrderGoodsDetail">
select <include refid="column"/>
from <include refid="tbName"/>
where uid=#{uid}
where id=#{id}
</select>
<!--查询用户名,加上密码-->

23
src/test/java/cn/chjyj/szwh/mapper/OrderGoodsDetailMapperTest.java

@ -0,0 +1,23 @@
package cn.chjyj.szwh.mapper;
import cn.chjyj.szwh.bean.OrderGoodsDetail;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import static org.junit.Assert.*;
@SpringBootTest
@RunWith(SpringRunner.class)
public class OrderGoodsDetailMapperTest {
@Autowired
private OrderGoodsDetailMapper orderGoodsDetailMapper;
@Test
public void getOrderGoodsDetailById() {
int id=1;
OrderGoodsDetail orderGoodsDetail = orderGoodsDetailMapper.getOrderGoodsDetailById(id);
System.out.println(orderGoodsDetail.getGoodsImage());
}
}
Loading…
Cancel
Save