linhw 2024-07-25 13:36:03 +08:00
parent b99154e174
commit 9c7db3bfca
4 changed files with 41 additions and 0 deletions

View File

@ -1,7 +1,10 @@
package com.ruoyi.app.domain; package com.ruoyi.app.domain;
import java.util.Date; import java.util.Date;
import java.util.List;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle; import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.core.annotation.Excel; import com.ruoyi.common.core.annotation.Excel;
@ -13,6 +16,7 @@ import com.ruoyi.common.core.web.domain.BaseEntity;
* @author wyh * @author wyh
* @date 2024-07-23 * @date 2024-07-23
*/ */
@Data
public class AppEvents extends BaseEntity public class AppEvents extends BaseEntity
{ {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@ -54,6 +58,8 @@ public class AppEvents extends BaseEntity
@Excel(name = "状态1-未开始2-报名中3-已结束") @Excel(name = "状态1-未开始2-报名中3-已结束")
private Long type; private Long type;
private List<Long> ids;
public void setId(Long id) public void setId(Long id)
{ {
this.id = id; this.id = id;
@ -136,6 +142,7 @@ public class AppEvents extends BaseEntity
return type; return type;
} }
@Override @Override
public String toString() { public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)

View File

@ -58,4 +58,6 @@ public interface AppEventsMapper
* @return * @return
*/ */
public int deleteAppEventsByIds(Long[] ids); public int deleteAppEventsByIds(Long[] ids);
int updateByTypeAppEvents(AppEvents appEvents);
} }

View File

@ -1,5 +1,7 @@
package com.ruoyi.app.service; package com.ruoyi.app.service;
import com.ruoyi.app.domain.AppEvents;
import com.ruoyi.app.mapper.AppEventsMapper;
import com.ruoyi.app.mapper.AppUserMapper; import com.ruoyi.app.mapper.AppUserMapper;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled; import org.springframework.scheduling.annotation.Scheduled;
@ -12,6 +14,9 @@ public class ScheduledService {
@Autowired @Autowired
private AppUserMapper appUserMapper; private AppUserMapper appUserMapper;
@Autowired
private AppEventsMapper appEventsMapper;
@Scheduled(cron = "0/5 * * * * *") @Scheduled(cron = "0/5 * * * * *")
public void updateUserMember(){ public void updateUserMember(){
appUserMapper.updateAppUserById(); appUserMapper.updateAppUserById();
@ -20,4 +25,13 @@ public class ScheduledService {
appUserMapper.updateAppUserById(ids); appUserMapper.updateAppUserById(ids);
}*/ }*/
} }
@Scheduled(cron = "0 */1 * * * *")
public void updateEvents(){
AppEvents appEvents = new AppEvents();
appEvents.setType(1l);
appEventsMapper.updateByTypeAppEvents(appEvents);
appEvents.setType(2l);
appEventsMapper.updateByTypeAppEvents(appEvents);
}
} }

View File

@ -99,6 +99,24 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where id = #{id} where id = #{id}
</update> </update>
<update id="updateByTypeAppEvents" parameterType="AppEvents">
update app_events
<trim prefix="SET" suffixOverrides=",">
<if test="type == 1">type = 2,</if>
<if test="type == 2">type = 3,</if>
update_time = now(),
</trim>
where
<if test="type == 1">
type = 1
and start_time gt;= now()
</if>
<if test="type == 2">
type = 2
and end_time gt;= now()
</if>
</update>
<delete id="deleteAppEventsById" parameterType="Long"> <delete id="deleteAppEventsById" parameterType="Long">
delete from app_events where id = #{id} delete from app_events where id = #{id}
</delete> </delete>