|
@@ -1704,36 +1704,10 @@ func MyCollectChance(header *protocol.RequestHeader, request *protocol.MyCollect |
|
@@ -1704,36 +1704,10 @@ func MyCollectChance(header *protocol.RequestHeader, request *protocol.MyCollect |
1704
|
commItem.Chance, commItem.ChanceStatus = agg.SetChanceItem(header, ormItem.CommChanceItemOrm)
|
1704
|
commItem.Chance, commItem.ChanceStatus = agg.SetChanceItem(header, ormItem.CommChanceItemOrm)
|
1705
|
commItem.ReviewStatus = ormItem.ReviewStatus
|
1705
|
commItem.ReviewStatus = ormItem.ReviewStatus
|
1706
|
commItem.ChanceId = ormItem.ChanceId
|
1706
|
commItem.ChanceId = ormItem.ChanceId
|
1707
|
- //if len(ormItem.SourceContent) == 0 || ormItem.ChanceEnableStatus == 0 { //机会删除
|
|
|
1708
|
- // commItem.ChanceStatus = protocol.ChanceStatusDelete
|
|
|
1709
|
- //}
|
|
|
1710
|
- //if ormItem.Status == models.ChanceStatusClose { //机会关闭
|
|
|
1711
|
- // commItem.ChanceStatus = protocol.ChanceStatusClose
|
|
|
1712
|
- //}
|
|
|
1713
|
- //
|
|
|
1714
|
- //if ormItem.ChanceUserId > 0 {
|
|
|
1715
|
- // if provider, err = agg.GetUserBaseInfo(ormItem.ChanceUserId, header.CompanyId); err != nil {
|
|
|
1716
|
- // commItem.ChanceStatus = protocol.ChanceStatusDelete
|
|
|
1717
|
- // log.Error(err)
|
|
|
1718
|
- // //return
|
|
|
1719
|
- // } else {
|
|
|
1720
|
- // item := protocol.ChanceItem{
|
|
|
1721
|
- // Id: ormItem.ChanceId,
|
|
|
1722
|
- // Provider: provider,
|
|
|
1723
|
- // CreateTime: ormItem.CreateTime.Unix() * 1000,
|
|
|
1724
|
- // PublicStatus: ormItem.PublishStatus,
|
|
|
1725
|
- // }
|
|
|
1726
|
- // jsonUnmarshal(ormItem.SourceContent, &item.FormList)
|
|
|
1727
|
- // item.FormList = clearEmptyForm(item.FormList)
|
|
|
1728
|
- // jsonUnmarshal(ormItem.Images, &item.Pictures)
|
|
|
1729
|
- // jsonUnmarshal(ormItem.Voices, &item.Speechs)
|
|
|
1730
|
- // jsonUnmarshal(ormItem.Videos, &item.Videos)
|
|
|
1731
|
- // commItem.Chance = item
|
|
|
1732
|
- // }
|
|
|
1733
|
- //}
|
|
|
1734
|
- //
|
|
|
1735
|
- //commItem.ReviewStatus = ormItem.ReviewStatus
|
|
|
1736
|
- {
|
1707
|
+ commItem.Chance.UpdateTime = 0
|
|
|
1708
|
+ commItem.Chance.ApproveTime = 0
|
|
|
1709
|
+
|
|
|
1710
|
+ //chanceData
|
1737
|
var chanceData = protocol.ChanceData{
|
1711
|
var chanceData = protocol.ChanceData{
|
1738
|
ThumbsUpTotal: ormItem.ZanTotal,
|
1712
|
ThumbsUpTotal: ormItem.ZanTotal,
|
1739
|
CommentTotal: ormItem.CommentTotal,
|
1713
|
CommentTotal: ormItem.CommentTotal,
|
|
@@ -1741,13 +1715,12 @@ func MyCollectChance(header *protocol.RequestHeader, request *protocol.MyCollect |
|
@@ -1741,13 +1715,12 @@ func MyCollectChance(header *protocol.RequestHeader, request *protocol.MyCollect |
1741
|
}
|
1715
|
}
|
1742
|
chanceData.IsThumbsUp, chanceData.IsCollect, _ = getChanceMarkFlag(header, ormItem.ChanceId)
|
1716
|
chanceData.IsThumbsUp, chanceData.IsCollect, _ = getChanceMarkFlag(header, ormItem.ChanceId)
|
1743
|
commItem.ChanceData = chanceData
|
1717
|
commItem.ChanceData = chanceData
|
1744
|
- }
|
|
|
1745
|
- {
|
1718
|
+
|
1746
|
//做一次查询 查回所有的模板数据
|
1719
|
//做一次查询 查回所有的模板数据
|
1747
|
commItem.ChanceTemplate = getTemplate(ormItem.TemplateId)
|
1720
|
commItem.ChanceTemplate = getTemplate(ormItem.TemplateId)
|
1748
|
commItem.ChanceType = getChanceType(ormItem.ChanceTypeId)
|
1721
|
commItem.ChanceType = getChanceType(ormItem.ChanceTypeId)
|
1749
|
- }
|
|
|
1750
|
- {
|
1722
|
+
|
|
|
1723
|
+ //收藏数据
|
1751
|
collect := protocol.CollectData{
|
1724
|
collect := protocol.CollectData{
|
1752
|
Id: ormItem.CollectId,
|
1725
|
Id: ormItem.CollectId,
|
1753
|
CollectTime: ormItem.CollectTime.Unix() * 1000,
|
1726
|
CollectTime: ormItem.CollectTime.Unix() * 1000,
|
|
@@ -1755,11 +1728,8 @@ func MyCollectChance(header *protocol.RequestHeader, request *protocol.MyCollect |
|
@@ -1755,11 +1728,8 @@ func MyCollectChance(header *protocol.RequestHeader, request *protocol.MyCollect |
1755
|
if collect.CollectTime <= 0 && ormItem.UpdateTime.Unix() > 0 {
|
1728
|
if collect.CollectTime <= 0 && ormItem.UpdateTime.Unix() > 0 {
|
1756
|
collect.CollectTime = ormItem.UpdateTime.Unix() * 1000
|
1729
|
collect.CollectTime = ormItem.UpdateTime.Unix() * 1000
|
1757
|
}
|
1730
|
}
|
1758
|
- //收藏数据
|
|
|
1759
|
commItem.CollectData = collect
|
1731
|
commItem.CollectData = collect
|
1760
|
|
1732
|
|
1761
|
- //commItem.ChanceId = chance.ChanceId
|
|
|
1762
|
- }
|
|
|
1763
|
rsp.List = append(rsp.List, commItem)
|
1733
|
rsp.List = append(rsp.List, commItem)
|
1764
|
}
|
1734
|
}
|
1765
|
agg.ValidChancePermission(header.UserId, header.CompanyId, rsp.List)
|
1735
|
agg.ValidChancePermission(header.UserId, header.CompanyId, rsp.List)
|
|
@@ -1769,9 +1739,8 @@ func MyCollectChance(header *protocol.RequestHeader, request *protocol.MyCollect |
|
@@ -1769,9 +1739,8 @@ func MyCollectChance(header *protocol.RequestHeader, request *protocol.MyCollect |
1769
|
//我点赞的机会
|
1739
|
//我点赞的机会
|
1770
|
func MyThumbUpChance(header *protocol.RequestHeader, request *protocol.MyThumbUpChanceRequest) (rsp *protocol.MyThumbUpChanceResponse, err error) {
|
1740
|
func MyThumbUpChance(header *protocol.RequestHeader, request *protocol.MyThumbUpChanceRequest) (rsp *protocol.MyThumbUpChanceResponse, err error) {
|
1771
|
var (
|
1741
|
var (
|
1772
|
- myChances []protocol.ChanceThumbUpItemOrm
|
1742
|
+ ormItems []protocol.ChanceThumbUpItemOrm
|
1773
|
total int
|
1743
|
total int
|
1774
|
- provider *protocol.BaseUserInfo
|
|
|
1775
|
favorite *models.ChanceFavorite
|
1744
|
favorite *models.ChanceFavorite
|
1776
|
)
|
1745
|
)
|
1777
|
if request.LastId > 0 {
|
1746
|
if request.LastId > 0 {
|
|
@@ -1781,7 +1750,7 @@ func MyThumbUpChance(header *protocol.RequestHeader, request *protocol.MyThumbUp |
|
@@ -1781,7 +1750,7 @@ func MyThumbUpChance(header *protocol.RequestHeader, request *protocol.MyThumbUp |
1781
|
}
|
1750
|
}
|
1782
|
request.LastId = favorite.ZanTime.Unix()
|
1751
|
request.LastId = favorite.ZanTime.Unix()
|
1783
|
}
|
1752
|
}
|
1784
|
- if total, err = models.GetChanceThumbUp(header.UserId, request.LastId, request.PageSize, &myChances); err != nil {
|
1753
|
+ if total, err = models.GetChanceThumbUp(header.UserId, request.LastId, request.PageSize, &ormItems); err != nil {
|
1785
|
if err == orm.ErrNoRows {
|
1754
|
if err == orm.ErrNoRows {
|
1786
|
err = nil
|
1755
|
err = nil
|
1787
|
return
|
1756
|
return
|
|
@@ -1790,63 +1759,38 @@ func MyThumbUpChance(header *protocol.RequestHeader, request *protocol.MyThumbUp |
|
@@ -1790,63 +1759,38 @@ func MyThumbUpChance(header *protocol.RequestHeader, request *protocol.MyThumbUp |
1790
|
return
|
1759
|
return
|
1791
|
}
|
1760
|
}
|
1792
|
rsp = &protocol.MyThumbUpChanceResponse{Total: total}
|
1761
|
rsp = &protocol.MyThumbUpChanceResponse{Total: total}
|
1793
|
- for i := 0; i < len(myChances); i++ {
|
|
|
1794
|
- chance := myChances[i]
|
1762
|
+ for i := 0; i < len(ormItems); i++ {
|
|
|
1763
|
+ ormItem := ormItems[i]
|
1795
|
commItem := &protocol.CommonListItem{}
|
1764
|
commItem := &protocol.CommonListItem{}
|
1796
|
- commItem.ReviewStatus = chance.ReviewStatus
|
|
|
1797
|
- commItem.ChanceId = chance.ChanceId
|
|
|
1798
|
- if len(chance.SourceContent) == 0 || chance.ChanceEnableStatus == 0 { //机会删除
|
|
|
1799
|
- commItem.ChanceStatus = protocol.ChanceStatusDelete
|
|
|
1800
|
- }
|
|
|
1801
|
- if chance.Status == models.ChanceStatusClose { //机会关闭
|
|
|
1802
|
- commItem.ChanceStatus = protocol.ChanceStatusClose
|
|
|
1803
|
- }
|
|
|
1804
|
- if chance.ChanceUserId > 0 {
|
|
|
1805
|
- if provider, err = agg.GetUserBaseInfo(chance.ChanceUserId, header.CompanyId); err != nil {
|
|
|
1806
|
- commItem.ChanceStatus = protocol.ChanceStatusDelete
|
|
|
1807
|
- log.Error(err)
|
|
|
1808
|
- //return
|
|
|
1809
|
- } else {
|
|
|
1810
|
- item := protocol.ChanceItem{
|
|
|
1811
|
- Id: chance.ChanceId,
|
|
|
1812
|
- Provider: provider,
|
|
|
1813
|
- CreateTime: chance.CreateTime.Unix() * 1000,
|
|
|
1814
|
- PublicStatus: chance.PublishStatus,
|
|
|
1815
|
- }
|
|
|
1816
|
- jsonUnmarshal(chance.SourceContent, &item.FormList)
|
|
|
1817
|
- item.FormList = clearEmptyForm(item.FormList)
|
|
|
1818
|
- jsonUnmarshal(chance.Images, &item.Pictures)
|
|
|
1819
|
- jsonUnmarshal(chance.Voices, &item.Speechs)
|
|
|
1820
|
- jsonUnmarshal(chance.Videos, &item.Videos)
|
|
|
1821
|
- commItem.Chance = item
|
|
|
1822
|
- }
|
|
|
1823
|
- }
|
|
|
1824
|
- commItem.ReviewStatus = chance.ReviewStatus
|
|
|
1825
|
- {
|
1765
|
+ commItem.Chance, commItem.ChanceStatus = agg.SetChanceItem(header, ormItem.CommChanceItemOrm)
|
|
|
1766
|
+ commItem.ReviewStatus = ormItem.ReviewStatus
|
|
|
1767
|
+ commItem.ChanceId = ormItem.ChanceId
|
|
|
1768
|
+ commItem.Chance.UpdateTime = 0
|
|
|
1769
|
+ commItem.Chance.ApproveTime = 0
|
|
|
1770
|
+
|
|
|
1771
|
+ //点赞收藏数据
|
1826
|
var chanceData = protocol.ChanceData{
|
1772
|
var chanceData = protocol.ChanceData{
|
1827
|
- ThumbsUpTotal: chance.ZanTotal,
|
|
|
1828
|
- CommentTotal: chance.CommentTotal,
|
|
|
1829
|
- PageViewTotal: chance.ViewTotal,
|
1773
|
+ ThumbsUpTotal: ormItem.ZanTotal,
|
|
|
1774
|
+ CommentTotal: ormItem.CommentTotal,
|
|
|
1775
|
+ PageViewTotal: ormItem.ViewTotal,
|
1830
|
}
|
1776
|
}
|
1831
|
- chanceData.IsThumbsUp, chanceData.IsCollect, _ = getChanceMarkFlag(header, chance.ChanceId)
|
1777
|
+ chanceData.IsThumbsUp, chanceData.IsCollect, _ = getChanceMarkFlag(header, ormItem.ChanceId)
|
1832
|
commItem.ChanceData = chanceData
|
1778
|
commItem.ChanceData = chanceData
|
1833
|
- }
|
|
|
1834
|
- {
|
|
|
1835
|
- //做一次查询 查回所有的模板数据
|
|
|
1836
|
- commItem.ChanceTemplate = getTemplate(chance.TemplateId)
|
|
|
1837
|
- commItem.ChanceType = getChanceType(chance.ChanceTypeId)
|
|
|
1838
|
- }
|
|
|
1839
|
- {
|
1779
|
+
|
|
|
1780
|
+ //模板数据
|
|
|
1781
|
+ commItem.ChanceTemplate = getTemplate(ormItem.TemplateId)
|
|
|
1782
|
+ commItem.ChanceType = getChanceType(ormItem.ChanceTypeId)
|
|
|
1783
|
+
|
|
|
1784
|
+ //点赞数据
|
1840
|
thumb := protocol.ThumbUpData{
|
1785
|
thumb := protocol.ThumbUpData{
|
1841
|
- Id: chance.CollectId,
|
|
|
1842
|
- ThumbUpTime: chance.ZanTime.Unix() * 1000,
|
1786
|
+ Id: ormItem.CollectId,
|
|
|
1787
|
+ ThumbUpTime: ormItem.ZanTime.Unix() * 1000,
|
1843
|
}
|
1788
|
}
|
1844
|
- if thumb.ThumbUpTime <= 0 && chance.UpdateTime.Unix() > 0 {
|
|
|
1845
|
- thumb.ThumbUpTime = chance.UpdateTime.Unix() * 1000
|
1789
|
+ if thumb.ThumbUpTime <= 0 && ormItem.UpdateTime.Unix() > 0 {
|
|
|
1790
|
+ thumb.ThumbUpTime = ormItem.UpdateTime.Unix() * 1000
|
1846
|
}
|
1791
|
}
|
1847
|
- //收藏数据
|
|
|
1848
|
commItem.ThumbUpData = thumb
|
1792
|
commItem.ThumbUpData = thumb
|
1849
|
- }
|
1793
|
+
|
1850
|
rsp.List = append(rsp.List, commItem)
|
1794
|
rsp.List = append(rsp.List, commItem)
|
1851
|
}
|
1795
|
}
|
1852
|
agg.ValidChancePermission(header.UserId, header.CompanyId, rsp.List)
|
1796
|
agg.ValidChancePermission(header.UserId, header.CompanyId, rsp.List)
|
|
@@ -1856,11 +1800,11 @@ func MyThumbUpChance(header *protocol.RequestHeader, request *protocol.MyThumbUp |
|
@@ -1856,11 +1800,11 @@ func MyThumbUpChance(header *protocol.RequestHeader, request *protocol.MyThumbUp |
1856
|
//我的评论
|
1800
|
//我的评论
|
1857
|
func MyComment(header *protocol.RequestHeader, request *protocol.MyCommentRequest) (rsp *protocol.MyCommentResponse, err error) {
|
1801
|
func MyComment(header *protocol.RequestHeader, request *protocol.MyCommentRequest) (rsp *protocol.MyCommentResponse, err error) {
|
1858
|
var (
|
1802
|
var (
|
1859
|
- myChances []protocol.ChanceCommentItemOrm
|
1803
|
+ ormItems []protocol.ChanceCommentItemOrm
|
1860
|
total int
|
1804
|
total int
|
1861
|
provider *protocol.BaseUserInfo
|
1805
|
provider *protocol.BaseUserInfo
|
1862
|
)
|
1806
|
)
|
1863
|
- if total, err = models.GetChanceComment(header.UserId, request.LastId, request.PageSize, &myChances); err != nil {
|
1807
|
+ if total, err = models.GetChanceComment(header.UserId, request.LastId, request.PageSize, &ormItems); err != nil {
|
1864
|
if err == orm.ErrNoRows {
|
1808
|
if err == orm.ErrNoRows {
|
1865
|
err = nil
|
1809
|
err = nil
|
1866
|
return
|
1810
|
return
|
|
@@ -1873,47 +1817,30 @@ func MyComment(header *protocol.RequestHeader, request *protocol.MyCommentReques |
|
@@ -1873,47 +1817,30 @@ func MyComment(header *protocol.RequestHeader, request *protocol.MyCommentReques |
1873
|
log.Error(err)
|
1817
|
log.Error(err)
|
1874
|
return
|
1818
|
return
|
1875
|
}
|
1819
|
}
|
1876
|
- for i := 0; i < len(myChances); i++ {
|
|
|
1877
|
- chance := myChances[i]
|
1820
|
+ for i := 0; i < len(ormItems); i++ {
|
|
|
1821
|
+ ormItem := ormItems[i]
|
1878
|
commItem := &protocol.CommonListItem{}
|
1822
|
commItem := &protocol.CommonListItem{}
|
1879
|
- commItem.ChanceId = chance.SourceId
|
|
|
1880
|
- if chance.SourceType == protocol.SourceTypeChance {
|
|
|
1881
|
- commItem.ReviewStatus = chance.ReviewStatus
|
|
|
1882
|
- if len(chance.SourceContent) == 0 { //机会删除
|
|
|
1883
|
- commItem.ChanceStatus = protocol.ChanceStatusDelete
|
|
|
1884
|
- } else if chance.ChanceEnableStatus == 0 { //机会关闭
|
|
|
1885
|
- commItem.ChanceStatus = protocol.ChanceStatusClose
|
|
|
1886
|
- }
|
|
|
1887
|
- if chance.Status == models.ChanceStatusClose { //机会关闭
|
|
|
1888
|
- commItem.ChanceStatus = protocol.ChanceStatusClose
|
|
|
1889
|
- }
|
|
|
1890
|
- item := protocol.ChanceItem{
|
|
|
1891
|
- Id: chance.SourceId,
|
|
|
1892
|
- Provider: provider,
|
|
|
1893
|
- CreateTime: chance.CreateTime.Unix() * 1000,
|
|
|
1894
|
- PublicStatus: chance.PublishStatus,
|
|
|
1895
|
- }
|
|
|
1896
|
- jsonUnmarshal(chance.SourceContent, &item.FormList)
|
|
|
1897
|
- item.FormList = clearEmptyForm(item.FormList)
|
|
|
1898
|
- jsonUnmarshal(chance.Images, &item.Pictures)
|
|
|
1899
|
- jsonUnmarshal(chance.Voices, &item.Speechs)
|
|
|
1900
|
- jsonUnmarshal(chance.Videos, &item.Videos)
|
|
|
1901
|
- commItem.Chance = item
|
|
|
1902
|
- commItem.ReviewStatus = chance.ReviewStatus
|
|
|
1903
|
- }
|
|
|
1904
|
- if chance.SourceType == protocol.SourceTypeComment {
|
1823
|
+ commItem.Chance, commItem.ChanceStatus = agg.SetChanceItem(header, ormItem.CommChanceItemOrm)
|
|
|
1824
|
+ commItem.ReviewStatus = ormItem.ReviewStatus
|
|
|
1825
|
+ commItem.ChanceId = ormItem.SourceId
|
|
|
1826
|
+ commItem.Chance.UpdateTime = 0
|
|
|
1827
|
+ commItem.Chance.ApproveTime = 0
|
|
|
1828
|
+ commItem.Chance.Provider = provider
|
|
|
1829
|
+ //被评论的数据内容
|
|
|
1830
|
+ if ormItem.SourceType == protocol.SourceTypeComment {
|
1905
|
commItem.CommentedData = protocol.CommentData{
|
1831
|
commItem.CommentedData = protocol.CommentData{
|
1906
|
- Id: chance.SourceId,
|
|
|
1907
|
- Content: chance.CommentedContent,
|
|
|
1908
|
- CommentTime: chance.CommentedTime.Unix() * 1000,
|
1832
|
+ Id: ormItem.SourceId,
|
|
|
1833
|
+ Content: ormItem.CommentedContent,
|
|
|
1834
|
+ CommentTime: ormItem.CommentedTime.Unix() * 1000,
|
1909
|
}
|
1835
|
}
|
1910
|
}
|
1836
|
}
|
|
|
1837
|
+ //评论内容
|
1911
|
commItem.CommentData = protocol.CommentData{
|
1838
|
commItem.CommentData = protocol.CommentData{
|
1912
|
- Id: chance.CommentId,
|
|
|
1913
|
- CommentTime: chance.CommentTime.Unix() * 1000,
|
|
|
1914
|
- Content: chance.CommentContent,
|
1839
|
+ Id: ormItem.CommentId,
|
|
|
1840
|
+ CommentTime: ormItem.CommentTime.Unix() * 1000,
|
|
|
1841
|
+ Content: ormItem.CommentContent,
|
1915
|
}
|
1842
|
}
|
1916
|
- commItem.SourceType = chance.SourceType
|
1843
|
+ commItem.SourceType = ormItem.SourceType
|
1917
|
rsp.List = append(rsp.List, commItem)
|
1844
|
rsp.List = append(rsp.List, commItem)
|
1918
|
}
|
1845
|
}
|
1919
|
agg.ValidChancePermission(header.UserId, header.CompanyId, rsp.List)
|
1846
|
agg.ValidChancePermission(header.UserId, header.CompanyId, rsp.List)
|