|
|
@ -11,13 +11,13 @@ import ( |
|
|
|
"github.com/gin-gonic/gin" |
|
|
|
) |
|
|
|
|
|
|
|
// @Tags SysApi
|
|
|
|
// @Tags ExaCustomer
|
|
|
|
// @Summary 创建客户
|
|
|
|
// @Security ApiKeyAuth
|
|
|
|
// @accept application/json
|
|
|
|
// @Produce application/json
|
|
|
|
// @Param data body model.ExaCustomer true "创建客户"
|
|
|
|
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
|
|
|
|
// @Param data body model.ExaCustomer true "客户用户名, 客户手机号码"
|
|
|
|
// @Success 200 {string} string "{"success":true,"data":{},"msg":"创建成功"}"
|
|
|
|
// @Router /customer/customer [post]
|
|
|
|
func CreateExaCustomer(c *gin.Context) { |
|
|
|
var cu model.ExaCustomer |
|
|
@ -26,66 +26,53 @@ func CreateExaCustomer(c *gin.Context) { |
|
|
|
"CustomerName": {utils.NotEmpty()}, |
|
|
|
"CustomerPhoneData": {utils.NotEmpty()}, |
|
|
|
} |
|
|
|
CustomerVerifyErr := utils.Verify(cu, CustomerVerify) |
|
|
|
if CustomerVerifyErr != nil { |
|
|
|
if CustomerVerifyErr := utils.Verify(cu, CustomerVerify); CustomerVerifyErr != nil { |
|
|
|
response.FailWithMessage(CustomerVerifyErr.Error(), c) |
|
|
|
return |
|
|
|
} |
|
|
|
claims, _ := c.Get("claims") |
|
|
|
waitUse := claims.(*request.CustomClaims) |
|
|
|
cu.SysUserID = waitUse.ID |
|
|
|
cu.SysUserAuthorityID = waitUse.AuthorityId |
|
|
|
err := service.CreateExaCustomer(cu) |
|
|
|
if err != nil { |
|
|
|
cu.SysUserID = getUserID(c) |
|
|
|
cu.SysUserAuthorityID = getUserAuthorityId(c) |
|
|
|
if err := service.CreateExaCustomer(cu); err != nil { |
|
|
|
response.FailWithMessage(fmt.Sprintf("删除失败:%v", err), c) |
|
|
|
} else { |
|
|
|
response.OkWithMessage("创建成功", c) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// @Tags SysApi
|
|
|
|
// @Tags ExaCustomer
|
|
|
|
// @Summary 删除客户
|
|
|
|
// @Security ApiKeyAuth
|
|
|
|
// @accept application/json
|
|
|
|
// @Produce application/json
|
|
|
|
// @Param data body model.ExaCustomer true "删除客户"
|
|
|
|
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
|
|
|
|
// @Param data body model.ExaCustomer true "客户ID"
|
|
|
|
// @Success 200 {string} string "{"success":true,"data":{},"msg":"删除成功"}"
|
|
|
|
// @Router /customer/customer [delete]
|
|
|
|
func DeleteExaCustomer(c *gin.Context) { |
|
|
|
var cu model.ExaCustomer |
|
|
|
_ = c.ShouldBindJSON(&cu) |
|
|
|
CustomerVerify := utils.Rules{ |
|
|
|
"ID": {utils.NotEmpty()}, |
|
|
|
} |
|
|
|
CustomerVerifyErr := utils.Verify(cu.GVA_MODEL, CustomerVerify) |
|
|
|
if CustomerVerifyErr != nil { |
|
|
|
if CustomerVerifyErr := utils.Verify(cu.GVA_MODEL, utils.Rules{"ID": {utils.NotEmpty()}}); CustomerVerifyErr != nil { |
|
|
|
response.FailWithMessage(CustomerVerifyErr.Error(), c) |
|
|
|
return |
|
|
|
} |
|
|
|
err := service.DeleteExaCustomer(cu) |
|
|
|
if err != nil { |
|
|
|
if err := service.DeleteExaCustomer(cu); err != nil { |
|
|
|
response.FailWithMessage(fmt.Sprintf("删除失败:%v", err), c) |
|
|
|
} else { |
|
|
|
response.OkWithMessage("删除成功", c) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// @Tags SysApi
|
|
|
|
// @Tags ExaCustomer
|
|
|
|
// @Summary 更新客户信息
|
|
|
|
// @Security ApiKeyAuth
|
|
|
|
// @accept application/json
|
|
|
|
// @Produce application/json
|
|
|
|
// @Param data body model.ExaCustomer true "创建客户"
|
|
|
|
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
|
|
|
|
// @Param data body model.ExaCustomer true "客户ID, 客户信息"
|
|
|
|
// @Success 200 {string} string "{"success":true,"data":{},"msg":"更新成功"}"
|
|
|
|
// @Router /customer/customer [put]
|
|
|
|
func UpdateExaCustomer(c *gin.Context) { |
|
|
|
var cu model.ExaCustomer |
|
|
|
_ = c.ShouldBindJSON(&cu) |
|
|
|
IdCustomerVerify := utils.Rules{ |
|
|
|
"ID": {utils.NotEmpty()}, |
|
|
|
} |
|
|
|
IdCustomerVerifyErr := utils.Verify(cu.GVA_MODEL, IdCustomerVerify) |
|
|
|
if IdCustomerVerifyErr != nil { |
|
|
|
if IdCustomerVerifyErr := utils.Verify(cu.GVA_MODEL, utils.Rules{"ID": {utils.NotEmpty()}}); IdCustomerVerifyErr != nil { |
|
|
|
response.FailWithMessage(IdCustomerVerifyErr.Error(), c) |
|
|
|
return |
|
|
|
} |
|
|
@ -93,35 +80,29 @@ func UpdateExaCustomer(c *gin.Context) { |
|
|
|
"CustomerName": {utils.NotEmpty()}, |
|
|
|
"CustomerPhoneData": {utils.NotEmpty()}, |
|
|
|
} |
|
|
|
CustomerVerifyErr := utils.Verify(cu, CustomerVerify) |
|
|
|
if CustomerVerifyErr != nil { |
|
|
|
if CustomerVerifyErr := utils.Verify(cu, CustomerVerify); CustomerVerifyErr != nil { |
|
|
|
response.FailWithMessage(CustomerVerifyErr.Error(), c) |
|
|
|
return |
|
|
|
} |
|
|
|
err := service.UpdateExaCustomer(&cu) |
|
|
|
if err != nil { |
|
|
|
if err := service.UpdateExaCustomer(&cu); err != nil { |
|
|
|
response.FailWithMessage(fmt.Sprintf("更新失败:%v", err), c) |
|
|
|
} else { |
|
|
|
response.OkWithMessage("更新成功", c) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// @Tags SysApi
|
|
|
|
// @Tags ExaCustomer
|
|
|
|
// @Summary 获取单一客户信息
|
|
|
|
// @Security ApiKeyAuth
|
|
|
|
// @accept application/json
|
|
|
|
// @Produce application/json
|
|
|
|
// @Param data body model.ExaCustomer true "获取单一客户信息"
|
|
|
|
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
|
|
|
|
// @Param data body model.ExaCustomer true "客户ID"
|
|
|
|
// @Success 200 {string} string "{"success":true,"data":{},"msg":"操作成功"}"
|
|
|
|
// @Router /customer/customer [get]
|
|
|
|
func GetExaCustomer(c *gin.Context) { |
|
|
|
var cu model.ExaCustomer |
|
|
|
_ = c.ShouldBindQuery(&cu) |
|
|
|
IdCustomerVerify := utils.Rules{ |
|
|
|
"ID": {utils.NotEmpty()}, |
|
|
|
} |
|
|
|
IdCustomerVerifyErr := utils.Verify(cu.GVA_MODEL, IdCustomerVerify) |
|
|
|
if IdCustomerVerifyErr != nil { |
|
|
|
if IdCustomerVerifyErr := utils.Verify(cu.GVA_MODEL, utils.Rules{"ID": {utils.NotEmpty()}}); IdCustomerVerifyErr != nil { |
|
|
|
response.FailWithMessage(IdCustomerVerifyErr.Error(), c) |
|
|
|
return |
|
|
|
} |
|
|
@ -133,25 +114,22 @@ func GetExaCustomer(c *gin.Context) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// @Tags SysApi
|
|
|
|
// @Tags ExaCustomer
|
|
|
|
// @Summary 获取权限客户列表
|
|
|
|
// @Security ApiKeyAuth
|
|
|
|
// @accept application/json
|
|
|
|
// @Produce application/json
|
|
|
|
// @Param data body request.PageInfo true "获取权限客户列表"
|
|
|
|
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
|
|
|
|
// @Param data body request.PageInfo true "页码, 每页大小"
|
|
|
|
// @Success 200 {string} string "{"success":true,"data":{},"msg":"操作成功"}"
|
|
|
|
// @Router /customer/customerList [get]
|
|
|
|
func GetExaCustomerList(c *gin.Context) { |
|
|
|
claims, _ := c.Get("claims") |
|
|
|
waitUse := claims.(*request.CustomClaims) |
|
|
|
var pageInfo request.PageInfo |
|
|
|
_ = c.ShouldBindQuery(&pageInfo) |
|
|
|
PageVerifyErr := utils.Verify(pageInfo, utils.CustomizeMap["PageVerify"]) |
|
|
|
if PageVerifyErr != nil { |
|
|
|
if PageVerifyErr := utils.Verify(pageInfo, utils.CustomizeMap["PageVerify"]); PageVerifyErr != nil { |
|
|
|
response.FailWithMessage(PageVerifyErr.Error(), c) |
|
|
|
return |
|
|
|
} |
|
|
|
err, customerList, total := service.GetCustomerInfoList(waitUse.AuthorityId, pageInfo) |
|
|
|
err, customerList, total := service.GetCustomerInfoList(getUserAuthorityId(c), pageInfo) |
|
|
|
if err != nil { |
|
|
|
response.FailWithMessage(fmt.Sprintf("获取失败:%v", err), c) |
|
|
|
} else { |
|
|
|