123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- package calc
- import (
- "errors"
- "zhiyuan/pkg/db"
- "github.com/gin-gonic/gin"
- )
- type Product struct {
- ID int64 `json:"id" prop:"add:false"`
- TypeId int64 `json:"typeId" type:"int" prop:"add" search:"="`
- Name string `json:"name" label:"产品名称" type:"string" prop:"add edit" search:"like"`
- Cover string `json:"cover" label:"产品图片" type:"string" prop:"edit"`
- Spec string `json:"spec" label:"规格" type:"string" prop:"edit"`
- Property string `json:"property" label:"属性" type:"string" prop:"edit"`
- Details string `json:"details" label:"产品详情" type:"string" prop:"edit"`
- DeletedAt int64 `json:"deleted_at" prop:"add:false select:false"`
- CreatedAt int64 `json:"created_at" prop:"add:false select:false"`
- UpdatedAt int64 `json:"updated_at" prop:"add:false select:false"`
- db.BaseModel
- }
- func (Product) TableName() string {
- return "zy_product"
- }
- func (Product) ListPrivilege(c *gin.Context, data map[string]interface{}, s *db.Select) bool {
- return true
- }
- func (Product) OnePrivilege(c *gin.Context, id int64) bool {
- return true
- }
- func (Product) AddPrivilege(c *gin.Context, data map[string]interface{}, post map[string]interface{}) error {
- if data["typeId"] != nil && data["typeId"].(int64) != 0 {
- var p ProductType
- db.GetModel(map[string]interface{}{
- "id": data["typeId"].(int64),
- }, &p)
- if p.ID == 0 {
- return errors.New("没有权限")
- }
- }
- return nil
- }
- func (Product) EditPrivilege(c *gin.Context, id int64, data map[string]interface{}, post map[string]interface{}) error {
- return nil
- }
- func (Product) DelPrivilege(c *gin.Context, id int64) error {
- return nil
- }
- func (Product) Page() bool {
- return true
- }
- func (Product) Count() bool {
- return true
- }
|