Merge branch 'master' of ssh://10.10.14.176:222/bigdata/dsMin
continuous-integration/drone/push Build is passing Details

master
kgdxpr 4 years ago
commit 7ddb92da53

@ -16,6 +16,7 @@ import (
"dsBaseRpc/RpcService/SysLoginperson/SysLoginpersonService"
"dsBaseRpc/Utils/CommonUtil"
"dsBaseRpc/Utils/DateUtil"
"dsBaseRpc/Utils/DbUtil"
"dsBaseRpc/Utils/LogUtil"
"dsBaseRpc/Utils/PinYinUtil"
"dsBaseRpc/Utils/SqlKit"
@ -741,12 +742,19 @@ func UpdateManager(bureauId string, bUse int32) error {
model.Lxdh = "18888888888"
model.Dzxx = "xx@dsideal.com"
model.BUse = 1
_, err := BaseTeacherDao.AddBaseTeacher(*model)
var db = DbUtil.Engine
var session = db.NewSession()
_, err := BaseTeacherDao.AddBaseTeacher(session, *model)
if err != nil {
session.Rollback()
return err
}
//生成人员的组织机构数据
BaseTeacherDao.AddTeacherOrgInfo([]string{personId}, bureauId, 1, 1)
_, _, _, err = BaseTeacherDao.AddTeacherOrgInfo(session, []string{personId}, bureauId, 1, 1)
if err != nil {
session.Rollback()
return err
}
//(2)生成登录名和密码
accountArray := SysLoginpersonService.GenerateLoginAccount(1, 1)
modelLoginPerson := new(models.TSysLoginperson)
@ -758,10 +766,13 @@ func UpdateManager(bureauId string, bUse int32) error {
modelLoginPerson.PersonId = personId
modelLoginPerson.PersonName = model.Xm
modelLoginPerson.BUse = 1
_, err = SysLoginpersonDao.AddSysLoginPerson(*modelLoginPerson)
_, err = SysLoginpersonDao.AddSysLoginPerson(session, *modelLoginPerson)
if err != nil {
session.Rollback()
return err
}
session.Commit()
//(3)、t_base_role
modelBaseRolePerson := new(models.TBaseRolePerson)
modelBaseRolePerson.Id = CommonUtil.GetUUID()

@ -22,6 +22,7 @@ import (
"github.com/360EntSecGroup-Skylar/excelize/v2"
"github.com/pkg/errors"
"github.com/xormplus/builder"
"github.com/xormplus/xorm"
"strconv"
)
@ -65,9 +66,9 @@ func GetMaxSortId(OrgId string) int64 {
}
//增加
func AddBaseTeacher(model models.TBaseTeacher) (int64, error) {
func AddBaseTeacher(session *xorm.Session, model models.TBaseTeacher) (int64, error) {
//插入基本表
count, err := db.Insert(model)
count, err := session.Insert(model)
return count, err
}

@ -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)

@ -13,13 +13,14 @@ import (
"errors"
"fmt"
"github.com/xormplus/builder"
"github.com/xormplus/xorm"
)
var db = DbUtil.Engine
//增加
func AddSysLoginPerson(model models.TSysLoginperson) (int64, error) {
return db.Insert(model)
func AddSysLoginPerson(session *xorm.Session, model models.TSysLoginperson) (int64, error) {
return session.Insert(model)
}
//修改

@ -5,6 +5,7 @@ import (
"dsBaseRpc/Utils/CommonUtil"
"dsBaseRpc/Utils/LdapUtil"
"dsBaseRpc/models"
"github.com/xormplus/xorm"
"time"
)
@ -54,7 +55,7 @@ func GenerateLoginAccount(identityId int32, count int64) []LoginAccount {
}
//增加登录人员
func AddLoginperson(identityId int32, personId string, personName string) (int64, error) {
func AddLoginperson(session *xorm.Session, identityId int32, personId string, personName string) (int64, error) {
//生成登录名和密码
accountArray := GenerateLoginAccount(identityId, 1)
//调用dao
@ -69,11 +70,10 @@ func AddLoginperson(identityId int32, personId string, personName string) (int64
model.PersonId = personId
model.PersonName = personName
model.BUse = 1
count, err := SysLoginpersonDao.AddSysLoginPerson(*model)
count, err := SysLoginpersonDao.AddSysLoginPerson(session, *model)
return count, err
}
/**
change_pwd,Golang

Loading…
Cancel
Save