package org.jeecg.modules.system.app.service.impl;


import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.shiro.SecurityUtils;
import org.jeecg.common.constant.CommonConstant;
import org.jeecg.common.system.vo.LoginUser;
import org.jeecg.modules.system.app.entity.AppCoursesVerificationRecord;
import org.jeecg.modules.system.app.form.CoursesVerificationRecordForm;
import org.jeecg.modules.system.app.mapper.AppCoursesVerificationRecordMapper;
import org.jeecg.modules.system.app.service.IAppCoursesVerificationRecordService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Description: nm_courses_verification_record
 * @Author: jeecg-boot
 * @Date: 2025-08-04
 * @Version: V1.0
 */
@Service
public class AppCoursesVerificationRecordServiceImpl extends ServiceImpl<AppCoursesVerificationRecordMapper, AppCoursesVerificationRecord> implements IAppCoursesVerificationRecordService {

    @Override
    public Boolean courseUploadImage(List<CoursesVerificationRecordForm> formList) {

        //获取登录用户信息
        LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();

        for (CoursesVerificationRecordForm coursesVerificationRecordForm : formList) {
            AppCoursesVerificationRecord appCoursesVerificationRecord = baseMapper.selectById(coursesVerificationRecordForm.getId());
            if (ObjectUtils.isEmpty(appCoursesVerificationRecord)) {
                appCoursesVerificationRecord.setVerifyStatus(CommonConstant.STATUS_1_INT);
                appCoursesVerificationRecord.setVerifyUserId(sysUser.getId());
                appCoursesVerificationRecord.setVerifyUserName(sysUser.getRealname());
                appCoursesVerificationRecord.setVerifyImage(coursesVerificationRecordForm.getVerifyImage());
                baseMapper.updateById(appCoursesVerificationRecord);
            }
        }
        return Boolean.TRUE;
    }
}
