|
|
|
@ -167,6 +167,44 @@ public class Ghre_TeacherChangeServices : BaseServices<Ghre_TeacherChange, Ghre_ |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region 状态是Wait 直接会写至主数据 |
|
|
|
|
var change = await base.QueryById(Id); |
|
|
|
|
if (change.Status == "Wait") |
|
|
|
|
{ |
|
|
|
|
var teacher = Mapper.Map(editModel).ToANew<Ghre_Teacher>(); |
|
|
|
|
teacher.Id = editModel.TeacherId.Value; |
|
|
|
|
await Db.Updateable(teacher).UpdateColumns(it => new { it.TeacherLevel, it.Price, it.SkillPoints }).ExecuteCommandAsync(); |
|
|
|
|
|
|
|
|
|
var teacherAttachmentIds = await Db.Queryable<Ghre_TeacherAttachment>().Where(x => x.TeacherId == editModel.TeacherId).Select(x => x.Id).ToListAsync(); |
|
|
|
|
if (teacherAttachmentIds.Any()) |
|
|
|
|
await Db.Updateable<Ghre_TeacherAttachment>() |
|
|
|
|
.SetColumns(it => new Ghre_TeacherAttachment() |
|
|
|
|
{ |
|
|
|
|
IsEnable = 0 |
|
|
|
|
}) |
|
|
|
|
.Where(it => teacherAttachmentIds.Contains(it.Id)) |
|
|
|
|
.ExecuteCommandAsync(); |
|
|
|
|
|
|
|
|
|
if (editModel.TeacherAttachments != null && editModel.TeacherAttachments.Any()) |
|
|
|
|
{ |
|
|
|
|
for (int i = 0; i < editModel.TeacherAttachments.Count; i++) |
|
|
|
|
{ |
|
|
|
|
var insert = Mapper.Map(editModel.TeacherAttachments[i]).ToANew<InsertGhre_TeacherAttachmentInput>(); ; |
|
|
|
|
insert.TeacherId = teacher.Id; |
|
|
|
|
var teacherAttachmentId = await _ghre_TeacherAttachmentServices.Add(insert); |
|
|
|
|
if (editModel.TeacherAttachments[i].Attachments != null && editModel.TeacherAttachments[i].Attachments.Any()) |
|
|
|
|
for (int j = 0; j < editModel.TeacherAttachments[i].Attachments.Count; j++) |
|
|
|
|
{ |
|
|
|
|
var attachment = await Db.Queryable<Ghre_Attachment>().FirstAsync(x => x.RelativePath == insert.Attachments[j].RelativePath); |
|
|
|
|
attachment.TableName = teacherAttachmentId.ToString(); |
|
|
|
|
await Db.Insertable(attachment).ExecuteReturnSnowflakeIdAsync(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
#endregion |
|
|
|
|
|
|
|
|
|
return result; |
|
|
|
|
} |
|
|
|
|
public async Task<ServiceResult<long>> InsertByStatus(InsertGhre_TeacherChangeInput insertModel, string status) |
|
|
|
|