2022-05-03 00:09:25 +00:00
package app
import (
. "code.hoteas.com/golang/hotime"
. "code.hoteas.com/golang/hotime/common"
)
var ArticleCtr = Ctr {
"getdispatchs" : func ( that * Context ) {
2022-05-04 16:29:30 +00:00
//判断类型
tp := that . Req . FormValue ( "type" )
//判断类型
data := Map { "del_flag" : 0 }
if tp == "notify" {
data [ "notify_id[!]" ] = nil
}
if tp == "policy" {
data [ "policy_id[!]" ] = nil
}
if tp == "declare" {
data [ "declare_id[!]" ] = nil
}
if len ( data ) > 1 {
data = Map { "AND" : data , "GROUP" : "dispatch_name" }
} else {
data [ "GROUP" ] = "dispatch_name"
}
res := that . Db . Select ( "article" , "dispatch_name" , data )
2022-05-03 00:09:25 +00:00
that . Display ( 0 , res )
} ,
//用户微信公众号或者小程序登录
"search" : func ( that * Context ) {
page := ObjToInt ( that . Req . FormValue ( "page" ) )
pageSize := ObjToInt ( that . Req . FormValue ( "pageSize" ) )
if page < 1 {
page = 1
}
if pageSize <= 0 {
pageSize = 20
}
data := Map { "del_flag" : 0 }
keywords := that . Req . FormValue ( "keywords" )
if keywords != "" {
data [ "OR" ] = Map { "title[~]" : keywords , "description[~]" : keywords , "content[~]" : keywords }
}
startTime := that . Req . FormValue ( "starttime" )
finishTime := that . Req . FormValue ( "finishtime" )
if startTime != "" {
2022-05-17 04:31:47 +00:00
data [ "release_time[>=]" ] = startTime
2022-05-03 00:09:25 +00:00
}
if finishTime != "" {
2022-05-17 04:31:47 +00:00
data [ "release_time[<=]" ] = finishTime
2022-05-03 00:09:25 +00:00
}
dispatchName := that . Req . FormValue ( "dispatch_name" )
if dispatchName != "" {
data [ "dispatch_name" ] = dispatchName
}
//判断类型
tp := that . Req . FormValue ( "type" )
if tp == "notify" {
data [ "notify_id[!]" ] = nil
}
if tp == "policy" {
data [ "policy_id[!]" ] = nil
}
if tp == "declare" {
data [ "declare_id[!]" ] = nil
}
if len ( data ) > 1 {
2022-05-03 07:17:27 +00:00
data = Map { "AND" : data , "ORDER" : "release_time DESC" }
2022-05-03 00:09:25 +00:00
}
count := that . Db . Count ( "article" , data )
res := that . Db . Page ( page , pageSize ) . PageSelect ( "article" , "id,title,description,department_id,click_num+click_num_base AS click_num," +
2022-05-04 16:29:30 +00:00
"favorite_num_base+favorite_num AS favorite_num,dispatch_num,dispatch_name,prepare_date,release_time,expire_date,area_id,status,policy_id,declare_id,notify_id,dispatch_name,policy_level" , data )
2022-05-03 00:09:25 +00:00
for _ , v := range res {
if v . GetCeilInt ( "notify_id" ) > 0 {
v [ "notify" ] = that . Db . Get ( "notify" , "tag" , Map { "id" : v . GetCeilInt ( "notify_id" ) } )
}
if v . GetCeilInt ( "policy_id" ) > 0 {
v [ "policy" ] = that . Db . Get ( "policy" , "tag" , Map { "id" : v . GetCeilInt ( "policy_id" ) } )
}
if v . GetCeilInt ( "declare_id" ) > 0 {
2022-05-03 07:17:27 +00:00
v [ "declare" ] = that . Db . Get ( "declare" , "money_scope_min,money_scope_max,status" , Map { "id" : v . GetCeilInt ( "declare_id" ) } )
2022-05-03 00:09:25 +00:00
}
}
that . Display ( 0 , Map { "total" : count , "data" : res } )
} ,
}