|
|
package BaseTeacherService
|
|
|
|
|
|
import (
|
|
|
"context"
|
|
|
"dsBaseRpc/Const"
|
|
|
"dsBaseRpc/Const/ErrorConst"
|
|
|
"dsBaseRpc/RpcService/BaseClass/BaseClassDao"
|
|
|
"dsBaseRpc/RpcService/BaseOrganizationManager/BaseOrganizationManagerDao"
|
|
|
"dsBaseRpc/RpcService/BaseTeacher/BaseTeacherDao"
|
|
|
"dsBaseRpc/RpcService/BaseTeacher/BaseTeacherProto"
|
|
|
"dsBaseRpc/RpcService/SysLoginperson/SysLoginpersonDao"
|
|
|
"dsBaseRpc/RpcService/SysLoginperson/SysLoginpersonService"
|
|
|
"dsBaseRpc/Utils/CommonUtil"
|
|
|
"dsBaseRpc/Utils/DateUtil"
|
|
|
"dsBaseRpc/Utils/DbUtil"
|
|
|
"dsBaseRpc/Utils/ExcelUtil"
|
|
|
"dsBaseRpc/Utils/IdCardUtil"
|
|
|
"dsBaseRpc/Utils/LogUtil"
|
|
|
"dsBaseRpc/Utils/MobileUtil"
|
|
|
"dsBaseRpc/Utils/PinYinUtil"
|
|
|
"dsBaseRpc/Utils/SqlKit"
|
|
|
"dsBaseRpc/models"
|
|
|
"fmt"
|
|
|
)
|
|
|
|
|
|
type Rpc struct{} //服务对象
|
|
|
|
|
|
//选择单条
|
|
|
func (s *Rpc) GetBaseTeacher(ctx context.Context, in *BaseTeacherProto.ModelArg) (*BaseTeacherProto.Reply, error) {
|
|
|
//异常处理
|
|
|
defer func() {
|
|
|
if err := recover(); err != nil {
|
|
|
fmt.Printf("%s\n", err)
|
|
|
}
|
|
|
}()
|
|
|
//rpc响应
|
|
|
var reply BaseTeacherProto.Reply
|
|
|
//通用获取单条
|
|
|
list := SqlKit.QueryByIds([]string{in.PersonId}, "t_base_teacher")
|
|
|
|
|
|
if len(list) > 0 {
|
|
|
//处理从教年月
|
|
|
if list[0]["cjny"].(string)[0:4] == "1900" {
|
|
|
list[0]["cjny"] = ""
|
|
|
}
|
|
|
//加上org_name
|
|
|
orgName, err := BaseTeacherDao.GetPersonOrgName(in.PersonId)
|
|
|
if err != nil {
|
|
|
reply.Success = false
|
|
|
reply.Message = Const.DataBaseActionError
|
|
|
LogUtil.Error(ErrorConst.SqlQueryError, "执行GetPersonOrgName时发生严重错误:"+err.Error())
|
|
|
return &reply, err
|
|
|
}
|
|
|
list[0]["org_name"] = orgName
|
|
|
//人员所在单位,获取人员在此单位下的职务
|
|
|
if in.BureauId != "" {
|
|
|
positionArray, err := BaseTeacherDao.GetPositionInfoByPersonIdAndBureauId(in.PersonId, in.BureauId)
|
|
|
if err != nil {
|
|
|
reply.Success = false
|
|
|
reply.Message = Const.DataBaseActionError
|
|
|
LogUtil.Error(ErrorConst.SqlQueryError, "执行GetPositionInfoByPersonIdAndBureauId时发生严重错误:"+err.Error())
|
|
|
return &reply, err
|
|
|
}
|
|
|
list[0]["position_id_array"] = positionArray
|
|
|
}
|
|
|
}
|
|
|
//将结果序列化
|
|
|
reply.Success = true
|
|
|
reply.Count = 1
|
|
|
reply.Message = Const.SuccessDataBaseAction
|
|
|
reply.List = CommonUtil.SerializeToString(list)
|
|
|
return &reply, nil
|
|
|
}
|
|
|
|
|
|
//增加
|
|
|
func (s *Rpc) AddBaseTeacher(ctx context.Context, in *BaseTeacherProto.ModelArg) (*BaseTeacherProto.Reply, error) {
|
|
|
//异常处理
|
|
|
defer func() {
|
|
|
if err := recover(); err != nil {
|
|
|
fmt.Printf("%s\n", err)
|
|
|
}
|
|
|
}()
|
|
|
//rpc响应
|
|
|
var reply BaseTeacherProto.Reply
|
|
|
//==========================================
|
|
|
//检查身份证的有效性
|
|
|
if len(in.Sfzjh) > 0 {
|
|
|
IdCardNo := []byte(in.Sfzjh)
|
|
|
if in.Sfzjlxm == "01" && !IdCardUtil.IsValidIdCardNo(&IdCardNo) {
|
|
|
reply.Success = false
|
|
|
reply.Message = "身份证号在不符合检查要求!"
|
|
|
return &reply, nil
|
|
|
}
|
|
|
//是不是重复
|
|
|
if !SysLoginpersonDao.IsValidIdCardNo(in.Sfzjh, "") {
|
|
|
reply.Success = false
|
|
|
reply.Message = "证件号在系统中已存在,无法创建!"
|
|
|
return &reply, nil
|
|
|
}
|
|
|
}
|
|
|
//==========================================
|
|
|
//如果是手机号,是不是合法
|
|
|
if len(in.Lxdh) > 0 && len(in.Lxdh) == 11 && !MobileUtil.VerifyMobileFormat(in.Lxdh) {
|
|
|
reply.Success = false
|
|
|
reply.Message = "联系电话在不是合法的手机号!"
|
|
|
return &reply, nil
|
|
|
}
|
|
|
//是不是重复
|
|
|
if len(in.Lxdh) > 0 && !SysLoginpersonDao.IsValidIdTel(in.Lxdh, "") {
|
|
|
reply.Success = false
|
|
|
reply.Message = "联系电话在系统中已存在,无法创建!"
|
|
|
return &reply, nil
|
|
|
}
|
|
|
//调用dao
|
|
|
model := new(models.TBaseTeacher)
|
|
|
model.PersonId = CommonUtil.GetUUID()
|
|
|
model.Xm = in.Xm
|
|
|
model.Xmpy = PinYinUtil.PinYin(in.Xm)
|
|
|
model.Cym = in.Cym
|
|
|
model.Sfzjlxm = in.Sfzjlxm
|
|
|
model.Sfzjh = in.Sfzjh
|
|
|
if model.Sfzjlxm == "1" {
|
|
|
//如果是身份证
|
|
|
by := []byte(in.Sfzjh)
|
|
|
if !IdCardUtil.IsValidIdCardNo(&by) {
|
|
|
reply.Success = false
|
|
|
reply.Message = "身份证号不合法!"
|
|
|
return &reply, nil
|
|
|
}
|
|
|
//根据身份证号,提取男女,出生日期
|
|
|
_, birthday, xbm := IdCardUtil.GetIdCardNoInfo(in.Sfzjh)
|
|
|
model.Csrq = DateUtil.ConvertDate(birthday)
|
|
|
model.Xbm = xbm
|
|
|
} else {
|
|
|
model.Csrq = DateUtil.ConvertDate(in.Csrq)
|
|
|
model.Xbm = in.Xbm
|
|
|
}
|
|
|
model.Mzm = in.Mzm
|
|
|
model.Zzmmm = in.Zzmmm
|
|
|
model.Xlm = in.Xlm
|
|
|
model.Xwm = in.Xwm
|
|
|
model.Zcm = in.Zcm
|
|
|
model.StateId = 1
|
|
|
model.Bzlbm = in.Bzlbm
|
|
|
if len(in.Cjny) == 0 {
|
|
|
model.Cjny = DateUtil.ConvertDate("1900-01-01")
|
|
|
} else {
|
|
|
//如果只传了年和月,手工补上日和时间
|
|
|
model.Cjny = DateUtil.ConvertDate(in.Cjny + "-01")
|
|
|
}
|
|
|
model.StageId = in.StageId
|
|
|
model.SubjectId = in.SubjectId
|
|
|
model.Gwzym = in.Gwzym
|
|
|
model.Lxdh = in.Lxdh
|
|
|
model.Dzxx = in.Dzxx
|
|
|
model.BUse = 1
|
|
|
//教师的身份ID
|
|
|
model.IdentityId = 2
|
|
|
|
|
|
//创建事务会话
|
|
|
var db = DbUtil.Engine
|
|
|
var session = db.NewSession()
|
|
|
//调用DAO保存
|
|
|
_, err := BaseTeacherDao.AddBaseTeacher(session, *model)
|
|
|
if err != nil {
|
|
|
//事务回滚
|
|
|
session.Rollback()
|
|
|
reply.Success = false
|
|
|
reply.Message = Const.DataBaseActionError
|
|
|
LogUtil.Error(ErrorConst.SqlUpdateError, "执行AddBaseTeacher时发生严重错误:"+err.Error())
|
|
|
return &reply, err
|
|
|
}
|
|
|
//记录教师所在单位和部门
|
|
|
personIds := []string{model.PersonId}
|
|
|
var fromSortId int32
|
|
|
//排序号
|
|
|
if in.SortId == 0 {
|
|
|
fromSortId = int32(BaseTeacherDao.GetMaxSortId(in.OrgId)) + 1
|
|
|
} else {
|
|
|
fromSortId = in.SortId
|
|
|
}
|
|
|
_, 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
|
|
|
}
|
|
|
//记录教师在此单位下的职务信息
|
|
|
_, _, 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)
|
|
|
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)
|
|
|
|
|
|
reply.Success = true
|
|
|
reply.Message = Const.SuccessDataBaseAction
|
|
|
return &reply, err
|
|
|
}
|
|
|
|
|
|
//删除
|
|
|
func (s *Rpc) DeleteBaseTeacher(ctx context.Context, in *BaseTeacherProto.DeleteIdsArg) (*BaseTeacherProto.Reply, error) {
|
|
|
//异常处理
|
|
|
defer func() {
|
|
|
if err := recover(); err != nil {
|
|
|
fmt.Printf("%s\n", err)
|
|
|
}
|
|
|
}()
|
|
|
//rpc响应
|
|
|
var reply BaseTeacherProto.Reply
|
|
|
//调用通用删除命令进行删除
|
|
|
err := SqlKit.DeleteIds("t_base_teacher", in.Ids)
|
|
|
//删除人员对应的部门领导关系,不管有没有,都要删除一下。
|
|
|
BaseOrganizationManagerDao.DeleteOrgManagerByPersonIds(in.Ids)
|
|
|
//错误处理
|
|
|
if err != nil {
|
|
|
LogUtil.Error(ErrorConst.SqlUpdateError, "执行DeleteBaseTeacher时发生严重错误:"+err.Error())
|
|
|
reply.Success = false
|
|
|
reply.Message = Const.DataBaseActionError
|
|
|
return &reply, err
|
|
|
}
|
|
|
//删除人员时,对应的班主任,也要删除一下~
|
|
|
err = BaseClassDao.ClearPersonBzr(in.Ids)
|
|
|
if err != nil {
|
|
|
LogUtil.Error(ErrorConst.SqlUpdateError, "执行ClearPersonBzr时发生严重错误:"+err.Error())
|
|
|
reply.Success = false
|
|
|
reply.Message = Const.DataBaseActionError
|
|
|
return &reply, err
|
|
|
}
|
|
|
//删除人员所在的部门关系
|
|
|
BaseTeacherDao.DeleteTeacherOrgInfoAll(in.Ids)
|
|
|
//删除人员与职务的关系(全部)
|
|
|
BaseTeacherDao.DeleteTeacherAllPosition(in.Ids)
|
|
|
//记录日志
|
|
|
ms, err := BaseTeacherDao.GetByIds(in.Ids)
|
|
|
if err != nil {
|
|
|
LogUtil.Error(ErrorConst.SqlUpdateError, "执行FindModelsByIds时发生严重错误:"+err.Error())
|
|
|
reply.Success = false
|
|
|
reply.Message = Const.DataBaseActionError
|
|
|
return &reply, err
|
|
|
}
|
|
|
BaseTeacherDao.ActionLog(ms, Const.ActionDelete, in.ActionPersonId, in.ActionIpAddress)
|
|
|
|
|
|
reply.Success = true
|
|
|
reply.Message = Const.SuccessDataBaseAction
|
|
|
return &reply, err
|
|
|
}
|
|
|
|
|
|
//修改
|
|
|
func (s *Rpc) UpdateBaseTeacher(ctx context.Context, in *BaseTeacherProto.ModelArg) (*BaseTeacherProto.Reply, error) {
|
|
|
//异常处理
|
|
|
defer func() {
|
|
|
if err := recover(); err != nil {
|
|
|
fmt.Printf("%s\n", err)
|
|
|
}
|
|
|
}()
|
|
|
//rpc响应
|
|
|
var reply BaseTeacherProto.Reply
|
|
|
|
|
|
//检查身份证的有效性
|
|
|
if len(in.Sfzjh) > 0 {
|
|
|
IdCardNo := []byte(in.Sfzjh)
|
|
|
if in.Sfzjlxm == "1" && !IdCardUtil.IsValidIdCardNo(&IdCardNo) {
|
|
|
reply.Success = false
|
|
|
reply.Message = "身份证号在不符合检查要求!"
|
|
|
return &reply, nil
|
|
|
}
|
|
|
//是不是重复
|
|
|
if !SysLoginpersonDao.IsValidIdCardNo(in.Sfzjh, in.PersonId) {
|
|
|
reply.Success = false
|
|
|
reply.Message = "证件号在系统中已存在,无法创建!"
|
|
|
return &reply, nil
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//如果是手机号,是不是合法
|
|
|
if len(in.Lxdh) > 0 && len(in.Lxdh) == 11 && !MobileUtil.VerifyMobileFormat(in.Lxdh) {
|
|
|
reply.Success = false
|
|
|
reply.Message = "联系电话在不是合法的手机号!"
|
|
|
return &reply, nil
|
|
|
}
|
|
|
//是不是重复
|
|
|
if len(in.Lxdh) > 0 && !SysLoginpersonDao.IsValidIdTel(in.Lxdh, in.PersonId) {
|
|
|
reply.Success = false
|
|
|
reply.Message = "联系电话在系统中已存在,无法创建!"
|
|
|
return &reply, nil
|
|
|
}
|
|
|
|
|
|
//3、修改
|
|
|
model := new(models.TBaseTeacher)
|
|
|
model.PersonId = in.PersonId
|
|
|
model.Xm = in.Xm
|
|
|
model.Xmpy = PinYinUtil.PinYin(in.Xmpy)
|
|
|
model.Cym = in.Cym
|
|
|
//身份证件类型
|
|
|
model.Sfzjlxm = in.Sfzjlxm
|
|
|
model.Sfzjh = in.Sfzjh
|
|
|
//如果是身份证
|
|
|
if model.Sfzjlxm == "1" {
|
|
|
//根据身份证号,提取男女,出生日期
|
|
|
_, birthday, xbm := IdCardUtil.GetIdCardNoInfo(in.Sfzjh)
|
|
|
model.Csrq = DateUtil.ConvertDate(birthday)
|
|
|
model.Xbm = xbm
|
|
|
} else {
|
|
|
model.Csrq = DateUtil.ConvertDate(in.Csrq)
|
|
|
model.Xbm = in.Xbm
|
|
|
}
|
|
|
model.Mzm = in.Mzm
|
|
|
model.Zzmmm = in.Zzmmm
|
|
|
model.Xlm = in.Xlm
|
|
|
model.Xwm = in.Xwm
|
|
|
model.Zcm = in.Zcm
|
|
|
model.Bzlbm = in.Bzlbm
|
|
|
//排序号
|
|
|
BaseTeacherDao.UpdateSortId(model.PersonId, in.SortId)
|
|
|
//从教年月
|
|
|
if len(in.Cjny) == 0 {
|
|
|
model.Cjny = DateUtil.ConvertDate("1900-01-01")
|
|
|
} else {
|
|
|
model.Cjny = DateUtil.ConvertDate(in.Cjny + "-01")
|
|
|
}
|
|
|
|
|
|
model.StageId = in.StageId
|
|
|
model.SubjectId = in.SubjectId
|
|
|
model.Gwzym = in.Gwzym
|
|
|
model.Lxdh = in.Lxdh
|
|
|
model.Dzxx = in.Dzxx
|
|
|
model.BUse = 1
|
|
|
_, err := BaseTeacherDao.UpdateBaseTeacher(*model, in.ForceUpdateFields)
|
|
|
//错误处理
|
|
|
if err != nil {
|
|
|
reply.Success = false
|
|
|
reply.Message = Const.DataBaseActionError
|
|
|
LogUtil.Error(ErrorConst.SqlUpdateError, "执行UpdateBaseTeacher时发生严重错误:"+err.Error())
|
|
|
return &reply, err
|
|
|
}
|
|
|
|
|
|
//更新人员与职务的关系
|
|
|
BaseTeacherDao.DeleteTeacherPosition([]string{in.PersonId}, in.BureauId)
|
|
|
BaseTeacherDao.AddTeacherPosition([]string{in.PersonId}, in.BureauId, in.PositionIds)
|
|
|
|
|
|
//记录日志
|
|
|
ms, err := BaseTeacherDao.GetByIds([]string{in.PersonId})
|
|
|
if err != nil {
|
|
|
LogUtil.Error(ErrorConst.SqlUpdateError, "执行FindModelsByIds时发生严重错误:"+err.Error())
|
|
|
reply.Success = false
|
|
|
reply.Message = Const.DataBaseActionError
|
|
|
return &reply, err
|
|
|
}
|
|
|
BaseTeacherDao.ActionLog(ms, Const.ActionInsert, in.ActionPersonId, in.ActionIpAddress)
|
|
|
|
|
|
reply.Success = true
|
|
|
reply.Message = Const.SuccessDataBaseAction
|
|
|
return &reply, nil
|
|
|
}
|
|
|
|
|
|
//分页查询
|
|
|
func (s *Rpc) PageBaseTeacher(ctx context.Context, in *BaseTeacherProto.QueryArg) (*BaseTeacherProto.Reply, error) {
|
|
|
//异常处理
|
|
|
defer func() {
|
|
|
if err := recover(); err != nil {
|
|
|
fmt.Printf("%s\n", err)
|
|
|
}
|
|
|
}()
|
|
|
//rpc响应
|
|
|
var reply BaseTeacherProto.Reply
|
|
|
list, count, err := BaseTeacherDao.PageBaseTeacher(in)
|
|
|
//错误处理
|
|
|
if err != nil {
|
|
|
reply.Success = false
|
|
|
reply.Message = Const.DataBaseActionError
|
|
|
LogUtil.Error(ErrorConst.SqlQueryError, "执行PageBaseTeacher时发生严重错误:"+err.Error())
|
|
|
return &reply, err
|
|
|
}
|
|
|
reply.Count = count
|
|
|
reply.Success = true
|
|
|
reply.Message = Const.SuccessDataBaseAction
|
|
|
reply.List = CommonUtil.SerializeToString(list)
|
|
|
return &reply, nil
|
|
|
}
|
|
|
|
|
|
//教师调整部门(批量)
|
|
|
func (s *Rpc) ReviseTeacherOrg(ctx context.Context, in *BaseTeacherProto.ReviseArg) (*BaseTeacherProto.Reply, error) {
|
|
|
//异常处理
|
|
|
defer func() {
|
|
|
if err := recover(); err != nil {
|
|
|
fmt.Printf("%s\n", err)
|
|
|
}
|
|
|
}()
|
|
|
//rpc响应
|
|
|
var reply BaseTeacherProto.Reply
|
|
|
//调用dao
|
|
|
err := BaseTeacherDao.ReviseTeacherOrg(in.Ids, in.OrgId)
|
|
|
//错误处理
|
|
|
if err != nil {
|
|
|
reply.Success = false
|
|
|
reply.Message = Const.DataBaseActionError
|
|
|
LogUtil.Error(ErrorConst.SqlQueryError, "执行ReviseTeacherOrg时发生严重错误:"+err.Error())
|
|
|
return &reply, err
|
|
|
}
|
|
|
reply.Count = int32(len(in.Ids))
|
|
|
reply.Success = true
|
|
|
reply.Message = Const.SuccessDataBaseAction
|
|
|
return &reply, nil
|
|
|
}
|
|
|
|
|
|
//导出本单位教职工账号信息到EXCEL
|
|
|
func (s *Rpc) ExportTeacherAccountInfoExcel(ctx context.Context, in *BaseTeacherProto.ModelArg) (*BaseTeacherProto.Reply, error) {
|
|
|
//异常处理
|
|
|
defer func() {
|
|
|
if err := recover(); err != nil {
|
|
|
fmt.Printf("%s\n", err)
|
|
|
}
|
|
|
}()
|
|
|
//rpc响应
|
|
|
var reply BaseTeacherProto.Reply
|
|
|
list, _, err := BaseTeacherDao.ExportTeacherAccountInfoExcel(in)
|
|
|
//错误处理
|
|
|
if err != nil {
|
|
|
reply.Success = false
|
|
|
reply.Message = Const.DataBaseActionError
|
|
|
LogUtil.Error(ErrorConst.SqlQueryError, "执行ExportTeacherAccountInfoExcel时发生严重错误:"+err.Error())
|
|
|
return &reply, err
|
|
|
}
|
|
|
//1、配置文件
|
|
|
jsonTemplate := "teacher_account.json"
|
|
|
//2、导出
|
|
|
TargetPath := CommonUtil.GetExportExcelFilePath()
|
|
|
ExcelUtil.ExportExcel(jsonTemplate, list, TargetPath)
|
|
|
reply.ExcelPath = TargetPath
|
|
|
return &reply, nil
|
|
|
}
|
|
|
|
|
|
//导出本单位教职工信息到EXCEL
|
|
|
func (s *Rpc) ExportTeacherInfoExcel(ctx context.Context, in *BaseTeacherProto.ModelArg) (*BaseTeacherProto.Reply, error) {
|
|
|
//异常处理
|
|
|
defer func() {
|
|
|
if err := recover(); err != nil {
|
|
|
fmt.Printf("%s\n", err)
|
|
|
}
|
|
|
}()
|
|
|
//rpc响应
|
|
|
var reply BaseTeacherProto.Reply
|
|
|
//导出
|
|
|
TargetPath := CommonUtil.GetExportExcelFilePath()
|
|
|
//哪个单位
|
|
|
bureauId := in.BureauId
|
|
|
//是不是需要空的excel
|
|
|
ExportExcelStatus := in.ExportExcelStatus
|
|
|
BaseTeacherDao.ExportTeacherInfoExcel(TargetPath, bureauId, ExportExcelStatus)
|
|
|
reply.ExcelPath = TargetPath
|
|
|
return &reply, nil
|
|
|
}
|
|
|
|
|
|
//导入本校教师信息
|
|
|
func (s *Rpc) ImportTeacherInfoExcel(ctx context.Context, in *BaseTeacherProto.ImportArg) (*BaseTeacherProto.Reply, error) {
|
|
|
//异常处理
|
|
|
defer func() {
|
|
|
if err := recover(); err != nil {
|
|
|
fmt.Printf("%s\n", err)
|
|
|
}
|
|
|
}()
|
|
|
//rpc响应
|
|
|
var reply BaseTeacherProto.Reply
|
|
|
//将业务逻辑封装到dao层
|
|
|
success, message, err := BaseTeacherDao.ImportTeacherInfoExcel(in.ExcelPath, in.BureauId, in.ActionPersonId, in.ActionIpAddress)
|
|
|
if err != nil {
|
|
|
reply.Success = false
|
|
|
reply.Message = message
|
|
|
return &reply, nil
|
|
|
}
|
|
|
reply.Success = success
|
|
|
reply.Message = message
|
|
|
return &reply, nil
|
|
|
}
|
|
|
|
|
|
//设置教师多单位
|
|
|
func (s *Rpc) SettingTeacherMultipleBureau(ctx context.Context, in *BaseTeacherProto.SettingMultipleBureauArg) (*BaseTeacherProto.Reply, error) {
|
|
|
//异常处理
|
|
|
defer func() {
|
|
|
if err := recover(); err != nil {
|
|
|
fmt.Printf("%s\n", err)
|
|
|
}
|
|
|
}()
|
|
|
//rpc响应
|
|
|
var reply BaseTeacherProto.Reply
|
|
|
//将业务逻辑封装到dao层
|
|
|
success, message, err := BaseTeacherDao.SettingTeacherMultipleBureau(in)
|
|
|
if err != nil {
|
|
|
reply.Success = false
|
|
|
reply.Message = message
|
|
|
return &reply, nil
|
|
|
}
|
|
|
reply.Success = success
|
|
|
reply.Message = message
|
|
|
return &reply, nil
|
|
|
}
|
|
|
|
|
|
//根据教职工ID获取该教职工所在多单位列表
|
|
|
func (s *Rpc) PageTeacherMultipleBureau(ctx context.Context, in *BaseTeacherProto.PageMultipleBureauArg) (*BaseTeacherProto.Reply, error) {
|
|
|
//异常处理
|
|
|
defer func() {
|
|
|
if err := recover(); err != nil {
|
|
|
fmt.Printf("%s\n", err)
|
|
|
}
|
|
|
}()
|
|
|
//rpc响应
|
|
|
var reply BaseTeacherProto.Reply
|
|
|
//将业务逻辑封装到dao层
|
|
|
list, count, err := BaseTeacherDao.PageTeacherMultipleBureau(in)
|
|
|
//错误处理
|
|
|
if err != nil {
|
|
|
reply.Success = false
|
|
|
reply.Message = Const.DataBaseActionError
|
|
|
LogUtil.Error(ErrorConst.SqlQueryError, "执行PageTeacherMultipleBureau时发生严重错误:"+err.Error())
|
|
|
return &reply, err
|
|
|
}
|
|
|
reply.Count = count
|
|
|
reply.Success = true
|
|
|
reply.Message = Const.SuccessDataBaseAction
|
|
|
reply.List = CommonUtil.SerializeToString(list)
|
|
|
return &reply, nil
|
|
|
}
|
|
|
|
|
|
//删除教职工所在多单位信息
|
|
|
func (s *Rpc) DeleteTeacherMultipleBureau(ctx context.Context, in *BaseTeacherProto.MultipleBureauIdArg) (*BaseTeacherProto.Reply, error) {
|
|
|
//异常处理
|
|
|
defer func() {
|
|
|
if err := recover(); err != nil {
|
|
|
fmt.Printf("%s\n", err)
|
|
|
}
|
|
|
}()
|
|
|
//rpc响应
|
|
|
var reply BaseTeacherProto.Reply
|
|
|
//调用通用删除命令进行删除
|
|
|
err := SqlKit.DeleteIds("t_base_teacher_org", []string{in.Id})
|
|
|
reply.Success = true
|
|
|
reply.Message = Const.SuccessDataBaseAction
|
|
|
return &reply, err
|
|
|
}
|
|
|
|
|
|
//设置主单位
|
|
|
func (s *Rpc) SettingMainOrg(ctx context.Context, in *BaseTeacherProto.SettingMainOrgArg) (*BaseTeacherProto.Reply, error) {
|
|
|
//异常处理
|
|
|
defer func() {
|
|
|
if err := recover(); err != nil {
|
|
|
fmt.Printf("%s\n", err)
|
|
|
}
|
|
|
}()
|
|
|
//rpc响应
|
|
|
var reply BaseTeacherProto.Reply
|
|
|
|
|
|
//将业务逻辑封装到dao层
|
|
|
success, message, err := BaseTeacherDao.SettingMainOrg(in)
|
|
|
if err != nil {
|
|
|
reply.Success = false
|
|
|
reply.Message = message
|
|
|
return &reply, nil
|
|
|
}
|
|
|
reply.Success = success
|
|
|
reply.Message = message
|
|
|
return &reply, nil
|
|
|
}
|
|
|
|
|
|
//教师调转单位
|
|
|
func (s *Rpc) TeacherTransfer(ctx context.Context, in *BaseTeacherProto.SettingMultipleBureauArg) (*BaseTeacherProto.Reply, error) {
|
|
|
//异常处理
|
|
|
defer func() {
|
|
|
if err := recover(); err != nil {
|
|
|
fmt.Printf("%s\n", err)
|
|
|
}
|
|
|
}()
|
|
|
//rpc响应
|
|
|
var reply BaseTeacherProto.Reply
|
|
|
|
|
|
//将业务逻辑封装到dao层
|
|
|
success, message, err := BaseTeacherDao.TeacherTransfer(in.PersonId, in.OrgId)
|
|
|
if err != nil {
|
|
|
reply.Success = false
|
|
|
reply.Message = message
|
|
|
return &reply, nil
|
|
|
}
|
|
|
reply.Success = success
|
|
|
reply.Message = message
|
|
|
return &reply, nil
|
|
|
}
|