12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- package bodychecklist
-
- import (
- "spaceofcheng/services/models"
- "spaceofcheng/services/models/model"
- "spaceofcheng/services/utils"
- "strconv"
-
- "github.com/go-xorm/xorm"
- )
-
- // BodychecklistDAO 当前数据库操作对象
- type BodychecklistDAO struct {
- ctx *utils.Context
- db *xorm.Session
- }
-
- // NewBodychecklistDAO New Inst
- func NewBodychecklistDAO(ctx *utils.Context) *BodychecklistDAO {
- return &BodychecklistDAO{
- ctx: ctx,
- db: ctx.DB,
- }
- }
-
- type BodyCheck struct {
- model.TaBodyCheck `xorm:"extends"`
- CaseName string
- Sex string
- CustomerName string
- Phone string
- }
-
- func (m *BodychecklistDAO) GetBodychecklist(phone, customerName, filters string, limit []int) ([]BodyCheck, int64, error) {
- var bodycheck []BodyCheck
- // if len(filters) > 0 {
- // filterString = strings.Join(filters, " and ")
- // filterString += " and "
- // }
- sql := `SELECT
- a.*,
- b.phone,
- b.customer_name,
- c.case_name,
- CASE
- b.sex
- WHEN 1 THEN
- '男' ELSE '女'
- END AS sex
- FROM
- ta_body_check a
- INNER JOIN ta_customer b ON a.user_id = b.customer_id
- INNER JOIN sys_case c ON c.case_id = a.case_id
- where ` + filters + ` and a.status > ` + strconv.Itoa(models.STATUS_DEL)
- if phone != "" {
- sql += ` and b.phone = '` + phone + `'`
- }
- if customerName != "" {
- sql += ` and b.customer_name like '%` + customerName + `%'`
- }
- sql += ` order by a.create_date desc`
- total, err := utils.NewPageNaviEngine(m.ctx).GetPageList(&bodycheck, sql, limit)
- if err != nil {
- return nil, 0, err
- }
- return bodycheck, total, err
- }
|