Ver Fonte

update:优化接口文档

zoie há 6 meses atrás
pai
commit
92ad6fba1b
43 ficheiros alterados com 594 adições e 1485 exclusões
  1. 2 11
      README.md
  2. 7 4
      app/admin/controller/address.go
  3. 0 195
      app/admin/controller/car.go
  4. 9 7
      app/admin/controller/company.go
  5. 15 12
      app/admin/controller/cooler_box.go
  6. 8 7
      app/admin/controller/customer.go
  7. 17 7
      app/admin/controller/device.go
  8. 3 3
      app/admin/controller/ice_locker.go
  9. 3 4
      app/admin/controller/ice_raft.go
  10. 4 59
      app/admin/controller/sys_user.go
  11. 0 195
      app/admin/controller/warehouse.go
  12. 54 35
      app/admin/controller/waybill.go
  13. 2 4
      app/admin/controller/waybill_logistics.go
  14. 15 5
      app/admin/controller/waybill_task.go
  15. 80 0
      app/admin/controller/weian.go
  16. 0 33
      app/admin/model/car.go
  17. 0 32
      app/admin/model/warehouse.go
  18. 57 0
      app/admin/model/weian.go
  19. 0 25
      app/admin/router/car.go
  20. 10 0
      app/admin/router/init_router.go
  21. 1 0
      app/admin/router/router.go
  22. 0 1
      app/admin/router/sys_user.go
  23. 0 26
      app/admin/router/warehouse.go
  24. 0 4
      app/admin/router/waybill.go
  25. 31 0
      app/admin/router/weian.go
  26. 0 281
      app/admin/service/car.go
  27. 1 14
      app/admin/service/customer.go
  28. 0 102
      app/admin/service/dto/car.go
  29. 1 1
      app/admin/service/dto/customer.go
  30. 1 1
      app/admin/service/dto/sys_user.go
  31. 0 107
      app/admin/service/dto/warehouse.go
  32. 1 0
      app/admin/service/dto/waybill.go
  33. 5 0
      app/admin/service/dto/weian.go
  34. 1 27
      app/admin/service/sys_user.go
  35. 0 278
      app/admin/service/warehouse.go
  36. 1 1
      common/actions/create.go
  37. 1 1
      common/actions/update.go
  38. 77 0
      common/middleware/openapi.go
  39. 4 0
      conf/extend.go
  40. 14 1
      conf/settings.yml
  41. 0 2
      db/migration.go
  42. 167 0
      openapi.md
  43. 2 0
      setting.yml

+ 2 - 11
README.md

@@ -61,26 +61,17 @@ env GOOS=windows GOARCH=amd64 go build main.go
 env GOOS=linux GOARCH=amd64 go build main.go
 ```
 
-### 初始化数据库,以及服务启动
 
-``` bash
-# 首次配置需要初始化数据库资源信息
-# macOS or linux 下使用
-$ ./OAuth migrate -c conf/settings.yml
-
-# ️注意:windows 下使用
-$ OAuth.exe migrate -c conf/settings.yml
-```
 
 ### 启动服务,也可以用IDE进行调试
 
 ```shell
 # macOS or linux 下使用
-$ ./OAuth server -c conf/settings.yml
+$ ./cold-delivery server -c conf/settings.yml
 
 
 # 注意:windows 下使用
-$ OAuth.exe server -c conf/settings.yml
+$ cold-delivery.exe server -c conf/settings.yml
 ```
 
 ### 接口文档

+ 7 - 4
app/admin/controller/address.go

@@ -20,6 +20,9 @@ type AddressController struct {
 // @Summary 获取地址列表
 // @Description 获取地址列表
 // @Tags 地址
+// @Param name query int false "电话/地址/省市区"
+// @Param addressType query int false "地址类型:sender-发货人 consignee-收货人"
+// @Param dataType query int false "我的my 全部all"
 // @Param pageSize query int false "页条数"
 // @Param page query int false "页码"
 // @Success 200 {object} response.Response{data=response.Page{list=[]model.Address}} "{"code": 200, "data": [...]}"
@@ -127,7 +130,7 @@ func (e AddressController) Insert(c *gin.Context) {
 		e.Error(500, err, err.Error())
 		return
 	}
-	e.OK(req.GetId(), "创建成功")
+	e.OK(req.GetId(), "添加成功")
 }
 
 // Update 修改地址
@@ -137,8 +140,8 @@ func (e AddressController) Insert(c *gin.Context) {
 // @Accept  application/json
 // @Product application/json
 // @Param data body dto.AddressUpdateReq true "body"
-// @Success 200 {string} string	"{"code": 200, "message": "添加成功"}"
-// @Success 200 {string} string	"{"code": -1, "message": "添加失败"}"
+// @Success 200 {string} string	"{"code": 200, "message": "修改成功"}"
+// @Success 200 {string} string	"{"code": -1, "message": "修改失败"}"
 // @Router /api/address [put]
 // @Security Bearer
 func (e AddressController) Update(c *gin.Context) {
@@ -162,7 +165,7 @@ func (e AddressController) Update(c *gin.Context) {
 		e.Error(500, err, err.Error())
 		return
 	}
-	e.OK(req.GetId(), "更新成功")
+	e.OK(req.GetId(), "修改成功")
 }
 
 // Delete 删除地址

+ 0 - 195
app/admin/controller/car.go

@@ -1,195 +0,0 @@
-package controller
-
-import (
-	"cold-delivery/app/admin/model"
-	"cold-delivery/app/admin/service"
-	"cold-delivery/app/admin/service/dto"
-	"cold-delivery/common/actions"
-	"github.com/gin-gonic/gin"
-	"github.com/gin-gonic/gin/binding"
-	"gogs.baozhida.cn/zoie/OAuth-core/api"
-	"gogs.baozhida.cn/zoie/OAuth-core/pkg/jwtauth/user"
-	_ "gogs.baozhida.cn/zoie/OAuth-core/pkg/response"
-)
-
-type CarController struct {
-	api.Api
-}
-
-// GetPage 获取车辆列表
-// @Summary 获取车辆列表
-// @Description 获取车辆列表
-// @Tags 车辆
-// @Param name query string false "车辆名称"
-// @Param pageSize query int false "页条数"
-// @Param page query int false "页码"
-// @Success 200 {object} response.Response{data=response.Page{list=[]model.Car}} "{"code": 200, "data": [...]}"
-// @Router /api/car [get]
-// @Security Bearer
-func (e CarController) GetPage(c *gin.Context) {
-	s := service.Car{}
-	req := dto.CarGetPageReq{}
-	err := e.MakeContext(c).
-		MakeOrm().
-		Bind(&req, binding.Query).
-		MakeService(&s.Service).
-		Errors
-	if err != nil {
-		e.Logger.Error(err)
-		e.Error(500, err, err.Error())
-		return
-	}
-
-	//数据权限检查
-	p := actions.GetPermissionFromContext(c)
-
-	list := make([]model.Car, 0)
-	var count int64
-
-	err = s.GetPage(&req, &list, &count, p)
-	if err != nil {
-		e.Error(500, err, err.Error())
-		return
-	}
-	e.PageOK(list, int(count), req.GetPageIndex(), req.GetPageSize(), "查询成功")
-}
-
-// Get 通过id获取车辆
-// @Summary 通过id获取车辆
-// @Description 通过id获取车辆
-// @Tags 车辆
-// @Param id path string true "车辆id"
-// @Success 200 {object} response.Response{data=model.Car} "{"code": 200, "data": [...]}"
-// @Router /api/car/{id} [get]
-// @Security Bearer
-func (e CarController) Get(c *gin.Context) {
-	s := service.Car{}
-	req := dto.CarGetReq{}
-	err := e.MakeContext(c).
-		MakeOrm().
-		Bind(&req, nil).
-		MakeService(&s.Service).
-		Errors
-	if err != nil {
-		e.Logger.Error(err)
-		e.Error(500, err, err.Error())
-		return
-	}
-	var object model.Car
-	p := actions.GetPermissionFromContext(c)
-
-	//数据权限检查
-	err = s.Get(&req, &object, p)
-	if err != nil {
-		e.Error(500, err, err.Error())
-		return
-	}
-
-	e.OK(object, "查询成功")
-}
-
-// Insert 添加车辆
-// @Summary 添加车辆
-// @Description 添加车辆
-// @Tags 车辆
-// @Accept  application/json
-// @Product application/json
-// @Param data body dto.CarInsertReq true "data"
-// @Success 200 {string} string	"{"code": 200, "message": "添加成功"}"
-// @Success 200 {string} string	"{"code": -1, "message": "添加失败"}"
-// @Router /api/car [post]
-// @Security Bearer
-func (e CarController) Insert(c *gin.Context) {
-	s := service.Car{}
-	req := dto.CarInsertReq{}
-	err := e.MakeContext(c).
-		MakeOrm().
-		Bind(&req, binding.JSON).
-		MakeService(&s.Service).
-		Errors
-	if err != nil {
-		e.Logger.Error(err)
-		e.Error(500, err, err.Error())
-		return
-	}
-	p := actions.GetPermissionFromContext(c)
-	// 设置创建人
-	req.SetCreateBy(user.GetUserId(c))
-	req.SetDeptId(p.DeptId)
-	err = s.Insert(&req)
-	if err != nil {
-		e.Error(500, err, err.Error())
-		return
-	}
-	e.OK(req.GetId(), "创建成功")
-}
-
-// Update 修改车辆
-// @Summary 修改车辆
-// @Description 修改车辆
-// @Tags 车辆
-// @Accept  application/json
-// @Product application/json
-// @Param data body dto.CarUpdateReq true "body"
-// @Success 200 {string} string	"{"code": 200, "message": "添加成功"}"
-// @Success 200 {string} string	"{"code": -1, "message": "添加失败"}"
-// @Router /api/car [put]
-// @Security Bearer
-func (e CarController) Update(c *gin.Context) {
-	s := service.Car{}
-	req := dto.CarUpdateReq{}
-	err := e.MakeContext(c).
-		MakeOrm().
-		Bind(&req).
-		MakeService(&s.Service).
-		Errors
-	if err != nil {
-		e.Logger.Error(err)
-		e.Error(500, err, err.Error())
-		return
-	}
-	p := actions.GetPermissionFromContext(c)
-
-	req.SetUpdateBy(user.GetUserId(c))
-	err = s.Update(&req, p)
-	if err != nil {
-		e.Error(500, err, err.Error())
-		return
-	}
-	e.OK(req.GetId(), "更新成功")
-}
-
-// Delete 删除车辆
-// @Summary 删除车辆
-// @Description 删除车辆
-// @Tags 车辆
-// @Accept  application/json
-// @Product application/json
-// @Param data body dto.CarDeleteReq true "body"
-// @Success 200 {string} string	"{"code": 200, "message": "删除成功"}"
-// @Success 200 {string} string	"{"code": -1, "message": "删除失败"}"
-// @Router /api/car [delete]
-// @Security Bearer
-func (e CarController) Delete(c *gin.Context) {
-	s := service.Car{}
-	req := dto.CarDeleteReq{}
-	err := e.MakeContext(c).
-		MakeOrm().
-		Bind(&req, binding.JSON, nil).
-		MakeService(&s.Service).
-		Errors
-	if err != nil {
-		e.Logger.Error(err)
-		e.Error(500, err, err.Error())
-		return
-	}
-
-	//数据权限检查
-	p := actions.GetPermissionFromContext(c)
-	err = s.Remove(&req, p)
-	if err != nil {
-		e.Error(500, err, err.Error())
-		return
-	}
-	e.OK(req.GetId(), "删除成功")
-}

+ 9 - 7
app/admin/controller/company.go

@@ -57,11 +57,13 @@ func (e CompanyController) GetPage(c *gin.Context) {
 // @Description 获取公司下面的用户列表
 // @Tags 公司
 // @Param username query string false "用户名"
-// @Param status query string false "状态 1-停用 2-正常"
+// @Param name query string false "姓名"
+// @Param type query int false "类型"
+// @Param companyId query int false "公司id"
 // @Param pageSize query int false "页条数"
 // @Param page query int false "页码"
 // @Success 200 {object} response.Response{data=response.Page{list=[]model.SysUser}}  "{"code": 200, "data": [...]}"
-// @Router /api/sys-user [get]
+// @Router /api/company/user [get]
 // @Security Bearer
 func (e CompanyController) GetUserPage(c *gin.Context) {
 	s := service.SysUser{}
@@ -97,7 +99,7 @@ func (e CompanyController) GetUserPage(c *gin.Context) {
 // @Summary 添加用户-获取公司列表
 // @Description 添加用户-获取公司列表
 // @Tags 公司
-// @Param id path string true "公司id"
+// @Param name query string false "公司名称"
 // @Success 200 {object} response.Response{data=model.SysDept} "{"code": 200, "data": [...]}"
 // @Router /api/company/{id} [get]
 // @Security Bearer
@@ -192,7 +194,7 @@ func (e CompanyController) Insert(c *gin.Context) {
 		e.Error(500, err, err.Error())
 		return
 	}
-	e.OK(req.GetId(), "创建成功")
+	e.OK(req.GetId(), "添加成功")
 }
 
 // Update 修改公司
@@ -202,8 +204,8 @@ func (e CompanyController) Insert(c *gin.Context) {
 // @Accept  application/json
 // @Product application/json
 // @Param data body dto.CompanyUpdateReq true "body"
-// @Success 200 {string} string	"{"code": 200, "message": "添加成功"}"
-// @Success 200 {string} string	"{"code": -1, "message": "添加失败"}"
+// @Success 200 {string} string	"{"code": 200, "message": "修改成功"}"
+// @Success 200 {string} string	"{"code": -1, "message": "修改失败"}"
 // @Router /api/company [put]
 // @Security Bearer
 func (e CompanyController) Update(c *gin.Context) {
@@ -226,7 +228,7 @@ func (e CompanyController) Update(c *gin.Context) {
 		e.Error(500, err, err.Error())
 		return
 	}
-	e.OK(req.GetId(), "更新成功")
+	e.OK(req.GetId(), "修改成功")
 }
 
 // Delete 删除公司

+ 15 - 12
app/admin/controller/cooler_box.go

@@ -21,10 +21,13 @@ type CoolerBoxController struct {
 // @Description 获取保温箱列表
 // @Tags 保温箱
 // @Param name query string false "保温箱名称"
+// @Param sn query string false "保温箱关联sn"
+// @Param status query string false "状态:1-停用 2-启用"
+// @Param showTemp query bool false "是否展示最新温度"
 // @Param pageSize query int false "页条数"
 // @Param page query int false "页码"
 // @Success 200 {object} response.Response{data=response.Page{list=[]model.CoolerBox}} "{"code": 200, "data": [...]}"
-// @Router /api/CoolerBox [get]
+// @Router /api/cooler-box [get]
 // @Security Bearer
 func (e CoolerBoxController) GetPage(c *gin.Context) {
 	s := service.CoolerBox{}
@@ -60,7 +63,7 @@ func (e CoolerBoxController) GetPage(c *gin.Context) {
 // @Tags 保温箱
 // @Param id path string true "保温箱id"
 // @Success 200 {object} response.Response{data=model.CoolerBox} "{"code": 200, "data": [...]}"
-// @Router /api/CoolerBox/{id} [get]
+// @Router /api/cooler-box/{id} [get]
 // @Security Bearer
 func (e CoolerBoxController) Get(c *gin.Context) {
 	s := service.CoolerBox{}
@@ -97,7 +100,7 @@ func (e CoolerBoxController) Get(c *gin.Context) {
 // @Param data body dto.CoolerBoxInsertReq true "data"
 // @Success 200 {string} string	"{"code": 200, "message": "添加成功"}"
 // @Success 200 {string} string	"{"code": -1, "message": "添加失败"}"
-// @Router /api/CoolerBox [post]
+// @Router /api/cooler-box [post]
 // @Security Bearer
 func (e CoolerBoxController) Insert(c *gin.Context) {
 	s := service.CoolerBox{}
@@ -121,7 +124,7 @@ func (e CoolerBoxController) Insert(c *gin.Context) {
 		e.Error(500, err, err.Error())
 		return
 	}
-	e.OK(req.GetId(), "创建成功")
+	e.OK(req.GetId(), "添加成功")
 }
 
 // Update 修改保温箱
@@ -131,9 +134,9 @@ func (e CoolerBoxController) Insert(c *gin.Context) {
 // @Accept  application/json
 // @Product application/json
 // @Param data body dto.CoolerBoxUpdateReq true "body"
-// @Success 200 {string} string	"{"code": 200, "message": "添加成功"}"
-// @Success 200 {string} string	"{"code": -1, "message": "添加失败"}"
-// @Router /api/CoolerBox [put]
+// @Success 200 {string} string	"{"code": 200, "message": "修改成功"}"
+// @Success 200 {string} string	"{"code": -1, "message": "修改失败"}"
+// @Router /api/cooler-box [put]
 // @Security Bearer
 func (e CoolerBoxController) Update(c *gin.Context) {
 	s := service.CoolerBox{}
@@ -156,7 +159,7 @@ func (e CoolerBoxController) Update(c *gin.Context) {
 		e.Error(500, err, err.Error())
 		return
 	}
-	e.OK(req.GetId(), "更新成功")
+	e.OK(req.GetId(), "修改成功")
 }
 
 // Delete 删除保温箱
@@ -168,7 +171,7 @@ func (e CoolerBoxController) Update(c *gin.Context) {
 // @Param data body dto.CoolerBoxDeleteReq true "body"
 // @Success 200 {string} string	"{"code": 200, "message": "删除成功"}"
 // @Success 200 {string} string	"{"code": -1, "message": "删除失败"}"
-// @Router /api/CoolerBox [delete]
+// @Router /api/cooler-box [delete]
 // @Security Bearer
 func (e CoolerBoxController) Delete(c *gin.Context) {
 	s := service.CoolerBox{}
@@ -200,10 +203,10 @@ func (e CoolerBoxController) Delete(c *gin.Context) {
 // @Tags 保温箱
 // @Accept  application/json
 // @Product application/json
-// @Param data body dto.CoolerBoxInsertReq true "data"
+// @Param data body dto.CoolerBoxBatchInsertReq true "data"
 // @Success 200 {string} string	"{"code": 200, "message": "添加成功"}"
 // @Success 200 {string} string	"{"code": -1, "message": "添加失败"}"
-// @Router /api/CoolerBox [post]
+// @Router /api/cooler-box [post]
 // @Security Bearer
 func (e CoolerBoxController) BatchInsert(c *gin.Context) {
 	s := service.CoolerBox{}
@@ -227,5 +230,5 @@ func (e CoolerBoxController) BatchInsert(c *gin.Context) {
 		e.Error(500, err, err.Error())
 		return
 	}
-	e.OK(nil, "创建成功")
+	e.OK(nil, "添加成功")
 }

+ 8 - 7
app/admin/controller/customer.go

@@ -30,7 +30,9 @@ type Customer struct {
 // @Summary 获取客户列表
 // @Description 获取客户列表
 // @Tags 客户
-// @Param username query string false "客户名"
+// @Param username query string false "用户名"
+// @Param name query string false "姓名"
+// @Param type query int false "类型"
 // @Param pageSize query int false "页条数"
 // @Param page query int false "页码"
 // @Success 200 {object} response.Response{data=response.Page{list=[]model.SysUser}}  "{"code": 200, "data": [...]}"
@@ -106,7 +108,7 @@ func (e Customer) Get(c *gin.Context) {
 // @Tags 客户
 // @Accept  application/json
 // @Product application/json
-// @Param data body dto.CustomerInsertReq true "客户数据"
+// @Param data body dto.CustomerInsertReq true "body"
 // @Success 200 {object} response.Response "{"code": 200, "data": [...]}"
 // @Router /api/customer [post]
 // @Security Bearer
@@ -140,7 +142,7 @@ func (e Customer) Insert(c *gin.Context) {
 		return
 	}
 
-	e.OK(req.GetId(), "创建成功")
+	e.OK(req.GetId(), "添加成功")
 }
 
 // Update 修改客户数据
@@ -177,7 +179,7 @@ func (e Customer) Update(c *gin.Context) {
 		e.Error(500, err, err.Error())
 		return
 	}
-	e.OK(req.GetId(), "更新成功")
+	e.OK(req.GetId(), "修改成功")
 }
 
 // Delete 通过id删除客户数据
@@ -257,7 +259,7 @@ func (e Customer) ResetPwd(c *gin.Context) {
 		return
 	}
 
-	e.OK(req.GetId(), "更新成功")
+	e.OK(req.GetId(), "修改成功")
 
 }
 
@@ -390,8 +392,7 @@ func (e Customer) GetInfo(c *gin.Context) {
 // @Summary 获取短信验证码
 // @Description 获取短信验证码
 // @Tags 登录
-// @Accept  application/json
-// @Product application/json
+// @Param phone query string false "电话号码"
 // @Success 200 {string} string "{"code": 200, "data": "18888888888"}"
 // @Router /verify-code [get]
 // @Security Bearer

+ 17 - 7
app/admin/controller/device.go

@@ -23,8 +23,8 @@ type DeviceController struct {
 // @Param name query string false "设备名称"
 // @Param pageSize query int false "页条数"
 // @Param page query int false "页码"
-// @Success 200 {object} response.Response{data=response.Page{list=[]model.Device_R}} "{"code": 200, "data": [...]}"
-// @Router /api/CoolerBox [get]
+// @Success 200 {object} response.Response{data=response.Page{list=[]nats_server.Device_R}} "{"code": 200, "data": [...]}"
+// @Router /api/device [get]
 // @Security Bearer
 func (e DeviceController) GetDevicePage(c *gin.Context) {
 	coolerBoxSvc := service.CoolerBox{}
@@ -117,15 +117,13 @@ func (e DeviceController) GetDevicePage(c *gin.Context) {
 	e.PageOK(currentPage, len(list2), req.GetPageIndex(), req.GetPageSize(), "查询成功")
 }
 
-// GetPage 获取传感器列表
+// GetDeviceSensorPage 获取传感器列表
 // @Summary 获取传感器列表
 // @Description 获取传感器列表
 // @Tags 设备
 // @Param sn query string true "sn"
-// @Param pageSize query int false "页条数"
-// @Param page query int false "页码"
-// @Success 200 {object} response.Response{data=response.Page{list=[]model.Device}} "{"code": 200, "data": [...]}"
-// @Router /api/ice-locker [get]
+// @Success 200 {object} response.Response{data=response.Page{list=[]nats_server.DeviceSensor_R}} "{"code": 200, "data": [...]}"
+// @Router /api/device-sensor [get]
 // @Security Bearer
 func (e DeviceController) GetDeviceSensorPage(c *gin.Context) {
 	s := service.Device{}
@@ -152,6 +150,18 @@ func (e DeviceController) GetDeviceSensorPage(c *gin.Context) {
 	e.PageOK(list, int(count), 0, 0, "查询成功")
 
 }
+
+// GetDeviceSensorDataPage 获取传感器数据列表
+// @Summary 获取传感器数据列表
+// @Description 获取传感器数据列表
+// @Tags 设备
+// @Param sn query string true "sn"
+// @Param t_ids query string true "传感器id列表"
+// @Param startTime query string true "开始时间"
+// @Param endTime query string true "结束时间"
+// @Success 200 {object} response.Response{data=response.Page{list=[]nats_server.DeviceSensor_R}} "{"code": 200, "data": [...]}"
+// @Router /api/device-sensor [get]
+// @Security Bearer
 func (e DeviceController) GetDeviceSensorDataPage(c *gin.Context) {
 	s := service.Device{}
 	req := dto.DeviceSensorGetDataReq{}

+ 3 - 3
app/admin/controller/ice_locker.go

@@ -121,7 +121,7 @@ func (e IceLockerController) Insert(c *gin.Context) {
 		e.Error(500, err, err.Error())
 		return
 	}
-	e.OK(req.GetId(), "创建成功")
+	e.OK(req.GetId(), "添加成功")
 }
 
 // Update 修改冷冻柜
@@ -156,7 +156,7 @@ func (e IceLockerController) Update(c *gin.Context) {
 		e.Error(500, err, err.Error())
 		return
 	}
-	e.OK(req.GetId(), "更新成功")
+	e.OK(req.GetId(), "修改成功")
 }
 
 // Delete 删除冷冻柜
@@ -227,5 +227,5 @@ func (e IceLockerController) BatchInsert(c *gin.Context) {
 		e.Error(500, err, err.Error())
 		return
 	}
-	e.OK(nil, "创建成功")
+	e.OK(nil, "添加成功")
 }

+ 3 - 4
app/admin/controller/ice_raft.go

@@ -190,7 +190,6 @@ func (e IceRaftController) GetNewestRecordPageSSE(c *gin.Context) {
 	}
 }
 
-
 // Get 通过id获取冰排
 // @Summary 通过id获取冰排
 // @Description 通过id获取冰排
@@ -258,7 +257,7 @@ func (e IceRaftController) Insert(c *gin.Context) {
 		e.Error(500, err, err.Error())
 		return
 	}
-	e.OK(req.GetId(), "创建成功")
+	e.OK(req.GetId(), "添加成功")
 }
 
 // Update 修改冰排
@@ -293,7 +292,7 @@ func (e IceRaftController) Update(c *gin.Context) {
 		e.Error(500, err, err.Error())
 		return
 	}
-	e.OK(req.GetId(), "更新成功")
+	e.OK(req.GetId(), "修改成功")
 }
 
 // Delete 删除冰排
@@ -475,7 +474,7 @@ func (e IceRaftRecordController) Update(c *gin.Context) {
 		e.Error(500, err, err.Error())
 		return
 	}
-	e.OK(req.GetId(), "更新成功")
+	e.OK(req.GetId(), "修改成功")
 }
 
 // Delete 删除冰排出入库历史记录

+ 4 - 59
app/admin/controller/sys_user.go

@@ -133,7 +133,7 @@ func (e SysUser) Insert(c *gin.Context) {
 		return
 	}
 
-	e.OK(req.GetId(), "创建成功")
+	e.OK(req.GetId(), "添加成功")
 }
 
 // Update 修改用户数据
@@ -170,7 +170,7 @@ func (e SysUser) Update(c *gin.Context) {
 		e.Error(500, err, err.Error())
 		return
 	}
-	e.OK(req.GetId(), "更新成功")
+	e.OK(req.GetId(), "修改成功")
 }
 
 // Delete 通过id删除用户数据
@@ -249,7 +249,7 @@ func (e SysUser) UpdateStatus(c *gin.Context) {
 		e.Error(500, err, err.Error())
 		return
 	}
-	e.OK(req.GetId(), "更新成功")
+	e.OK(req.GetId(), "修改成功")
 }
 
 // ResetPwd 重置用户密码
@@ -288,7 +288,7 @@ func (e SysUser) ResetPwd(c *gin.Context) {
 		return
 	}
 
-	e.OK(req.GetId(), "更新成功")
+	e.OK(req.GetId(), "修改成功")
 
 }
 
@@ -460,58 +460,3 @@ func (e SysUser) VerifyCode(c *gin.Context) {
 	e.OK(req.Phone, "发送成功")
 
 }
-
-// GetPageFoeBind 获取用户列表-仓库/车辆绑定
-// @Summary 获取用户列表-仓库/车辆绑定
-// @Description 获取用户列表-仓库/车辆绑定
-// @Tags 用户
-// @Param username query string false "用户名"
-// @Param deptId query int false "部门id"
-// @Param roleId query string false "角色id"
-// @Param postId query string false "岗位id"
-// @Param status query string false "状态 1-停用 2-正常"
-// @Param pageSize query int false "页条数"
-// @Param page query int false "页码"
-// @Success 200 {object} response.Response{data=response.Page{list=[]model.SysUser}}  "{"code": 200, "data": [...]}"
-// @Router /api/sys-user [get]
-// @Security Bearer
-func (e SysUser) GetPageFoeBind(c *gin.Context) {
-	warehouseSvc := service.Warehouse{}
-	carSvc := service.Car{}
-	req := dto.SysUserGetPageReq{}
-	err := e.MakeContext(c).
-		MakeOrm().
-		Bind(&req, binding.Query).
-		MakeService(&warehouseSvc.Service).
-		MakeService(&carSvc.Service).
-		Errors
-
-	if err != nil {
-		e.Logger.Error(err)
-		e.Error(500, err, err.Error())
-		return
-	}
-
-	//数据权限检查
-	p := actions.GetPermissionFromContext(c)
-
-	list := make([]model.SysUserForBind, 0)
-	var count int64
-
-	if req.Type == 2 {
-		err = warehouseSvc.GetUserList(&req, p, &list, &count)
-		if err != nil {
-			e.Error(500, err, err.Error())
-			return
-		}
-	}
-	if req.Type == 3 {
-		err = carSvc.GetUserList(&req, p, &list, &count)
-		if err != nil {
-			e.Error(500, err, err.Error())
-			return
-		}
-	}
-
-	e.PageOK(list, int(count), req.GetPageIndex(), req.GetPageSize(), "查询成功")
-}

+ 0 - 195
app/admin/controller/warehouse.go

@@ -1,195 +0,0 @@
-package controller
-
-import (
-	"cold-delivery/app/admin/model"
-	"cold-delivery/app/admin/service"
-	"cold-delivery/app/admin/service/dto"
-	"cold-delivery/common/actions"
-	"github.com/gin-gonic/gin"
-	"github.com/gin-gonic/gin/binding"
-	"gogs.baozhida.cn/zoie/OAuth-core/api"
-	"gogs.baozhida.cn/zoie/OAuth-core/pkg/jwtauth/user"
-	_ "gogs.baozhida.cn/zoie/OAuth-core/pkg/response"
-)
-
-type WarehouseController struct {
-	api.Api
-}
-
-// GetPage 获取仓库列表
-// @Summary 获取仓库列表
-// @Description 获取仓库列表
-// @Tags 仓库
-// @Param name query string false "仓库名称"
-// @Param pageSize query int false "页条数"
-// @Param page query int false "页码"
-// @Success 200 {object} response.Response{data=response.Page{list=[]model.Warehouse}} "{"code": 200, "data": [...]}"
-// @Router /api/warehouse [get]
-// @Security Bearer
-func (e WarehouseController) GetPage(c *gin.Context) {
-	s := service.Warehouse{}
-	req := dto.WarehouseGetPageReq{}
-	err := e.MakeContext(c).
-		MakeOrm().
-		Bind(&req, binding.Query).
-		MakeService(&s.Service).
-		Errors
-	if err != nil {
-		e.Logger.Error(err)
-		e.Error(500, err, err.Error())
-		return
-	}
-
-	//数据权限检查
-	p := actions.GetPermissionFromContext(c)
-
-	list := make([]model.Warehouse, 0)
-	var count int64
-
-	err = s.GetPage(&req, &list, &count, p)
-	if err != nil {
-		e.Error(500, err, err.Error())
-		return
-	}
-	e.PageOK(list, int(count), req.GetPageIndex(), req.GetPageSize(), "查询成功")
-}
-
-// Get 通过id获取仓库
-// @Summary 通过id获取仓库
-// @Description 通过id获取仓库
-// @Tags 仓库
-// @Param id path string true "仓库id"
-// @Success 200 {object} response.Response{data=model.Warehouse} "{"code": 200, "data": [...]}"
-// @Router /api/warehouse/{id} [get]
-// @Security Bearer
-func (e WarehouseController) Get(c *gin.Context) {
-	s := service.Warehouse{}
-	req := dto.WarehouseGetReq{}
-	err := e.MakeContext(c).
-		MakeOrm().
-		Bind(&req, nil).
-		MakeService(&s.Service).
-		Errors
-	if err != nil {
-		e.Logger.Error(err)
-		e.Error(500, err, err.Error())
-		return
-	}
-	var object model.Warehouse
-	p := actions.GetPermissionFromContext(c)
-
-	//数据权限检查
-	err = s.Get(&req, &object, p)
-	if err != nil {
-		e.Error(500, err, err.Error())
-		return
-	}
-
-	e.OK(object, "查询成功")
-}
-
-// Insert 添加仓库
-// @Summary 添加仓库
-// @Description 添加仓库
-// @Tags 仓库
-// @Accept  application/json
-// @Product application/json
-// @Param data body dto.WarehouseInsertReq true "data"
-// @Success 200 {string} string	"{"code": 200, "message": "添加成功"}"
-// @Success 200 {string} string	"{"code": -1, "message": "添加失败"}"
-// @Router /api/warehouse [post]
-// @Security Bearer
-func (e WarehouseController) Insert(c *gin.Context) {
-	s := service.Warehouse{}
-	req := dto.WarehouseInsertReq{}
-	err := e.MakeContext(c).
-		MakeOrm().
-		Bind(&req, binding.JSON).
-		MakeService(&s.Service).
-		Errors
-	if err != nil {
-		e.Logger.Error(err)
-		e.Error(500, err, err.Error())
-		return
-	}
-	p := actions.GetPermissionFromContext(c)
-	// 设置创建人
-	req.SetCreateBy(user.GetUserId(c))
-	req.SetDeptId(p.DeptId)
-	err = s.Insert(&req)
-	if err != nil {
-		e.Error(500, err, err.Error())
-		return
-	}
-	e.OK(req.GetId(), "创建成功")
-}
-
-// Update 修改仓库
-// @Summary 修改仓库
-// @Description 修改仓库
-// @Tags 仓库
-// @Accept  application/json
-// @Product application/json
-// @Param data body dto.WarehouseUpdateReq true "body"
-// @Success 200 {string} string	"{"code": 200, "message": "添加成功"}"
-// @Success 200 {string} string	"{"code": -1, "message": "添加失败"}"
-// @Router /api/warehouse [put]
-// @Security Bearer
-func (e WarehouseController) Update(c *gin.Context) {
-	s := service.Warehouse{}
-	req := dto.WarehouseUpdateReq{}
-	err := e.MakeContext(c).
-		MakeOrm().
-		Bind(&req).
-		MakeService(&s.Service).
-		Errors
-	if err != nil {
-		e.Logger.Error(err)
-		e.Error(500, err, err.Error())
-		return
-	}
-	p := actions.GetPermissionFromContext(c)
-
-	req.SetUpdateBy(user.GetUserId(c))
-	err = s.Update(&req, p)
-	if err != nil {
-		e.Error(500, err, err.Error())
-		return
-	}
-	e.OK(req.GetId(), "更新成功")
-}
-
-// Delete 删除仓库
-// @Summary 删除仓库
-// @Description 删除仓库
-// @Tags 仓库
-// @Accept  application/json
-// @Product application/json
-// @Param data body dto.WarehouseDeleteReq true "body"
-// @Success 200 {string} string	"{"code": 200, "message": "删除成功"}"
-// @Success 200 {string} string	"{"code": -1, "message": "删除失败"}"
-// @Router /api/warehouse [delete]
-// @Security Bearer
-func (e WarehouseController) Delete(c *gin.Context) {
-	s := service.Warehouse{}
-	req := dto.WarehouseDeleteReq{}
-	err := e.MakeContext(c).
-		MakeOrm().
-		Bind(&req, binding.JSON, nil).
-		MakeService(&s.Service).
-		Errors
-	if err != nil {
-		e.Logger.Error(err)
-		e.Error(500, err, err.Error())
-		return
-	}
-
-	//数据权限检查
-	p := actions.GetPermissionFromContext(c)
-	err = s.Remove(&req, p)
-	if err != nil {
-		e.Error(500, err, err.Error())
-		return
-	}
-	e.OK(req.GetId(), "删除成功")
-}

+ 54 - 35
app/admin/controller/waybill.go

@@ -45,7 +45,11 @@ type WaybillController struct {
 // @Summary 获取运单列表
 // @Description 获取运单列表
 // @Tags 运单
-// @Param no query string false "运单号"
+// @Param waybillNo query string false "运单号"
+// @Param orderNo query string false "订单号"
+// @Param status query int false "状态"
+// @Param orderStartTime query string false "下单开始时间"
+// @Param orderEndTime query string false "下单结束时间"
 // @Param pageSize query int false "页条数"
 // @Param page query int false "页码"
 // @Success 200 {object} response.Response{data=response.Page{list=[]model.Waybill}} "{"code": 200, "data": [...]}"
@@ -91,15 +95,15 @@ func (e WaybillController) GetPage(c *gin.Context) {
 	e.PageOK(list, int(count), req.GetPageIndex(), req.GetPageSize(), "查询成功")
 }
 
-// GetPage 获取运单列表
-// @Summary 获取运单列表
-// @Description 获取运单列表
+// Export 导出运单列表
+// @Summary 导出运单列表
+// @Description 导出运单列表
 // @Tags 运单
-// @Param no query string false "运单号"
+// @Param waybillNo query string false "运单号"
 // @Param pageSize query int false "页条数"
 // @Param page query int false "页码"
 // @Success 200 {object} response.Response{data=response.Page{list=[]model.Waybill}} "{"code": 200, "data": [...]}"
-// @Router /api/waybill [get]
+// @Router /api/waybill/export [get]
 // @Security Bearer
 func (e WaybillController) Export(c *gin.Context) {
 	s := service.Waybill{}
@@ -190,11 +194,11 @@ func (e WaybillController) Export(c *gin.Context) {
 // @Summary 首页统计
 // @Description 首页统计
 // @Tags 运单
-// @Param no query string false "运单号"
-// @Param pageSize query int false "页条数"
-// @Param page query int false "页码"
+// @Param data body dto.WaybillStatsReq true "data"
+// @Param date query string true "日期"
+// @Param type query string true "类型 month-月 year-年"
 // @Success 200 {object} response.Response{data=response.Page{list=[]model.Waybill}} "{"code": 200, "data": [...]}"
-// @Router /api/waybill [get]
+// @Router /api/waybill/home [get]
 // @Security Bearer
 func (e WaybillController) Home(c *gin.Context) {
 	s := service.Waybill{}
@@ -229,15 +233,13 @@ func (e WaybillController) Home(c *gin.Context) {
 	e.OK(res, "查询成功")
 }
 
-// Home 用户运单数量统计
+// UserStats 用户运单数量统计
 // @Summary 首页统计
 // @Description 首页统计
 // @Tags 运单
-// @Param no query string false "运单号"
-// @Param pageSize query int false "页条数"
-// @Param page query int false "页码"
+// @Param data body dto.WaybillUserStatsReq true "data"
 // @Success 200 {object} response.Response{data=response.Page{list=[]model.Waybill}} "{"code": 200, "data": [...]}"
-// @Router /api/waybill [get]
+// @Router /api/waybill/user-stats [post]
 // @Security Bearer
 func (e WaybillController) UserStats(c *gin.Context) {
 	s := service.Waybill{}
@@ -288,11 +290,10 @@ func (e WaybillController) UserStats(c *gin.Context) {
 // @Summary 获取运单列表
 // @Description 获取运单列表
 // @Tags 运单
-// @Param no query string false "运单号"
-// @Param pageSize query int false "页条数"
-// @Param page query int false "页码"
+// @Param waybillNo query string false "运单号"
+// @Param status query int false "状态"
 // @Success 200 {object} response.Response{data=response.Page{list=[]model.Waybill}} "{"code": 200, "data": [...]}"
-// @Router /api/waybill [get]
+// @Router /api/waybill/applet [get]
 // @Security Bearer
 func (e WaybillController) GetAppletPage(c *gin.Context) {
 	s := service.Waybill{}
@@ -325,7 +326,8 @@ func (e WaybillController) GetAppletPage(c *gin.Context) {
 // @Summary 获取app运单统计数量
 // @Description 获取app运单统计数量
 // @Tags 运单
-// @Param no query string false "运单号"
+// @Param waybillNo query string false "运单号"
+// @Param status query int false "状态"
 // @Success 200 {object} response.Response{data=response.Page{list=[]model.Waybill}} "{"code": 200, "data": [...]}"
 // @Router /api/waybill/applet-count [get]
 // @Security Bearer
@@ -431,7 +433,7 @@ func (e WaybillController) Get(c *gin.Context) {
 // @Summary 通过id获取运单
 // @Description 通过id获取运单
 // @Tags 运单
-// @Param id path string true "运单id"
+// @Param waybillNo path string true "运单编号-必填"
 // @Success 200 {object} response.Response{data=model.Waybill} "{"code": 200, "data": [...]}"
 // @Router /api/waybill/no [get]
 // @Security Bearer
@@ -493,7 +495,7 @@ func (e WaybillController) Insert(c *gin.Context) {
 		e.Error(500, err, err.Error())
 		return
 	}
-	e.OK(req.GetId(), "创建成功")
+	e.OK(req.GetId(), "添加成功")
 }
 
 // UpdateStatus 修改运单状态
@@ -505,7 +507,7 @@ func (e WaybillController) Insert(c *gin.Context) {
 // @Param data body dto.WaybillUpdateStatusReq true "body"
 // @Success 200 {string} string	"{"code": 200, "message": "添加成功"}"
 // @Success 200 {string} string	"{"code": -1, "message": "添加失败"}"
-// @Router /api/waybill [put]
+// @Router /api/waybill/update-status [put]
 // @Security Bearer
 func (e WaybillController) UpdateStatus(c *gin.Context) {
 	s := service.Waybill{}
@@ -528,7 +530,7 @@ func (e WaybillController) UpdateStatus(c *gin.Context) {
 		e.Error(500, err, err.Error())
 		return
 	}
-	e.OK(req.GetId(), "更新成功")
+	e.OK(req.GetId(), "修改成功")
 }
 
 // Update 修改运单
@@ -563,7 +565,7 @@ func (e WaybillController) Update(c *gin.Context) {
 		e.Error(500, err, err.Error())
 		return
 	}
-	e.OK(req.GetId(), "更新成功")
+	e.OK(req.GetId(), "修改成功")
 }
 
 // Delivery 派单
@@ -575,7 +577,7 @@ func (e WaybillController) Update(c *gin.Context) {
 // @Param data body dto.WaybillDeliveryReq true "body"
 // @Success 200 {string} string	"{"code": 200, "message": "添加成功"}"
 // @Success 200 {string} string	"{"code": -1, "message": "添加失败"}"
-// @Router /api/waybill [put]
+// @Router /api/waybill/delivery [put]
 // @Security Bearer
 func (e WaybillController) Delivery(c *gin.Context) {
 	s := service.Waybill{}
@@ -671,7 +673,7 @@ func (e WaybillController) Delete(c *gin.Context) {
 // @Param data body dto.WaybillInOutReq true "body"
 // @Success 200 {string} string	"{"code": 200, "message": "删除成功"}"
 // @Success 200 {string} string	"{"code": -1, "message": "删除失败"}"
-// @Router /api/waybill/car-out [post]
+// @Router /api/waybill/receipt [post]
 // @Security Bearer
 func (e WaybillController) Receipt(c *gin.Context) {
 	s := service.Waybill{}
@@ -706,7 +708,7 @@ func (e WaybillController) Receipt(c *gin.Context) {
 // @Param data body dto.WaybillReceiptReq true "body"
 // @Success 200 {string} string	"{"code": 200, "message": "删除成功"}"
 // @Success 200 {string} string	"{"code": -1, "message": "删除失败"}"
-// @Router /api/waybill/car-out [post]
+// @Router /api/waybill/customer/receipt [post]
 // @Security Bearer
 func (e WaybillController) CustomerReceipt(c *gin.Context) {
 	s := service.Waybill{}
@@ -736,7 +738,11 @@ func (e WaybillController) CustomerReceipt(c *gin.Context) {
 // @Summary 获取客户运单列表
 // @Description 获取客户运单列表
 // @Tags 运单
-// @Param no query string false "运单号"
+// @Param waybillNo query string false "运单号"
+// @Param orderNo query string false "订单号"
+// @Param status query int false "状态"
+// @Param orderStartTime query string false "下单开始时间"
+// @Param orderEndTime query string false "下单结束时间"
 // @Param pageSize query int false "页条数"
 // @Param page query int false "页码"
 // @Success 200 {object} response.Response{data=response.Page{list=[]model.Waybill}} "{"code": 200, "data": [...]}"
@@ -770,6 +776,20 @@ func (e WaybillController) GetCustomerPage(c *gin.Context) {
 	e.PageOK(list, int(count), req.GetPageIndex(), req.GetPageSize(), "查询成功")
 }
 
+// CustomerExport 导出客户运单列表
+// @Summary 导出客户运单列表
+// @Description 导出客户运单列表
+// @Tags 运单
+// @Param waybillNo query string false "运单号"
+// @Param orderNo query string false "订单号"
+// @Param status query int false "状态"
+// @Param orderStartTime query string false "下单开始时间"
+// @Param orderEndTime query string false "下单结束时间"
+// @Param pageSize query int false "页条数"
+// @Param page query int false "页码"
+// @Success 200 {object} response.Response{data=response.Page{list=[]model.Waybill}} "{"code": 200, "data": [...]}"
+// @Router /api/waybill/customer/export [get]
+// @Security Bearer
 func (e WaybillController) CustomerExport(c *gin.Context) {
 	s := service.Waybill{}
 	req := dto.WaybillGetCustomerPageReq{}
@@ -905,7 +925,7 @@ func (e WaybillController) CustomerInsert(c *gin.Context) {
 		e.Error(500, err, err.Error())
 		return
 	}
-	e.OK(req.GetId(), "创建成功")
+	e.OK(req.GetId(), "添加成功")
 }
 
 // Import 导入运单
@@ -914,7 +934,7 @@ func (e WaybillController) CustomerInsert(c *gin.Context) {
 // @Tags 运单
 // @Accept  application/json
 // @Product application/json
-// @Param data body dto.WaybillInsertReq true "data"
+// @Param data body dto.WaybillImportReq true "data"
 // @Success 200 {string} string	"{"code": 200, "message": "添加成功"}"
 // @Success 200 {string} string	"{"code": -1, "message": "添加失败"}"
 // @Router /api/waybill/import [post]
@@ -1021,10 +1041,9 @@ func (e WaybillController) Import(c *gin.Context) {
 // @Tags 运单
 // @Accept  application/json
 // @Product application/json
-// @Param data body dto.WaybillInsertReq true "data"
 // @Success 200 {string} string	"{"code": 200, "message": "添加成功"}"
 // @Success 200 {string} string	"{"code": -1, "message": "添加失败"}"
-// @Router /api/waybill/export-template [post]
+// @Router /api/waybill/export-template [get]
 // @Security Bearer
 func (e WaybillController) ExportTemplate(c *gin.Context) {
 	s := service.Waybill{}
@@ -1064,10 +1083,10 @@ func (e WaybillController) ExportTemplate(c *gin.Context) {
 // @Tags 运单
 // @Accept  application/json
 // @Product application/json
-// @Param data body dto.WaybillInsertReq true "data"
+// @Param data body dto.WaybillGetByWaybillPdfReq true "data"
 // @Success 200 {string} string	"{"code": 200, "message": "添加成功"}"
 // @Success 200 {string} string	"{"code": -1, "message": "添加失败"}"
-// @Router /api/waybill/temperature-pdf [post]
+// @Router /api/waybill/temperature-pdf [get]
 // @Security Bearer
 func (e WaybillController) TemperaturePDF(c *gin.Context) {
 	s := service.Waybill{}

+ 2 - 4
app/admin/controller/waybill_logistics.go

@@ -18,9 +18,8 @@ type WaybillLogisticsController struct {
 // @Summary 获取运单列表
 // @Description 获取运单列表
 // @Tags 运单
-// @Param no query string false "运单号"
-// @Param pageSize query int false "页条数"
-// @Param page query int false "页码"
+// @Param waybillNo query string true "运单号"
+// @Param status query string false "状态"
 // @Success 200 {object} response.Response{data=response.Page{list=[]model.WaybillLogistics}} "{"code": 200, "data": [...]}"
 // @Router /api/waybill [get]
 // @Security Bearer
@@ -46,6 +45,5 @@ func (e WaybillLogisticsController) GetPage(c *gin.Context) {
 		e.Error(500, err, err.Error())
 		return
 	}
-	//e.PageOK(list, int(count), req.GetPageIndex(), req.GetPageSize(), "查询成功")
 	e.PageOK(list, int(count), 0, 0, "查询成功")
 }

+ 15 - 5
app/admin/controller/waybill_task.go

@@ -19,7 +19,7 @@ type WaybillTaskController struct {
 // @Summary 获取运单任务列表
 // @Description 获取运单任务列表
 // @Tags 运单任务
-// @Param no query string true "运单号"
+// @Param waybillNo query string true "运单号"
 // @Success 200 {object} response.Response{data=response.Page{list=[]model.WaybillTask}} "{"code": 200, "data": [...]}"
 // @Router /api/waybill-task [get]
 // @Security Bearer
@@ -50,8 +50,8 @@ func (e WaybillTaskController) GetPage(c *gin.Context) {
 }
 
 // GetData 获取温湿度记录
-// @Summary 获取传感器列表
-// @Description 获取传感器列表
+// @Summary 获取温湿度记录
+// @Description 获取温湿度记录
 // @Tags 运单任务
 // @Accept  application/json
 // @Product application/json
@@ -90,9 +90,9 @@ func (e WaybillTaskController) GetData(c *gin.Context) {
 // @Tags 运单任务
 // @Accept  application/json
 // @Product application/json
-// @Param data body dto.WaybillTaskGetDataPageReq true "body"
+// @Param data body dto.WaybillTaskGetNewestDataPageReq true "body"
 // @Success 200 {object} response.Response{data=response.Page{list=[]model.WaybillTask}} "{"code": 200, "data": [...]}"
-// @Router /api/waybill-task/data [post]
+// @Router /api/waybill-task/newest-locus [post]
 // @Security Bearer
 func (e WaybillTaskController) GetNewestData(c *gin.Context) {
 	s := service.WaybillTask{}
@@ -118,6 +118,16 @@ func (e WaybillTaskController) GetNewestData(c *gin.Context) {
 	e.OK(data, "查询成功")
 }
 
+// GetLocus 获取轨迹信息
+// @Summary 获取轨迹信息
+// @Description 获取轨迹信息
+// @Tags 运单任务
+// @Accept  application/json
+// @Product application/json
+// @Param data body dto.WaybillTaskGetNewestDataPageReq true "body"
+// @Success 200 {object} response.Response{data=response.Page{list=[]model.WaybillTask}} "{"code": 200, "data": [...]}"
+// @Router /api/waybill-task/locus [post]
+// @Security Bearer
 func (e WaybillTaskController) GetLocus(c *gin.Context) {
 	s := service.WaybillTask{}
 	req := dto.WaybillGetLocusReq{}

+ 80 - 0
app/admin/controller/weian.go

@@ -0,0 +1,80 @@
+package controller
+
+import (
+	"cold-delivery/app/admin/model"
+	"cold-delivery/app/admin/service"
+	"cold-delivery/app/admin/service/dto"
+	"cold-delivery/conf"
+	"encoding/json"
+	"github.com/gin-gonic/gin"
+	"github.com/gin-gonic/gin/binding"
+	"github.com/go-resty/resty/v2"
+	"gogs.baozhida.cn/zoie/OAuth-core/api"
+	_ "gogs.baozhida.cn/zoie/OAuth-core/pkg/response"
+)
+
+type WeianController struct {
+	api.Api
+}
+
+// Get 获取维安智配送订单详情
+// @Summary 获取维安智配送订单详情
+// @Description 获取维安智配送订单详情
+// @Tags 维安智配送
+// @Param no query string false "订单号"
+// @Success 200 {object} response.Response{data=response.Page{list=[]model.Waybill}} "{"code": 200, "data": [...]}"
+// @Router /api/waybill [get]
+// @Security Bearer
+func (e WeianController) GetOrderInfo(c *gin.Context) {
+	s := service.Waybill{}
+	req := dto.WeianGetOrderInfoReq{}
+	err := e.MakeContext(c).
+		MakeOrm().
+		Bind(&req, binding.Query).
+		MakeService(&s.Service).
+		Errors
+	if err != nil {
+		e.Logger.Error(err)
+		e.Error(500, err, err.Error())
+		return
+	}
+
+	client := resty.New()
+	resp, err := client.R().
+		SetQueryParams(map[string]string{
+			"orderId": req.OrderId,
+		}).
+		Get(conf.ExtConfig.Weian.OrderInfoUrl)
+
+	if err != nil {
+		e.Logger.Error(err)
+		e.Error(500, err, "获取维安智配送订单信息失败")
+		return
+	}
+	var info model.WeianOrderResponse
+
+	if err = json.Unmarshal(resp.Body(), &info); err != nil {
+		e.Error(500, err, "获取药品扫码信息失败")
+		return
+	}
+	if info.Code != 200 {
+		e.Error(500, err, info.Msg)
+		return
+	}
+
+	e.OK(info.Data, "查询成功")
+}
+func (e WeianController) Test(c *gin.Context) {
+	s := service.Waybill{}
+	err := e.MakeContext(c).
+		MakeOrm().
+		MakeService(&s.Service).
+		Errors
+	if err != nil {
+		e.Logger.Error(err)
+		e.Error(500, err, err.Error())
+		return
+	}
+
+	e.OK(nil, "查询成功")
+}

+ 0 - 33
app/admin/model/car.go

@@ -1,33 +0,0 @@
-package model
-
-import (
-	model2 "cold-delivery/common/model"
-)
-
-// 仓库
-type Car struct {
-	model2.Model
-	CarNo     string            `json:"carNo" gorm:"size:128"`                                // 商品名称
-	Sn        string            `json:"sn" gorm:"size:128"`                                   // sn
-	Status    string            `json:"status" gorm:"size:4;not null;default:'2';comment:状态"` // 1-停用 2-正常
-	UserId    int               `json:"userId" gorm:"size:255;"`                              // 司机id
-	HistorySn model2.StringList `json:"historySn"`                                            // 历史绑定的sn
-	User      SysUserOmit       `json:"user"`
-	model2.ControlBy
-	model2.ModelTime
-	model2.DeptBy
-}
-
-type CarOmit struct {
-	Id     int         `json:"id,omitempty"`     // 主键编码
-	CarNo  string      `json:"carNo,omitempty"`  // 商品名称
-	UserId int         `json:"userId,omitempty"` // 仓管id
-	User   SysUserOmit `json:"user,omitempty"`
-}
-
-func (Car) TableName() string {
-	return "car"
-}
-func (CarOmit) TableName() string {
-	return "car"
-}

+ 0 - 32
app/admin/model/warehouse.go

@@ -1,32 +0,0 @@
-package model
-
-import model2 "cold-delivery/common/model"
-
-// 仓库
-type Warehouse struct {
-	model2.Model
-	Name      string            `json:"name" gorm:"size:128"`                                 // 商品名称
-	Sn        string            `json:"sn" gorm:"size:128"`                                   // sn
-	Address   string            `json:"address" gorm:"size:255;"`                             // 地址
-	Status    string            `json:"status" gorm:"size:4;not null;default:'2';comment:状态"` // 1-停用 2-正常
-	UserId    int               `json:"userId" gorm:"size:255;"`                              // 仓管id
-	HistorySn model2.StringList `json:"historySn"`                                            // 历史绑定的sn
-
-	User SysUserOmit `json:"user"`
-	model2.ControlBy
-	model2.ModelTime
-	model2.DeptBy
-}
-type WarehouseOmit struct {
-	Id     int         `json:"id,omitempty"`     // 主键编码
-	Name   string      `json:"name,omitempty"`   // 商品名称
-	UserId int         `json:"userId,omitempty"` // 仓管id
-	User   SysUserOmit `json:"user,omitempty"`
-}
-
-func (Warehouse) TableName() string {
-	return "warehouse"
-}
-func (WarehouseOmit) TableName() string {
-	return "warehouse"
-}

+ 57 - 0
app/admin/model/weian.go

@@ -0,0 +1,57 @@
+package model
+
+type WeianOrderResponse struct {
+	Msg  string     `json:"msg"`
+	Code int        `json:"code"`
+	Data WeianOrder `json:"data"`
+}
+
+type WeianOrder struct {
+	OrderID              string                 `json:"orderId"`              //订单编号
+	ShopID               int                    `json:"shopId"`               //门店编号
+	ShopName             string                 `json:"shopName"`             //门店名称
+	OrderTime            string                 `json:"orderTime"`            //下单时间
+	ExpectedDeliveryTime string                 `json:"dxpectedDeliveryTime"` //患者要求配送时间
+	DistributionType     int                    `json:"distributionType"`     //配送类型
+	ActualServiceTime    string                 `json:"actualServiceTime"`    //实际送达时间
+	CourierName          string                 `json:"courierName"`          //配送员姓名
+	OrderWay             int                    `json:"orderWay"`             //订单状态(1=未确认,2=待审核,3=待配送,4=已配送,5=已完成,6=取消)
+	OrderRemark          string                 `json:"orderRemark"`          //备注
+	ShippingPersonName   string                 `json:"shippingPersonName"`   //患者姓名
+	PlaceOfDomicile      string                 `json:"placeOfDomicile"`      //医保归属地
+	ShippingAddress      string                 `json:"shippingAddress"`      //收货地址
+	CityIf               int                    `json:"cityif"`               //收货地址为市内\市外(1=市内,2=市外)
+	OrderGoods           []WeianOrderGoods      `json:"orderGoods"`
+	PrescriptionImgs     []WeianPrescriptionImg `json:"prescriptionImgs"`
+}
+
+type WeianOrderGoods struct {
+	ID             string      `json:"id"`
+	OsID           string      `json:"osId"`
+	GoodsID        int         `json:"goodsId"`   //药品编号
+	GoodsName      string      `json:"goodsName"` //药品名称
+	GoodsSize      int         `json:"goodsSize"` //数量
+	ColdChain      interface{} `json:"coldChain"`
+	UnitPrice      float64     `json:"unitPrice"`  // 单价
+	TotalMoney     float64     `json:"totalMoney"` // 总价
+	ImgPath        interface{} `json:"imgPath"`
+	TwoChannelGood interface{} `json:"twoChannelGood"`
+	Remark         *string     `json:"remark"`
+	//CreateBy       interface{} `json:"createBy"`
+	//CreateTime     interface{} `json:"createTime"`
+	//UpdateBy       interface{} `json:"updateBy"`
+	//UpdateTime     interface{} `json:"updateTime"`
+}
+
+type WeianPrescriptionImg struct {
+	ID         int     `json:"id"`
+	OrderID    string  `json:"orderId"`
+	ImgPath    string  `json:"imgPath"` //处方图片地址
+	ImgType    int     `json:"imgType"`
+	UploadTime string  `json:"uploadTime"`
+	Remark     *string `json:"remark"`
+	//CreateBy    interface{} `json:"createBy"`
+	//CreateTime  interface{} `json:"createTime"`
+	//UpdateBy    interface{} `json:"updateBy"`
+	//UpdateTime  interface{} `json:"updateTime"`
+}

+ 0 - 25
app/admin/router/car.go

@@ -1,25 +0,0 @@
-package router
-
-import (
-	"cold-delivery/app/admin/controller"
-	"cold-delivery/common/actions"
-	"github.com/gin-gonic/gin"
-	jwt "gogs.baozhida.cn/zoie/OAuth-core/pkg/jwtauth"
-)
-
-func init() {
-	routerCheckRole = append(routerCheckRole, registerCarRouter)
-}
-
-// 需认证的路由代码
-func registerCarRouter(v1 *gin.RouterGroup, authMiddleware *jwt.GinJWTMiddleware) {
-	cont := controller.CarController{}
-	r := v1.Group("/car").Use(authMiddleware.MiddlewareFunc()).Use(actions.PermissionAction())
-	{
-		r.GET("", cont.GetPage)
-		r.GET("/:id", cont.Get)
-		r.POST("", cont.Insert)
-		r.PUT("", cont.Update)
-		r.DELETE("", cont.Delete)
-	}
-}

+ 10 - 0
app/admin/router/init_router.go

@@ -52,6 +52,9 @@ func InitSysRouter(r *gin.Engine, authMiddleware *jwt.GinJWTMiddleware) *gin.Rou
 	// 需要认证
 	sysCheckRoleRouterInit(g, authMiddleware)
 
+	// openapi
+	sysOpenapiRouter(g, middleware.ApiKeyAuthMiddleware())
+
 	return g
 }
 
@@ -88,3 +91,10 @@ func registerBaseRouter(v1 *gin.RouterGroup, authMiddleware *jwt.GinJWTMiddlewar
 		v1auth.POST("/logout", handler2.LogOut)
 	}
 }
+
+func sysOpenapiRouter(r *gin.RouterGroup, openapiMiddleware gin.HandlerFunc) {
+	v1 := r.Group("/openapi/")
+	for _, f := range routerOpenapi {
+		f(v1, openapiMiddleware)
+	}
+}

+ 1 - 0
app/admin/router/router.go

@@ -7,5 +7,6 @@ import (
 
 var (
 	routerNoCheckRole = make([]func(*gin.RouterGroup), 0)
+	routerOpenapi     = make([]func(v1 *gin.RouterGroup, openapiMiddleware gin.HandlerFunc), 0)
 	routerCheckRole   = make([]func(v1 *gin.RouterGroup, authMiddleware *jwt.GinJWTMiddleware), 0)
 )

+ 0 - 1
app/admin/router/sys_user.go

@@ -20,7 +20,6 @@ func registerSysUserRouter(v1 *gin.RouterGroup, authMiddleware *jwt.GinJWTMiddle
 	r := v1.Group("/sys-user").Use(authMiddleware.MiddlewareFunc()).Use(actions.PermissionAction())
 	{
 		r.GET("", cont.GetPage)
-		r.GET("/bind", cont.GetPageFoeBind)
 		r.GET("/:id", cont.Get)
 		r.POST("", cont.Insert)
 		r.PUT("", cont.Update)

+ 0 - 26
app/admin/router/warehouse.go

@@ -1,26 +0,0 @@
-package router
-
-import (
-	"cold-delivery/app/admin/controller"
-	"cold-delivery/common/actions"
-	"github.com/gin-gonic/gin"
-	jwt "gogs.baozhida.cn/zoie/OAuth-core/pkg/jwtauth"
-)
-
-func init() {
-	routerCheckRole = append(routerCheckRole, registerWarehouseRouter)
-}
-
-// 派费管理
-// 需认证的路由代码
-func registerWarehouseRouter(v1 *gin.RouterGroup, authMiddleware *jwt.GinJWTMiddleware) {
-	cont := controller.WarehouseController{}
-	r := v1.Group("/warehouse").Use(authMiddleware.MiddlewareFunc()).Use(actions.PermissionAction())
-	{
-		r.GET("", cont.GetPage)
-		r.GET("/:id", cont.Get)
-		r.POST("", cont.Insert)
-		r.PUT("", cont.Update)
-		r.DELETE("", cont.Delete)
-	}
-}

+ 0 - 4
app/admin/router/waybill.go

@@ -25,10 +25,6 @@ func registerWaybillRouter(v1 *gin.RouterGroup, authMiddleware *jwt.GinJWTMiddle
 		r.POST("/delivery", cont.Delivery)
 		r.PUT("", cont.Update)
 		r.DELETE("", cont.Delete)
-		//r.POST("/warehouse-in", cont.WarehouseIn)   // 入库
-		//r.POST("/warehouse-out", cont.WarehouseOut) // 出库
-		//r.POST("/car-in", cont.CarIn)               // 装车
-		//r.POST("/car-out", cont.CarOut)             // 下车
 		r.POST("/receipt", cont.Receipt)         // 签收
 		r.GET("/customer", cont.GetCustomerPage) // 客户下单列表
 		r.POST("/customer", cont.CustomerInsert) // 客户下单

+ 31 - 0
app/admin/router/weian.go

@@ -0,0 +1,31 @@
+package router
+
+import (
+	"cold-delivery/app/admin/controller"
+	"cold-delivery/common/actions"
+	"github.com/gin-gonic/gin"
+	jwt "gogs.baozhida.cn/zoie/OAuth-core/pkg/jwtauth"
+)
+
+func init() {
+	routerCheckRole = append(routerCheckRole, registerWeianRouter)
+	routerOpenapi = append(routerOpenapi, registerOpenApiRouter)
+}
+
+// 派费管理
+// 需认证的路由代码
+func registerWeianRouter(v1 *gin.RouterGroup, authMiddleware *jwt.GinJWTMiddleware) {
+	cont := controller.WeianController{}
+	r := v1.Group("/weian").Use(authMiddleware.MiddlewareFunc()).Use(actions.PermissionAction())
+	{
+		r.GET("/orderInfo", cont.GetOrderInfo)
+	}
+}
+
+func registerOpenApiRouter(v1 *gin.RouterGroup, openapiMiddleware gin.HandlerFunc) {
+	cont := controller.WeianController{}
+	r := v1.Group("/weian").Use(openapiMiddleware)
+	{
+		r.GET("/test", cont.Test)
+	}
+}

+ 0 - 281
app/admin/service/car.go

@@ -1,281 +0,0 @@
-package service
-
-import (
-	"cold-delivery/app/admin/model"
-	"cold-delivery/app/admin/service/dto"
-	"cold-delivery/common/actions"
-	cDto "cold-delivery/common/dto"
-	"cold-delivery/common/global"
-	"errors"
-	"gogs.baozhida.cn/zoie/OAuth-core/service"
-	"gorm.io/gorm"
-)
-
-type Car struct {
-	service.Service
-}
-
-func CarIsBindUserScopes(isBind bool) func(db *gorm.DB) *gorm.DB {
-	return func(db *gorm.DB) *gorm.DB {
-		// 未发货
-		if isBind {
-			return db.Where("user_id > 0")
-		}
-		return db
-	}
-}
-
-// GetPage 获取Car列表
-func (e *Car) GetPage(c *dto.CarGetPageReq, list *[]model.Car, count *int64, p *actions.DataPermission) error {
-	var err error
-	var data model.Car
-
-	err = e.Orm.Model(&data).
-		Scopes(
-			cDto.MakeCondition(c.GetNeedSearch()),
-			cDto.Paginate(c.GetPageSize(), c.GetPageIndex()),
-			actions.Permission(data.TableName(), p),
-			CarIsBindUserScopes(c.IsBind),
-		).
-		Joins("User").
-		Where("car_no like ? or User.nick_name like ?", "%"+c.Name+"%", "%"+c.Name+"%").
-		Find(list).Limit(-1).Offset(-1).
-		Count(count).Error
-	if err != nil {
-		e.Log.Errorf("db error: %s", err)
-		return global.GetFailedErr
-	}
-	return nil
-}
-
-// Get 获取Car对象
-func (e *Car) Get(d *dto.CarGetReq, carModel *model.Car, p *actions.DataPermission) error {
-	err := e.Orm.
-		Scopes(actions.Permission(carModel.TableName(), p)).
-		Preload("User").
-		First(carModel, d.GetId()).Error
-	if err != nil {
-		e.Log.Errorf("db error: %s", err)
-		if errors.Is(err, gorm.ErrRecordNotFound) {
-			return global.GetNotFoundOrNoPermissionErr
-		}
-		return global.GetFailedErr
-	}
-
-	return nil
-}
-
-// Insert 创建Car对象
-func (e *Car) Insert(c *dto.CarInsertReq) error {
-	var err error
-	var data model.Car
-
-	tx := e.Orm.Begin()
-	defer func() {
-		if err != nil {
-			tx.Rollback()
-		} else {
-			tx.Commit()
-		}
-	}()
-
-	var i int64
-	err = tx.Model(&data).Where("car_no = ?", c.CarNo).Count(&i).Error
-	if err != nil {
-		e.Log.Errorf("db error: %s", err)
-		return global.CreateFailedErr
-	}
-	if i > 0 {
-		err = errors.New("车牌号已存在!")
-		e.Log.Errorf("db error: %s", err)
-		return err
-	}
-	var j int64
-	err = tx.Model(&data).Where("user_id = ?", c.UserId).Count(&j).Error
-	if err != nil {
-		e.Log.Errorf("db error: %s", err)
-		return global.CreateFailedErr
-	}
-	if j > 0 {
-		err = errors.New("该用户已绑定其他车辆!")
-		e.Log.Errorf("db error: %s", err)
-		return err
-	}
-
-	var k int64
-	err = tx.Model(&data).Where("sn = ?", c.Sn).Count(&k).Error
-	if err != nil {
-		e.Log.Errorf("db error: %s", err)
-		return global.CreateFailedErr
-	}
-	if k > 0 {
-		err = errors.New("该Sn已绑定其他车辆!")
-		e.Log.Errorf("db error: %s", err)
-		return err
-	}
-
-	// 添加仓库
-	c.Generate(&data)
-	data.HistorySn = []string{data.Sn}
-	err = tx.Create(&data).Error
-	if err != nil {
-		e.Log.Errorf("db error: %s", err)
-		return global.CreateFailedErr
-	}
-	c.Id = data.Id
-
-	return nil
-
-}
-
-// Update 修改Car对象
-func (e *Car) Update(c *dto.CarUpdateReq, p *actions.DataPermission) error {
-	var err error
-
-	tx := e.Orm.Begin()
-	defer func() {
-		if err != nil {
-			tx.Rollback()
-		} else {
-			tx.Commit()
-		}
-	}()
-
-	var carModel = model.Car{}
-	// 查询仓库是否存在
-	err = e.Orm.Scopes(actions.Permission(carModel.TableName(), p)).
-		First(&carModel, c.GetId()).Error
-	if err != nil {
-		e.Log.Errorf("db error: %s", err)
-		if errors.Is(err, gorm.ErrRecordNotFound) {
-			return global.UpdateNotFoundOrNoPermissionErr
-		}
-		return global.UpdateFailedErr
-	}
-
-	if carModel.Sn != c.Sn {
-		var k int64
-		var data = model.Car{}
-		err = tx.Model(&data).Where("sn = ?", c.Sn).Count(&k).Error
-		if err != nil {
-			e.Log.Errorf("db error: %s", err)
-			return global.CreateFailedErr
-		}
-		if k > 0 {
-			err = errors.New("该Sn已绑定其他车辆!")
-			e.Log.Errorf("db error: %s", err)
-			return err
-		}
-
-		carModel.HistorySn = append(carModel.HistorySn, c.Sn)
-	}
-
-	if carModel.UserId != c.UserId {
-		var k int64
-		var data = model.Car{}
-		err = tx.Model(&data).Where("user_id = ?", c.UserId).Count(&k).Error
-		if err != nil {
-			e.Log.Errorf("db error: %s", err)
-			return global.CreateFailedErr
-		}
-		if k > 0 {
-			err = errors.New("该用户已绑定其他车辆!")
-			e.Log.Errorf("db error: %s", err)
-			return err
-		}
-	}
-
-	c.Generate(&carModel)
-	err = tx.Save(&carModel).Error
-	if err != nil {
-		e.Log.Errorf("db error: %s", err)
-		return global.UpdateFailedErr
-	}
-
-	c.Id = carModel.Id
-	return nil
-}
-
-// Remove 删除Car
-func (e *Car) Remove(c *dto.CarDeleteReq, p *actions.DataPermission) error {
-	var err error
-
-	tx := e.Orm.Begin()
-	defer func() {
-		if err != nil {
-			tx.Rollback()
-		} else {
-			tx.Commit()
-		}
-	}()
-
-	var carModel model.Car
-
-	// 查询仓库是否存在
-	err = e.Orm.Scopes(actions.Permission(carModel.TableName(), p)).
-		First(&carModel, c.GetId()).Error
-	if err != nil {
-		e.Log.Errorf("db error: %s", err)
-		if errors.Is(err, gorm.ErrRecordNotFound) {
-			return global.DeleteNotFoundOrNoPermissionErr
-		}
-		return global.DeleteFailedErr
-	}
-
-	db := tx.Delete(&carModel)
-
-	if err = db.Error; err != nil {
-		e.Log.Errorf("db error: %s", err)
-		return global.DeleteFailedErr
-	}
-	if db.RowsAffected == 0 {
-		return global.DeleteNotFoundOrNoPermissionErr
-	}
-
-	return nil
-}
-
-// GetUserList 获取绑定车辆的用户
-func (e *Car) GetUserList(c *dto.SysUserGetPageReq, p *actions.DataPermission, list *[]model.SysUserForBind, count *int64) error {
-	var err error
-	var userList []model.SysUserForBind
-
-	var carModel model.Car
-	var userModel model.SysUserForBind
-	var userIds []int
-	// 查询仓库是否存在
-	err = e.Orm.Model(&carModel).Select("user_id").Scopes(actions.Permission(carModel.TableName(), p)).
-		Find(&userIds).Error
-	if err != nil {
-		e.Log.Errorf("db error: %s", err)
-		return global.GetFailedErr
-	}
-
-	err = e.Orm.
-		Scopes(
-			cDto.MakeCondition(c.GetNeedSearch()),
-			cDto.Paginate(c.GetPageSize(), c.GetPageIndex()),
-			actions.UserPermission(userModel.TableName(), p),
-		).
-		Where("user_type = ? ", model.UserTypeSys).
-		Find(&userList).Limit(-1).Offset(-1).
-		Count(count).Error
-
-	if err != nil {
-		e.Log.Errorf("db error: %s", err)
-		return global.GetFailedErr
-	}
-	userIdMap := make(map[int]bool)
-	for _, id := range userIds {
-		userIdMap[id] = true
-	}
-
-	for i := 0; i < len(userList); i++ {
-		if _, ok := userIdMap[userList[i].Id]; ok {
-			userList[i].IsBind = true
-		}
-	}
-
-	*list = userList
-	return nil
-}

+ 1 - 14
app/admin/service/customer.go

@@ -229,20 +229,7 @@ func (e *Customer) Remove(c *dto.CustomerDeleteReq, p *actions.DataPermission) e
 		return global.DeleteNotFoundOrNoPermissionErr
 	}
 
-	var car model.Car
-	var j int64
-	err = e.Orm.Model(&car).Where("user_id = ?", c.GetId()).Count(&j).Error
-	if err != nil {
-		e.Log.Errorf("db error: %s", err)
-		return global.CreateFailedErr
-	}
-	if j > 0 {
-		err = errors.New("该用户已绑定车辆,禁止删除!")
-		e.Log.Errorf("db error: %s", err)
-		return err
-	}
-
-	if err := tx.Delete(&data, c.GetId()).Error; err != nil {
+	if err = tx.Delete(&data, c.GetId()).Error; err != nil {
 		if errors.Is(err, model.ErrForbidDeleteSysRole) {
 			return model.ErrForbidDeleteSysRole
 		}

+ 0 - 102
app/admin/service/dto/car.go

@@ -1,102 +0,0 @@
-package dto
-
-import (
-	"cold-delivery/app/admin/model"
-	"cold-delivery/common/dto"
-	common "cold-delivery/common/model"
-)
-
-type CarGetPageReq struct {
-	dto.Pagination `search:"-"`
-	Name           string `form:"name" search:"-"`                               // 车牌号
-	Sn             string `form:"sn" search:"type:contains;column:sn;table:car"` // sn
-	IsBind         bool   `form:"isBind" search:"-"`                             // 是否绑定司机
-	CarOrder
-}
-
-type CarOrder struct {
-	CreatedAtOrder string `search:"type:order;column:created_at;table:car" form:"createdAtOrder" default:"desc"`
-}
-
-func (m *CarGetPageReq) GetNeedSearch() interface{} {
-	return *m
-}
-
-type CarInsertReq struct {
-	Id               int    `json:"id" comment:"编码" swaggerignore:"true"` // 编码
-	CarNo            string `json:"carNo"`                                  // 商品名称
-	Sn               string `json:"sn"`                                     // sn
-	Status           string `json:"status"`                                 // 1-停用 2-正常
-	UserId           int    `json:"userId"`                                 // 绑定的用户id
-	common.ControlBy `swaggerignore:"true"`
-	common.DeptBy    `swaggerignore:"true"`
-}
-
-func (s *CarInsertReq) Generate(model *model.Car) {
-	if s.Id != 0 {
-		model.Id = s.Id
-	}
-	model.CarNo = s.CarNo
-	model.Sn = s.Sn
-	model.Status = s.Status
-	model.UserId = s.UserId
-	if s.ControlBy.UpdateBy != 0 {
-		model.UpdateBy = s.UpdateBy
-	}
-	if s.ControlBy.CreateBy != 0 {
-		model.CreateBy = s.CreateBy
-	}
-	if s.DeptBy.DeptId != 0 {
-		model.DeptId = s.DeptId
-	}
-}
-
-func (s *CarInsertReq) GetId() interface{} {
-	return s.Id
-}
-
-type CarUpdateReq struct {
-	Id               int    `json:"id" comment:"编码"` // 编码
-	CarNo            string `json:"carNo"`             // 商品名称
-	Sn               string `json:"sn"`                // sn
-	Status           string `json:"status"`            // 1-停用 2-正常
-	UserId           int    `json:"userId"`            // 绑定的用户id
-	common.ControlBy `swaggerignore:"true"`
-}
-
-func (s *CarUpdateReq) Generate(model *model.Car) {
-	if s.Id != 0 {
-		model.Id = s.Id
-	}
-	model.CarNo = s.CarNo
-	model.Sn = s.Sn
-	model.Status = s.Status
-	model.UserId = s.UserId
-	if s.ControlBy.UpdateBy != 0 {
-		model.UpdateBy = s.UpdateBy
-	}
-	if s.ControlBy.CreateBy != 0 {
-		model.CreateBy = s.CreateBy
-	}
-}
-
-func (s *CarUpdateReq) GetId() interface{} {
-	return s.Id
-}
-
-type CarGetReq struct {
-	Id int `uri:"id"`
-}
-
-func (s *CarGetReq) GetId() interface{} {
-	return s.Id
-}
-
-type CarDeleteReq struct {
-	Id               int `json:"id"`
-	common.ControlBy `swaggerignore:"true"`
-}
-
-func (s *CarDeleteReq) GetId() interface{} {
-	return s.Id
-}

+ 1 - 1
app/admin/service/dto/customer.go

@@ -10,7 +10,7 @@ type CustomerGetPageReq struct {
 	dto2.Pagination `search:"-"`
 	Username        string `form:"username" search:"type:contains;column:username;table:sys_user" comment:"用户名"`
 	Name            string `form:"name" search:"type:contains;column:nick_name;table:sys_user" comment:"昵称"`
-	Type            int    `form:"type" search:"type:exact;column:type;table:sys_user" comment:"状态"`
+	Type            int    `form:"type" search:"type:exact;column:type;table:sys_user" comment:"累心"`
 	CustomerOrder
 }
 type CustomerOrder struct {

+ 1 - 1
app/admin/service/dto/sys_user.go

@@ -25,7 +25,7 @@ type SysUserGetPageByDeptIdReq struct {
 	dto2.Pagination `search:"-"`
 	Username        string `form:"username" search:"type:contains;column:username;table:sys_user" comment:"用户名"`
 	Name            string `form:"name" search:"type:contains;column:nick_name;table:sys_user" comment:"昵称"`
-	Type            int    `form:"type" search:"type:exact;column:type;table:sys_user" comment:"状态"`
+	Type            int    `form:"type" search:"type:exact;column:type;table:sys_user" comment:"类型"`
 	CompanyId       int    `form:"companyId" search:"-" comment:"公司id"`
 	SysUserOrder
 }

+ 0 - 107
app/admin/service/dto/warehouse.go

@@ -1,107 +0,0 @@
-package dto
-
-import (
-	"cold-delivery/app/admin/model"
-	"cold-delivery/common/dto"
-	common "cold-delivery/common/model"
-)
-
-type WarehouseGetPageReq struct {
-	dto.Pagination `search:"-"`
-	//Code           string `form:"name" search:"type:contains;column:name;table:warehouse"` // 仓库名称
-	Name   string `form:"name" search:"-"`                                     // 仓库名称
-	Sn     string `form:"sn" search:"type:contains;column:sn;table:warehouse"` // sn
-	IsBind bool   `form:"isBind" search:"-"`                                   // 是否绑定司机
-	WarehouseOrder
-}
-
-type WarehouseOrder struct {
-	CreatedAtOrder string `search:"type:order;column:created_at;table:warehouse" form:"createdAtOrder" default:"desc"`
-}
-
-func (m *WarehouseGetPageReq) GetNeedSearch() interface{} {
-	return *m
-}
-
-type WarehouseInsertReq struct {
-	Id               int    `json:"id" comment:"编码" swaggerignore:"true"` // 编码
-	Name             string `json:"name"`                                 // 商品名称
-	Sn               string `json:"sn"`                                   // sn
-	Address          string `json:"address"`                              // 地址
-	Status           string `json:"status"`                               // 1-停用 2-正常
-	UserId           int    `json:"userId"`                               // 绑定的用户id
-	common.ControlBy `swaggerignore:"true"`
-	common.DeptBy    `swaggerignore:"true"`
-}
-
-func (s *WarehouseInsertReq) Generate(model *model.Warehouse) {
-	if s.Id != 0 {
-		model.Id = s.Id
-	}
-	model.Name = s.Name
-	model.Sn = s.Sn
-	model.Status = s.Status
-	model.Address = s.Address
-	model.UserId = s.UserId
-	if s.ControlBy.UpdateBy != 0 {
-		model.UpdateBy = s.UpdateBy
-	}
-	if s.ControlBy.CreateBy != 0 {
-		model.CreateBy = s.CreateBy
-	}
-	if s.DeptBy.DeptId != 0 {
-		model.DeptId = s.DeptId
-	}
-}
-
-func (s *WarehouseInsertReq) GetId() interface{} {
-	return s.Id
-}
-
-type WarehouseUpdateReq struct {
-	Id               int    `json:"id" comment:"编码"` // 编码
-	Name             string `json:"name"`            // 商品名称
-	Sn               string `json:"sn"`              // sn
-	Address          string `json:"address"`         // 地址
-	Status           string `json:"status"`          // 1-停用 2-正常
-	UserId           int    `json:"userId"`          // 绑定的用户id
-	common.ControlBy `swaggerignore:"true"`
-}
-
-func (s *WarehouseUpdateReq) Generate(model *model.Warehouse) {
-	if s.Id != 0 {
-		model.Id = s.Id
-	}
-	model.Name = s.Name
-	model.Sn = s.Sn
-	model.Address = s.Address
-	model.Status = s.Status
-	model.UserId = s.UserId
-	if s.ControlBy.UpdateBy != 0 {
-		model.UpdateBy = s.UpdateBy
-	}
-	if s.ControlBy.CreateBy != 0 {
-		model.CreateBy = s.CreateBy
-	}
-}
-
-func (s *WarehouseUpdateReq) GetId() interface{} {
-	return s.Id
-}
-
-type WarehouseGetReq struct {
-	Id int `uri:"id"`
-}
-
-func (s *WarehouseGetReq) GetId() interface{} {
-	return s.Id
-}
-
-type WarehouseDeleteReq struct {
-	Id               int `json:"id"`
-	common.ControlBy `swaggerignore:"true"`
-}
-
-func (s *WarehouseDeleteReq) GetId() interface{} {
-	return s.Id
-}

+ 1 - 0
app/admin/service/dto/waybill.go

@@ -31,6 +31,7 @@ func (m *WaybillGetPageReq) GetNeedSearch() interface{} {
 type WaybillGetCustomerPageReq struct {
 	dto.Pagination `search:"-"`
 	WaybillNo      string `form:"waybillNo" search:"type:contains;column:waybill_no;table:waybill"`                      // 运单编号
+	OrderNo        string `form:"orderNo" search:"type:contains;column:order_no;table:waybill"`                          // 运单编号
 	Status         int    `form:"status" search:"-"`                                                                     // 状态
 	OrderStartTime string `form:"orderStartTime" search:"type:gte;column:order_time;table:waybill"`                      // 下单开始时间
 	OrderEndTime   string `form:"orderEndTime" search:"type:lte;column:order_time;table:waybill"`                        // 下单结束时间

+ 5 - 0
app/admin/service/dto/weian.go

@@ -0,0 +1,5 @@
+package dto
+
+type WeianGetOrderInfoReq struct {
+	OrderId string `form:"orderId"`
+}

+ 1 - 27
app/admin/service/sys_user.go

@@ -316,33 +316,7 @@ func (e *SysUser) Remove(c *dto.SysUserDeleteReq, p *actions.DataPermission) err
 		return errors.New("禁止删除管理员")
 	}
 
-	var car model.Car
-	var j int64
-	err = e.Orm.Model(&car).Where("user_id = ?", c.GetId()).Count(&j).Error
-	if err != nil {
-		e.Log.Errorf("db error: %s", err)
-		return global.CreateFailedErr
-	}
-	if j > 0 {
-		err = errors.New("该用户已绑定车辆,禁止删除!")
-		e.Log.Errorf("db error: %s", err)
-		return err
-	}
-
-	var warehouse model.Warehouse
-	var k int64
-	err = e.Orm.Model(&warehouse).Where("user_id = ?", c.GetId()).Count(&k).Error
-	if err != nil {
-		e.Log.Errorf("db error: %s", err)
-		return global.CreateFailedErr
-	}
-	if k > 0 {
-		err = errors.New("该用户已绑定仓库,禁止删除!")
-		e.Log.Errorf("db error: %s", err)
-		return err
-	}
-
-	if err := tx.Delete(&data, c.GetId()).Error; err != nil {
+	if err = tx.Delete(&data, c.GetId()).Error; err != nil {
 		if errors.Is(err, model.ErrForbidDeleteSysRole) {
 			return model.ErrForbidDeleteSysRole
 		}

+ 0 - 278
app/admin/service/warehouse.go

@@ -1,278 +0,0 @@
-package service
-
-import (
-	"cold-delivery/app/admin/model"
-	"cold-delivery/app/admin/service/dto"
-	"cold-delivery/common/actions"
-	cDto "cold-delivery/common/dto"
-	"cold-delivery/common/global"
-	"errors"
-	"gogs.baozhida.cn/zoie/OAuth-core/service"
-	"gorm.io/gorm"
-)
-
-type Warehouse struct {
-	service.Service
-}
-
-func WarehouseIsBindUserScopes(isBind bool) func(db *gorm.DB) *gorm.DB {
-	return func(db *gorm.DB) *gorm.DB {
-		// 未发货
-		if isBind {
-			return db.Where("user_id > 0")
-		}
-		return db
-	}
-}
-
-// GetPage 获取Warehouse列表
-func (e *Warehouse) GetPage(c *dto.WarehouseGetPageReq, list *[]model.Warehouse, count *int64, p *actions.DataPermission) error {
-	var err error
-	var data model.Warehouse
-	err = e.Orm.Model(&data).
-		Scopes(
-			cDto.MakeCondition(c.GetNeedSearch()),
-			cDto.Paginate(c.GetPageSize(), c.GetPageIndex()),
-			actions.Permission(data.TableName(), p),
-			WarehouseIsBindUserScopes(c.IsBind),
-		).
-		Joins("User").
-		Where("name like ? or User.nick_name like ?", "%"+c.Name+"%", "%"+c.Name+"%").
-		Find(list).Limit(-1).Offset(-1).
-		Count(count).Error
-	if err != nil {
-		e.Log.Errorf("db error: %s", err)
-		return global.GetFailedErr
-	}
-	return nil
-}
-
-// Get 获取Warehouse对象
-func (e *Warehouse) Get(d *dto.WarehouseGetReq, warehouseModel *model.Warehouse, p *actions.DataPermission) error {
-	err := e.Orm.
-		Scopes(actions.Permission(warehouseModel.TableName(), p)).
-		Preload("User").
-		First(warehouseModel, d.GetId()).Error
-	if err != nil {
-		e.Log.Errorf("db error: %s", err)
-		if errors.Is(err, gorm.ErrRecordNotFound) {
-			return global.GetNotFoundOrNoPermissionErr
-		}
-		return global.GetFailedErr
-	}
-
-	return nil
-}
-
-// Insert 创建Warehouse对象
-func (e *Warehouse) Insert(c *dto.WarehouseInsertReq) error {
-	var err error
-	var data model.Warehouse
-
-	tx := e.Orm.Begin()
-	defer func() {
-		if err != nil {
-			tx.Rollback()
-		} else {
-			tx.Commit()
-		}
-	}()
-
-	var i int64
-	err = tx.Model(&data).Where("name = ? and dept_id = ?", c.Name, c.DeptId).Count(&i).Error
-	if err != nil {
-		e.Log.Errorf("db error: %s", err)
-		return global.CreateFailedErr
-	}
-	if i > 0 {
-		err = errors.New("仓库名已存在!")
-		e.Log.Errorf("db error: %s", err)
-		return err
-	}
-	var j int64
-	err = tx.Model(&data).Where("user_id = ?", c.UserId).Count(&j).Error
-	if err != nil {
-		e.Log.Errorf("db error: %s", err)
-		return global.CreateFailedErr
-	}
-	if j > 0 {
-		err = errors.New("该用户已绑定其他仓库!")
-		e.Log.Errorf("db error: %s", err)
-		return err
-	}
-
-	var k int64
-	err = tx.Model(&data).Where("sn = ?", c.Sn).Count(&k).Error
-	if err != nil {
-		e.Log.Errorf("db error: %s", err)
-		return global.CreateFailedErr
-	}
-	if k > 0 {
-		err = errors.New("该Sn已绑定其他仓库!")
-		e.Log.Errorf("db error: %s", err)
-		return err
-	}
-
-	// 添加仓库
-	c.Generate(&data)
-	data.HistorySn = []string{c.Sn}
-	err = tx.Create(&data).Error
-	if err != nil {
-		e.Log.Errorf("db error: %s", err)
-		return global.CreateFailedErr
-	}
-	c.Id = data.Id
-
-	return nil
-
-}
-
-// Update 修改Warehouse对象
-func (e *Warehouse) Update(c *dto.WarehouseUpdateReq, p *actions.DataPermission) error {
-	var err error
-
-	tx := e.Orm.Begin()
-	defer func() {
-		if err != nil {
-			tx.Rollback()
-		} else {
-			tx.Commit()
-		}
-	}()
-
-	var warehouseModel = model.Warehouse{}
-	// 查询仓库是否存在
-	err = e.Orm.Scopes(actions.Permission(warehouseModel.TableName(), p)).
-		First(&warehouseModel, c.GetId()).Error
-	if err != nil {
-		e.Log.Errorf("db error: %s", err)
-		if errors.Is(err, gorm.ErrRecordNotFound) {
-			return global.UpdateNotFoundOrNoPermissionErr
-		}
-		return global.UpdateFailedErr
-	}
-	if warehouseModel.Sn != c.Sn {
-		var k int64
-		var data = model.Warehouse{}
-		err = tx.Model(&data).Where("sn = ?", c.Sn).Count(&k).Error
-		if err != nil {
-			e.Log.Errorf("db error: %s", err)
-			return global.CreateFailedErr
-		}
-		if k > 0 {
-			err = errors.New("该Sn已绑定其他仓库!")
-			e.Log.Errorf("db error: %s", err)
-			return err
-		}
-		warehouseModel.HistorySn = append(warehouseModel.HistorySn, c.Sn)
-	}
-
-	if warehouseModel.UserId != c.UserId {
-		var k int64
-		var data = model.Warehouse{}
-		err = tx.Model(&data).Where("user_id = ?", c.UserId).Count(&k).Error
-		if err != nil {
-			e.Log.Errorf("db error: %s", err)
-			return global.CreateFailedErr
-		}
-		if k > 0 {
-			err = errors.New("该用户绑定其他仓库!")
-			e.Log.Errorf("db error: %s", err)
-			return err
-		}
-	}
-
-	c.Generate(&warehouseModel)
-	err = tx.Save(&warehouseModel).Error
-	if err != nil {
-		e.Log.Errorf("db error: %s", err)
-		return global.UpdateFailedErr
-	}
-
-	c.Id = warehouseModel.Id
-	return nil
-}
-
-// Remove 删除Warehouse
-func (e *Warehouse) Remove(c *dto.WarehouseDeleteReq, p *actions.DataPermission) error {
-	var err error
-
-	tx := e.Orm.Begin()
-	defer func() {
-		if err != nil {
-			tx.Rollback()
-		} else {
-			tx.Commit()
-		}
-	}()
-
-	var warehouseModel model.Warehouse
-
-	// 查询仓库是否存在
-	err = e.Orm.Scopes(actions.Permission(warehouseModel.TableName(), p)).
-		First(&warehouseModel, c.GetId()).Error
-	if err != nil {
-		e.Log.Errorf("db error: %s", err)
-		if errors.Is(err, gorm.ErrRecordNotFound) {
-			return global.DeleteNotFoundOrNoPermissionErr
-		}
-		return global.DeleteFailedErr
-	}
-
-	db := tx.Delete(&warehouseModel)
-
-	if err = db.Error; err != nil {
-		e.Log.Errorf("db error: %s", err)
-		return global.DeleteFailedErr
-	}
-	if db.RowsAffected == 0 {
-		return global.DeleteNotFoundOrNoPermissionErr
-	}
-
-	return nil
-}
-
-// GetUserList 获取绑定车辆的用户
-func (e *Warehouse) GetUserList(c *dto.SysUserGetPageReq, p *actions.DataPermission, list *[]model.SysUserForBind, count *int64) error {
-	var err error
-	var userList []model.SysUserForBind
-
-	var warehouseModel model.Warehouse
-	var userModel model.SysUserForBind
-	var userIds []int
-	// 查询仓库是否存在
-	err = e.Orm.Model(&warehouseModel).Select("user_id").Scopes(actions.Permission(warehouseModel.TableName(), p)).
-		Find(&userIds).Error
-	if err != nil {
-		e.Log.Errorf("db error: %s", err)
-		return global.GetFailedErr
-	}
-
-	err = e.Orm.
-		Scopes(
-			cDto.MakeCondition(c.GetNeedSearch()),
-			cDto.Paginate(c.GetPageSize(), c.GetPageIndex()),
-			actions.UserPermission(userModel.TableName(), p),
-		).
-		Where("user_type = ? ", model.UserTypeSys).
-		Find(&userList).Limit(-1).Offset(-1).
-		Count(count).Error
-
-	if err != nil {
-		e.Log.Errorf("db error: %s", err)
-		return global.GetFailedErr
-	}
-	userIdMap := make(map[int]bool)
-	for _, id := range userIds {
-		userIdMap[id] = true
-	}
-
-	for i := 0; i < len(userList); i++ {
-		if _, ok := userIdMap[userList[i].Id]; ok {
-			userList[i].IsBind = true
-		}
-	}
-
-	*list = userList
-	return nil
-}

+ 1 - 1
common/actions/create.go

@@ -43,7 +43,7 @@ func CreateAction(control dto.Control) gin.HandlerFunc {
 			response.Error(c, 500, err, "创建失败")
 			return
 		}
-		response.OK(c, object.GetId(), "创建成功")
+		response.OK(c, object.GetId(), "添加成功")
 		c.Next()
 	}
 }

+ 1 - 1
common/actions/update.go

@@ -53,7 +53,7 @@ func UpdateAction(control dto.Control) gin.HandlerFunc {
 			response.Error(c, http.StatusForbidden, nil, "无权更新该数据")
 			return
 		}
-		response.OK(c, object.GetId(), "更新成功")
+		response.OK(c, object.GetId(), "修改成功")
 		c.Next()
 	}
 }

+ 77 - 0
common/middleware/openapi.go

@@ -0,0 +1,77 @@
+package middleware
+
+import (
+	"crypto/hmac"
+	"crypto/sha256"
+	"encoding/hex"
+	"errors"
+	"github.com/gin-gonic/gin"
+	"gogs.baozhida.cn/zoie/OAuth-core/pkg/response"
+	"net/http"
+	"strconv"
+	"time"
+)
+
+const apiKeyHeader = "X-API-KEY"
+const apiSignatureHeader = "X-API-SIGNATURE"
+const apiTimestampHeader = "X-API-TIMESTAMP"
+
+// 这些 API Key 和 Secret 应该存储在安全的存储中,例如数据库或配置文件
+var validAPIKeys = map[string]string{
+	"01HsBYiG": "A8CDJ1GQW4XNB3SZY7PKT92R6LQV8FW5",
+}
+
+// 验证签名是否有效
+func isValidSignature(apiKey, signature, timestamp string) bool {
+	// 使用提供的 API Key 查找对应的 API Secret
+	secret, ok := validAPIKeys[apiKey]
+	if !ok {
+		return false
+	}
+
+	// 计算签名,签名内容是 "apiKey + timestamp"
+	message := apiKey + timestamp
+	mac := hmac.New(sha256.New, []byte(secret))
+	mac.Write([]byte(message))
+	expectedSignature := hex.EncodeToString(mac.Sum(nil))
+
+	// 验证客户端提供的签名是否与预期签名匹配
+	return hmac.Equal([]byte(signature), []byte(expectedSignature))
+}
+
+// AuthCheckRole 权限检查中间件
+func ApiKeyAuthMiddleware() gin.HandlerFunc {
+
+	return func(c *gin.Context) {
+		apiKey := c.GetHeader(apiKeyHeader)
+		signature := c.GetHeader(apiSignatureHeader)
+		timestamp := c.GetHeader(apiTimestampHeader)
+
+		// 检查 API Key, 签名和时间戳是否存在
+		if apiKey == "" || signature == "" || timestamp == "" {
+			err := errors.New("API Key, Signature, and Timestamp required")
+			response.Error(c, http.StatusUnauthorized, err, err.Error())
+			return
+		}
+
+		// 校验请求的签名是否有效
+		if !isValidSignature(apiKey, signature, timestamp) {
+			err := errors.New("Invalid Signature")
+			response.Error(c, http.StatusForbidden, err, err.Error())
+			return
+		}
+
+		// 校验时间戳是否在合理范围内(防止重放攻击)
+		sec, _ := strconv.ParseInt(timestamp, 10, 64)
+		reqTime := time.Unix(sec, 0)
+		if time.Since(reqTime) > 5*time.Minute {
+			err := errors.New("Request too old or invalid timestamp")
+			response.Error(c, http.StatusForbidden, err, err.Error())
+			return
+		}
+		// 如果鉴权成功,继续处理请求
+		c.Next()
+		return
+	}
+
+}

+ 4 - 0
conf/extend.go

@@ -16,6 +16,7 @@ type Extend struct {
 	Nats    Nats    `yaml:"nats"`
 	Amap    Amap    `yaml:"amap"`
 	Apk     Apk     `yaml:"apk"`
+	Weian   Weian   `yaml:"weian"`
 }
 
 type SubMail struct {
@@ -49,3 +50,6 @@ type Amap struct {
 type Apk struct {
 	Path string `json:"path"`
 }
+type Weian struct {
+	OrderInfoUrl string `json:"orderInfoUrl"`
+}

+ 14 - 1
conf/settings.yml

@@ -50,4 +50,17 @@ settings:
       endpoint: "https://bzdcdn.baozhida.cn/"
       accessKeyID: "-8ezB_d-8-eUFTMvhOGbGzgeQRPeKQnaQ3DBcUxo"
       accessKeySecret: "KFhkYxTAJ2ZPN3ZS3euTsfWk8-C92rKgkhAMkDRN"
-      bucketName: "bzdcdn"
+      bucketName: "bzdcdn"
+    applet:
+      appid: "wx7d2f59a537c6ffdd"
+      appSecret: "b6ae826c8c64dd246e8bd8c281c33bde"
+      tokenExpire: 30
+      waybillUrl: "https://coldlogistics.coldbaozhida.com/newInquiry?waybillNo="
+    nats:
+      url: "127.0.0.1:43422"
+    amap:
+      key: "c3dbf424f12240b2de8ace32893c1aa2"
+    apk:
+      path: "/Users/zoie/work/bzd_project/cold-delivery/ofile"
+    weian:
+      orderInfoUrl: "http://127.0.0.1:4523/m2/4530431-0-default/215455750"

+ 0 - 2
db/migration.go

@@ -20,10 +20,8 @@ func AutoMigrateDB() {
 			&model.SysDept{},
 			&model.SysLoginLog{},
 			&model.SysOperaLog{},
-			//&model.Warehouse{},
 			&model.Address{},
 			&model.AddressDefault{},
-			//&model.Car{},
 			&model.CoolerBox{},
 			&model.Waybill{},
 			&model.WaybillLogistics{},

+ 167 - 0
openapi.md

@@ -0,0 +1,167 @@
+### 基于 HMAC 的 API Key + Secret 鉴权实现
+
+#### 1. 导入相关依赖
+
+```go
+package main
+
+import (
+    "crypto/hmac"
+    "crypto/sha256"
+    "encoding/hex"
+    "fmt"
+    "log"
+    "net/http"
+    "time"
+)
+
+const apiKeyHeader = "X-API-KEY"
+const apiSignatureHeader = "X-API-SIGNATURE"
+const apiTimestampHeader = "X-API-TIMESTAMP"
+
+// 这些 API Key 和 Secret 应该存储在安全的存储中,例如数据库或配置文件
+var validAPIKeys = map[string]string{
+    "your-api-key": "your-api-secret",
+}
+
+// 验证签名是否有效
+func isValidSignature(apiKey, signature, timestamp string) bool {
+    // 使用提供的 API Key 查找对应的 API Secret
+    secret, ok := validAPIKeys[apiKey]
+    if !ok {
+        return false
+    }
+
+    // 计算签名,签名内容是 "apiKey + timestamp"
+    message := apiKey + timestamp
+    mac := hmac.New(sha256.New, []byte(secret))
+    mac.Write([]byte(message))
+    expectedSignature := hex.EncodeToString(mac.Sum(nil))
+
+    // 验证客户端提供的签名是否与预期签名匹配
+    return hmac.Equal([]byte(signature), []byte(expectedSignature))
+}
+
+func apiKeyAuthMiddleware(next http.Handler) http.Handler {
+    return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+        apiKey := r.Header.Get(apiKeyHeader)
+        signature := r.Header.Get(apiSignatureHeader)
+        timestamp := r.Header.Get(apiTimestampHeader)
+
+        // 检查 API Key, 签名和时间戳是否存在
+        if apiKey == "" || signature == "" || timestamp == "" {
+            http.Error(w, "API Key, Signature, and Timestamp required", http.StatusUnauthorized)
+            return
+        }
+
+        // 校验请求的签名是否有效
+        if !isValidSignature(apiKey, signature, timestamp) {
+            http.Error(w, "Invalid Signature", http.StatusForbidden)
+            return
+        }
+
+        // 校验时间戳是否在合理范围内(防止重放攻击)
+        reqTime, err := time.Parse(time.RFC3339, timestamp)
+        if err != nil || time.Since(reqTime) > 5*time.Minute {
+            http.Error(w, "Request too old or invalid timestamp", http.StatusForbidden)
+            return
+        }
+
+        // 如果鉴权成功,继续处理请求
+        next.ServeHTTP(w, r)
+    })
+}
+
+func helloHandler(w http.ResponseWriter, r *http.Request) {
+    fmt.Fprintf(w, "Hello, World!")
+}
+
+func main() {
+    // 路由定义
+    mux := http.NewServeMux()
+
+    // 在 API 处理器中使用中间件进行鉴权
+    mux.Handle("/", apiKeyAuthMiddleware(http.HandlerFunc(helloHandler)))
+
+    // 启动服务器
+    log.Println("Server starting on :8080")
+    log.Fatal(http.ListenAndServe(":8080", mux))
+}
+```
+
+#### 2. 代码详解
+
+##### 1. **HMAC 签名验证**
+   - 使用 `HMAC-SHA256` 算法来对请求进行签名。服务器和客户端都需要拥有一对 **API Key** 和 **API Secret**。客户端用它们生成签名,服务端用相同的算法生成签名来进行比对。
+   - 具体流程如下:
+     1. 服务器通过 `apiKey` 在内存或数据库中查找对应的 `secret`。
+     2. 服务器生成一个字符串,这个字符串由 `apiKey` 和 `timestamp` 组成。
+     3. 使用 `HMAC-SHA256` 算法生成签名。
+     4. 将生成的签名与客户端提供的签名进行对比,若匹配则鉴权通过。
+
+##### 2. **防止重放攻击**
+   - 在请求头中加入一个时间戳 `X-API-TIMESTAMP`,服务器验证时间戳是否在当前时间的合理范围内(例如5分钟内)。这有助于防止旧请求被恶意重放。
+
+##### 3. **主函数**
+   - 服务器的每个请求都会通过 `apiKeyAuthMiddleware` 中间件来进行 API Key、签名以及时间戳的校验。
+   - 如果签名和时间戳都有效,允许请求继续处理,否则返回 `401` 或 `403` 错误。
+
+#### 3. 客户端请求的生成方法
+
+客户端在发出请求时,需要生成以下内容:
+1. **API Key**: 作为请求头的一部分发送,表示客户端的身份。
+2. **时间戳**: 使用 RFC3339 格式化的当前时间(例如 `"2024-09-20T12:00:00Z"`)。
+3. **签名**: 使用 HMAC-SHA256 算法生成的签名,签名的内容是 `apiKey + timestamp` 的组合,密钥为该客户端的 API Secret。
+
+以下是客户端伪代码示例(可以用任意语言实现):
+
+```go
+import (
+    "crypto/hmac"
+    "crypto/sha256"
+    "encoding/hex"
+    "net/http"
+    "time"
+)
+
+func generateSignature(apiKey, apiSecret, timestamp string) string {
+    message := apiKey + timestamp
+    mac := hmac.New(sha256.New, []byte(apiSecret))
+    mac.Write([]byte(message))
+    return hex.EncodeToString(mac.Sum(nil))
+}
+
+func makeRequest() {
+    apiKey := "your-api-key"
+    apiSecret := "your-api-secret"
+    timestamp := time.Now().UTC().Format(time.RFC3339)
+    signature := generateSignature(apiKey, apiSecret, timestamp)
+
+    req, _ := http.NewRequest("GET", "http://localhost:8080", nil)
+    req.Header.Set("X-API-KEY", apiKey)
+    req.Header.Set("X-API-TIMESTAMP", timestamp)
+    req.Header.Set("X-API-SIGNATURE", signature)
+
+    client := &http.Client{}
+    res, _ := client.Do(req)
+    defer res.Body.Close()
+    // 处理响应
+}
+```
+
+#### 4. 测试流程
+
+在服务启动后,你可以通过命令行或代码发出请求,携带 API Key、时间戳、签名等。
+
+```bash
+curl -H "X-API-KEY: your-api-key" \
+     -H "X-API-TIMESTAMP: 2024-09-20T12:00:00Z" \
+     -H "X-API-SIGNATURE: <计算出的签名>" \
+     http://localhost:8080/
+```
+
+如果鉴权成功,返回 `"Hello, World!"`;否则会返回 `401 Unauthorized` 或 `403 Forbidden` 错误。
+
+### 总结
+
+通过使用 HMAC 签名,你可以大大提升 API 鉴权的安全性,并防止重放攻击。

+ 2 - 0
setting.yml

@@ -62,4 +62,6 @@ settings:
       key: "c3dbf424f12240b2de8ace32893c1aa2"
     apk:
       path: "/Users/zoie/work/bzd_project/cold-delivery/ofile"
+    weian:
+      orderInfoUrl: "http://127.0.0.1:4523/m2/4530431-0-default/215455750"