Browse Source

group: 牧场端配方数据同步

Yi 1 year ago
parent
commit
0f70ef4b48
5 changed files with 46 additions and 46 deletions
  1. 3 3
      conf/app-develop.ini
  2. 2 1
      http/handle/api/user.go
  3. 25 25
      models/feed_templet.go
  4. 8 4
      module/group.go
  5. 8 13
      service/group/group.go

+ 3 - 3
conf/app-develop.ini

@@ -41,9 +41,9 @@ Description = tmrgo
 [database]
 Type = mysql
 User = root
-Password = root
-Host = 192.168.1.93:3326
-Name = tmrwatch3
+Password = 123456
+Host = 192.168.1.70:3306
+Name = tmrwatch2
 TablePrefix =
 
 ShowXormlog = false

+ 2 - 1
http/handle/api/user.go

@@ -49,7 +49,7 @@ func Auth(c *gin.Context) {
 	valid := validation.Validation{}
 	valid.MaxSize(reqInfo.Username, 100, "username").Message("最长为100字符")
 	valid.MaxSize(reqInfo.Password, 100, "password").Message("最长为100字符")
-
+	fmt.Println("==========reqInfo===========", reqInfo)
 	if valid.HasErrors() {
 		app.MarkErrors(valid.Errors)
 		appG.Response(http.StatusInternalServerError, e.ERROR_ADD_FAIL, valid.Errors)
@@ -58,6 +58,7 @@ func Auth(c *gin.Context) {
 
 	authService := user_service.User{Username: reqInfo.Username, Password: reqInfo.Password}
 	isExist, err := authService.Check()
+	fmt.Println("==========Check===========", isExist, err)
 	if err != nil {
 		appG.Response(http.StatusInternalServerError, e.ERROR_AUTH_CHECK_TOKEN_FAIL, err)
 		return

+ 25 - 25
models/feed_templet.go

@@ -1,31 +1,31 @@
 package models
 
 type FeedTemplate struct {
-	Id           int64   `xorm:"id"`
-	PastureId    int64   `xorm:"pastureid"`
-	TCode        string  `xorm:"tcode"`
-	TName        string  `xorm:"tname"`
-	TColor       string  `xorm:"tcolor"`
-	CCid         int64   `xorm:"ccid"`
-	CCName       string  `xorm:"ccname"`
-	FTType       string  `xorm:"fttype"`
-	FTTypeId     int32   `xorm:"fttypeid"`
-	Source       string  `xorm:"source"`
-	Remark       string  `xorm:"remark"`
-	Enable       int32   `xorm:"enable"`
-	Sort         int64   `xorm:"sort"`
-	Owner        string  `xorm:"owner"`
-	Weight       float64 `xorm:"weight"`
-	DryWeight    float64 `xorm:"dryweight"`
-	IsDelete     int32   `xorm:"isdelete"`
-	Version      int64   `xorm:"version"`
-	SaveTime     string  `xorm:"savetime"`
-	IsIssue      int32   `xorm:"isissue"`
-	IssueVersion int32   `xorm:"issueversion"`
-	IssueId      int64   `xorm:"issueid"`
-	Backup1      string  `xorm:"backup1"`
-	Backup2      string  `xorm:"backup2"`
-	IsModify     int32   `xorm:"is_modify"`
+	Id           int64   `xorm:"id" json:"id"`
+	PastureId    int64   `xorm:"pastureid" json:"pasture_id"`
+	TCode        string  `xorm:"tcode" json:"t_code"`
+	TName        string  `xorm:"tname" json:"t_name"`
+	TColor       string  `xorm:"tcolor" json:"t_color"`
+	CCid         int64   `xorm:"ccid" json:"c_cid"`
+	CCName       string  `xorm:"ccname" json:"cc_name"`
+	FTType       string  `xorm:"fttype" json:"ft_type"`
+	FTTypeId     int32   `xorm:"fttypeid" json:"ft_type_id"`
+	Source       string  `xorm:"source" json:"source"`
+	Remark       string  `xorm:"remark" json:"remark"`
+	Enable       int32   `xorm:"enable" json:"enable"`
+	Sort         int64   `xorm:"sort" json:"sort"`
+	Owner        string  `xorm:"owner" json:"owner"`
+	Weight       float64 `xorm:"weight" json:"weight"`
+	DryWeight    float64 `xorm:"dryweight" json:"dry_weight"`
+	IsDelete     int32   `xorm:"isdelete" json:"is_delete"`
+	Version      int64   `xorm:"version" json:"version"`
+	SaveTime     string  `xorm:"savetime" json:"save_time"`
+	IsIssue      int32   `xorm:"isissue" json:"is_issue"`
+	IssueVersion int32   `xorm:"issueversion" json:"issue_version"`
+	IssueId      int64   `xorm:"issueid" json:"issue_id"`
+	Backup1      string  `xorm:"backup1" json:"backup1"`
+	Backup2      string  `xorm:"backup2" json:"backup2"`
+	IsModify     int32   `xorm:"is_modify" json:"is_modify"`
 }
 
 func (f *FeedTemplate) TableName() string {

+ 8 - 4
module/group.go

@@ -343,13 +343,17 @@ func FeedTemplateList(req *models.FeedFormulaListRequest) ([]*models.FeedTemplat
 		total int64
 		err   error
 	)
-
-	total, err = restful.Engine.Table(new(models.FeedTemplate).TableName()).
-		Where("pastureid = ?", req.PastureId).
-		Limit(int(req.PageSize), int(req.Page-1)*int(req.PageSize)).Count(&res)
+	newSession := restful.Engine.NewSession()
+	total, err = newSession.Table(new(models.FeedTemplate).TableName()).
+		Where("pastureid = ?", req.PastureId).Count(&res)
 	if err != nil {
 		return nil, 0, err
 	}
+
+	if err = newSession.Table(new(models.FeedTemplate).TableName()).Limit(int(req.PageSize), int(req.Page-1)*int(req.PageSize)).Find(&res); err != nil {
+		return nil, 0, err
+	}
+
 	return res, total, nil
 }
 

+ 8 - 13
service/group/group.go

@@ -2,7 +2,6 @@ package group
 
 import (
 	"fmt"
-	"net/http"
 	"sort"
 	"time"
 	"tmr-watch/models"
@@ -45,24 +44,20 @@ func FeedFormulaIsModifyService(req *models.PastureFeedFormulaIsModifyRequest) e
 	return module.FeedFormulaIsModify(req)
 }
 
-func FeedFormulaList(req *models.FeedFormulaListRequest) (*models.FeedFormulaListResponse, error) {
-	res := &models.FeedFormulaListResponse{
-		Code: http.StatusOK,
-		Msg:  "ok",
-		Data: &models.FeedFormulaData{
-			Total:    0,
-			Page:     req.Page,
-			PageSize: req.PageSize,
-			List:     make([]*models.FeedTemplate, 0),
-		},
+func FeedFormulaList(req *models.FeedFormulaListRequest) (*models.FeedFormulaData, error) {
+	res := &models.FeedFormulaData{
+		Total:    0,
+		Page:     req.Page,
+		PageSize: req.PageSize,
+		List:     make([]*models.FeedTemplate, 0),
 	}
 
 	dataList, total, err := module.FeedTemplateList(req)
 	if err != nil {
 		return nil, err
 	}
-	res.Data.Total = int32(total)
-	res.Data.List = dataList
+	res.Total = int32(total)
+	res.List = dataList
 	return res, nil
 }