12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- package plan
- import (
- "fmt"
- "zhiyuan/pkg/db"
- "github.com/gin-gonic/gin"
- )
- type PlanFinish struct {
- ID int64 `json:"id" prop:"add:false"`
- AdminId int64 `json:"adminId" label:"人员ID" type:"int" prop:"add:false" search:"="`
- Time int64 `json:"time" label:"时间" type:"int" prop:"add" search:"="`
- BuildingId int64 `json:"buildingId" label:"楼盘ID" type:"int" prop:"add" search:"="`
- TypeId int64 `json:"typeId" label:"类型ID" type:"int" prop:"add" search:"="`
- Num int64 `json:"num" label:"数量" type:"int" prop:"add edit"`
- TypeName string `json:"type_name" prop:"add:false select:plantype.name"`
- BuildingName string `json:"building_name" prop:"add:false select:building.name"`
- 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 (PlanFinish) TableName() string {
- return "zy_plan_finish"
- }
- func (model PlanFinish) ListPrivilege(c *gin.Context, data map[string]interface{}, s *db.Select) bool {
- if _, ok := data["starttime"]; ok {
- if starttime, ok := db.ToInt64(data["starttime"]); ok {
- s.Where = append(s.Where, fmt.Sprintf("(%s >= %s)", fmt.Sprintf("`%s`.`time`", model.TableName()), s.Param(starttime)))
- }
- }
- if _, ok := data["endtime"]; ok {
- if endtime, ok := db.ToInt64(data["endtime"]); ok {
- s.Where = append(s.Where, fmt.Sprintf("(%s <= %s)", fmt.Sprintf("`%s`.`time`", model.TableName()), s.Param(endtime)))
- }
- }
- s.Where = append(s.Where, fmt.Sprintf("(%s = %s)", fmt.Sprintf("`%s`.`adminId`", model.TableName()), s.Param(c.GetInt("adminID"))))
- return true
- }
- func (PlanFinish) OnePrivilege(c *gin.Context, id int64) bool {
- return true
- }
- func (PlanFinish) AddPrivilege(c *gin.Context, data map[string]interface{}, post map[string]interface{}) error {
- data["adminId"] = c.GetInt("adminID")
- return nil
- }
- func (PlanFinish) EditPrivilege(c *gin.Context, id int64, data map[string]interface{}, post map[string]interface{}) error {
- return nil
- }
- func (PlanFinish) DelPrivilege(c *gin.Context, id int64) error {
- return nil
- }
- func (PlanFinish) Page() bool {
- return false
- }
- func (PlanFinish) Count() bool {
- return true
- }
- func (model PlanFinish) LeftJoin(data map[string]interface{}, s *db.Select) []db.JoinModel {
- return []db.JoinModel{
- {
- Model: PlanType{},
- As: "plantype",
- On: []string{"`plantype`.`id` = " + model.TableName() + ".`typeId`"},
- },
- {
- Model: Building{},
- As: "building",
- On: []string{"`building`.`id` = " + model.TableName() + ".`buildingId`"},
- },
- }
- }
|