You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
165 lines
7.0 KiB
Go
165 lines
7.0 KiB
Go
package cmd
|
|
|
|
import (
|
|
"github.com/go-resty/resty/v2"
|
|
"github.com/mizuki1412/go-core-kit/class/exception"
|
|
"github.com/mizuki1412/go-core-kit/init/initkit"
|
|
"github.com/mizuki1412/go-core-kit/library/commonkit"
|
|
"github.com/mizuki1412/go-core-kit/service/configkit"
|
|
"github.com/mizuki1412/go-core-kit/service/logkit"
|
|
"github.com/spf13/cast"
|
|
"github.com/spf13/cobra"
|
|
"github.com/tidwall/gjson"
|
|
"time"
|
|
)
|
|
|
|
//纪检监察
|
|
|
|
func init() {
|
|
rootCmd.AddCommand(disCmd)
|
|
defFlagsDis(disCmd)
|
|
}
|
|
|
|
var disCmd = &cobra.Command{
|
|
Use: "dis",
|
|
Short: "Batch processing operations of the discipline inspection platform",
|
|
Run: func(cmd *cobra.Command, args []string) {
|
|
initkit.BindFlags(cmd)
|
|
handleDis()
|
|
},
|
|
}
|
|
|
|
func defFlagsDis(cmd *cobra.Command) {
|
|
cmd.Flags().String("ut", "", "*Specify the ut")
|
|
cmd.Flags().String("wid", "", "*Specify the wid")
|
|
cmd.Flags().String("pid", "", "*Specify the pid")
|
|
}
|
|
|
|
var disClient = resty.New().SetRetryCount(5).SetRetryWaitTime(10 * time.Second)
|
|
|
|
func handleDis() {
|
|
_ = commonkit.RecoverFuncWrapper(func() {
|
|
//签到
|
|
resp, err := disClient.R().
|
|
SetHeaders(map[string]string{
|
|
"Content-type": "application/json;charset=UTF-8",
|
|
"Ut": cast.ToString(configkit.Get("ut", "")),
|
|
"Wid": cast.ToString(configkit.Get("wid", "")),
|
|
"Pid": cast.ToString(configkit.Get("pid", "")),
|
|
"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36",
|
|
}).SetQueryParams(map[string]string{
|
|
"_": cast.ToString(time.Now().UnixNano() / int64(time.Millisecond)),
|
|
}).Get("http://aiportal.unicom.local/pcm/punchIn/addClockIn")
|
|
if err != nil || resp.IsError() || gjson.Get(resp.String(), "code").Int() != 200 {
|
|
panic(exception.New("签到失败 " + cast.ToString(resp.String())))
|
|
}
|
|
logkit.Info("签到成功,今日积分+1😄")
|
|
})
|
|
//拿菜单
|
|
resp, err := disClient.R().
|
|
SetHeaders(map[string]string{
|
|
"Content-type": "application/json;charset=UTF-8",
|
|
"Ut": cast.ToString(configkit.Get("ut", "")),
|
|
"Wid": cast.ToString(configkit.Get("wid", "")),
|
|
"Pid": cast.ToString(configkit.Get("pid", "")),
|
|
"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36",
|
|
}).SetQueryParams(map[string]string{
|
|
"accessType": "1",
|
|
"_": cast.ToString(time.Now().UnixNano() / int64(time.Millisecond)),
|
|
}).Get("http://aiportal.unicom.local/wsq/site/newsOne/v1/category/v1")
|
|
if err != nil || resp.IsError() || gjson.Get(resp.String(), "code").Int() != 200 {
|
|
panic(exception.New("获取菜单失败"))
|
|
}
|
|
//拿到一级菜单
|
|
var catID []string
|
|
first := gjson.Get(resp.String(), "data").Array()
|
|
for _, v := range first {
|
|
second := v.Get("categoryList").Array()
|
|
for _, vv := range second {
|
|
catID = append(catID, vv.Get("id").String())
|
|
}
|
|
}
|
|
for _, id := range catID {
|
|
resp, err = disClient.R().
|
|
SetHeaders(map[string]string{
|
|
"Content-type": "application/json;charset=UTF-8",
|
|
"Ut": cast.ToString(configkit.Get("ut", "")),
|
|
"Wid": cast.ToString(configkit.Get("wid", "")),
|
|
"Pid": cast.ToString(configkit.Get("pid", "")),
|
|
"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36",
|
|
}).SetQueryParams(map[string]string{
|
|
"page": "1",
|
|
"catid": id,
|
|
"limit": "5",
|
|
"_": cast.ToString(time.Now().UnixNano() / int64(time.Millisecond)),
|
|
}).Get("http://aiportal.unicom.local/wsq/site/newsOne/v1/index/newList")
|
|
if err != nil || resp.IsError() || gjson.Get(resp.String(), "code").Int() != 200 {
|
|
panic(exception.New("获取文章信息失败"))
|
|
}
|
|
list := gjson.Get(resp.String(), "data.list").Array()
|
|
var artID []string
|
|
var artName []string
|
|
for _, v := range list {
|
|
artID = append(artID, v.Get("id").String())
|
|
artName = append(artName, v.Get("title").String())
|
|
}
|
|
for i, v := range artID {
|
|
_ = commonkit.RecoverFuncWrapper(func() {
|
|
resp, err = disClient.R().
|
|
SetHeaders(map[string]string{
|
|
"Content-type": "application/json;charset=UTF-8",
|
|
"Ut": cast.ToString(configkit.Get("ut", "")),
|
|
"Wid": cast.ToString(configkit.Get("wid", "")),
|
|
"Pid": cast.ToString(configkit.Get("pid", "")),
|
|
"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36",
|
|
}).SetQueryParams(map[string]string{
|
|
"articleid": v,
|
|
"href": "/modules/subsite/jijianjiancha/newsdetail.html?id=" + v + "&wid=" + cast.ToString(configkit.Get("wid", "")),
|
|
"title": artName[i],
|
|
"_": cast.ToString(time.Now().UnixNano() / int64(time.Millisecond)),
|
|
}).Get("http://aiportal.unicom.local/pcm/msview/v1/view")
|
|
if err != nil || resp.IsError() || gjson.Get(resp.String(), "code").Int() != 200 {
|
|
panic(exception.New("浏览失败 " + artName[i] + cast.ToString(resp.String())))
|
|
}
|
|
logkit.Info("浏览成功 " + artName[i])
|
|
resp, err = disClient.R().
|
|
SetHeaders(map[string]string{
|
|
"Content-type": "application/json;charset=UTF-8",
|
|
"Ut": cast.ToString(configkit.Get("ut", "")),
|
|
"Wid": cast.ToString(configkit.Get("wid", "")),
|
|
"Pid": cast.ToString(configkit.Get("pid", "")),
|
|
"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36",
|
|
}).SetQueryParams(map[string]string{
|
|
"articleid": v,
|
|
"status": "1",
|
|
"href": "/modules/news/newsdetail.html?id=" + v,
|
|
"title": artName[i],
|
|
"_": cast.ToString(time.Now().UnixNano() / int64(time.Millisecond)),
|
|
}).Get("http://aiportal.unicom.local/pcm/mslike/v1/like")
|
|
if err != nil || resp.IsError() || gjson.Get(resp.String(), "code").Int() != 200 {
|
|
panic(exception.New("点赞失败 " + artName[i] + cast.ToString(resp.String())))
|
|
}
|
|
resp, err = disClient.R().
|
|
SetHeaders(map[string]string{
|
|
"Content-type": "application/json;charset=UTF-8",
|
|
"Ut": cast.ToString(configkit.Get("ut", "")),
|
|
"Wid": cast.ToString(configkit.Get("wid", "")),
|
|
"Pid": cast.ToString(configkit.Get("pid", "")),
|
|
"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36",
|
|
}).SetQueryParams(map[string]string{
|
|
"articleid": v,
|
|
"status": "1",
|
|
"href": "/modules/news/newsdetail.html?id=" + v,
|
|
"title": artName[i],
|
|
"_": cast.ToString(time.Now().UnixNano() / int64(time.Millisecond)),
|
|
}).Get("http://aiportal.unicom.local/pcm/collect/v1/collect")
|
|
if err != nil || resp.IsError() || gjson.Get(resp.String(), "code").Int() != 200 {
|
|
panic(exception.New("收藏失败 " + artName[i] + cast.ToString(resp.String())))
|
|
}
|
|
logkit.Info("点赞收藏成功 " + artName[i])
|
|
time.Sleep(1 * time.Second)
|
|
})
|
|
}
|
|
}
|
|
}
|