审批添加搜索条件

main
jhc 1 year ago
parent 0431b6f003
commit cf150b00c8

@ -1227,6 +1227,11 @@ type ListRequest struct {
Type string `protobuf:"bytes,5,opt,name=Type,json=type,proto3" json:"Type,omitempty"` //类型
UserID uint64 `protobuf:"varint,6,opt,name=UserID,json=userID,proto3" json:"UserID,omitempty"` //
ApprovedBossId uint64 `protobuf:"varint,7,opt,name=ApprovedBossId,json=approvedBossId,proto3" json:"ApprovedBossId,omitempty"` //
SubmitterName string `protobuf:"bytes,8,opt,name=SubmitterName,json=submitterName,proto3" json:"SubmitterName,omitempty"` // 提交人姓名
OrderBy string `protobuf:"bytes,9,opt,name=OrderBy,json=orderBy,proto3" json:"OrderBy,omitempty"` // 排序方式 asc
StartTime string `protobuf:"bytes,10,opt,name=StartTime,json=startTime,proto3" json:"StartTime,omitempty"` // 提交时间
EndTime string `protobuf:"bytes,11,opt,name=EndTime,json=endTime,proto3" json:"EndTime,omitempty"`
ApprovalStatus uint64 `protobuf:"varint,12,opt,name=ApprovalStatus,json=approvalStatus,proto3" json:"ApprovalStatus,omitempty"` // 审批状态 1 待审批 2 审批通过 3 审批未通过 4 未阅 5 已阅
}
func (x *ListRequest) Reset() {
@ -1310,6 +1315,41 @@ func (x *ListRequest) GetApprovedBossId() uint64 {
return 0
}
func (x *ListRequest) GetSubmitterName() string {
if x != nil {
return x.SubmitterName
}
return ""
}
func (x *ListRequest) GetOrderBy() string {
if x != nil {
return x.OrderBy
}
return ""
}
func (x *ListRequest) GetStartTime() string {
if x != nil {
return x.StartTime
}
return ""
}
func (x *ListRequest) GetEndTime() string {
if x != nil {
return x.EndTime
}
return ""
}
func (x *ListRequest) GetApprovalStatus() uint64 {
if x != nil {
return x.ApprovalStatus
}
return 0
}
type ListResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
@ -5616,7 +5656,7 @@ var file_api_approval_approval_proto_rawDesc = []byte{
0x65, 0x61, 0x76, 0x65, 0x42, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x65, 0x18, 0x09, 0x20, 0x01, 0x28,
0x09, 0x52, 0x0c, 0x6c, 0x65, 0x61, 0x76, 0x65, 0x42, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x65, 0x22,
0x10, 0x0a, 0x0e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73,
0x65, 0x22, 0xd0, 0x01, 0x0a, 0x0b, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73,
0x65, 0x22, 0xf0, 0x02, 0x0a, 0x0b, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73,
0x74, 0x12, 0x25, 0x0a, 0x06, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28,
0x09, 0x42, 0x0d, 0xe2, 0xdf, 0x1f, 0x09, 0x2a, 0x05, 0x37, 0x30, 0x30, 0x30, 0x31, 0x58, 0x01,
0x52, 0x06, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x12, 0x1a, 0x0a, 0x08, 0x50, 0x61, 0x67, 0x65,
@ -5629,7 +5669,17 @@ var file_api_approval_approval_proto_rawDesc = []byte{
0x20, 0x01, 0x28, 0x04, 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x44, 0x12, 0x26, 0x0a, 0x0e,
0x41, 0x70, 0x70, 0x72, 0x6f, 0x76, 0x65, 0x64, 0x42, 0x6f, 0x73, 0x73, 0x49, 0x64, 0x18, 0x07,
0x20, 0x01, 0x28, 0x04, 0x52, 0x0e, 0x61, 0x70, 0x70, 0x72, 0x6f, 0x76, 0x65, 0x64, 0x42, 0x6f,
0x73, 0x73, 0x49, 0x64, 0x22, 0x51, 0x0a, 0x0c, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70,
0x73, 0x73, 0x49, 0x64, 0x12, 0x24, 0x0a, 0x0d, 0x53, 0x75, 0x62, 0x6d, 0x69, 0x74, 0x74, 0x65,
0x72, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x73, 0x75, 0x62,
0x6d, 0x69, 0x74, 0x74, 0x65, 0x72, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x4f, 0x72,
0x64, 0x65, 0x72, 0x42, 0x79, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6f, 0x72, 0x64,
0x65, 0x72, 0x42, 0x79, 0x12, 0x1c, 0x0a, 0x09, 0x53, 0x74, 0x61, 0x72, 0x74, 0x54, 0x69, 0x6d,
0x65, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, 0x74, 0x61, 0x72, 0x74, 0x54, 0x69,
0x6d, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x45, 0x6e, 0x64, 0x54, 0x69, 0x6d, 0x65, 0x18, 0x0b, 0x20,
0x01, 0x28, 0x09, 0x52, 0x07, 0x65, 0x6e, 0x64, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x26, 0x0a, 0x0e,
0x41, 0x70, 0x70, 0x72, 0x6f, 0x76, 0x61, 0x6c, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x0c,
0x20, 0x01, 0x28, 0x04, 0x52, 0x0e, 0x61, 0x70, 0x70, 0x72, 0x6f, 0x76, 0x61, 0x6c, 0x53, 0x74,
0x61, 0x74, 0x75, 0x73, 0x22, 0x51, 0x0a, 0x0c, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70,
0x6f, 0x6e, 0x73, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20,
0x01, 0x28, 0x04, 0x52, 0x05, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x2b, 0x0a, 0x04, 0x64, 0x61,
0x74, 0x61, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x61, 0x70, 0x70, 0x72, 0x6f,

@ -163,6 +163,11 @@ message ListRequest {
string Type = 5 [json_name = "type"]; //
uint64 UserID = 6 [json_name = "userID"]; //
uint64 ApprovedBossId = 7 [json_name = "approvedBossId"]; //
string SubmitterName = 8 [json_name = "submitterName"]; //
string OrderBy = 9 [json_name = "orderBy"]; // asc
string StartTime = 10 [json_name = "startTime"]; //
string EndTime = 11 [json_name = "endTime"];
uint64 ApprovalStatus = 12 [json_name = "approvalStatus"]; // 1 2 3 4 5
}
message ListResponse {

@ -591,20 +591,36 @@ func MyAllWorkApprovals(in *approval.ListRequest) ([]*Approval, int64) {
Preload("ApprovalOA")
//我未阅读的和我未操作的
DB.Model(&Approval{}).Where(&Approval{Type: in.Type}).Where(&Approval{NowUserId: in.UserID, Status: StatusDoing}).Order("id desc").Select("id").Find(&ids)
s1 := DB.Model(&ApprovalCopy{}).Where(&ApprovalCopy{UserId: in.UserID}).Select("approval_id")
queryApproval := &Approval{NowUserId: in.UserID, Status: StatusDoing}
if in.ApprovalStatus <= StatusFail {
queryApproval.Status = int8(in.ApprovalStatus)
}
if in.SubmitterName != "" {
queryApproval.SubmitterName = in.SubmitterName
}
DB.Model(&Approval{}).Where(&Approval{Type: in.Type}).Where(queryApproval).Order("id " + in.OrderBy).Select("id").Find(&ids)
queryApprovalCopy := &ApprovalCopy{UserId: in.UserID}
if in.ApprovalStatus > StatusFail {
if in.ApprovalStatus == 4 {
queryApprovalCopy.Status = StatusNeedViewed
} else if in.ApprovalStatus == 5 {
queryApprovalCopy.Status = StatusViewed
}
}
s1 := DB.Model(&ApprovalCopy{}).Where(queryApprovalCopy).Select("approval_id")
modelObj = modelObj.Where(&Approval{Type: in.Type}).Where(
DB.Where(&Approval{NowUserId: in.UserID, Status: StatusDoing}). // 我需要审批的
Or(DB.Where("status = ?", StatusOk).Where("id in (?)", s1))) // 已完成,抄送给我的
Or(DB.Where("status = ?", StatusOk).Where("id in (?)", s1))) // 已完成,抄送给我的
modelObj.Count(&count)
if len(ids) > 0 { //根据具体id排序
modelObj = modelObj.Clauses(clause.OrderBy{
Expression: clause.Expr{SQL: "FIELD(id,?) desc", Vars: []interface{}{ids}, WithoutParentheses: true},
Expression: clause.Expr{SQL: "FIELD(id,?) " + in.OrderBy, Vars: []interface{}{ids}, WithoutParentheses: true},
})
} else {
modelObj = modelObj.Order("id desc")
modelObj = modelObj.Order("id " + in.OrderBy)
}
modelObj.Limit(int(in.PageSize)).Offset(page.GetOffset(in.Page, in.PageSize)).Find(&list)
@ -643,8 +659,8 @@ func MyApprovalWorkApprovals(in *approval.ListRequest) ([]*Approval, int64) {
if in.UserID != 0 {
modelObj = modelObj.Where(
DB.Where("JSON_CONTAINS(approval_users,JSON_OBJECT('ID', ?))", in.UserID).
Where("status != ?", StatusDoing). //完成,我参与审批
Or(DB.Where("now_user_id", in.UserID).Where("status = ?", StatusDoing)). //进行中,当前审批人是我,
Where("status != ?", StatusDoing). //完成,我参与审批
Or(DB.Where("now_user_id", in.UserID).Where("status = ?", StatusDoing)). //进行中,当前审批人是我,
Or(DB.Where("JSON_CONTAINS(copy_users,JSON_OBJECT('ID', ?))", in.UserID).Where("status = ?", StatusOk))) //抄送人(完成抄送)
}
@ -665,7 +681,7 @@ func MyApprovalWorkApprovals(in *approval.ListRequest) ([]*Approval, int64) {
modelObj.Count(&count)
modelObj.Order("id desc").Limit(int(in.PageSize)).Offset(page.GetOffset(in.Page, in.PageSize)).Find(&list)
modelObj.Order("id " + in.OrderBy).Limit(int(in.PageSize)).Offset(page.GetOffset(in.Page, in.PageSize)).Find(&list)
return list, count
}
@ -692,6 +708,10 @@ func MyWorkApprovals(in *approval.ListRequest) ([]*Approval, int64) {
modelObj = modelObj.Where(&Approval{Type: in.Type})
}
if in.SubmitterName != "" {
modelObj = modelObj.Where(&Approval{SubmitterName: in.SubmitterName})
}
/**
* ()
/ \
@ -702,8 +722,8 @@ func MyWorkApprovals(in *approval.ListRequest) ([]*Approval, int64) {
if in.UserID != 0 {
modelObj = modelObj.Where(
DB.Where("JSON_CONTAINS(approval_users,JSON_OBJECT('ID', ?))", in.UserID).
Where("status != ?", StatusDoing). //完成,我参与审批
Or(DB.Where("now_user_id", in.UserID).Where("status = ?", StatusDoing)). //进行中,当前审批人是我,
Where("status != ?", StatusDoing). //完成,我参与审批
Or(DB.Where("now_user_id", in.UserID).Where("status = ?", StatusDoing)). //进行中,当前审批人是我,
Or(DB.Where("JSON_CONTAINS(copy_users,JSON_OBJECT('ID', ?))", in.UserID).Where("status = ?", StatusOk))) //抄送人(完成抄送)
}
@ -724,7 +744,7 @@ func MyWorkApprovals(in *approval.ListRequest) ([]*Approval, int64) {
modelObj.Count(&count)
modelObj.Order("id desc").Limit(int(in.PageSize)).Offset(page.GetOffset(in.Page, in.PageSize)).Find(&list)
modelObj.Order("id " + in.OrderBy).Limit(int(in.PageSize)).Offset(page.GetOffset(in.Page, in.PageSize)).Find(&list)
return list, count
}
@ -758,7 +778,7 @@ func MySubmitApprovals(in *approval.ListRequest) ([]*Approval, int64) {
modelObj.Count(&count)
modelObj.Limit(int(in.PageSize)).Offset(page.GetOffset(in.Page, in.PageSize)).Order("id desc").Find(&list)
modelObj.Limit(int(in.PageSize)).Offset(page.GetOffset(in.Page, in.PageSize)).Order("id " + in.OrderBy).Find(&list)
return list, count
}
@ -790,7 +810,7 @@ func MyReadApprovals(in *approval.ListRequest) ([]*Approval, int64) {
modelObj.Count(&count)
modelObj.Limit(int(in.PageSize)).Offset(page.GetOffset(in.Page, in.PageSize)).Order("id desc").Find(&list)
modelObj.Limit(int(in.PageSize)).Offset(page.GetOffset(in.Page, in.PageSize)).Order("id " + in.OrderBy).Find(&list)
return list, count
}

Loading…
Cancel
Save