修改customer文件位restful模式 提供示例
This commit is contained in:
@@ -17,7 +17,7 @@ import (
|
||||
// @Produce application/json
|
||||
// @Param data body model.ExaCustomer true "创建客户"
|
||||
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
|
||||
// @Router /customer/createExaCustomer [post]
|
||||
// @Router /customer/customer [post]
|
||||
func CreateExaCustomer(c *gin.Context) {
|
||||
var cu model.ExaCustomer
|
||||
_ = c.ShouldBindJSON(&cu)
|
||||
@@ -40,7 +40,7 @@ func CreateExaCustomer(c *gin.Context) {
|
||||
// @Produce application/json
|
||||
// @Param data body model.ExaCustomer true "删除客户"
|
||||
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
|
||||
// @Router /customer/deleteExaCustomer [post]
|
||||
// @Router /customer/customer [delete]
|
||||
func DeleteExaCustomer(c *gin.Context) {
|
||||
var cu model.ExaCustomer
|
||||
_ = c.ShouldBindJSON(&cu)
|
||||
@@ -59,7 +59,7 @@ func DeleteExaCustomer(c *gin.Context) {
|
||||
// @Produce application/json
|
||||
// @Param data body model.ExaCustomer true "创建客户"
|
||||
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
|
||||
// @Router /customer/updateExaCustomer [post]
|
||||
// @Router /customer/customer [put]
|
||||
func UpdateExaCustomer(c *gin.Context) {
|
||||
var cu model.ExaCustomer
|
||||
_ = c.ShouldBindJSON(&cu)
|
||||
@@ -78,10 +78,10 @@ func UpdateExaCustomer(c *gin.Context) {
|
||||
// @Produce application/json
|
||||
// @Param data body model.ExaCustomer true "获取单一客户信息"
|
||||
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
|
||||
// @Router /customer/getExaCustomer [post]
|
||||
// @Router /customer/customer [get]
|
||||
func GetExaCustomer(c *gin.Context) {
|
||||
var cu model.ExaCustomer
|
||||
_ = c.ShouldBindJSON(&cu)
|
||||
_ = c.ShouldBindQuery(&cu)
|
||||
err, customer := service.GetExaCustomer(cu.ID)
|
||||
if err != nil {
|
||||
response.FailWithMessage(fmt.Sprintf("获取失败:%v", err), c)
|
||||
@@ -97,12 +97,12 @@ func GetExaCustomer(c *gin.Context) {
|
||||
// @Produce application/json
|
||||
// @Param data body model.PageInfo true "获取权限客户列表"
|
||||
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
|
||||
// @Router /customer/getExaCustomerList [post]
|
||||
// @Router /customer/customerList [get]
|
||||
func GetExaCustomerList(c *gin.Context) {
|
||||
claims, _ := c.Get("claims")
|
||||
waitUse := claims.(*request.CustomClaims)
|
||||
var pageInfo request.PageInfo
|
||||
_ = c.ShouldBindJSON(&pageInfo)
|
||||
_ = c.ShouldBindQuery(&pageInfo)
|
||||
err, customerList, total := service.GetCustomerInfoList(waitUse.AuthorityId, pageInfo)
|
||||
if err != nil {
|
||||
response.FailWithMessage(fmt.Sprintf("获取失败:%v", err), c)
|
||||
|
||||
@@ -6,9 +6,9 @@ import (
|
||||
|
||||
type ExaCustomer struct {
|
||||
gorm.Model
|
||||
CustomerName string `json:"customerName"`
|
||||
CustomerPhoneData string `json:"customerPhoneData"`
|
||||
SysUserID uint `json:"sysUserId"`
|
||||
SysUserAuthorityID string `json:"sysUserAuthorityID"`
|
||||
SysUser SysUser `json:"sysUser"`
|
||||
CustomerName string `json:"customerName" form:"customerName"`
|
||||
CustomerPhoneData string `json:"customerPhoneData" form:"customerPhoneData"`
|
||||
SysUserID uint `json:"sysUserId" form:"sysUserId"`
|
||||
SysUserAuthorityID string `json:"sysUserAuthorityID" form:"sysUserAuthorityID"`
|
||||
SysUser SysUser `json:"sysUser" form:"sysUser"`
|
||||
}
|
||||
@@ -2,11 +2,11 @@ package request
|
||||
|
||||
// Paging common input parameter structure
|
||||
type PageInfo struct {
|
||||
Page int `json:"page"`
|
||||
PageSize int `json:"pageSize"`
|
||||
Page int `json:"page" form:"page"`
|
||||
PageSize int `json:"pageSize" form:"pageSize"`
|
||||
}
|
||||
|
||||
// Find by id structure
|
||||
type GetById struct {
|
||||
Id float64 `json:"id"`
|
||||
Id float64 `json:"id" form:"id"`
|
||||
}
|
||||
|
||||
@@ -11,4 +11,4 @@ g = _, _
|
||||
e = some(where (p.eft == allow))
|
||||
|
||||
[matchers]
|
||||
m = r.sub == p.sub && r.obj == p.obj && r.act == p.act
|
||||
m = r.sub == p.sub && ParamsMatch(r.obj,p.obj) && r.act == p.act
|
||||
|
||||
@@ -9,10 +9,10 @@ import (
|
||||
func InitCustomerRouter(Router *gin.RouterGroup) {
|
||||
ApiRouter := Router.Group("customer").Use(middleware.JWTAuth()).Use(middleware.CasbinHandler())
|
||||
{
|
||||
ApiRouter.POST("createExaCustomer", v1.CreateExaCustomer) // 创建客户
|
||||
ApiRouter.POST("updateExaCustomer", v1.UpdateExaCustomer) // 更新客户
|
||||
ApiRouter.POST("deleteExaCustomer", v1.DeleteExaCustomer) // 删除客户
|
||||
ApiRouter.POST("getExaCustomer", v1.GetExaCustomer) // 获取单一客户信息
|
||||
ApiRouter.POST("getExaCustomerList", v1.GetExaCustomerList) // 获取客户列表
|
||||
ApiRouter.POST("customer", v1.CreateExaCustomer) // 创建客户
|
||||
ApiRouter.PUT("customer", v1.UpdateExaCustomer) // 更新客户
|
||||
ApiRouter.DELETE("customer", v1.DeleteExaCustomer) // 删除客户
|
||||
ApiRouter.GET("customer", v1.GetExaCustomer) // 获取单一客户信息
|
||||
ApiRouter.GET("customerList", v1.GetExaCustomerList) // 获取客户列表
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,7 +55,10 @@ func AddCasbin(cm model.CasbinModel) bool {
|
||||
// @return error
|
||||
func UpdateCasbinApi(oldPath string, newPath string, oldMethod string, newMethod string) error {
|
||||
var cs []model.CasbinModel
|
||||
err := global.GVA_DB.Table("casbin_rule").Where("v1 = ? AND v2 = ?", oldPath,oldMethod).Find(&cs).Update("v1", newPath).Update("v2", newMethod).Error
|
||||
err := global.GVA_DB.Table("casbin_rule").Where("v1 = ? AND v2 = ?", oldPath,oldMethod).Find(&cs).Updates(map[string]string{
|
||||
"v1": newPath,
|
||||
"v2": newMethod,
|
||||
}).Error
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user