package com.xjrsoft.module.liteflow.node;

import cn.hutool.core.convert.Convert;
import com.xjrsoft.module.oa.service.IFileReceiveService;
import com.xjrsoft.module.student.entity.StudentChangeClass;
import com.xjrsoft.module.student.mapper.StudentChangeClassMapper;
import com.xjrsoft.module.student.service.IBaseStudentSchoolRollService;
import com.yomahub.liteflow.core.NodeComponent;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * 学生转班流程结束后，修改学生班级信息
 */
@Component("student_change_class_node")
public class StudentChangeClassNode extends NodeComponent {
    @Autowired
    private StudentChangeClassMapper studentChangeClassMapper;
    @Autowired
    private IBaseStudentSchoolRollService studentSchoolRollService;
    @Override
    public void process() throws Exception {
        // 获取表单中数据编号
        Map<String, Object> params = this.getFirstContextBean();
        Object value = util.getFormDatKey(params,"id");
        Long formId = Convert.toLong(value);
        if (formId != null) {
            //查询出数据
            StudentChangeClass changeClass = studentChangeClassMapper.selectById(formId);
            //修改学生班级
            studentSchoolRollService.updateStudentClass(changeClass.getAfterClassId(), changeClass.getStudentUserId());
        }
    }
}
