//获取投诉列表 func GetComplainList(filter map[string]interface{}) (compalins []*models.JobComplaint, cnt int64, err error) { defer func() { if err != nil { utils.GetLog().Error("services.job.GetList : error : %s", err.Error()) } else { utils.GetLog().Debug("services.job.GetList : debug : filter=%s, compalints=%v", utils.Sdump(filter), utils.Sdump(compalins)) } }() q := models.GetDB().QueryTable("job_complaints").OrderBy("-created").RelatedSel("Job", "User", "Project", "Employee") //按照传入的条件进行过滤查询结果 for k, v := range filter { if k != "limit" && k != "offset" && v != "" { q = q.Filter(k, v) } } cnt, _ = q.Count() if filter["limit"] != nil { q = q.Limit(filter["limit"].(int)) } if filter["offset"] != nil { q = q.Offset(filter["offset"].(int)) } _, err = q.All(&compalins) return }
func (pr *PasswordModify) Do() (err error) { defer func() { if err != nil { utils.GetLog().Error("accountSrv.PasswordReset.Do : %s", err.Error()) } else { utils.GetLog().Debug("accountSrv.PasswordReset.Do : pr %v", pr) } }() if !pr.newPasswordConfirm() { return ErrPasswordNotSame } if err = pr.newPasswordValid(); err != nil { return err } if !pr.oldPasswordValid() { return ErrOldPassword } if err = pr.updatePassword(); err != nil { return err } return nil }
func (ja *JobAssignment) Do() (err error) { defer func() { if err != nil { utils.GetLog().Error("job.JobAssignment.Do : error = %s, ojb= %s", err.Error(), utils.Sdump(ja)) } utils.GetLog().Debug("job.JobAssignment.Do : ojb= %s", utils.Sdump(ja)) }() if ja.jobAssign.Job, err = ja.getJob(); err != nil { return } if ja.jobAssign.FromUser, err = ja.getFromUser(); err != nil { return } if ja.jobAssign.ToUser, err = ja.getToUser(); err != nil { return } if ja.jobAssign.Remark, err = ja.getRemark(); err != nil { return } if err = ja.jobAssign.Insert(); err != nil { return } if err = ja.afterAssignment(); err != nil { return } return }
func AddHistory(j *models.Job, user *models.User, isCreate bool) (jid uint, err error) { defer func() { if err != nil { utils.GetLog().Error("services.job.AddHistory : error : %s, ", err.Error()) } else { utils.GetLog().Debug("services.job.AddHistory : debug : Job=%s", utils.Sdump(j)) } }() var jh models.JobHistory jh.Job = j jh.IsCreate = isCreate jh.Code = j.Code jh.CreateUser = j.CreateUser jh.Project = j.Project jh.Employee = j.Employee jh.Type = j.Type jh.Department = j.Department jh.Target = j.Target jh.TargetUrl = j.TargetUrl jh.Desc = j.Desc jh.Message = j.Message jh.FinishTime = j.FinishTime jh.ValidTime = j.ValidTime jh.ClaimTime = j.ClaimTime jh.ValidStatus = j.ValidStatus jh.ClaimStatus = j.ClaimStatus jh.SubmitStatus = j.SubmitStatus var insertId int64 insertId, err = models.GetDB().Insert(&jh) jid = uint(insertId) return }
func (userList *UserList) do() *UserList { if userList.isDo { return userList } userList.isDo = true var err error defer func() { if err != nil { utils.GetLog().Error("services.user.GetList : error : %s", err.Error()) } else { utils.GetLog().Debug("services.user.GetList : debug : users=%v", utils.Sdump(userList.users)) } }() q := models.GetDB().QueryTable("users").RelatedSel("Company") if !userList.includeDel { q = q.Filter("deleted__isnull", true) } for k, v := range userList.filter { if k != "limit" && k != "offset" && v != "" { q = q.Filter(k, v) } else if k == "limit" { limit := v.(int) if limit < 0 { limit = 10 } q = q.Limit(limit) } else if k == "offset" { limit := userList.filter["limit"].(int) if limit < 0 { limit = 10 } offset := v.(int) if offset > 0 { offset = (offset - 1) * limit } q = q.Offset(offset) } } userList.count, _ = q.Count() _, err = q.All(&userList.users) if err != nil { return userList } return userList }
func GetTodayJobCount() (cnt int64) { var err error defer func() { if err != nil { utils.GetLog().Error("services.job.GetTodayJobCount : error : %s", err.Error()) } else { utils.GetLog().Debug("services.job.GetTodayJobCount : count=%v", cnt) } }() q := models.GetDB().QueryTable(models.TABLE_NAME_JOB).Filter("created__gte", time.Now().Format("2006-01-02")) cnt, err = q.Count() return }
func (cp *ComplaintCreator) CreateComplian(mapComplain map[string]interface{}, user *models.User) (complainId, jobId uint, err error) { defer func() { if err != nil { utils.GetLog().Error("services.complain.Create : error : %s, ", err.Error()) } else { utils.GetLog().Debug("services.complain.Create : debug : mapComplain=%s", utils.Sdump(mapComplain)) } }() var complian models.JobComplaint pid, _ := mapComplain["JobId"].(string) filter := make(map[string]interface{}) filter["id"] = pid var job *models.Job job, err = GetOneJob(filter) complian.Job = &models.Job{Id: job.Id} complian.Project = &models.Project{Id: job.Project.Id} if mapComplain["employee_id"] != nil { employId, _ := strconv.Atoi(mapComplain["employee_id"].(string)) complian.Employee = &models.User{Id: uint(employId)} } complian.Complain = mapComplain["Complain"].(string) complian.Source = mapComplain["source"].(string) complian.Type = mapComplain["Type"].(string) response, _ := mapComplain["response"].(int) complian.Response = uint(response) if mapComplain["editstatus"] != nil { editStatus, _ := strconv.Atoi(mapComplain["editstatus"].(string)) complian.EditStatus = uint(editStatus) } complian.User = user //cp.compliant = complian var insertId int64 insertId, err = models.GetDB().Insert(&complian) if err != nil { utils.GetLog().Debug("services.complian.Create : debug : job=%s", utils.Sdump(complian)) return } complainId = uint(insertId) jobId = uint(job.Id) return }
func (c *Creation) Do() (err error) { defer func() { if err != nil { utils.GetLog().Error("user.Creatin.Do : err = %v , obj = %s ", err, c) } }() if err = c.valid(); err != nil { return } c.password.GenSalt() c.password.GenPwd() u := models.User{ Name: c.name, Email: c.email.EmailAddress(), Password: c.password.Encryped(), Salt: c.password.Salt(), Company: &models.Company{Id: uint(c.companyId)}, Roles: c.roles.String(), LastLoginTime: time.Now(), } models.GetDB().Insert(&u) return }
func (c *BaseController) setCurrentUser() { if !c.isLogin { return } userId := c.GetSession("user_id").(uint) var err error defer func() { if err != nil { utils.GetLog().Error("controllers.BaseController.setCurrentUser : NewUserWithId error : userId = %v, noNeedLogin=%v", userId, c.noNeedLogin) } }() if c.currentUser, err = user.NewUserWithId(userId); err != nil { if !c.noNeedLogin { c.Redirect("/login", 302) } return } c.userId = int(userId) c.Data["user_info"] = c.currentUser.GetUser() c.setUserCookie() }
func (p *Project) UpdateProjectStatus(filter map[string]interface{}) (num int64, err error) { defer func() { if err != nil { utils.GetLog().Error("services.project.UpdateProjectStatus: error : %s", err.Error()) } else { utils.GetLog().Error("services.project updateProjectStatus: debug: filter=%s,id=%v", utils.Sdump(filter)) } }() q := models.GetDB().QueryTable(models.TABLE_NAME_PROJECT) for k, v := range filter { if k == "project_id" { num, err = q.Filter("Id", v).Update(orm.Params{"del_status": 1}) } } return }
func GetCount(filter map[string]interface{}) (cnt int64, err error) { defer func() { if err != nil { utils.GetLog().Error("services.job.GetCount : error : %s", err.Error()) } else { utils.GetLog().Debug("services.job.GetCount : debug : filter=%s, count=%v", utils.Sdump(filter), cnt) } }() q := models.GetDB().QueryTable(models.TABLE_NAME_JOB) for k, v := range filter { q = q.Filter(k, v) } cnt, err = q.Count() return }
//更新删除状态 func (jobList *JobList) UpdateJobDelStatus(filter map[string]interface{}, Delstatus uint) (num int64, err error) { defer func() { if err != nil { utils.GetLog().Error("services.job.updateJobDelStatus: error : %s", err.Error()) } else { utils.GetLog().Debug("services.job.update: debug: filter=%s,job=%v", utils.Sdump(filter)) } }() q := models.GetDB().QueryTable(models.TABLE_NAME_JOB) for k, v := range filter { if k == "Job_id" { num, err = q.Filter("Id", v).Update(orm.Params{"del_status": Delstatus}) } } return }
//更新投诉状态 func UpdateComplaint(filter map[string]interface{}) (num int64, err error) { defer func() { if err != nil { utils.GetLog().Error("services.job.UpdateComplain : error : %s", err.Error()) } else { utils.GetLog().Debug("services.job.UpdateComplain : debug : filter=%s, job=%v", utils.Sdump(filter)) } }() q := models.GetDB().QueryTable("job_complaints") for k, v := range filter { if k == "Complain_id" { num, err = q.Filter("Id", v).Update(orm.Params{"ReplyStatus": 1}) } } return }
//根据投诉编号获取投诉信息 func GetOneComplain(filter map[string]interface{}) (*models.JobComplaint, error) { var complaint models.JobComplaint var err error defer func() { if err != nil { utils.GetLog().Error("services.job.GetOneComplain : error : %s", err.Error()) } else { utils.GetLog().Debug("services.job.GetOneComplain : debug : filter=%s, job=%v", utils.Sdump(filter), utils.Sdump(complaint)) } }() q := models.GetDB().QueryTable("job_complaints").RelatedSel("Job", "User", "Project") for k, v := range filter { q = q.Filter(k, v) } err = q.One(&complaint) if err == orm.ErrNoRows { err = errors.New("投诉找不到") } return &complaint, err }
func (u *User) Login(email string, password string) (err error) { defer func() { if err != nil { utils.GetLog().Error("user.User.Login : error :%s", err.Error()) } utils.GetLog().Debug("user.User.Login : user = %s", utils.Sdump(u)) }() u.email = NewEmail(email) u.password = NewPassword(password) if err = u.validLogin(); err != nil { return err } if err = u.afterLogin(); err != nil { return err } return nil }
//根据ID查询对应的job func GetOneJob(filter map[string]interface{}) (*models.Job, error) { var retJob models.Job var err error defer func() { if err != nil { utils.GetLog().Error("services.job.GetOne : error : %s", err.Error()) } else { utils.GetLog().Debug("services.job.GetOne : debug : filter=%s, job=%v", utils.Sdump(filter), utils.Sdump(retJob)) } }() q := models.GetDB().QueryTable(models.TABLE_NAME_JOB).RelatedSel("Project", "Employee") for k, v := range filter { q = q.Filter(k, v) } err = q.One(&retJob) if err == orm.ErrNoRows { err = errors.New("查找作业不存在") } return &retJob, err }
func (jv *JobClaim) insertJobClaim() (err error) { jv.jobClaim.Status = uint8(jv.mapJob["Status"].(int)) jv.jobClaim.Remark = jv.mapJob["Remark"].(string) jv.jobClaim.ClaimUser = jv.user jv.jobClaim.Job = &models.Job{Id: jv.jobId} _, err = models.GetDB().Insert(jv.jobClaim) if err != nil { utils.GetLog().Debug("services.job.Claim : debug : jobClaim=%s", utils.Sdump(jv.jobClaim)) return } return }
func (jv *JobValidation) Do() (err error) { defer func() { if err != nil { utils.GetLog().Error("job.JobValidation.Do : error = %s, ojb= %s", err.Error(), utils.Sdump(jv)) } utils.GetLog().Debug("job.JobValidation.Do : ojb= %s", utils.Sdump(jv)) }() if jv.jobValidation.Job, err = jv.getJob(); err != nil { return } if jv.jobValidation.OperationUser, err = jv.getUser(); err != nil { return } if jv.jobValidation.Status, err = jv.getResult(); err != nil { return } if jv.jobValidation.Message, err = jv.getMessage(); err != nil { return } jv.jobValidation.FinishTime, err = jv.getFinishTime() if jv.jobValidation.Status == 0 && err != nil { return } if err = jv.jobValidation.Insert(); err != nil { return } if err = jv.afterValidation(); err != nil { return } return }
//创建一个投诉的回复 func (cpr *ComplaintReplytor) CreateComplaintReply(mapComplainReply map[string]interface{}, user *models.User) (replyId, jobId uint, err error) { defer func() { if err != nil { utils.GetLog().Error("services.complainReply.Create : error : %s, ", err.Error()) } else { utils.GetLog().Debug("services.complainReply.Create : debug : mapComplainReply=%s", utils.Sdump(mapComplainReply)) } }() var complainReply models.JobComplaintReply complainReply.Message = mapComplainReply["Desc"].(string) var complainId uint switch v := mapComplainReply["Complain_id"].(type) { case int: complainId = uint(v) case string: tmp, _ := strconv.Atoi(v) complainId = uint(tmp) } filter := make(map[string]interface{}) filter["Id"] = complainId complians, _ := GetOneComplain(filter) complainReply.Complaint = &models.JobComplaint{Id: complainId} complainReply.User = user cpr.complain = *complians var repId int64 repId, err = models.GetDB().Insert(&complainReply) if err != nil { utils.GetLog().Debug("services.complianReply.Create : debug : job=%s", utils.Sdump(complainReply)) return } replyId = uint(repId) jobId = uint(complians.Job.Id) return }
func CreateComlian(mapComplain map[string]interface{}, user *models.User) (complainId uint, err error) { defer func() { if err != nil { utils.GetLog().Error("services.complain.Create : error : %s, ", err.Error()) } else { utils.GetLog().Debug("services.complain.Create : debug : mapComplain=%s", utils.Sdump(mapComplain)) } }() var complian models.JobComplaint pid, _ := mapComplain["Jobcode"].(string) filter := make(map[string]interface{}) filter["code"] = pid var job *models.Job job, err = GetOneJob(filter) complian.Job = &models.Job{Id: job.Id} complian.Project = &models.Project{Id: job.Project.Id} complian.Employee = &models.User{Id: job.Employee.Id} complian.Complain = mapComplain["Complain"].(string) complian.Type = mapComplain["Type"].(string) response, _ := mapComplain["response"].(int) complian.Response = uint(response) complian.User = user var insertId int64 insertId, err = models.GetDB().Insert(&complian) if err != nil { utils.GetLog().Debug("services.complian.Create : debug : job=%s", utils.Sdump(complian)) return } complainId = uint(insertId) return }
func httpSend(url string, body io.Reader) (result []byte, err error) { responseHandler, err := http.Post(url, "application/x-www-form-urlencoded", body) if err != nil { utils.GetLog().Error("httpSend error : %s", err.Error()) return nil, err } defer responseHandler.Body.Close() bodyByte, err := ioutil.ReadAll(responseHandler.Body) if err != nil { return nil, err } return bodyByte, nil }
// make email sending as a queue, never block the progress func (e *Email) Send() (err error) { defer func() { if err != nil { utils.GetLog().Error("notify.Email.Send err=%s", err.Error()) } else { utils.GetLog().Debug("notify.Email.Send obj=%s", utils.Sdump(e)) } }() if !e.IsEnable() { err = errors.New("email is not enabled") return nil } e.data.Set("template_invoke_name", string(e.notifier.GetTemplateName())) var subs string if subs, err = e.handleSubs(); err != nil { return } e.data.Set("substitution_vars", subs) postData := e.data.Encode() postBody := bytes.NewBufferString(postData) resp, err := httpSend(sendEmailByTempUrl, postBody) if err != nil { return } var result map[string]interface{} err = json.Unmarshal(resp, &result) if result["message"] != "success" || err != nil { return err } return }
func (pl *ProgressList) Do() (err error) { defer func() { if err != nil { utils.GetLog().Error("progress.ProgressList.Do : err = %s", err.Error()) } //utils.GetLog().Debug("progress.progresslist.Do : obj = %s", utils.Sdump(pl)) }() if err = pl.fetchProgresses(); err != nil { return } pl.getProgressIds() pl.groupProgresses() if err = pl.fetchGroupedProgresses(); err != nil { return } return }
func (js *JobSubmit) submit() (submitId uint, err error) { if js.getJob() != nil { return } var jc models.JobSubmit jc.Job = js.job jc.Status = uint8(js.mapJob["Status"].(int)) jc.Remark = js.mapJob["Remark"].(string) jc.ProduceUser = js.user q := models.GetDB().QueryTable(models.TABLE_NAME_JOB).Filter("id", js.jobId) newData := orm.Params{ "submit_status": jc.Status, } var codeType uint8 = job.JobCode_NoneModify if jc.Status == models.Job_Submit_Wait_Acceptance { newData["submit_time"] = time.Now() if js.job.SubmitStatus == models.Job_Submit_Acceptance_Refuse { codeType = job.JobCode_ProduceModify } } else if jc.Status == models.Job_Submit_Acceptance_OK { newData["acceptance_time"] = time.Now() } newData["Code"] = job.NewJobCode(js.job.Code, js.user.Company.Code, codeType).GetCode() _, err = q.Update(newData) var insertId int64 insertId, err = models.GetDB().Insert(&jc) if err != nil { utils.GetLog().Debug("services.job.Submit : debug : jobSubmit=%s", utils.Sdump(jc)) return } submitId = uint(insertId) return }
func IsValueExists(table string, column string, value interface{}) bool { utils.GetLog().Debug("models.IsValueExists : table: %s, columns: %s, value: %v", table, column, value) return GetDB().QueryTable(table).Filter(column, value).Exist() }
func (p *Project) Update(data map[string]interface{}) (err error) { defer func() { if err != nil { utils.GetLog().Error("project.Project.Update : error : %s", err.Error()) } else { utils.GetLog().Debug("project.Project.Update : debug : %s", utils.Sdump(p)) } }() Orm := orm.NewOrm() err = Orm.Begin() if err != nil { return } var projectLogs []models.ProjectLog //project_id, _ := strconv.Atoi(data["id"].(string)) //p.project.Id = uint(project_id) p.project.Registrant = &models.User{Id: data["registrant"].(uint)} if p.project.Name != data["name"].(string) { projectLog := models.GetProjectLogForEdit(p.project.Id, data["registrant"].(uint)).SetColumn(models.NAME, p.project.Name, data["name"].(string)) projectLogs = append(projectLogs, *projectLog) p.project.Name = data["name"].(string) } scale, _ := strconv.Atoi(data["scale"].(string)) if p.project.Scale != uint(scale) { projectLog := models.GetProjectLogForEdit(p.project.Id, data["registrant"].(uint)).SetColumn(models.SCALE, strconv.Itoa(int(p.project.Scale)), data["scale"].(string)) projectLogs = append(projectLogs, *projectLog) p.project.Scale = uint(scale) } priority, _ := strconv.Atoi(data["priority"].(string)) if p.project.Priority != uint(priority) { projectLog := models.GetProjectLogForEdit(p.project.Id, data["registrant"].(uint)).SetColumn(models.PRIORITY, strconv.Itoa(int(p.project.Priority)), data["priority"].(string)) projectLogs = append(projectLogs, *projectLog) p.project.Priority = uint(priority) } if p.project.ClientName != data["clientName"].(string) { projectLog := models.GetProjectLogForEdit(p.project.Id, data["registrant"].(uint)).SetColumn(models.CLIENT_NAME, p.project.ClientName, data["clientName"].(string)) projectLogs = append(projectLogs, *projectLog) p.project.ClientName = data["clientName"].(string) } if p.project.ContractNo != data["contractNo"].(string) { projectLog := models.GetProjectLogForEdit(p.project.Id, data["registrant"].(uint)).SetColumn(models.CONRACT_NO, p.project.ContractNo, data["contractNo"].(string)) projectLogs = append(projectLogs, *projectLog) p.project.ContractNo = data["contractNo"].(string) } if p.project.ServiceItem != data["serviceItem"].(string) { projectLog := models.GetProjectLogForEdit(p.project.Id, data["registrant"].(uint)).SetColumn(models.SERVICE_ITEM, p.project.ServiceItem, data["serviceItem"].(string)) projectLogs = append(projectLogs, *projectLog) p.project.ServiceItem = data["serviceItem"].(string) } gameDate, err := utils.FormatTime(data["gameDate"].(string)) if p.project.GameDate.Format("2006-01-02 15:04") != data["gameDate"].(string) { projectLog := models.GetProjectLogForEdit(p.project.Id, data["registrant"].(uint)).SetColumn(models.GAME_DATE, p.project.GameDate.Format("2006-01-02 15:04"), data["gameDate"].(string)) projectLogs = append(projectLogs, *projectLog) p.project.GameDate = gameDate } regStartDate, err := utils.FormatTime(data["regStartDate"].(string)) if p.project.RegStartDate.Format("2006-01-02 15:04") != data["regStartDate"].(string) { projectLog := models.GetProjectLogForEdit(p.project.Id, data["registrant"].(uint)).SetColumn(models.REG_START_DATE, p.project.RegStartDate.Format("2006-01-02 15:04"), data["regStartDate"].(string)) projectLogs = append(projectLogs, *projectLog) p.project.RegStartDate = regStartDate } regCloseDate, err := utils.FormatTime(data["regCloseDate"].(string)) if p.project.RegCloseDate.Format("2006-01-02 15:04") != data["regCloseDate"].(string) { projectLog := models.GetProjectLogForEdit(p.project.Id, data["registrant"].(uint)).SetColumn(models.REG_CLOSE_DATA, p.project.RegCloseDate.Format("2006-01-02 15:04"), data["regCloseDate"].(string)) projectLogs = append(projectLogs, *projectLog) p.project.RegCloseDate = regCloseDate } progress, _ := strconv.Atoi(data["progress"].(string)) if p.project.Progress.Id != uint(progress) { projectLog := models.GetProjectLogForEdit(p.project.Id, data["registrant"].(uint)).SetColumn(models.PROGRESS, strconv.Itoa(int(p.project.Progress.Id)), data["progress"].(string)) projectLogs = append(projectLogs, *projectLog) p.project.Progress = &models.Progress{Id: uint(progress)} } bussinessUserId, _ := strconv.Atoi(data["bussinessUser"].(string)) if p.project.BussinessUser.Id != uint(bussinessUserId) { projectLog := models.GetProjectLogForEdit(p.project.Id, data["registrant"].(uint)).SetColumn(models.BUSSINESS_USER, strconv.Itoa(int(p.project.BussinessUser.Id)), data["bussinessUser"].(string)) projectLogs = append(projectLogs, *projectLog) p.project.BussinessUser = &models.User{Id: uint(bussinessUserId)} } artUserId, _ := strconv.Atoi(data["artUser"].(string)) if p.project.ArtUser.Id != uint(artUserId) { projectLog := models.GetProjectLogForEdit(p.project.Id, data["registrant"].(uint)).SetColumn(models.ART_USER_ID, strconv.Itoa(int(p.project.ArtUser.Id)), data["artUser"].(string)) projectLogs = append(projectLogs, *projectLog) p.project.ArtUser = &models.User{Id: uint(artUserId)} } techUserId, _ := strconv.Atoi(data["techUser"].(string)) if p.project.TechUser.Id != uint(techUserId) { projectLog := models.GetProjectLogForEdit(p.project.Id, data["registrant"].(uint)).SetColumn(models.TECH_USER_ID, strconv.Itoa(int(p.project.TechUser.Id)), data["techUser"].(string)) projectLogs = append(projectLogs, *projectLog) p.project.TechUser = &models.User{Id: uint(techUserId)} } started, err := utils.FormatTime(data["started"].(string)) if p.project.Started.Format("2006-01-02 15:04") != data["started"].(string) { projectLog := models.GetProjectLogForEdit(p.project.Id, data["registrant"].(uint)).SetColumn(models.STARTED, p.project.Started.Format("2006-01-02 15:04"), data["started"].(string)) projectLogs = append(projectLogs, *projectLog) p.project.Started = started } p.project.Updated = time.Now().Local() utils.GetLog().Debug("p.project= %s", utils.Sdump(p.project)) err = p.CheckData() if err != nil { return } _, err = Orm.Update(p.project) if err != nil { err1 := Orm.Rollback() if err1 != nil { return err1 } return err } _, err = Orm.InsertMulti(1, projectLogs) if err != nil { err1 := Orm.Rollback() if err1 != nil { return err1 } return err } err = Orm.Commit() if err != nil { return } return }
func (p *Project) Create(data map[string]interface{}) (err error, projectId int64) { defer func() { if err != nil { utils.GetLog().Error("project.Project.Create : error : %s", err.Error()) } else { utils.GetLog().Debug("project.Project.Create : debug : %s", utils.Sdump(p)) } }() Orm := orm.NewOrm() err = Orm.Begin() if err != nil { return } p.project.Name = data["name"].(string) priority, _ := strconv.Atoi(data["priority"].(string)) p.project.Priority = uint(priority) progress, _ := strconv.Atoi(data["progress"].(string)) p.project.Progress = &models.Progress{Id: uint(progress)} scale, _ := strconv.Atoi(data["scale"].(string)) p.project.Scale = uint(scale) p.project.ClientName = data["clientName"].(string) p.project.ContractNo = data["contractNo"].(string) p.project.ServiceItem = data["serviceItem"].(string) p.project.GameDate, err = utils.FormatTime(data["gameDate"].(string)) p.project.RegStartDate, err = utils.FormatTime(data["regStartDate"].(string)) p.project.RegCloseDate, err = utils.FormatTime(data["regCloseDate"].(string)) bussinessUserId, _ := strconv.Atoi(data["bussinessUser"].(string)) p.project.BussinessUser = &models.User{Id: uint(bussinessUserId)} //registrant, _ := strconv.Atoi(data["registrant"].(string)) p.project.Registrant = &models.User{Id: data["registrant"].(uint)} artUserId, _ := strconv.Atoi(data["artUser"].(string)) p.project.ArtUser = &models.User{Id: uint(artUserId)} techUserId, _ := strconv.Atoi(data["techUser"].(string)) p.project.TechUser = &models.User{Id: uint(techUserId)} p.project.Started, err = utils.FormatTime(data["started"].(string)) p.project.Created = time.Now().Local() err = p.CheckData() if err != nil { return } projectId, err = Orm.Insert(p.project) if err != nil { err1 := Orm.Rollback() if err1 != nil { return err1, projectId } return err, projectId } var projectLog models.ProjectLog projectLog.Project = &models.Project{Id: uint(projectId)} projectLog.User = &models.User{Id: data["registrant"].(uint)} projectLog.Operation = models.CREATE _, err = Orm.Insert(&projectLog) if err != nil { fmt.Println(err) err1 := Orm.Rollback() if err1 != nil { return err1, projectId } return err, projectId } err = Orm.Commit() if err != nil { return } //emial notifier if err = p.sendEmailNotifier(); err != nil { return } return }
func (p *Password) GenPwd() string { passSalt := []byte(p.pwd + p.salt) p.encryptedPwd = fmt.Sprintf("%x", md5.Sum(passSalt)) utils.GetLog().Debug("user.Password.Encryped : %s", utils.Sdump(p)) return p.encryptedPwd }
// Finish 在请求结束后需要手动调用 func (c *BaseController) Finish() { c.pageReqestEnd = time.Since(c.pageRequestStart) utils.GetLog().Trace("request finished in : %s", c.pageReqestEnd) }