Browse Source

活动时间查询问题修改

liweifan 3 years ago
parent
commit
9b16d491f4

+ 9 - 12
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/dto/search/ActivityPlanSearch.java

@@ -8,6 +8,7 @@ import org.springframework.format.annotation.DateTimeFormat;
 
 import java.time.LocalDateTime;
 import java.time.LocalTime;
+import java.util.Date;
 
 /**
  * @Author: liweifan
@@ -25,11 +26,11 @@ public class ActivityPlanSearch extends QueryInfo{
 	@ApiModelProperty(value = "活动开始时间")
 	@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
 	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
-	private LocalDateTime startTime;
+	private Date startTime;
 	@ApiModelProperty(value = "活动结束时间")
 	@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
 	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
-	private LocalDateTime endTime;
+	private Date endTime;
 
 	public String getActivityName() {
 		return activityName;
@@ -55,23 +56,19 @@ public class ActivityPlanSearch extends QueryInfo{
 		this.activityState = activityState;
 	}
 
-	public LocalDateTime getStartTime() {
+	public Date getStartTime() {
 		return startTime;
 	}
 
-	public void setStartTime(LocalDateTime startTime) {
-		if(null != startTime){
-			this.startTime = LocalDateTime.of(startTime.toLocalDate(), LocalTime.MIN);
-		}
+	public void setStartTime(Date startTime) {
+		this.startTime = startTime;
 	}
 
-	public LocalDateTime getEndTime() {
+	public Date getEndTime() {
 		return endTime;
 	}
 
-	public void setEndTime(LocalDateTime endTime) {
-		if(null != endTime){
-			this.endTime = LocalDateTime.of(endTime.toLocalDate(), LocalTime.MAX);
-		}
+	public void setEndTime(Date endTime) {
+		this.endTime = endTime;
 	}
 }

+ 11 - 5
cooleshow-user/user-biz/src/main/resources/config/mybatis/ActivityPlanMapper.xml

@@ -72,11 +72,17 @@
             <if test="param.activityState != null">
                 and t.activity_state_ = #{param.activityState}
             </if>
-            <if test="param.startTime !=null">
-                <![CDATA[AND t.activity_end_ >= #{param.startTime} ]]>
-            </if>
-            <if test="param.endTime !=null">
-                <![CDATA[AND t.activity_start_ <= #{param.endTime} ]]>
+            <if test="param.startTime !=null or param.endTime !=null">
+                and NOT (
+                    <trim prefixOverrides="OR">
+                        <if test="param.startTime !=null">
+                            OR t.activity_end_ &lt; #{param.startTime}
+                        </if>
+                        <if test="param.endTime !=null">
+                            OR t.activity_start_ &gt; #{param.endTime}
+                        </if>
+                    </trim>
+                )
             </if>
         </where>
         order by t.id_ desc