12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- package storehouse
- import (
- "github.com/gin-gonic/gin"
- "server/dao"
- "server/global"
- "server/model/common/request"
- "server/model/common/response"
- )
- type SupplierApi struct{}
- func (sa *SupplierApi) QueryAllSupplier(c *gin.Context) {
- suppliers, err := supplierService.QueryAllSupplier()
- if err != nil {
- response.FailWithMessage("查询失败", c)
- global.GVA_LOG.Error("QueryAllSupplier ====== " + err.Error())
- return
- }
- response.OkWithData(suppliers, c)
- }
- func (sa *SupplierApi) QuerySupplierList(c *gin.Context) {
- var info request.SearchSupplierList
- err := c.ShouldBindJSON(&info)
- if err != nil {
- response.FailWithMessage("参数解析失败", c)
- global.GVA_LOG.Error("QuerySupplierList ====== " + err.Error())
- return
- }
- list, total, err := supplierService.QuerySupplierList(info)
- if err != nil {
- response.FailWithMessage("查询失败", c)
- global.GVA_LOG.Error("QuerySupplierList ====== " + err.Error())
- return
- }
- response.OkWithDetailed(response.PageResult{
- List: list,
- Total: total,
- Page: info.PageInfo.Page,
- PageSize: info.PageInfo.PageSize,
- }, "获取成功", c)
- }
- func (sa *SupplierApi) CreateSupplier(c *gin.Context) {
- var supplier dao.Supplier
- err := c.ShouldBindJSON(&supplier)
- if err != nil {
- response.FailWithMessage("参数解析失败", c)
- global.GVA_LOG.Error("CreateSupplier ====== " + err.Error())
- return
- }
- err = supplierService.CreateSupplier(supplier)
- if err != nil {
- response.FailWithMessage("创建失败", c)
- global.GVA_LOG.Error("CreateSupplier ====== " + err.Error())
- return
- }
- response.OkWithMessage("创建成功", c)
- }
- func (sa *SupplierApi) UpdateSupplier(c *gin.Context) {
- var supplier dao.Supplier
- err := c.ShouldBindJSON(&supplier)
- if err != nil {
- response.FailWithMessage("参数解析失败", c)
- global.GVA_LOG.Error("UpdateSupplier ====== " + err.Error())
- return
- }
- err = supplierService.UpdateSupplier(supplier)
- if err != nil {
- response.FailWithMessage("更新失败", c)
- global.GVA_LOG.Error("UpdateSupplier ====== " + err.Error())
- return
- }
- response.OkWithMessage("更新成功", c)
- }
- func (sa *SupplierApi) DeleteSupplier(c *gin.Context) {
- var supplier dao.Supplier
- err := c.ShouldBindJSON(&supplier)
- if err != nil {
- response.FailWithMessage("参数解析失败", c)
- global.GVA_LOG.Error("DeleteSupplier ====== " + err.Error())
- return
- }
- err = supplierService.DeleteSupplier(supplier)
- if err != nil {
- response.FailWithMessage("删除失败", c)
- global.GVA_LOG.Error("DeleteSupplier ====== " + err.Error())
- return
- }
- response.OkWithMessage("删除成功", c)
- }
|