12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- package entity
- import (
- "strings"
- . "app.yhyue.com/moapp/jybase/common"
- . "bp.jydev.jianyu360.cn/BaseService/resourceCenter/rpc/internal/db"
- )
- var Base_goods_function = base_goods_function{}
- //商品功能表
- type base_goods_function struct {
- Id int64
- Appid string
- Goods_code string //商品代码
- Function_code string //功能代码
- Limit_strategy string //限制频率;1d:1天 1m:1个月
- Strategy_count int64 //频率数量
- Power_type int64 //权益所属类型;1:个人 2:企业
- Use_count int64 //使用数量
- Power_count int64 //授权数量;-1:默认对企业下所有人授权 0:不授权
- Base_function *base_function
- }
- //根据商品代码查找商品的功能明细
- func (b *base_goods_function) FindByGoodsCode(appid, goods_code string) *[]*base_goods_function {
- list := Mysql_BaseService.SelectBySql(`select a.id as a_id,a.appid as a_appid,a.goods_code as a_goods_code,a.function_code as a_function_code,a.limit_strategy as a_limit_strategy,a.strategy_count as a_strategy_count,a.power_type as a_power_type,a.use_count as a_use_count,a.power_count as a_power_count,
- b.id as b_id,b.appid as b_appid,b.name as b_name,b.code as b_code,b.status as b_status,b.haspower as b_haspower,b.version as b_version,b.power_rule as b_power_rule,b.power_type as b_power_type
- from base_goods_function a inner join base_function b on (a.appid=? and a.goods_code=? and b.appid=? and a.function_code=b.code)`, appid, goods_code, appid)
- l := []*base_goods_function{}
- if list != nil {
- for _, v := range *list {
- a, b := map[string]interface{}{}, map[string]interface{}{}
- for kk, vv := range v {
- if strings.HasPrefix(kk, "a_") {
- a[strings.TrimPrefix(kk, "a_")] = vv
- } else if strings.HasPrefix(kk, "b_") {
- b[strings.TrimPrefix(kk, "b_")] = vv
- }
- }
- aa := JsonUnmarshal(a, &base_goods_function{}).(*base_goods_function)
- bb := JsonUnmarshal(b, &base_function{}).(*base_function)
- aa.Base_function = bb
- l = append(l, aa)
- }
- }
- return &l
- }
|