Parcourir la source

- goods 表的查询
- goods mapper 关键字修改

tianyunperfect il y a 3 ans
Parent
commit
4c834e50e4

+ 4 - 4
book-dao/src/main/resources/mapper/cps/GoodsMapper.xml

@@ -102,7 +102,7 @@
     -->
     id, category_id, money, type, business_line, kandian, free_kandian, day, free_day, 
     title, first_description, second_description, icon, show_type, weigh, createtime, 
-    updatetime, desc
+    updatetime, `desc`
   </sql>
   <select id="selectByExample" parameterType="com.book.dao.cps.pojo.example.GoodsExample" resultMap="BaseResultMap">
     <!--
@@ -229,7 +229,7 @@
       free_kandian, day, free_day, 
       title, first_description, second_description, 
       icon, show_type, weigh, 
-      createtime, updatetime, desc
+      createtime, updatetime, `desc`
       )
     values (#{id,jdbcType=INTEGER}, #{categoryId,jdbcType=VARCHAR}, #{money,jdbcType=DECIMAL}, 
       #{type,jdbcType=CHAR}, #{businessLine,jdbcType=VARCHAR}, #{kandian,jdbcType=INTEGER}, 
@@ -646,7 +646,7 @@
     insert into goods
     (id, category_id, money, type, business_line, kandian, free_kandian, day, free_day, 
       title, first_description, second_description, icon, show_type, weigh, createtime, 
-      updatetime, desc)
+      updatetime, `desc`)
     values
     <foreach collection="list" item="item" separator=",">
       (#{item.id,jdbcType=INTEGER}, #{item.categoryId,jdbcType=VARCHAR}, #{item.money,jdbcType=DECIMAL}, 
@@ -946,7 +946,7 @@
     insert into goods
     (id, category_id, money, type, business_line, kandian, free_kandian, day, free_day, 
       title, first_description, second_description, icon, show_type, weigh, createtime, 
-      updatetime, desc)
+      updatetime, `desc`)
     values
     (#{id,jdbcType=INTEGER}, #{categoryId,jdbcType=VARCHAR}, #{money,jdbcType=DECIMAL}, 
       #{type,jdbcType=CHAR}, #{businessLine,jdbcType=VARCHAR}, #{kandian,jdbcType=INTEGER}, 

+ 32 - 0
book-server/src/main/java/com/book/server/controller/GoodsController.java

@@ -0,0 +1,32 @@
+package com.book.server.controller;
+
+import com.book.dao.cps.entity.Goods;
+import com.book.server.common.entity.Result;
+import com.book.server.service.GoodsService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.List;
+
+/**
+ * 商品
+ */
+@RestController
+@RequestMapping("/api/goods")
+@Slf4j
+public class GoodsController extends BaseController{
+    @Autowired
+    private GoodsService goodsService;
+
+    /**
+     * 获取固定支付种类
+     * @return
+     */
+    @GetMapping("/get")
+    public Result<List<Goods>> getUnPayedGoods() {
+        return Result.success(goodsService.getUnPayedGoods());
+    }
+}

+ 9 - 0
book-server/src/main/java/com/book/server/service/GoodsService.java

@@ -0,0 +1,9 @@
+package com.book.server.service;
+
+import com.book.dao.cps.entity.Goods;
+
+import java.util.List;
+
+public interface GoodsService {
+    List<Goods> getUnPayedGoods();
+}

+ 25 - 0
book-server/src/main/java/com/book/server/service/impl/GoodServiceImpl.java

@@ -0,0 +1,25 @@
+package com.book.server.service.impl;
+
+import com.book.dao.cps.entity.Goods;
+import com.book.dao.cps.mapper.GoodsMapper;
+import com.book.dao.cps.pojo.example.GoodsExample;
+import com.book.server.service.GoodsService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+@Service
+public class GoodServiceImpl implements GoodsService {
+    @Autowired
+    private GoodsMapper goodsMapper;
+
+    @Override
+    public List<Goods> getUnPayedGoods() {
+        GoodsExample example = GoodsExample.newAndCreateCriteria()
+                .andShowTypeEqualTo("2")
+                .example();
+        example.orderBy(Goods.Column.weigh.desc());
+        return goodsMapper.selectByExample(example);
+    }
+}