Преглед изворни кода

change structure of SQL Table `coupon` and change property `effective` of Coupon to `valid`.

tubinyan пре 5 година
родитељ
комит
01ad7edb72

+ 2 - 2
sql/courselearning.sql

@@ -330,8 +330,8 @@ CREATE TABLE `coupon` (
   `cut_down` int DEFAULT '0',
   `start_time` datetime DEFAULT NULL,
   `end_time` datetime DEFAULT NULL,
-  `effective` tinyint(1) NOT NULL DEFAULT '1',
-  `sharable` tinyint(1) NOT NULL DEFAULT '1',
+  `is_valid` tinyint(1) NOT NULL DEFAULT '1',
+  `is_sharable` tinyint(1) NOT NULL DEFAULT '1',
   PRIMARY KEY (`id`)
 ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4;
 

+ 32 - 0
src/main/java/cn/seecoder/courselearning/config/LocalDateTimeConvertConfig.java

@@ -0,0 +1,32 @@
+package cn.seecoder.courselearning.config;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
+import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
+import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
+
+@Configuration
+public class LocalDateTimeConvertConfig {
+    @Bean
+    public ObjectMapper getObjectMapper() {
+        ObjectMapper objectMapper = new ObjectMapper();
+        JavaTimeModule javaTimeModule = new JavaTimeModule();
+         
+        // 日期序列化
+        javaTimeModule.addSerializer(LocalDateTime.class, new LocalDateTimeSerializer(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
+//        javaTimeModule.addSerializer(LocalDate.class, new LocalDateSerializer(DateTimeFormatter.ofPattern("yyyy-MM-dd")));
+//        javaTimeModule.addSerializer(LocalTime.class, new LocalTimeSerializer(DateTimeFormatter.ofPattern("HH:mm:ss")));
+         
+        // 日期反序列化
+        javaTimeModule.addDeserializer(LocalDateTime.class,new LocalDateTimeDeserializer(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
+//        javaTimeModule.addDeserializer(LocalDate.class,new LocalDateDeserializer(DateTimeFormatter.ofPattern("yyyy-MM-dd")));
+//        javaTimeModule.addDeserializer(LocalTime.class,new LocalTimeDeserializer(DateTimeFormatter.ofPattern("HH:mm:ss")));
+         
+        objectMapper.registerModule(javaTimeModule);
+        return objectMapper;
+    }
+}

+ 23 - 23
src/main/java/cn/seecoder/courselearning/controller/CouponController.java

@@ -24,17 +24,17 @@ public class CouponController {
         return couponService.createUniversalCoupon(universalCouponDTO);
     }
 
-    // 创建课程型优惠券
-    @PostMapping("/create/course")
-    ResultVO<CouponVO> createCourseCoupon(@RequestBody CourseCouponDTO courseCouponDTO) {
-        return couponService.createCourseCoupon(courseCouponDTO);
-    }
-
-    // 创建用户定制化优惠券
-    @PostMapping("/create/universal")
-    ResultVO<CouponVO> createUserCoupon(@RequestBody UserCouponDTO userCouponDTO) {
-        return couponService.createUserCoupon(userCouponDTO);
-    }
+//    // 创建课程型优惠券
+//    @PostMapping("/create/course")
+//    ResultVO<CouponVO> createCourseCoupon(@RequestBody CourseCouponDTO courseCouponDTO) {
+//        return couponService.createCourseCoupon(courseCouponDTO);
+//    }
+//
+//    // 创建用户定制化优惠券
+//    @PostMapping("/create/user")
+//    ResultVO<CouponVO> createUserCoupon(@RequestBody UserCouponDTO userCouponDTO) {
+//        return couponService.createUserCoupon(userCouponDTO);
+//    }
 
     // 查看所有的网站通用型优惠券
     @GetMapping("/universal")
@@ -43,21 +43,21 @@ public class CouponController {
     }
 
 
-    // 查看当前课程所有的课程优惠券(不含网站通用优惠券、用户定制化优惠券) 包含已经失效了的优惠活动
-    @GetMapping("/course/{courseId}")
-    List<CouponVO> getCourseCoupons(@PathVariable Integer courseId) {
-        return couponService.getCourseCoupons(courseId);
-    }
-
+//    // 查看当前课程所有的课程优惠券(不含网站通用优惠券、用户定制化优惠券) 包含已经失效了的优惠活动
+//    @GetMapping("/course/{courseId}")
+//    List<CouponVO> getCourseCoupons(@PathVariable Integer courseId) {
+//        return couponService.getCourseCoupons(courseId);
+//    }
+//
 //    // 查询 userId 对应的用户 目前可以使用的有效的优惠券
 //    @GetMapping("/user/{userId}")
 //    List<CouponVO> getAllEffectiveCouponsForUser(@PathVariable Integer userId) {
 //        return couponService.getAllEffectiveUserCoupons(userId);
 //    }
-
-    // 查看当前用户购买此课程可生效的所有优惠
-    @GetMapping("/check_for_order")
-    List<CouponVO> getAllEffectiveCouponsForOrder(@RequestBody CourseOrderVO orderVO) {
-        return couponService.getAllEffectiveCouponsForOrder(orderVO);
-    }
+//
+//    // 查看当前用户购买此课程可生效的所有优惠
+//    @GetMapping("/check_for_order")
+//    List<CouponVO> getAllEffectiveCouponsForOrder(@RequestBody CourseOrderVO orderVO) {
+//        return couponService.getAllEffectiveCouponsForOrder(orderVO);
+//    }
 }

+ 4 - 1
src/main/java/cn/seecoder/courselearning/dto/CourseCouponDTO.java

@@ -2,6 +2,7 @@ package cn.seecoder.courselearning.dto;
 
 import cn.seecoder.courselearning.enums.CouponType;
 import lombok.Data;
+import org.springframework.format.annotation.DateTimeFormat;
 
 import java.time.LocalDateTime;
 
@@ -15,10 +16,12 @@ public class CourseCouponDTO {
     private String name;
     private String description;
     private Integer courseId;
-    private double discount;
+    private Double discount;
     private Integer threshold;
     private Integer cutDown;
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
     private LocalDateTime startTime;
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
     private LocalDateTime endTime;
     private Boolean sharable;
 }

+ 3 - 1
src/main/java/cn/seecoder/courselearning/dto/UniversalCouponDTO.java

@@ -1,7 +1,9 @@
 package cn.seecoder.courselearning.dto;
 
 import cn.seecoder.courselearning.enums.CouponType;
+import com.fasterxml.jackson.annotation.JsonFormat;
 import lombok.Data;
+import org.springframework.format.annotation.DateTimeFormat;
 
 import java.time.LocalDateTime;
 
@@ -14,7 +16,7 @@ public class UniversalCouponDTO {
     private CouponType type;
     private String name;
     private String description;
-    private double discount;
+    private Double discount;
     private Integer threshold;
     private Integer cutDown;
     private LocalDateTime startTime;

+ 4 - 1
src/main/java/cn/seecoder/courselearning/dto/UserCouponDTO.java

@@ -2,6 +2,7 @@ package cn.seecoder.courselearning.dto;
 
 import cn.seecoder.courselearning.enums.CouponType;
 import lombok.Data;
+import org.springframework.format.annotation.DateTimeFormat;
 
 import java.time.LocalDateTime;
 
@@ -16,10 +17,12 @@ public class UserCouponDTO {
     private String description;
     private Integer courseId;
     private Integer validUserId;
-    private double discount;
+    private Double discount;
     private Integer threshold;
     private Integer cutDown;
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
     private LocalDateTime startTime;
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
     private LocalDateTime endTime;
     private Boolean sharable;
 }

+ 15 - 3
src/main/java/cn/seecoder/courselearning/po/Coupon.java

@@ -2,7 +2,9 @@ package cn.seecoder.courselearning.po;
 
 import cn.seecoder.courselearning.enums.CouponType;
 import cn.seecoder.courselearning.vo.CouponVO;
+import lombok.AccessLevel;
 import lombok.Data;
+import lombok.Getter;
 import lombok.NoArgsConstructor;
 
 import java.time.LocalDateTime;
@@ -69,13 +71,23 @@ public class Coupon {
     /**
      * 优惠券是否可用 true可用 false失效(一次性的券使用后就失效 或 网站关闭活动)
      */
-    private Boolean effective;
+    @Getter(AccessLevel.NONE)
+    private Boolean valid;
 
     /**
      * 能否与其他优惠券同时使用 true可同时使用 false不能同时使用
      */
+    @Getter(AccessLevel.NONE)
     private Boolean sharable;
 
+    public Boolean isValid() {
+        return valid;
+    }
+
+    public Boolean isSharable() {
+        return sharable;
+    }
+
     public Coupon(CouponVO couponVO) {
         this.type = CouponType.valueOf(couponVO.getType());
         this.name = couponVO.getName();
@@ -87,7 +99,7 @@ public class Coupon {
         this.cutDown = couponVO.getCutDown();
         this.startTime = couponVO.getStartTime();
         this.endTime = couponVO.getEndTime();
-        this.effective = couponVO.getEffective();
-        this.sharable = couponVO.getSharable();
+        this.valid = couponVO.isValid();
+        this.sharable = couponVO.isSharable();
     }
 }

+ 6 - 4
src/main/java/cn/seecoder/courselearning/service/CouponService.java

@@ -15,8 +15,10 @@ public interface CouponService {
     ResultVO<CouponVO> createUserCoupon(UserCouponDTO userCouponDTO);
     // 查看所有的网站通用型优惠券
     List<CouponVO> getUniversalCoupons();
-    // 查看当前课程所有的课程优惠券(不含网站通用优惠券、用户定制化优惠券) 包含已经失效了的优惠活动
-    List<CouponVO> getCourseCoupons(Integer courseId);
-    // 查看当前用户购买此课程可生效的所有优惠
-    List<CouponVO> getAllEffectiveCouponsForOrder(CourseOrderVO orderVO);
+//    // 查看当前课程所有的课程优惠券(不含网站通用优惠券、用户定制化优惠券) 包含已经失效了的优惠活动
+//    List<CouponVO> getCourseCoupons(Integer courseId);
+//    // 查询 userId 对应的用户 目前可以使用的有效的优惠券
+//    List<CouponVO> getAllEffectiveUserCoupons(Integer userId);
+//    // 查看当前用户购买此课程可生效的所有优惠
+//    List<CouponVO> getAllEffectiveCouponsForOrder(CourseOrderVO orderVO);
 }

+ 1 - 1
src/main/java/cn/seecoder/courselearning/service/CouponStrategy.java

@@ -27,7 +27,7 @@ public interface CouponStrategy {
         // 获取当前时间
         LocalDateTime now = LocalDateTime.now();
         if (isMatch(orderVO, coupon)) {
-            return coupon.getEffective() && coupon.getThreshold()>=orderVO.getCost()
+            return coupon.isValid() && coupon.getThreshold()>=orderVO.getCost()
                     && (coupon.getStartTime()==null || now.isAfter(coupon.getStartTime()))
                     && (coupon.getEndTime()==null || now.isBefore(coupon.getEndTime()));
         }

+ 59 - 39
src/main/java/cn/seecoder/courselearning/serviceimpl/CouponServiceImpl.java

@@ -21,6 +21,7 @@ import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
 import java.util.ArrayList;
+import java.util.Date;
 import java.util.List;
 
 @Service
@@ -28,28 +29,31 @@ public class CouponServiceImpl implements CouponService {
     @Resource
     private CouponMapper couponMapper;
 
-    private final List<CouponStrategy> couponStrategyList;
-
-    @Autowired
-    public CouponServiceImpl(UniversalCouponStrategyImpl universalCouponMatchStrategy, CourseCouponStrategyImpl courseCouponMatchStrategy, UserCouponStrategyImpl userCouponMatchStrategy) {
-        couponStrategyList = new ArrayList<>();
-        couponStrategyList.add(universalCouponMatchStrategy);
-        couponStrategyList.add(courseCouponMatchStrategy);
-        couponStrategyList.add(userCouponMatchStrategy);
-    }
+//    private final List<CouponStrategy> couponStrategyList;
+//
+//    @Autowired
+//    public CouponServiceImpl(UniversalCouponStrategyImpl universalCouponMatchStrategy, CourseCouponStrategyImpl courseCouponMatchStrategy, UserCouponStrategyImpl userCouponMatchStrategy) {
+//        couponStrategyList = new ArrayList<>();
+//        couponStrategyList.add(universalCouponMatchStrategy);
+//        couponStrategyList.add(courseCouponMatchStrategy);
+//        couponStrategyList.add(userCouponMatchStrategy);
+//    }
 
     @Override
     public ResultVO<CouponVO> createUniversalCoupon(UniversalCouponDTO universalCouponDTO) {
+        System.out.println(universalCouponDTO);
         Coupon coupon = new Coupon();
         BeanUtils.copyProperties(universalCouponDTO, coupon);
         // 网站优惠活动生成的优惠券一定是对所有用户、所有课程均有效的
         coupon.setValidUserId(-1);
         coupon.setCourseId(-1);
-        coupon.setEffective(true);
+        coupon.setValid(true);
         if(CouponValidator.isInvalid(coupon))
             return new ResultVO<>(Constant.REQUEST_FAIL, "优惠信息填写有误!");
-        if(couponMapper.insert(coupon) > 0)
+        if(couponMapper.insert(coupon) > 0) {
+            System.out.println(coupon);
             return new ResultVO<>(Constant.REQUEST_SUCCESS, "网站优惠活动创建成功", new CouponVO(coupon));
+        }
         return new ResultVO<>(Constant.REQUEST_FAIL, "网站优惠活动创建失败");
     }
 
@@ -59,7 +63,7 @@ public class CouponServiceImpl implements CouponService {
         BeanUtils.copyProperties(courseCouponDTO, coupon);
         // 课程优惠活动生成的优惠券是对所有用户均有效的
         coupon.setValidUserId(-1);
-        coupon.setEffective(true);
+        coupon.setValid(true);
         if(CouponValidator.isInvalid(coupon) || coupon.getCourseId() == -1)
             return new ResultVO<>(Constant.REQUEST_FAIL, "优惠信息填写有误!");
         if(couponMapper.insert(coupon) > 0)
@@ -71,7 +75,7 @@ public class CouponServiceImpl implements CouponService {
     public ResultVO<CouponVO> createUserCoupon(UserCouponDTO userCouponDTO) {
         Coupon coupon = new Coupon();
         BeanUtils.copyProperties(userCouponDTO, coupon);
-        coupon.setEffective(true);
+        coupon.setValid(true);
         // 用户定制化优惠活动生成的优惠券仅对某个用户有效
         if(CouponValidator.isInvalid(coupon) || coupon.getValidUserId() == -1)
             return new ResultVO<>(Constant.REQUEST_FAIL, "优惠信息填写有误!");
@@ -88,31 +92,47 @@ public class CouponServiceImpl implements CouponService {
         return ret;
     }
 
-    @Override
-    public List<CouponVO> getCourseCoupons(Integer courseId) {
-        List<Coupon> couponList = couponMapper.selectByCourseIdAndUserId(courseId, -1);
-        List<CouponVO> ret = new ArrayList<>();
-        couponList.forEach(coupon -> ret.add(new CouponVO(coupon)));
-        return ret;
-    }
+//    @Override
+//    public List<CouponVO> getCourseCoupons(Integer courseId) {
+//        List<Coupon> couponList = couponMapper.selectByCourseIdAndUserId(courseId, -1);
+//        List<CouponVO> ret = new ArrayList<>();
+//        couponList.forEach(coupon -> ret.add(new CouponVO(coupon)));
+//        return ret;
+//    }
 
-    @Override
-    public List<CouponVO> getAllEffectiveCouponsForOrder(CourseOrderVO orderVO) {
-        List<Coupon> universalCoupons = couponMapper.selectByCourseIdAndUserId(-1, -1);
-        List<Coupon> courseCoupons = couponMapper.selectByCourseIdAndUserId(orderVO.getCourseId(), -1);
-        List<Coupon> userCoupons = couponMapper.selectByUserId(orderVO.getUserId());
-        List<Coupon> temp = new ArrayList<>(universalCoupons);
-        temp.addAll(courseCoupons);
-        temp.addAll(userCoupons);
-        List<CouponVO> ret = new ArrayList<>();
-        temp.forEach(coupon -> {
-            for(CouponStrategy strategy: couponStrategyList) {
-                if (strategy.isEffective(orderVO, coupon)) {
-                    ret.add(new CouponVO(coupon));
-                    break;
-                }
-            }
-        });
-        return ret;
-    }
+//    @Override
+//    public List<CouponVO> getAllEffectiveUserCoupons(Integer userId) {
+//        List<Coupon> couponList = couponMapper.selectByUserId(userId);
+//        List<CouponVO> ret = new ArrayList<>();
+//        couponList.forEach(coupon -> {
+//            CourseOrderVO orderVO = new CourseOrderVO();
+//            orderVO.setCourseId(coupon.getCourseId());
+//            orderVO.setUserId(userId);
+//            orderVO.setCost(0);
+//            orderVO.setCreateTime(new Date());
+//            if (couponStrategyList.get(2).isEffective(orderVO, coupon))
+//                ret.add(new CouponVO(coupon));
+//        });
+//        return ret;
+//    }
+//
+//    @Override
+//    public List<CouponVO> getAllEffectiveCouponsForOrder(CourseOrderVO orderVO) {
+//        List<Coupon> universalCoupons = couponMapper.selectByCourseIdAndUserId(-1, -1);
+//        List<Coupon> courseCoupons = couponMapper.selectByCourseIdAndUserId(orderVO.getCourseId(), -1);
+//        List<Coupon> userCoupons = couponMapper.selectByUserId(orderVO.getUserId());
+//        List<Coupon> temp = new ArrayList<>(universalCoupons);
+//        temp.addAll(courseCoupons);
+//        temp.addAll(userCoupons);
+//        List<CouponVO> ret = new ArrayList<>();
+//        temp.forEach(coupon -> {
+//            for(CouponStrategy strategy: couponStrategyList) {
+//                if (strategy.isEffective(orderVO, coupon)) {
+//                    ret.add(new CouponVO(coupon));
+//                    break;
+//                }
+//            }
+//        });
+//        return ret;
+//    }
 }

+ 16 - 3
src/main/java/cn/seecoder/courselearning/vo/CouponVO.java

@@ -1,7 +1,9 @@
 package cn.seecoder.courselearning.vo;
 
 import cn.seecoder.courselearning.po.Coupon;
+import lombok.AccessLevel;
 import lombok.Data;
+import lombok.Getter;
 import lombok.NoArgsConstructor;
 
 import java.time.LocalDateTime;
@@ -67,14 +69,25 @@ public class CouponVO {
     /**
      * 优惠券是否可用 true可用 false失效(一次性的券使用后就失效 或 网站关闭活动)
      */
-    private Boolean effective;
+    @Getter(AccessLevel.NONE)
+    private Boolean valid;
 
     /**
      * 能否与其他优惠券同时使用 true可同时使用 false不能同时使用
      */
+    @Getter(AccessLevel.NONE)
     private Boolean sharable;
 
+    public Boolean isValid() {
+        return valid;
+    }
+
+    public Boolean isSharable() {
+        return sharable;
+    }
+
     public CouponVO(Coupon coupon) {
+        this.id = coupon.getId();
         this.type = coupon.getType().toString();
         this.name = coupon.getName();
         this.description = coupon.getDescription();
@@ -85,7 +98,7 @@ public class CouponVO {
         this.cutDown = coupon.getCutDown();
         this.startTime = coupon.getStartTime();
         this.endTime = coupon.getEndTime();
-        this.effective = coupon.getEffective();
-        this.sharable = coupon.getSharable();
+        this.valid = coupon.isValid();
+        this.sharable = coupon.isSharable();
     }
 }

+ 1 - 1
src/main/java/cn/seecoder/courselearning/vo/CourseVO.java

@@ -55,7 +55,7 @@ public class CourseVO {
         manageable = false;
     }
 
-    public CourseVO(@NonNull Course course, @NonNull boolean bought, @NonNull boolean manageable){
+    public CourseVO(@NonNull Course course, boolean bought, boolean manageable){
         id = course.getId();
         name = course.getName();
         type = course.getType();

+ 1 - 1
src/main/java/cn/seecoder/courselearning/vo/CourseWareVO.java

@@ -49,7 +49,7 @@ public class CourseWareVO {
         uploadTime = courseWare.getUploadTime();
     }
 
-    public CourseWareVO(@NonNull CourseWare courseWare, @NonNull boolean isBought) {
+    public CourseWareVO(@NonNull CourseWare courseWare, boolean isBought) {
         id = courseWare.getId();
         courseId = courseWare.getCourseId();
         number = courseWare.getNumber();

+ 11 - 17
src/main/resources/mapper/CouponMapper.xml

@@ -13,8 +13,8 @@
     <result column="cut_down" jdbcType="INTEGER" property="cutDown" />
     <result column="start_time" jdbcType="TIMESTAMP" property="startTime" />
     <result column="end_time" jdbcType="TIMESTAMP" property="endTime" />
-    <result column="effective" jdbcType="BIT" property="effective" />
-    <result column="sharable" jdbcType="BIT" property="sharable" />
+    <result column="is_valid" jdbcType="BIT" property="valid" />
+    <result column="is_sharable" jdbcType="BIT" property="sharable" />
   </resultMap>
   <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
     delete from coupon
@@ -24,12 +24,12 @@
     insert into coupon (id, type, name, 
       description, course_id, valid_user_id, 
       threshold, discount, cut_down, 
-      start_time, end_time, effective, 
-      sharable)
+      start_time, end_time, is_valid, 
+      is_sharable)
     values (#{id,jdbcType=INTEGER}, #{type,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, 
       #{description,jdbcType=VARCHAR}, #{courseId,jdbcType=INTEGER}, #{validUserId,jdbcType=INTEGER}, 
       #{threshold,jdbcType=INTEGER}, #{discount,jdbcType=DOUBLE}, #{cutDown,jdbcType=INTEGER}, 
-      #{startTime,jdbcType=TIMESTAMP}, #{endTime,jdbcType=TIMESTAMP}, #{effective,jdbcType=BIT}, 
+      #{startTime,jdbcType=TIMESTAMP}, #{endTime,jdbcType=TIMESTAMP}, #{valid,jdbcType=BIT}, 
       #{sharable,jdbcType=BIT})
   </insert>
   <update id="updateByPrimaryKey" parameterType="cn.seecoder.courselearning.po.Coupon">
@@ -44,36 +44,30 @@
       cut_down = #{cutDown,jdbcType=INTEGER},
       start_time = #{startTime,jdbcType=TIMESTAMP},
       end_time = #{endTime,jdbcType=TIMESTAMP},
-      effective = #{effective,jdbcType=BIT},
-      sharable = #{sharable,jdbcType=BIT}
+      is_valid = #{valid,jdbcType=BIT},
+      is_sharable = #{sharable,jdbcType=BIT}
     where id = #{id,jdbcType=INTEGER}
   </update>
   <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
     select id, type, name, description, course_id, valid_user_id, threshold, discount, cut_down, 
-    start_time, end_time, effective, sharable
+    start_time, end_time, is_valid, is_sharable
     from coupon
     where id = #{id,jdbcType=INTEGER}
   </select>
   <select id="selectAll" resultMap="BaseResultMap">
     select id, type, name, description, course_id, valid_user_id, threshold, discount, cut_down, 
-    start_time, end_time, effective, sharable
+    start_time, end_time, is_valid, is_sharable
     from coupon
   </select>
-<!--  <select id="selectAllCourseCoupon" parameterType="java.lang.Integer" resultMap="BaseResultMap">-->
-<!--    select id, type, name, description, course_id, valid_user_id, threshold, discount, cut_down,-->
-<!--           start_time, end_time, effective, sharable-->
-<!--    from coupon-->
-<!--    where (course_id = -1 or course_id = #{courseId,jdbcType=INTEGER}) and valid_user_id = -1-->
-<!--  </select>-->
   <select id="selectByCourseIdAndUserId" parameterType="java.lang.Integer" resultMap="BaseResultMap">
     select id, type, name, description, course_id, valid_user_id, threshold, discount, cut_down,
-           start_time, end_time, effective, sharable
+           start_time, end_time, is_valid, is_sharable
     from coupon
     where course_id = #{courseId,jdbcType=INTEGER} and valid_user_id = #{validUserId,jdbcType=INTEGER}
   </select>
   <select id="selectByUserId" parameterType="java.lang.Integer" resultMap="BaseResultMap">
     select id, type, name, description, course_id, valid_user_id, threshold, discount, cut_down,
-           start_time, end_time, effective, sharable
+           start_time, end_time, is_valid, is_sharable
     from coupon
     where valid_user_id = #{validUserId,jdbcType=INTEGER}
   </select>