123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- package frontm
- import ("github.com/astaxie/beego/orm"
- "wuyebaoxiuapi/models")
- type RepairUserPicture struct {
- Id int
- UserId int
- PictureId int
- RepairId int
- Types int
- }
- func NewRepairUserPicture()(*RepairUserPicture) {
- return new(RepairUserPicture)
- }
- func (a *RepairUserPicture) TableName() string {
- return models.TableName("repair_user_picture")
- }
- func (a *RepairUserPicture)Add()(int64, error) {
- return orm.NewOrm().Insert(a)
- }
- func (a *RepairUserPicture)DeleteByPictureId(pictureId int) (int64, error) {
- query := orm.NewOrm().QueryTable(models.TableName("repair_user_picture"))
- return query.Filter("picture_id", pictureId).Delete()
- }
- type OutPicture struct {
- Path string
- }
- // 查找维修图片
- func (a *RepairUserPicture)FindPictureByUserIdAndReparId(userid int,repairId int)([]string) {
- o := orm.NewOrm()
- outPictures := make([]*OutPicture,0)
- var err error
- where := " pr.user_id = ? and pr.repair_id = ? and pr.types = 1 "
- _,err = o.Raw("SELECT pp.path as path" +
- " FROM pp_repair_user_picture pr left join pp_picture pp on pr.picture_id = pp.id WHERE"+where,userid,repairId).QueryRows(&outPictures)
- if err != nil {
- return nil
- }
- images := make([]string,0)
- for _, v := range outPictures {
- images = append(images,v.Path)
- }
- return images
- }
- func init() {
- orm.RegisterModel(new(RepairUserPicture))
- }
|