85 lines
2.1 KiB
Java
85 lines
2.1 KiB
Java
package com.bruce.sams.service.impl;
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.bruce.sams.domain.ams.Activity;
|
|
import com.bruce.sams.mapper.ActivityMapper;
|
|
import com.bruce.sams.service.ActivityService;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import java.util.List;
|
|
|
|
/**
|
|
* 管理社团活动
|
|
*
|
|
* @author bruce
|
|
* @description 针对表【ams_activity(活动表)】的数据库操作Service实现
|
|
* @createDate 2025-02-17 11:41:53
|
|
*/
|
|
@Service
|
|
public class ActivityServiceImpl extends ServiceImpl<ActivityMapper, Activity>
|
|
implements ActivityService {
|
|
@Autowired
|
|
private ActivityMapper activityMapper;
|
|
|
|
/**
|
|
* 获取所有活动
|
|
*/
|
|
public List<Activity> getAllActivities() {
|
|
return activityMapper.selectList(null);
|
|
}
|
|
|
|
/**
|
|
* 获取活动详情
|
|
*/
|
|
public Activity getActivityById(Long actId) {
|
|
return activityMapper.selectById(actId);
|
|
}
|
|
|
|
/**
|
|
* 获取某个社团的所有活动
|
|
*/
|
|
public List<Activity> getActivitiesByClubId(Long clubId) {
|
|
LambdaQueryWrapper<Activity> wrapper = new LambdaQueryWrapper<>();
|
|
wrapper.eq(Activity::getClubId, clubId);
|
|
return activityMapper.selectList(wrapper);
|
|
}
|
|
|
|
/**
|
|
* 添加活动
|
|
*/
|
|
public void addActivity(Activity activity) {
|
|
activityMapper.insert(activity);
|
|
}
|
|
|
|
/**
|
|
* 更新活动信息
|
|
*/
|
|
public void updateActivity(Activity activity) {
|
|
activityMapper.updateById(activity);
|
|
}
|
|
|
|
/**
|
|
* 删除活动
|
|
*/
|
|
public void deleteActivity(Long actId) {
|
|
activityMapper.deleteById(actId);
|
|
}
|
|
|
|
/**
|
|
* 启动/暂停/取消活动
|
|
*/
|
|
public void changeActivityStatus(Long actId, String newStatus) {
|
|
Activity activity = activityMapper.selectById(actId);
|
|
if (activity != null) {
|
|
activity.setStatus(newStatus);
|
|
activityMapper.updateById(activity);
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|