Ver código fonte

修改程序结构

Simon Zhou 5 anos atrás
pai
commit
6de5acd57d
1 arquivos alterados com 0 adições e 124 exclusões
  1. 0 124
      account/account.go

+ 0 - 124
account/account.go

@@ -1,124 +0,0 @@
-package account
-
-import (
-	"time"
-
-	"mtp2_if/db"
-	"mtp2_if/token"
-	"net/http"
-
-	"github.com/gin-gonic/gin"
-)
-
-// AccountQueryReq 账户查询请求
-type AccountQueryReq struct {
-	Token     string `json:"token" binding:"required"`
-	AccountID int    `json:"accountid" binding:"required"`
-}
-
-// AccountQueryRsp 账户查询响应
-type AccountQueryRsp struct {
-	Accountid  int       `json:"accountid" binding:"required"`
-	Userid     int       `json:"userid" binding:"required"`
-	Currencyid int       `json:"currencyid" binding:"required"`
-	Changeflag int       `json:"changeflag" binding:"required"`
-	Changetime time.Time `json:"changetime" binding:"required"`
-}
-
-// Taaccount 账户表结构定义
-type Taaccount struct {
-	Accountid  int       `json:"accountid" xorm:"'ACCOUNTID'" binding:"required"`
-	Userid     int       `json:"userid" xorm:"'USERID'"  binding:"required"`
-	Currencyid int       `json:"currencyid" xorm:"'CURRENCYID'"  binding:"required"`
-	Changeflag int       `json:"changeflag" xorm:"'CHANGEFLAG'"  binding:"required"`
-	Changetime time.Time `json:"changetime" xorm:"'CHANGETIME'"  binding:"required"`
-}
-
-// Reckondaytaaccount 账户结算日照表结构定义
-type Reckondaytaaccount struct {
-	Accountid  int    `json:"accountid" xorm:"'ACCOUNTID'" binding:"required"`
-	Userid     int    `json:"userid" xorm:"'USERID'"  binding:"required"`
-	Currencyid int    `json:"currencyid" xorm:"'CURRENCYID'"  binding:"required"`
-	Changeflag int    `json:"changeflag" xorm:"'CHANGEFLAG'"  binding:"required"`
-	Reckondate string `json:"reckondate" xorm:"'RECKONDATE'"  binding:"required"`
-}
-
-// TableName 返回表名接口
-func (Taaccount) TableName() string {
-	return "TAACCOUNT"
-}
-
-// TableName 返回表名接口
-func (Reckondaytaaccount) TableName() string {
-	return "RECKON_DAYTAACCOUNT"
-}
-
-// GetAccount 获取账户接口
-func GetAccount(c *gin.Context) {
-	var account AccountQueryReq
-	err := c.ShouldBind(&account)
-	if err != nil {
-		c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
-	}
-
-	var ok bool
-	ok, err = token.CheckToken(account.AccountID, account.Token)
-	if err != nil || !ok {
-		c.JSON(http.StatusBadRequest, gin.H{"token check failed": err.Error()})
-		return
-	}
-
-	engine := db.GetEngine()
-
-	accountinfo := new(Taaccount)
-	has, err := engine.Where("accountid=?", account.AccountID).Get(accountinfo)
-	if err != nil {
-		c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
-		return
-	}
-
-	if !has {
-		c.JSON(http.StatusBadRequest, gin.H{"error": "not find"})
-		return
-	}
-
-	ret := AccountQueryRsp{
-		Accountid:  accountinfo.Accountid,
-		Userid:     accountinfo.Userid,
-		Currencyid: accountinfo.Currencyid,
-		Changeflag: accountinfo.Changeflag,
-		Changetime: accountinfo.Changetime,
-	}
-	c.SecureJSON(http.StatusOK, ret)
-}
-
-// GetReckonAccount 获取日照账户接口
-func GetReckonAccount(c *gin.Context) {
-	var account AccountQueryReq
-	err := c.ShouldBind(&account)
-	if err != nil {
-		c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
-	}
-
-	engine := db.GetEngine()
-
-	accountinfo := new(Reckondaytaaccount)
-	has, err := engine.Where("accountid=?", account.AccountID).And("reckondate=?", "20200314").Get(accountinfo)
-	if err != nil {
-		c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
-		return
-	}
-
-	if !has {
-		c.JSON(http.StatusBadRequest, gin.H{"error": "not find"})
-		return
-	}
-
-	ret := AccountQueryRsp{
-		Accountid:  accountinfo.Accountid,
-		Userid:     accountinfo.Userid,
-		Currencyid: accountinfo.Currencyid,
-		Changeflag: accountinfo.Changeflag,
-	}
-	c.SecureJSON(http.StatusOK, ret)
-}