12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- package query
- import (
- "context"
- jsoniter "github.com/json-iterator/go"
- "gd_adm_data/apis"
- "gd_adm_data/errors"
- "gd_adm_data/model"
- "git.getensh.com/common/gopkgsv2/database"
- )
- type p09Reqeust struct {
- StyleId string `json:"style_id"`
- }
- type p09Config struct {
- Useage string `json:"useage"`
- Detail string `json:"detail"`
- AttributeRule string `json:"attribute_rule"`
- }
- type p09Data struct {
- Config p09Config `json:"config"`
- C2Name string `json:"c2_name"`
- C2Id int64 `json:"c2_id"`
- }
- type p09Response struct {
- List []p09Data `json:"list"`
- }
- func P09(ctx context.Context, params string) (reply *apis.QueryResponse, err error) {
- reply = &apis.QueryResponse{}
- var req p09Reqeust
- err = jsoniter.UnmarshalFromString(params, &req)
- if err != nil && req.StyleId == "" {
- return nil, errors.ParamsError
- }
- list, err := model.NewAds14Model().List(database.DB().Where("style_id = ?", req.StyleId))
- if err != nil {
- return reply, errors.DataNotExistError
- }
- res := p09Response{
- List: make([]p09Data, 0, len(list)),
- }
- for _, v := range list {
- res.List = append(res.List, p09Data{
- C2Name: v.C2Name,
- C2Id: v.C2Id,
- Config: p09Config{
- Useage: v.Useage,
- Detail: v.Detail,
- AttributeRule: v.AttributeRule,
- },
- })
- }
- reply.Data, _ = jsoniter.MarshalToString(res)
- return reply, nil
- }
|