|
|
|
@ -12,6 +12,7 @@ import (
|
|
|
|
|
"dsBaseRpc/RpcService/SysLoginperson/SysLoginpersonService"
|
|
|
|
|
"dsBaseRpc/Utils/CommonUtil"
|
|
|
|
|
"dsBaseRpc/Utils/DateUtil"
|
|
|
|
|
"dsBaseRpc/Utils/DbUtil"
|
|
|
|
|
"dsBaseRpc/Utils/ExcelUtil"
|
|
|
|
|
"dsBaseRpc/Utils/IdCardUtil"
|
|
|
|
|
"dsBaseRpc/Utils/LogUtil"
|
|
|
|
@ -156,9 +157,14 @@ func (s *Rpc) AddBaseTeacher(ctx context.Context, in *BaseTeacherProto.ModelArg)
|
|
|
|
|
//教师的身份ID
|
|
|
|
|
model.IdentityId = 2
|
|
|
|
|
|
|
|
|
|
//创建事务会话
|
|
|
|
|
var db = DbUtil.Engine
|
|
|
|
|
var session = db.NewSession()
|
|
|
|
|
//调用DAO保存
|
|
|
|
|
_, err := BaseTeacherDao.AddBaseTeacher(*model)
|
|
|
|
|
_, err := BaseTeacherDao.AddBaseTeacher(session, *model)
|
|
|
|
|
if err != nil {
|
|
|
|
|
//事务回滚
|
|
|
|
|
session.Rollback()
|
|
|
|
|
reply.Success = false
|
|
|
|
|
reply.Message = Const.DataBaseActionError
|
|
|
|
|
LogUtil.Error(ErrorConst.SqlUpdateError, "执行AddBaseTeacher时发生严重错误:"+err.Error())
|
|
|
|
@ -173,18 +179,36 @@ func (s *Rpc) AddBaseTeacher(ctx context.Context, in *BaseTeacherProto.ModelArg)
|
|
|
|
|
} else {
|
|
|
|
|
fromSortId = in.SortId
|
|
|
|
|
}
|
|
|
|
|
_, bureauId, _, _ := BaseTeacherDao.AddTeacherOrgInfo(personIds, in.OrgId, 1, fromSortId)
|
|
|
|
|
_, bureauId, _, err := BaseTeacherDao.AddTeacherOrgInfo(personIds, in.OrgId, 1, fromSortId)
|
|
|
|
|
if err != nil {
|
|
|
|
|
reply.Success = false
|
|
|
|
|
reply.Message = Const.DataBaseActionError
|
|
|
|
|
LogUtil.Error(ErrorConst.SqlUpdateError, "执行AddTeacherOrgInfo时发生严重错误:"+err.Error())
|
|
|
|
|
return &reply, err
|
|
|
|
|
}
|
|
|
|
|
//记录教师在此单位下的职务信息
|
|
|
|
|
BaseTeacherDao.AddTeacherPosition(personIds, bureauId, in.PositionIds)
|
|
|
|
|
|
|
|
|
|
_, _, err = BaseTeacherDao.AddTeacherPosition(personIds, bureauId, in.PositionIds)
|
|
|
|
|
if err != nil {
|
|
|
|
|
//事务回滚
|
|
|
|
|
session.Rollback()
|
|
|
|
|
reply.Success = false
|
|
|
|
|
reply.Message = Const.DataBaseActionError
|
|
|
|
|
LogUtil.Error(ErrorConst.SqlUpdateError, "执行AddLoginperson时发生严重错误:"+err.Error())
|
|
|
|
|
return &reply, err
|
|
|
|
|
}
|
|
|
|
|
// 生成教师账号
|
|
|
|
|
_, err = SysLoginpersonService.AddLoginperson(2, model.PersonId, model.Xm)
|
|
|
|
|
_, err = SysLoginpersonService.AddLoginperson(session, 2, model.PersonId, model.Xm)
|
|
|
|
|
if err != nil {
|
|
|
|
|
//事务回滚
|
|
|
|
|
session.Rollback()
|
|
|
|
|
reply.Success = false
|
|
|
|
|
reply.Message = Const.DataBaseActionError
|
|
|
|
|
LogUtil.Error(ErrorConst.SqlUpdateError, "执行AddLoginperson时发生严重错误:"+err.Error())
|
|
|
|
|
return &reply, err
|
|
|
|
|
}
|
|
|
|
|
//事务提交
|
|
|
|
|
session.Commit()
|
|
|
|
|
|
|
|
|
|
//记录日志
|
|
|
|
|
BaseTeacherDao.ActionLog([]models.TBaseTeacher{*model}, Const.ActionInsert, in.ActionPersonId, in.ActionIpAddress)
|
|
|
|
|
|
|
|
|
|