Browse Source

Merge branch 'dev1.0.0' of https://app.yhyue.com/moapp/jyInfo into dev1.0.0

wangshan 3 years ago
parent
commit
0253afbed6

+ 5 - 0
api/internal/handler/routes.go

@@ -87,6 +87,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
 				Path:    "/jyinfo/manage/infoDetail",
 				Handler: infoDetailHandler(serverCtx),
 			},
+			{
+				Method:  http.MethodPost,
+				Path:    "/jyinfo/manage/infoDetail",
+				Handler: infoDetailHandler(serverCtx),
+			},
 			{
 				Method:  http.MethodPost,
 				Path:    "/jyinfo/manage/infoExamine",

+ 40 - 43
rpc/consumer/internal/logic/mypublishlistlogic.go

@@ -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
 }

+ 26 - 34
rpc/manager/internal/logic/infolistlogic.go

@@ -28,12 +28,13 @@ func NewInfoListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *InfoList
 	}
 }
 
-// 信息列表
+//InfoList 信息列表
 func (l *InfoListLogic) InfoList(in *manager.InfoListReq) (*manager.InfoListResp, error) {
 	var (
 		query     []string
 		queryInfo string
 		count     int64
+		results   []*manager.InfoList
 	)
 	if in.MsgType != 0 {
 		query = append(query, `type=`+common.InterfaceToStr(in.MsgType)+` `)
@@ -74,19 +75,16 @@ func (l *InfoListLogic) InfoList(in *manager.InfoListReq) (*manager.InfoListResp
 		queryInfo = fmt.Sprintf(" where %s", strings.Join(query, " and "))
 		//querySup = fmt.Sprintf(" where %s", strings.Join(supQuery, " and "))
 	}
-	if in.PageSize == 0 {
+	if in.PageSize <= 0 {
 		in.PageSize = 10
 	}
-	if in.PageIndex == 0 {
-		in.PageIndex = 1
-	}
 	if in.PageIndex == 1 {
 		count = model.Mysql.CountBySql(`SELECT count(1)  from (SELECT id,type,status,phone,contact_person,contact_phone,title,create_time  from information ` + queryInfo + `
 			union all
 			SELECT id,type,status,phone,contact_person,contact_phone,title,create_time  from supply_info ` + queryInfo + ` ) a`)
 	}
 	var offset int
-	if in.PageIndex == 1 {
+	if in.PageIndex <= 1 {
 		offset = 0
 	} else {
 		offset = common.IntAll((in.PageIndex - 1) * in.PageSize)
@@ -94,36 +92,30 @@ func (l *InfoListLogic) InfoList(in *manager.InfoListReq) (*manager.InfoListResp
 	allData := model.Mysql.SelectBySql(`SELECT a.id,a.type,a.status,a.phone,a.contact_person,a.contact_person,a.title,a.create_time  from (SELECT id,type,status,phone,contact_person,contact_phone,title,create_time  from information `+queryInfo+`
 			union all
 			SELECT id,type,status,phone,contact_person,contact_phone,title,create_time  from supply_info `+queryInfo+` ) a  order by a.create_time limit ?,? `, offset, in.PageSize)
-	if allData == nil || len(*allData) == 0 {
-		return &manager.InfoListResp{
-			ErrCode: 0,
-			ErrMsg:  "暂无数据",
-			Data:    nil,
-		}, nil
-	}
-
-	results := []*manager.InfoList{}
-	for _, v := range *allData {
-		res := manager.InfoList{}
-		var contact manager.Contact
-		if common.IntAll(v["type"]) == 1 || common.IntAll(v["type"]) == 2 {
-			res.Checked = model.Sensitive.Information
-		} else {
-			res.Checked = model.Sensitive.SupplyInfo
+	if allData != nil && len(*allData) > 0 {
+		for _, v := range *allData {
+			res := manager.InfoList{}
+			var contact manager.Contact
+			if common.IntAll(v["type"]) == 1 || common.IntAll(v["type"]) == 2 {
+				res.Checked = model.Sensitive.Information
+			} else {
+				res.Checked = model.Sensitive.SupplyInfo
+			}
+			res.Id = se.SE.EncodeString(common.InterfaceToStr(v["id"])) //信息id加密
+			res.Title = common.InterfaceToStr(v["title"])
+			res.MsgType = common.Int64All(v["type"])
+			res.Phone = common.InterfaceToStr(v["phone"])
+			res.ReviewStatus = common.Int64All(v["status"])
+			res.Published = common.Int64All(v["published"])
+			res.IsDel = common.Int64All(v["published"])
+			res.ApplyTime = common.InterfaceToStr(v["create_time"])
+			contact.Name = common.InterfaceToStr(v["contact_person"])
+			contact.Phone = common.InterfaceToStr(v["contact_phone"])
+			res.Contact = &contact
+			results = append(results, &res)
 		}
-		res.Id = se.SE.EncodeString(common.InterfaceToStr(v["id"])) //信息id加密
-		res.Title = common.InterfaceToStr(v["title"])
-		res.MsgType = common.Int64All(v["type"])
-		res.Phone = common.InterfaceToStr(v["phone"])
-		res.ReviewStatus = common.Int64All(v["status"])
-		res.Published = common.Int64All(v["published"])
-		res.IsDel = common.Int64All(v["published"])
-		res.ApplyTime = common.InterfaceToStr(v["create_time"])
-		contact.Name = common.InterfaceToStr(v["contact_person"])
-		contact.Phone = common.InterfaceToStr(v["contact_phone"])
-		res.Contact = &contact
-		results = append(results, &res)
 	}
+
 	data := manager.Data{}
 	data.Count = count
 	data.List = results