123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165 |
- package v1
- import (
- "encoding/json"
- "sfbase/global"
- "sfis/middleware"
- "sfis/model/response"
- "sfis/service"
- "sfis/utils"
- "github.com/gin-gonic/gin"
- "go.uber.org/zap"
- )
- /**
- 项目相关接口服务
- */
- func ProjectApiRegister(router *gin.Engine) {
- routerGroup := router.Group("/sfis/api/v1/")
- routerGroup.Use(middleware.TokenAuth())
- {
- routerGroup.POST("/projectList", getProjectsList)
- routerGroup.POST("/projectDetail", getProjectDetail)
- routerGroup.POST("/projectListDetail", getProjectsListDetail)
- routerGroup.POST("/callLog", callLog)
- routerGroup.POST("/biddingInfoList", biddingInfoList)
- routerGroup.POST("/healthInfoList", healthInfoList)
- routerGroup.POST("/healthinfo", healthinfo)
- }
- }
- //获取项目列表接口
- func getProjectsList(c *gin.Context) {
- productID := c.MustGet("productID").(int)
- appID := c.MustGet("appID").(string)
- requestIP := c.MustGet("requestIP").(string)
- projectName := c.PostForm("project_name")
- winner := c.PostForm("winner")
- bidTime := c.PostForm("bid_time")
- p := gin.H{
- "projectName": projectName,
- "winner": winner,
- "bidTime": bidTime,
- }
- bs, _ := json.Marshal(p)
- param := string(bs)
- global.Logger.Info("api getProjectList:", zap.Any("productID:", productID), zap.Any("appID", appID), zap.Any("param:", param))
- if projectName != "" || winner != "" {
- utils.Check(appID, productID, c, func() ([]map[string]interface{}, int, error) {
- return service.ProjectListData(productID, appID, projectName, winner, bidTime, false)
- }, param, requestIP, false)
- } else {
- response.FailWithDetailed(response.ParamError, nil, "参数错误", c)
- }
- }
- //获取项目列表及详情接口
- func getProjectsListDetail(c *gin.Context) {
- productID := c.MustGet("productID").(int)
- appID := c.MustGet("appID").(string)
- requestIP := c.MustGet("requestIP").(string)
- winner := c.PostForm("winner")
- p := gin.H{
- "winner": winner,
- }
- bs, _ := json.Marshal(p)
- param := string(bs)
- global.Logger.Info("api getProjectList:", zap.Any("productID:", productID), zap.Any("appID", appID), zap.Any("param:", param))
- if winner != "" {
- utils.Check(appID, productID, c, func() ([]map[string]interface{}, int, error) {
- return service.ProjectListData(productID, appID, "", winner, "", true)
- }, param, requestIP, false)
- }
- }
- //获取项目详情
- func getProjectDetail(c *gin.Context) {
- productID := c.MustGet("productID").(int)
- appID := c.MustGet("appID").(string)
- requestIP := c.MustGet("requestIP").(string)
- _id := c.PostForm("project_id")
- id := service.SE.DecodeString(_id)
- p := gin.H{
- "id": id,
- }
- bs, _ := json.Marshal(p)
- param := string(bs)
- global.Logger.Info("api getProjectDetail:", zap.Any("productID:", productID), zap.Any("appID", appID), zap.Any("param:", param))
- if id != "" {
- utils.Check(appID, productID, c, func() ([]map[string]interface{}, int, error) {
- return service.ProjectDetailData(id)
- }, param, requestIP, false)
- }
- }
- //调用日志
- func callLog(c *gin.Context) {
- appID := c.PostForm("app_id")
- productId := c.PostForm("product_id")
- startTime := c.PostForm("start_time")
- endTime := c.PostForm("end_time")
- isSelf := c.PostForm("isSelf")
- isSelfs := false
- if isSelf != "" {
- isSelfs = true
- }
- datas := []map[string]interface{}{}
- var err error
- p := gin.H{
- "appID": appID,
- "startTime": startTime,
- "endTime": endTime,
- "productId": productId,
- "isSelf": isSelf,
- }
- global.Logger.Info("api callLog:", zap.Any("param:", p))
- datas, err = service.CallLog(appID, productId, startTime, endTime, isSelfs)
- if err == nil {
- response.FailWithDetailed(response.SUCCESS, datas, "", c)
- } else {
- response.FailWithDetailed(response.QueryError, datas, "系统查询异常", c)
- }
- }
- func biddingInfoList(c *gin.Context) {
- productID := c.MustGet("productID").(int)
- appID := c.MustGet("appID").(string)
- requestIP := c.MustGet("requestIP").(string)
- p := gin.H{
- }
- bs, _ := json.Marshal(p)
- param := string(bs)
- utils.Check(appID, productID, c, func() ([]map[string]interface{}, int, error) {
- return []map[string]interface{}{}, 200, nil
- }, param, requestIP, false)
- }
- func healthInfoList(c *gin.Context) {
- productID := c.MustGet("productID").(int)
- appID := c.MustGet("appID").(string)
- requestIP := c.MustGet("requestIP").(string)
- p := gin.H{
- }
- bs, _ := json.Marshal(p)
- param := string(bs)
- utils.Check(appID, productID, c, func() ([]map[string]interface{}, int, error) {
- return []map[string]interface{}{}, 200, nil
- }, param, requestIP, false)
- }
- func healthinfo(c *gin.Context) {
- productID := c.MustGet("productID").(int)
- appID := c.MustGet("appID").(string)
- requestIP := c.MustGet("requestIP").(string)
- p := gin.H{
- }
- bs, _ := json.Marshal(p)
- param := string(bs)
- utils.Check(appID, productID, c, func() ([]map[string]interface{}, int, error) {
- return []map[string]interface{}{}, 200, nil
- }, param, requestIP, false)
- }
|