12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- package final
- import (
- "fmt"
- "strings"
- "zhiyuan/pkg/db"
- "github.com/gin-gonic/gin"
- )
- type FinalMatItem struct {
- ID int64 `json:"id" prop:"add:false"`
- Name string `json:"name" label:"项目名称" type:"string" prop:"add edit" search:"like"`
- Type int64 `json:"type" label:"类型" type:"int" prop:"add edit" search:"="`
- TypeId int64 `json:"type_id" label:"辅材类型" type:"int" prop:"edit" search:"="`
- PType int64 `json:"ptype" label:"类型" type:"int" prop:"edit" search:"="`
- MatTypeIds string `json:"mattype_ids" label:"选材类型" type:"string" prop:"add edit"`
- OrderAt int64 `json:"order_at" prop:"add:false select:false"`
- DeletedAt int64 `json:"deleted_at" prop:"add:false select:false"`
- CreatedAt int64 `json:"created_at" prop:"add:false"`
- UpdatedAt int64 `json:"updated_at" prop:"add:false"`
- db.BaseModel
- }
- func (FinalMatItem) TableName() string {
- return "zy_final_mat_item"
- }
- func (model FinalMatItem) ListPrivilege(c *gin.Context, data map[string]interface{}, s *db.Select) bool {
- if mattype_id, ok := data["mattype_id"]; ok {
- mattype_id, _ = db.ToInt64(mattype_id)
- var mattype FinalMatType
- db.GetModel(map[string]interface{}{
- "id": mattype_id,
- }, &mattype)
- where := "1=2"
- where += fmt.Sprintf(" OR find_in_set(%s, `%s`.`mattype_ids`)", s.Param(mattype.ID), model.TableName())
- for _, v := range strings.Split(mattype.Path, ",") {
- if v != "" {
- i, _ := db.ToInt64(v)
- where += fmt.Sprintf(" OR find_in_set(%s, `%s`.`mattype_ids`)", s.Param(i), model.TableName())
- }
- }
- s.Where = append(s.Where, where)
- }
- return true
- }
- func (FinalMatItem) OnePrivilege(c *gin.Context, id int64) bool {
- return true
- }
- func (FinalMatItem) AddPrivilege(c *gin.Context, data map[string]interface{}, post map[string]interface{}) error {
- return nil
- }
- func (FinalMatItem) EditPrivilege(c *gin.Context, id int64, data map[string]interface{}, post map[string]interface{}) error {
- return nil
- }
- func (FinalMatItem) DelPrivilege(c *gin.Context, id int64) error {
- return nil
- }
- func (FinalMatItem) OrderField() string {
- return "order_at"
- }
- func (FinalMatItem) Page() bool {
- return false
- }
- func (FinalMatItem) Count() bool {
- return true
- }
- func (model FinalMatItem) LeftJoin(data map[string]interface{}, s *db.Select) []db.JoinModel {
- return []db.JoinModel{}
- }
|