12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- package logic
- import (
- "app.yhyue.com/moapp/jybase/common"
- "app.yhyue.com/moapp/jybase/encrypt"
- T "bp.jydev.jianyu360.cn/CRM/application/api/common"
- "context"
- "fmt"
- "bp.jydev.jianyu360.cn/CRM/application/api/internal/svc"
- "bp.jydev.jianyu360.cn/CRM/application/api/internal/types"
- "github.com/zeromicro/go-zero/core/logx"
- )
- type InfoDetailLogic struct {
- logx.Logger
- ctx context.Context
- svcCtx *svc.ServiceContext
- }
- func NewInfoDetailLogic(ctx context.Context, svcCtx *svc.ServiceContext) *InfoDetailLogic {
- return &InfoDetailLogic{
- Logger: logx.WithContext(ctx),
- ctx: ctx,
- svcCtx: svcCtx,
- }
- }
- type Infomation struct {
- Title string `ch:"title"`
- Summary string `ch:"summary"`
- Content string `ch:"content"`
- Basis string `ch:"basis"`
- Area string `ch:"area"`
- City string `ch:"city"`
- DataJsonId string `ch:"datajson_id"`
- ProjectName string `json:"project_name"`
- Href string `json:"href"`
- IsIgnore int `json:"isIgnore"`
- IsCreate int `json:"isCreate"`
- }
- func (l *InfoDetailLogic) InfoDetail(req *types.InfoDetailReq) (resp *types.Reply, err error) {
- logx.Info(fmt.Sprintf("%+v", req))
- resp = &types.Reply{}
- sql := `SELECT title, summary, content, basis, area, city, datajson_id FROM information.information WHERE id = ?`
- info := Infomation{}
- row := T.ClickhouseConn.QueryRow(context.TODO(), sql, req.InfoId)
- err1 := row.ScanStruct(&info)
- if err1 == nil {
- info.DataJsonId = encrypt.EncodeArticleId2ByCheck(info.DataJsonId)
- binfo, b := T.MgoBidding.FindById("bidding", info.DataJsonId, map[string]interface{}{"title": 1, "projectname": 1})
- if b && binfo != nil && len(*binfo) > 0 {
- info.ProjectName = common.ObjToString((*binfo)["projectname"])
- info.Href = fmt.Sprintf("/article/content/%s.html", encrypt.EncodeArticleId2ByCheck(info.DataJsonId))
- }
- q1 := `SELECT relate_id, is_ignore, is_create FROM crm.connection_status WHERE position_id = ? AND relate_id = ? AND itype = 2`
- cinfo := T.CrmMysql.SelectBySql(q1, req.PositionId, req.InfoId)
- if cinfo != nil && len(*cinfo) > 0 {
- info.IsIgnore = common.IntAll((*cinfo)[0]["is_ignore"])
- info.IsCreate = common.IntAll((*cinfo)[0]["is_create"])
- }
- resp.Data = info
- } else {
- resp.Error_code = -1
- resp.Error_msg = "未查询到情报信息"
- }
- return
- }
|