| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- package settle_account_bill
- import (
- "fmt"
- "github.com/gogf/gf/util/gconv"
- "lims_adapter/dao/account"
- "lims_adapter/model"
- accountModel "lims_adapter/model/account"
- )
- // Service 会议室服务
- type Service struct {
- Dao *account.SettleAccountBillDao
- Tenant string
- }
- // NewSrv 服务初始化
- func NewService(tenant string) Service {
- return Service{Dao: account.NewSettleAccountBillDao(tenant), Tenant: tenant}
- }
- // List 会议室列表
- func (s Service) List(req model.ListReq) ([]accountModel.SettleAccountBill, int, error) {
- entityModel := s.Dao.M
- where := "1=1"
- if req.Entity != nil {
- entity := new(accountModel.SettleAccountBillReq)
- err := gconv.Struct(req.Entity, entity)
- if err != nil {
- return nil, 0, err
- }
- if entity.MainUserId != 0 {
- where += fmt.Sprintf(" AND MainUserId='%v'", entity.MainUserId)
- }
- if entity.Status != "" {
- where += fmt.Sprintf(" AND Status='%v'", entity.Status)
- }
- }
- entityModel = entityModel.Where(where)
- total, err := entityModel.Count()
- if err != nil {
- return nil, 0, err
- }
- if total == 0 {
- return nil, 0, nil
- }
- res, err := entityModel.Page(req.Current, req.Size).Order("settle_account_bill.CreateOn DESC").Fields("settle_account_bill.*").FindAll()
- if err != nil {
- return nil, 0, err
- }
- if res.IsEmpty() {
- return nil, 0, nil
- }
- list := make([]accountModel.SettleAccountBill, 0)
- err = res.Structs(&list)
- if err != nil {
- return nil, 0, err
- }
- return list, total, nil
- }
|