作者 郑周

1. 查询列表数据 不等nil

正在显示 30 个修改的文件 包含 67 行增加62 行删除
... ... @@ -3,10 +3,10 @@ package command
import "github.com/beego/beego/v2/core/validation"
type QueryLogCommand struct {
CompanyId int64 `cname:"公司ID" json:"-"`
TaskId int `cname:"任务ID" json:"taskId,string" valid:"Required"`
PageNumber int64 `cname:"分页页码" json:"pageNumber" valid:"Required"`
PageSize int64 `cname:"分页数量" json:"pageSize" valid:"Required"`
CompanyId int64 `cname:"公司ID" json:"-"`
TaskId string `cname:"任务ID" json:"taskId" valid:"Required"`
PageNumber int64 `cname:"分页页码" json:"pageNumber" valid:"Required"`
PageSize int64 `cname:"分页数量" json:"pageSize" valid:"Required"`
}
func (in *QueryLogCommand) Valid(*validation.Validation) {
... ...
... ... @@ -103,12 +103,13 @@ func (repo *CompanyRepository) Find(queryOptions map[string]interface{}) (int, [
if err != nil {
return 0, nil, err
}
var resultList []*domain.Company
arrays := make([]*domain.Company, 0)
for i := range companyModel {
result := repo.TransformToCompanyDomain(&companyModel[i])
resultList = append(resultList, result)
arrays = append(arrays, result)
}
return cnt, resultList, nil
return cnt, arrays, nil
}
func (repo *CompanyRepository) TransformToCompanyDomain(m *models.Company) *domain.Company {
... ...
... ... @@ -112,12 +112,13 @@ func (repo *DepartmentRepository) Find(queryOptions map[string]interface{}) (int
if err != nil {
return 0, nil, err
}
var resultList []*domain.Department
arrays := make([]*domain.Department, 0)
for i := range dparmentModel {
result := repo.TransformToCompanyDomain(&dparmentModel[i])
resultList = append(resultList, result)
arrays = append(arrays, result)
}
return cnt, resultList, nil
return cnt, arrays, nil
}
func (repo *DepartmentRepository) FindAll(companyId int64) ([]*domain.Department, error) {
... ...
... ... @@ -161,7 +161,7 @@ func (repo *EvaluationCycleRepository) Find(queryOptions map[string]interface{})
if err != nil {
return 0, nil, err
}
var arrays []*domain.EvaluationCycle
arrays := make([]*domain.EvaluationCycle, 0)
for _, v := range m {
d := repo.TransformToDomain(v)
arrays = append(arrays, &d)
... ... @@ -212,7 +212,7 @@ func (repo *EvaluationCycleRepository) FindCycleEnd(limit int) ([]*domain.Evalua
if err != nil {
return nil, err
}
var arrays []*domain.EvaluationCycle
arrays := make([]*domain.EvaluationCycle, 0)
for _, v := range m {
d := repo.TransformToDomain(v)
arrays = append(arrays, &d)
... ...
... ... @@ -175,7 +175,7 @@ func (repo *EvaluationCycleTemplateRepository) Find(queryOptions map[string]inte
if err != nil {
return 0, nil, err
}
var arrays []*domain.EvaluationCycleTemplate
arrays := make([]*domain.EvaluationCycleTemplate, 0)
for _, v := range m {
d := repo.TransformToDomain(v)
arrays = append(arrays, &d)
... ...
... ... @@ -111,10 +111,10 @@ func (repo *EvaluationItemUsedRepository) Find(queryOptions map[string]interface
if err != nil {
return 0, nil, err
}
var datas []*domain.EvaluationItemUsed
arrays := make([]*domain.EvaluationItemUsed, 0)
for _, v := range m {
d := repo.TransformToDomain(v)
datas = append(datas, d)
arrays = append(arrays, d)
}
return count, datas, nil
return count, arrays, nil
}
... ...
... ... @@ -208,7 +208,7 @@ func (repo *EvaluationProjectRepository) Find(queryOptions map[string]interface{
if err != nil {
return 0, nil, err
}
var arrays []*domain.EvaluationProject
arrays := make([]*domain.EvaluationProject, 0)
for _, v := range m {
d := repo.TransformToDomain(v)
arrays = append(arrays, &d)
... ...
... ... @@ -163,7 +163,7 @@ func (repo *EvaluationRuleRepository) Find(queryOptions map[string]interface{})
if err != nil {
return 0, nil, err
}
var arrays []*domain.EvaluationRule
arrays := make([]*domain.EvaluationRule, 0)
for _, v := range m {
d := repo.TransformToDomain(v)
arrays = append(arrays, &d)
... ...
... ... @@ -176,7 +176,7 @@ func (repo *EvaluationTemplateRepository) Find(queryOptions map[string]interface
if err != nil {
return 0, nil, err
}
var arrays []*domain.EvaluationTemplate
arrays := make([]*domain.EvaluationTemplate, 0)
for _, v := range m {
d := repo.TransformToDomain(v)
arrays = append(arrays, &d)
... ...
... ... @@ -145,7 +145,7 @@ func (repo *LogOptRepository) Find(queryOptions map[string]interface{}) (int64,
if err != nil {
return 0, nil, err
}
var arrays []*domain.LogOpt
arrays := make([]*domain.LogOpt, 0)
for _, v := range m {
d := repo.TransformToDomain(v)
arrays = append(arrays, &d)
... ...
... ... @@ -78,12 +78,13 @@ func (repo *LogSmsRepository) Find(queryOptions map[string]interface{}) (int, []
if err != nil {
return 0, nil, err
}
var datas []*domain.LogSms
arrays := make([]*domain.LogSms, 0)
for _, v := range m {
d := repo.TransformToDomain(v)
datas = append(datas, d)
arrays = append(arrays, d)
}
return count, datas, nil
return count, arrays, nil
}
func (repo *LogSmsRepository) TransformToDomain(d *models.LogSms) *domain.LogSms {
... ...
... ... @@ -81,11 +81,12 @@ func (repo *MessagePersonalRepository) Find(param map[string]interface{}) (int,
if err != nil {
return 0, nil, err
}
var datas []*domain.MessagePersonal
arrays := make([]*domain.MessagePersonal, 0)
for _, v := range m {
d := repo.TransformToDomain(v)
datas = append(datas, d)
arrays = append(arrays, d)
}
return count, datas, nil
return count, arrays, nil
}
... ...
... ... @@ -159,7 +159,7 @@ func (repo *NodeTaskRepository) Find(queryOptions map[string]interface{}) ([]*do
if err != nil {
return nil, err
}
var arrays []*domain.NodeTask
arrays := make([]*domain.NodeTask, 0)
for _, v := range m {
d := repo.TransformToDomain(v)
arrays = append(arrays, &d)
... ...
... ... @@ -119,7 +119,7 @@ func (repo *PermissionRepository) Find(queryOptions map[string]interface{}) (int
if err != nil {
return 0, nil, err
}
var arrays []*domain.Permission
arrays := make([]*domain.Permission, 0)
for _, v := range m {
d := repo.TransformToDomain(v)
arrays = append(arrays, &d)
... ...
... ... @@ -90,12 +90,12 @@ func (repo *PositionRepository) Find(queryOptions map[string]interface{}) (int,
if err != nil {
return 0, nil, err
}
var resultList []*domain.Position
arrays := make([]*domain.Position, 0)
for i := range positionModel {
result := repo.transferToDomain(&positionModel[i])
resultList = append(resultList, result)
arrays = append(arrays, result)
}
return cnt, resultList, nil
return cnt, arrays, nil
}
func (repository *PositionRepository) transferToDomain(model *models.Position) *domain.Position {
... ...
... ... @@ -137,7 +137,8 @@ func (repo *RoleRepository) Find(queryOptions map[string]interface{}) (int64, []
if err != nil {
return 0, nil, err
}
var arrays []*domain.Role
arrays := make([]*domain.Role, 0)
for _, v := range m {
d := repo.TransformToDomain(v)
arrays = append(arrays, &d)
... ...
... ... @@ -139,7 +139,7 @@ func (repo *RoleUserRepository) Find(queryOptions map[string]interface{}) (int64
if err != nil {
return 0, nil, err
}
var arrays []*domain.RoleUser
arrays := make([]*domain.RoleUser, 0)
for _, v := range m {
d := repo.TransformToDomain(v)
arrays = append(arrays, &d)
... ...
... ... @@ -125,7 +125,7 @@ func (repo *StaffAssessCacheRepository) Find(queryOptions map[string]interface{}
if err != nil {
return 0, nil, err
}
var arrays []*domain.StaffAssessCache
arrays := make([]*domain.StaffAssessCache, 0)
for _, v := range m {
d := repo.TransformToDomain(v)
arrays = append(arrays, &d)
... ...
... ... @@ -139,7 +139,7 @@ func (repo *StaffAssessContentRepository) Find(queryOptions map[string]interface
if err != nil {
return 0, nil, err
}
var arrays []*domain.StaffAssessContent
arrays := make([]*domain.StaffAssessContent, 0)
for _, v := range m {
d := repo.TransformToDomain(v)
arrays = append(arrays, d)
... ...
... ... @@ -172,7 +172,7 @@ func (repo *StaffAssessRepository) Find(queryOptions map[string]interface{}) (in
if err != nil {
return 0, nil, err
}
var arrays []*domain.StaffAssess
arrays := make([]*domain.StaffAssess, 0)
for _, v := range m {
d := repo.TransformToDomain(v)
arrays = append(arrays, d)
... ...
... ... @@ -136,7 +136,7 @@ func (repo *StaffAssessTaskRepository) Find(queryOptions map[string]interface{})
if err != nil {
return 0, nil, err
}
var arrays []*domain.StaffAssessTask
arrays := make([]*domain.StaffAssessTask, 0)
for _, v := range m {
d := repo.TransformToDomain(v)
arrays = append(arrays, d)
... ...
... ... @@ -180,12 +180,12 @@ func (repo *SummaryEvaluationRepository) Find(queryOptions map[string]interface{
if err != nil {
return 0, nil, err
}
var datas []*domain.SummaryEvaluation
arrays := make([]*domain.SummaryEvaluation, 0)
for _, v := range m {
d := repo.TransformToDomain(v)
datas = append(datas, d)
arrays = append(arrays, d)
}
return count, datas, nil
return count, arrays, nil
}
func (repo *SummaryEvaluationRepository) RemoveByProjectId(id int) error {
... ...
... ... @@ -125,10 +125,10 @@ func (repo *SummaryEvaluationValueRepository) Find(queryOptions map[string]inter
if err != nil {
return 0, nil, err
}
var datas []*domain.SummaryEvaluationValue
arrays := make([]*domain.SummaryEvaluationValue, 0)
for _, v := range m {
d := repo.TransformToDomain(v)
datas = append(datas, d)
arrays = append(arrays, d)
}
return count, datas, nil
return count, arrays, nil
}
... ...
... ... @@ -138,10 +138,10 @@ func (repo *TaskAnomalyRepository) Find(queryOptions map[string]interface{}) (in
if err != nil {
return 0, nil, err
}
var datas []*domain.TaskAnomaly
arrays := make([]*domain.TaskAnomaly, 0)
for _, v := range m {
d := repo.TransformToDomain(v)
datas = append(datas, d)
arrays = append(arrays, d)
}
return count, datas, nil
return count, arrays, nil
}
... ...
... ... @@ -99,10 +99,10 @@ func (repo *TaskIgnoreRepository) Find(queryOptions map[string]interface{}) (int
if err != nil {
return 0, nil, err
}
var datas []*domain.TaskIgnore
arrays := make([]*domain.TaskIgnore, 0)
for _, v := range m {
d := repo.TransformToDomain(v)
datas = append(datas, d)
arrays = append(arrays, d)
}
return count, datas, nil
return count, arrays, nil
}
... ...
... ... @@ -64,10 +64,10 @@ func (repo *TaskLevelRepository) Find(queryOptions map[string]interface{}) (int,
if err != nil {
return 0, nil, err
}
var datas []*domain.TaskLevel
arrays := make([]*domain.TaskLevel, 0)
for _, v := range m {
d := repo.TransformToDomain(v)
datas = append(datas, d)
arrays = append(arrays, d)
}
return count, datas, nil
return count, arrays, nil
}
... ...
... ... @@ -177,7 +177,7 @@ func (repo *TaskRecordRepository) Find(queryOptions map[string]interface{}) (int
if err != nil {
return 0, nil, err
}
var arrays []*domain.TaskRecord
arrays := make([]*domain.TaskRecord, 0)
for _, v := range m {
d := repo.TransformToDomain(v)
arrays = append(arrays, &d)
... ...
... ... @@ -179,10 +179,10 @@ func (repo *TaskRepository) Find(queryOptions map[string]interface{}) (int, []*d
if err != nil {
return 0, nil, err
}
var datas []*domain.Task
arrays := make([]*domain.Task, 0)
for _, v := range m {
d := repo.TransformToDomain(v)
datas = append(datas, d)
arrays = append(arrays, d)
}
return count, datas, nil
return count, arrays, nil
}
... ...
... ... @@ -118,10 +118,10 @@ func (repo *TaskStageRepository) Find(queryOptions map[string]interface{}) (int,
if err != nil {
return 0, nil, err
}
var datas []*domain.TaskStage
arrays := make([]*domain.TaskStage, 0)
for _, v := range m {
d := repo.TransformToDomain(v)
datas = append(datas, d)
arrays = append(arrays, d)
}
return count, datas, nil
return count, arrays, nil
}
... ...
... ... @@ -169,12 +169,12 @@ func (repo *UserRepository) Find(queryOptions map[string]interface{}) (int, []*d
if err != nil {
return 0, nil, err
}
var resultList []*domain.User
arrays := make([]*domain.User, 0)
for i := range userModel {
result := repo.TransformToUserDomain(&userModel[i])
resultList = append(resultList, result)
arrays = append(arrays, result)
}
return cnt, resultList, nil
return cnt, arrays, nil
}
func (repo *UserRepository) TransformToUserDomain(user *models.User) *domain.User {
... ...