Files
Nexus-api/src/main/java/com/dota/nexus/service/impl/GoalServiceImpl.java
2025-10-10 11:40:34 +08:00

35 lines
967 B
Java

package com.dota.nexus.service.impl;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.dota.nexus.entity.Goal;
import com.dota.nexus.entity.GoalEnum;
import com.dota.nexus.mapper.GoalMapper;
import com.dota.nexus.service.GoalService;
import org.springframework.stereotype.Service;
@Service
public class GoalServiceImpl extends ServiceImpl<GoalMapper, Goal> implements GoalService {
@Override
public void doneGoal(Integer id) {
updateStatus(id, GoalEnum.DONE);
}
@Override
public void doingGoal(Integer id) {
updateStatus(id, GoalEnum.DOING);
}
@Override
public void cancelGoal(Integer id) {
updateStatus(id, GoalEnum.CANCEL);
}
private void updateStatus(Integer id, GoalEnum status) {
var update = new LambdaUpdateWrapper<Goal>();
update.eq(Goal::getId, id);
update.set(Goal::getStatus, status);
this.baseMapper.update(update);
}
}