package com.education.business.service.education.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.education.auth.AuthUtil;
import com.education.auth.session.UserSession;
import com.education.business.service.BaseService;
import com.education.common.enums.LoginEnum;
import com.education.common.model.PageInfo;
import com.education.common.utils.Result;
import com.education.model.dto.GoalInfoReqDto;
import com.education.model.entity.GoalInfo;
import com.education.business.service.education.GoalInfoService;
import com.education.business.mapper.education.GoalInfoMapper;
import com.education.model.request.PageParam;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
* @author harri
* @description 针对表【goal_info(导向目标设定表)】的数据库操作Service实现
* @createDate 2025-07-15 19:24:28
*/
@Service
public class GoalInfoServiceImpl extends BaseService<GoalInfoMapper, GoalInfo>
    implements GoalInfoService{

    //实现查询列表
    @Override
    public PageInfo<GoalInfo> selectPageList(PageParam pageParam, GoalInfo goalInfo) {
        Page<GoalInfo> page = new Page<>(pageParam.getPageNumber(), pageParam.getPageSize());
        Page<GoalInfo> resultPage = this.baseMapper.selectPageList(page, goalInfo);
        return selectPage(resultPage);
    }

    @Override
    public Integer add(GoalInfo goalInfo) {
        UserSession userSession = AuthUtil.getSession(LoginEnum.ADMIN.getValue());
        //添加目标
        goalInfo.setCreateUser(userSession.getId().intValue());
        super.saveOrUpdate(goalInfo);
        return goalInfo.getId();
    }
}




