|
@@ -25,96 +25,93 @@ func NewMyPublishListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *MyP
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-// 我的发布列表
|
|
|
+// MyPublishList 我的发布列表
|
|
|
func (l *MyPublishListLogic) MyPublishList(in *consumer.MyPublishListReq) (*consumer.MyPublishListResp, error) {
|
|
|
// todo: add your logic here and delete this line
|
|
|
var (
|
|
|
- quryname string
|
|
|
+ queryName string
|
|
|
data consumer.MyPublishListResp
|
|
|
amount, inReview, approved, auditFailed, total int64
|
|
|
+ ListData consumer.MyPublishListData
|
|
|
)
|
|
|
if in.Match != "" {
|
|
|
- quryname = ` and title LIKE '%` + in.Match + `%' `
|
|
|
+ queryName = ` and title LIKE '%` + in.Match + `%' `
|
|
|
}
|
|
|
if in.MsgType != 0 {
|
|
|
- quryname = quryname + ` and type=` + mc.InterfaceToStr(in.MsgType)
|
|
|
+ queryName = queryName + ` and type=` + mc.InterfaceToStr(in.MsgType)
|
|
|
}
|
|
|
if in.PageIndex == 1 {
|
|
|
//全部
|
|
|
- amount = model.Mysql.CountBySql(`SELECT count(1) from (SELECT id from information WHERE is_del = 1 and user_id= "` + in.UserId + `" ` + quryname + `
|
|
|
+ amount = model.Mysql.CountBySql(`SELECT count(1) from (SELECT id from information WHERE is_del = 1 and user_id= "` + in.UserId + `" ` + queryName + `
|
|
|
union all
|
|
|
- SELECT id from supply_info WHERE is_del = 1 and user_id= "` + in.UserId + `" ` + quryname + `) a`)
|
|
|
+ SELECT id from supply_info WHERE is_del = 1 and user_id= "` + in.UserId + `" ` + queryName + `) a`)
|
|
|
//审核中
|
|
|
- inReview = model.Mysql.CountBySql(`SELECT count(1) from (SELECT id from information WHERE is_del = 1 and user_id= "` + in.UserId + `" ` + quryname + ` and status in (0,1,2,3,4) and published = 1
|
|
|
+ inReview = model.Mysql.CountBySql(`SELECT count(1) from (SELECT id from information WHERE is_del = 1 and user_id= "` + in.UserId + `" ` + queryName + ` and status in (0,1,2,3,4) and published = 1
|
|
|
union all
|
|
|
- SELECT id from supply_info WHERE is_del = 1 and user_id= "` + in.UserId + `" ` + quryname + ` and status in (0,1,2,3,4) and published = 1) a`)
|
|
|
+ SELECT id from supply_info WHERE is_del = 1 and user_id= "` + in.UserId + `" ` + queryName + ` and status in (0,1,2,3,4) and published = 1) a`)
|
|
|
//审核通过
|
|
|
- approved = model.Mysql.CountBySql(`SELECT count(1) from (SELECT id from information WHERE is_del = 1 and user_id= "` + in.UserId + `" ` + quryname + ` and published = 2
|
|
|
+ approved = model.Mysql.CountBySql(`SELECT count(1) from (SELECT id from information WHERE is_del = 1 and user_id= "` + in.UserId + `" ` + queryName + ` and published = 2
|
|
|
union all
|
|
|
- SELECT id from supply_info WHERE is_del = 1 and user_id= "` + in.UserId + `" ` + quryname + ` and published = 2) a`)
|
|
|
+ SELECT id from supply_info WHERE is_del = 1 and user_id= "` + in.UserId + `" ` + queryName + ` and published = 2) a`)
|
|
|
//审核不通过
|
|
|
- auditFailed = model.Mysql.CountBySql(`SELECT count(1) from (SELECT id from information WHERE is_del = 1 and user_id= "` + in.UserId + `" ` + quryname + ` and status in (-1,-2) and published = 1` + `
|
|
|
+ auditFailed = model.Mysql.CountBySql(`SELECT count(1) from (SELECT id from information WHERE is_del = 1 and user_id= "` + in.UserId + `" ` + queryName + ` and status in (-1,-2) and published = 1` + `
|
|
|
union all
|
|
|
- SELECT id from supply_info WHERE is_del = 1 and user_id= "` + in.UserId + `" ` + quryname + ` and status in (-1,-2) and published = 1) a`)
|
|
|
+ SELECT id from supply_info WHERE is_del = 1 and user_id= "` + in.UserId + `" ` + queryName + ` and status in (-1,-2) and published = 1) a`)
|
|
|
}
|
|
|
|
|
|
if in.ReviewStatus != 0 {
|
|
|
if in.ReviewStatus == 1 {
|
|
|
- quryname = quryname + ` and status in (0,1,2,3,4) and published = 1`
|
|
|
+ queryName = queryName + ` and status in (0,1,2,3,4) and published = 1`
|
|
|
} else if in.ReviewStatus == 2 {
|
|
|
- quryname = quryname + ` and published = 2`
|
|
|
+ queryName = queryName + ` and published = 2`
|
|
|
} else if in.ReviewStatus == 3 {
|
|
|
- quryname = quryname + ` and status in (-1,-2)`
|
|
|
+ queryName = queryName + ` and status in (-1,-2)`
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if in.PageSize == 0 {
|
|
|
+ if in.PageSize <= 0 {
|
|
|
in.PageSize = 10
|
|
|
}
|
|
|
var offset int
|
|
|
- if in.PageIndex == 1 {
|
|
|
+ if in.PageIndex <= 1 {
|
|
|
offset = 0
|
|
|
} else {
|
|
|
offset = mc.IntAll((in.PageIndex - 1) * in.PageSize)
|
|
|
}
|
|
|
if in.PageIndex == 1 {
|
|
|
- count := model.Mysql.CountBySql(`SELECT count(1) from (SELECT id,type,title,create_time,status,published from information WHERE is_del = 1 and user_id= "` + in.UserId + `" ` + quryname + `
|
|
|
+ count := model.Mysql.CountBySql(`SELECT count(1) from (SELECT id,type,title,create_time,status,published from information WHERE is_del = 1 and user_id= "` + in.UserId + `" ` + queryName + `
|
|
|
union all
|
|
|
- SELECT id,type,title,create_time,status,published from supply_info WHERE is_del = 1 and user_id= "` + in.UserId + `" ` + quryname + ` ) a`)
|
|
|
+ SELECT id,type,title,create_time,status,published from supply_info WHERE is_del = 1 and user_id= "` + in.UserId + `" ` + queryName + ` ) a`)
|
|
|
total = mc.Int64All(mc.MathCeil(mc.Float64All(count) / mc.Float64All(in.PageSize)))
|
|
|
}
|
|
|
- allData := model.Mysql.SelectBySql(`SELECT a.id,a.type,a.title,a.create_time,a.published,a.status from (SELECT id,type,title,create_time,status,published from information WHERE is_del = 1 and user_id= "`+in.UserId+`" `+quryname+`
|
|
|
+ allData := model.Mysql.SelectBySql(`SELECT a.id,a.type,a.title,a.create_time,a.published,a.status from (SELECT id,type,title,create_time,status,published from information WHERE is_del = 1 and user_id= "`+in.UserId+`" `+queryName+`
|
|
|
union all
|
|
|
- SELECT id,type,title,create_time,status,published from supply_info WHERE is_del = 1 and user_id= "`+in.UserId+`" `+quryname+` ) a order by a.create_time desc limit ?,?`, offset, in.PageSize)
|
|
|
- if allData == nil || len(*allData) == 0 {
|
|
|
- return &data, nil
|
|
|
- }
|
|
|
-
|
|
|
- var ListData consumer.MyPublishListData
|
|
|
- for _, v := range *allData {
|
|
|
- var vs = consumer.ListResp{}
|
|
|
- vs.Id = se.SE.EncodeString(mc.InterfaceToStr(v["id"])) //信息id加密
|
|
|
- vs.ReviewStatus = 1
|
|
|
- status := mc.IntAll(v["status"])
|
|
|
- published := mc.IntAll(v["published"])
|
|
|
- //1 审核中 2 已发布(审核通过)3 status(-1,-2) 审核不通过
|
|
|
- if published == 2 {
|
|
|
- vs.ReviewStatus = 2
|
|
|
- } else if status == -2 || status == -1 {
|
|
|
- vs.ReviewStatus = 3
|
|
|
+ SELECT id,type,title,create_time,status,published from supply_info WHERE is_del = 1 and user_id= "`+in.UserId+`" `+queryName+` ) a order by a.create_time desc limit ?,?`, offset, in.PageSize)
|
|
|
+ if allData != nil && len(*allData) > 0 {
|
|
|
+ for _, v := range *allData {
|
|
|
+ var vs = consumer.ListResp{}
|
|
|
+ vs.Id = se.SE.EncodeString(mc.InterfaceToStr(v["id"])) //信息id加密
|
|
|
+ vs.ReviewStatus = 1
|
|
|
+ status := mc.IntAll(v["status"])
|
|
|
+ published := mc.IntAll(v["published"])
|
|
|
+ //1 审核中 2 已发布(审核通过)3 status(-1,-2) 审核不通过
|
|
|
+ if published == 2 {
|
|
|
+ vs.ReviewStatus = 2
|
|
|
+ } else if status == -2 || status == -1 {
|
|
|
+ vs.ReviewStatus = 3
|
|
|
+ }
|
|
|
+ ListData.Total = total
|
|
|
+ vs.MsgType = mc.Int64All(v["type"])
|
|
|
+ vs.CreateTime = mc.InterfaceToStr(v["create_time"])
|
|
|
+ vs.Title = mc.InterfaceToStr(v["title"])
|
|
|
+ ListData.List = append(ListData.List, &vs)
|
|
|
}
|
|
|
- ListData.Total = total
|
|
|
- vs.MsgType = mc.Int64All(v["type"])
|
|
|
- vs.CreateTime = mc.InterfaceToStr(v["create_time"])
|
|
|
- vs.Title = mc.InterfaceToStr(v["title"])
|
|
|
- ListData.List = append(ListData.List, &vs)
|
|
|
}
|
|
|
|
|
|
ListData.Amount = amount
|
|
|
ListData.Approved = approved
|
|
|
ListData.InReview = inReview
|
|
|
ListData.AuditFailed = auditFailed
|
|
|
-
|
|
|
data.Results = &ListData
|
|
|
return &data, nil
|
|
|
}
|