Browse Source

[20250508]运营中心修改

lin-jim-leon 12 hours ago
parent
commit
d8347000ab

+ 43 - 0
db/job.go

@@ -128,3 +128,46 @@ func GetJobDetail(ctx context.Context, req *http_model.JobDetailRequest) (*http_
 	}
 	return subaccountInfolist, nil
 }
+
+func GetJobdDetail(ctx context.Context, req *http_model.JobShowRequest) (*http_model.GetJobshowData, error) {
+	db := GetReadDB(ctx)
+	var jobdetail gorm_model.YounggeeJob
+	err := db.Model(gorm_model.YounggeeJob{}).Where("job_id = ?", req.JobId).Find(&jobdetail).Error
+	if err != nil {
+		return nil, err
+	}
+	response := &http_model.GetJobshowData{
+		JobId:                jobdetail.JobId,
+		JobName:              jobdetail.JobName,
+		JobDetail:            jobdetail.JobDetail,
+		WorkshopPermission:   jobdetail.WorkshopPermission,
+		TaskcenterPermission: jobdetail.TaskcenterPermission,
+		SectaskPermisson:     jobdetail.SectaskPermisson,
+		FinancialPermission:  jobdetail.FinancialPermission,
+		UsercenterPermission: jobdetail.UsercenterPermission,
+		OperatePermission:    jobdetail.OperatePermission,
+	}
+	return response, nil
+}
+
+func GetJobList(ctx context.Context, req *http_model.JobListRequest) (*http_model.JobListResponse, error) {
+	db := GetReadDB(ctx)
+	var jobs []gorm_model.YounggeeJob
+	if err := db.Find(&jobs).Error; err != nil {
+		return nil, err
+	}
+
+	response := &http_model.JobListResponse{
+		Jobs: make([]http_model.JoBInfo, 0, len(jobs)), // 预分配空间
+	}
+
+	// 遍历并映射每个 Job
+	for _, job := range jobs {
+		response.Jobs = append(response.Jobs, http_model.JoBInfo{
+			JobId:   job.JobId,
+			JobName: job.JobName,
+		})
+	}
+
+	return response, nil
+}

+ 10 - 0
db/set_serveratio.go

@@ -14,3 +14,13 @@ func SetServeratio(ctx context.Context, req *http_model.SetServeratioRequest) er
 	}
 	return nil
 }
+
+func GetServeratio(ctx context.Context, req *http_model.GetServeratioRequest) (*http_model.GetServeratioResponse, error) {
+	db := GetReadDB(ctx)
+	var serve_ratio gorm_model.YounggeeServeRatio
+	err := db.First(&serve_ratio).Error
+	if err != nil {
+		return nil, err
+	}
+	return &http_model.GetServeratioResponse{Ratio: serve_ratio.Ratio}, nil
+}

+ 17 - 5
db/subaccount.go

@@ -103,11 +103,8 @@ func GetSubAccountDetail(ctx context.Context, req *http_model.SubAccountDetailRe
 	if req.AccountStatus != nil {
 		query = query.Where("account_status = ?", *req.AccountStatus)
 	}
-	if req.PhoneNumber != nil {
-		query = query.Where("phone_number = ?", *req.PhoneNumber)
-	}
-	if req.SubAccountName != nil {
-		query = query.Where("account_name = ?", *req.SubAccountName)
+	if req.Others != "" {
+		query = query.Where("phone_number LIKE ? OR sub_account_name LIKE ?", "%"+req.Others+"%", "%"+req.Others+"%")
 	}
 
 	// 查询总数
@@ -224,3 +221,18 @@ func DeleteSubAccount(ctx context.Context, req *http_model.DeleteSubAccountReque
 	tx.Commit()
 	return nil
 }
+
+func GetSubAccdDetail(ctx context.Context, req *http_model.SubAccShowRequest) (*http_model.GetSubAccountData, error) {
+	db := GetReadDB(ctx)
+	var subaccount gorm_model.YounggeeSubAccount
+	err := db.Model(gorm_model.YounggeeSubAccount{}).Where("sub_account_id = ?", req.SubaccountId).Find(&subaccount).Error
+	if err != nil {
+		return nil, err
+	}
+	response := &http_model.GetSubAccountData{
+		SubAccountName: subaccount.SubAccountName,
+		Phonenumber:    subaccount.PhoneNumber,
+		JobId:          subaccount.JobId,
+	}
+	return response, nil
+}

+ 1 - 0
handler/create_job.go

@@ -37,6 +37,7 @@ func (c CreateJobHandler) run() {
 	}
 	c.resp.Message = "成功创建岗位"
 	c.resp.Data = res
+	c.resp.Status = consts.ErrorSuccess
 
 }
 func (c CreateJobHandler) checkParam() error {

+ 2 - 5
handler/create_sub_account.go

@@ -49,12 +49,9 @@ func (c CreateSubAccountHandler) run() {
 		c.resp.Message = "创建成功"
 		// 4. 返回ok
 		c.resp.Data = res
+		c.resp.Status = consts.ErrorSuccess
 	} else if message == "手机号已存在" {
-		c.resp.Message = message
-		c.resp.Status = 1
-	} else {
-		c.resp.Message = message
-		c.resp.Status = 2
+		c.resp.Status = consts.ErrorInternal
 	}
 
 }

+ 1 - 0
handler/delete_job.go

@@ -36,6 +36,7 @@ func (c DeleteJobHandler) run() {
 		return
 	}
 	c.resp.Message = "成功删除岗位"
+	c.resp.Status = consts.ErrorSuccess
 }
 func (c DeleteJobHandler) checkParam() error {
 	return nil

+ 1 - 0
handler/delete_ks.go

@@ -36,6 +36,7 @@ func (c DeleteKsauthorizationHandler) run() {
 		return
 	}
 	c.resp.Message = "成功删除授权"
+	c.resp.Status = consts.ErrorSuccess
 }
 func (c DeleteKsauthorizationHandler) checkParam() error {
 	return nil

+ 1 - 0
handler/delete_subaccount.go

@@ -41,6 +41,7 @@ func (d DeleteSubAccount) run() {
 		return
 	}
 	d.resp.Message = "删除成功"
+	d.resp.Status = consts.ErrorSuccess
 }
 
 func (d DeleteSubAccount) checkParam() error {

+ 53 - 0
handler/get_serveraio.go

@@ -0,0 +1,53 @@
+package handler
+
+import (
+	"github.com/gin-gonic/gin"
+	"github.com/sirupsen/logrus"
+	"youngee_m_api/consts"
+	"youngee_m_api/db"
+	"youngee_m_api/model/http_model"
+	"youngee_m_api/util"
+)
+
+func WrapGetServeratioHandler(ctx *gin.Context) {
+	handler := newGetServeratioHandler(ctx)
+	BaseRun(handler)
+}
+
+type GetServeratioHandler struct {
+	ctx  *gin.Context
+	req  *http_model.GetServeratioRequest
+	resp *http_model.CommonResponse
+}
+
+func (c GetServeratioHandler) getContext() *gin.Context { return c.ctx }
+func (c GetServeratioHandler) getResponse() interface{} { return c.resp }
+func (c GetServeratioHandler) getRequest() interface{} {
+	return c.req
+}
+func (c GetServeratioHandler) run() {
+	data := http_model.GetServeratioRequest{}
+	data = *c.req
+	res, err := db.GetServeratio(c.ctx, &data)
+	if err != nil {
+		logrus.Errorf("[GetServeratioHandler] call GetServeratio err:%+v\n", err)
+		util.HandlerPackErrorResp(c.resp, consts.ErrorInternal, "")
+		logrus.Info("GetServeratioHandler fail,req:%+v", c.req)
+		return
+	}
+	c.resp.Message = "成功获取服务费率"
+	c.resp.Status = consts.ErrorSuccess
+	c.resp.Data = res
+
+}
+func (c GetServeratioHandler) checkParam() error {
+	return nil
+}
+
+func newGetServeratioHandler(ctx *gin.Context) *GetServeratioHandler {
+	return &GetServeratioHandler{
+		ctx:  ctx,
+		req:  http_model.NewGetServeratioRequest(),
+		resp: http_model.NewGetServeratioResponse(),
+	}
+}

+ 1 - 0
handler/getauthorization.go

@@ -37,6 +37,7 @@ func (c GetAuthorizationHandler) run() {
 	}
 	c.resp.Message = "成功查询"
 	c.resp.Data = res
+	c.resp.Status = consts.ErrorSuccess
 }
 func (c GetAuthorizationHandler) checkParam() error {
 	return nil

+ 60 - 0
handler/joblist.go

@@ -0,0 +1,60 @@
+package handler
+
+import (
+	"github.com/gin-gonic/gin"
+	"github.com/sirupsen/logrus"
+	"youngee_m_api/consts"
+	"youngee_m_api/db"
+	"youngee_m_api/model/http_model"
+	"youngee_m_api/util"
+)
+
+func WrapJobListHandler(ctx *gin.Context) {
+	handler := newJobListHandler(ctx)
+	BaseRun(handler)
+}
+
+type JobList struct {
+	ctx  *gin.Context
+	req  *http_model.JobListRequest
+	resp *http_model.CommonResponse
+}
+
+func (c JobList) getContext() *gin.Context {
+	return c.ctx
+}
+
+func (c JobList) getResponse() interface{} {
+	return c.resp
+}
+
+func (c JobList) getRequest() interface{} {
+	return c.req
+}
+
+func (c JobList) run() {
+	data := http_model.JobListRequest{}
+	data = *c.req
+	res, err := db.GetJobList(c.ctx, &data)
+	if err != nil {
+		logrus.Errorf("[JobList] call JobList err:%+v\n", err)
+		util.HandlerPackErrorResp(c.resp, consts.ErrorParamCheck, "")
+		logrus.Info("JobList fail,req:%+v", c.req)
+		return
+	}
+	c.resp.Message = "成功查询岗位"
+	c.resp.Data = res
+	c.resp.Status = consts.ErrorSuccess
+}
+
+func (c JobList) checkParam() error {
+	return nil
+}
+
+func newJobListHandler(ctx *gin.Context) *JobList {
+	return &JobList{
+		ctx:  ctx,
+		req:  http_model.NewJobListRequest(),
+		resp: http_model.NewJobListResponse(),
+	}
+}

+ 52 - 0
handler/jobshow.go

@@ -0,0 +1,52 @@
+package handler
+
+import (
+	"github.com/gin-gonic/gin"
+	"github.com/sirupsen/logrus"
+	"youngee_m_api/consts"
+	"youngee_m_api/db"
+	"youngee_m_api/model/http_model"
+	"youngee_m_api/util"
+)
+
+func WrapJobShowHandler(ctx *gin.Context) {
+	handler := newJobShowHandler(ctx)
+	BaseRun(handler)
+}
+
+type JobShowHandler struct {
+	ctx  *gin.Context
+	req  *http_model.JobShowRequest
+	resp *http_model.CommonResponse
+}
+
+func (c JobShowHandler) getContext() *gin.Context { return c.ctx }
+func (c JobShowHandler) getResponse() interface{} { return c.resp }
+func (c JobShowHandler) getRequest() interface{} {
+	return c.req
+}
+func (c JobShowHandler) run() {
+	data := http_model.JobShowRequest{}
+	data = *c.req
+	res, err := db.GetJobdDetail(c.ctx, &data)
+	if err != nil {
+		logrus.Errorf("[JobShowHandler] call JobShow err:%+v\n", err)
+		util.HandlerPackErrorResp(c.resp, consts.ErrorInternal, "")
+		logrus.Info("JobShowHandler fail,req:%+v", c.req)
+		return
+	}
+	c.resp.Message = "成功查询"
+	c.resp.Data = res
+	c.resp.Status = consts.ErrorSuccess
+}
+func (c JobShowHandler) checkParam() error {
+	return nil
+}
+
+func newJobShowHandler(ctx *gin.Context) *JobShowHandler {
+	return &JobShowHandler{
+		ctx:  ctx,
+		req:  http_model.NewJobShowRequest(),
+		resp: http_model.NewJobShowResponse(),
+	}
+}

+ 1 - 0
handler/kuaishouauthorization.go

@@ -36,6 +36,7 @@ func (c AuthkuaishouHandler) run() {
 		return
 	}
 	c.resp.Message = "成功创建授权账号"
+	c.resp.Status = consts.ErrorSuccess
 
 }
 func (c AuthkuaishouHandler) checkParam() error {

+ 1 - 0
handler/send_code.go

@@ -72,6 +72,7 @@ func (h *SendCodeHandler) run() {
 		return
 	}
 	h.resp.Message = "验证码发送成功,请注意查收"
+	h.resp.Status = consts.ErrorSuccess
 }
 func (h *SendCodeHandler) checkParam() error {
 	return nil

+ 1 - 0
handler/set_serveratio.go

@@ -36,6 +36,7 @@ func (c SetServeratioHandler) run() {
 		return
 	}
 	c.resp.Message = "成功设置服务费率"
+	c.resp.Status = consts.ErrorSuccess
 
 }
 func (c SetServeratioHandler) checkParam() error {

+ 1 - 0
handler/stop_subaccount.go

@@ -44,6 +44,7 @@ func (s StopSubAccountHandler) run() {
 	}
 	s.resp.Message = "成功停用岗位"
 	s.resp.Data = res
+	s.resp.Status = consts.ErrorSuccess
 
 }
 

+ 3 - 0
handler/sub_account_detail.go

@@ -43,6 +43,9 @@ func (s SubAccountDetailHandler) run() {
 		return
 	}
 	s.resp.Data = res
+	s.resp.Status = consts.ErrorSuccess
+	s.resp.Message = "成功查询子账号列表" +
+		""
 
 }
 

+ 52 - 0
handler/subaccshow.go

@@ -0,0 +1,52 @@
+package handler
+
+import (
+	"github.com/gin-gonic/gin"
+	"github.com/sirupsen/logrus"
+	"youngee_m_api/consts"
+	"youngee_m_api/db"
+	"youngee_m_api/model/http_model"
+	"youngee_m_api/util"
+)
+
+func WrapSubAccShowHandler(ctx *gin.Context) {
+	handler := newSubAccShowHandler(ctx)
+	BaseRun(handler)
+}
+
+type SubAccShowHandler struct {
+	ctx  *gin.Context
+	req  *http_model.SubAccShowRequest
+	resp *http_model.CommonResponse
+}
+
+func (c SubAccShowHandler) getContext() *gin.Context { return c.ctx }
+func (c SubAccShowHandler) getResponse() interface{} { return c.resp }
+func (c SubAccShowHandler) getRequest() interface{} {
+	return c.req
+}
+func (c SubAccShowHandler) run() {
+	data := http_model.SubAccShowRequest{}
+	data = *c.req
+	res, err := db.GetSubAccdDetail(c.ctx, &data)
+	if err != nil {
+		logrus.Errorf("[SubAccShowHandler] call SubAccShow err:%+v\n", err)
+		util.HandlerPackErrorResp(c.resp, consts.ErrorInternal, "")
+		logrus.Info("SubAccShowHandler fail,req:%+v", c.req)
+		return
+	}
+	c.resp.Message = "成功查询"
+	c.resp.Data = res
+	c.resp.Status = consts.ErrorSuccess
+}
+func (c SubAccShowHandler) checkParam() error {
+	return nil
+}
+
+func newSubAccShowHandler(ctx *gin.Context) *SubAccShowHandler {
+	return &SubAccShowHandler{
+		ctx:  ctx,
+		req:  http_model.NewSubAccShowRequest(),
+		resp: http_model.NewSubAccShowResponse(),
+	}
+}

+ 1 - 0
handler/update_job_info.go

@@ -47,6 +47,7 @@ func (u UpdateJobInfoHandler) run() {
 	}
 	u.resp.Message = "编辑创建岗位"
 	u.resp.Data = res
+	u.resp.Status = consts.ErrorSuccess
 }
 func (u UpdateJobInfoHandler) checkParam() error {
 	return nil

+ 2 - 0
handler/update_subaccount_info.go

@@ -57,8 +57,10 @@ func (u UpdateSubAccountInfoHandler) run() {
 		}
 		u.resp.Message = "编辑成功"
 		u.resp.Data = res
+		u.resp.Status = consts.ErrorSuccess
 	} else {
 		u.resp.Message = message
+		u.resp.Status = consts.ErrorInternal
 	}
 }
 func (u UpdateSubAccountInfoHandler) checkParam() error {

+ 5 - 6
model/http_model/SubAccountDetail.go

@@ -3,12 +3,11 @@ package http_model
 import "youngee_m_api/model/gorm_model"
 
 type SubAccountDetailRequest struct {
-	PageSize       int     `json:"page_size"`
-	PageNum        int     `json:"page_num"`
-	JobId          *int    `json:"job_id,omitempty"`           // 可选的岗位类型
-	AccountStatus  *int    `json:"account_status,omitempty"`   // 可选的账号状态
-	PhoneNumber    *string `json:"phone_number,omitempty"`     // 可选的手机号
-	SubAccountName *string `json:"sub_account_name,omitempty"` // 可选的账号名称
+	PageSize      int    `json:"page_size"`
+	PageNum       int    `json:"page_num"`
+	JobId         *int   `json:"job_id,omitempty"`         // 可选的岗位类型
+	AccountStatus *int   `json:"account_status,omitempty"` // 可选的账号状态
+	Others        string `json:"others,omitempty"`         //手机号或账号名称
 }
 
 type SubAccountDetailResponse struct {

+ 13 - 0
model/http_model/get_serveratio.go

@@ -0,0 +1,13 @@
+package http_model
+
+type GetServeratioRequest struct {
+}
+
+type GetServeratioResponse struct {
+	Ratio string `json:"ratio"`
+}
+
+func NewGetServeratioRequest() *GetServeratioRequest { return new(GetServeratioRequest) }
+func NewGetServeratioResponse() *CommonResponse {
+	return new(CommonResponse)
+}

+ 23 - 0
model/http_model/joblistrequest.go

@@ -0,0 +1,23 @@
+package http_model
+
+type JobListRequest struct {
+}
+
+type JobListResponse struct {
+	Jobs []JoBInfo `json:"Jobs"`
+}
+
+type JoBInfo struct {
+	JobId   int    `json:"job_id"`
+	JobName string `json:"job_name"`
+}
+
+func NewJobListRequest() *JobListRequest {
+	return new(JobListRequest)
+}
+
+func NewJobListResponse() *CommonResponse {
+	resp := new(CommonResponse)
+	resp.Data = new(JobListResponse)
+	return resp
+}

+ 26 - 0
model/http_model/jobshow.go

@@ -0,0 +1,26 @@
+package http_model
+
+type JobShowRequest struct {
+	JobId string `json:"job_id"`
+}
+
+type GetJobshowData struct {
+	JobId                int    `json:"job_id"`                //岗位ID
+	JobName              string `json:"job_name"`              //岗位名称
+	JobDetail            string `json:"ob_detail"`             //岗位描述
+	WorkshopPermission   string `json:"workshop_permission"`   //工作台权限
+	TaskcenterPermission string `json:"taskcenter_permission"` //任务中心权限
+	SectaskPermisson     string `json:"sectask_permisson"`     //商单中心权限
+	FinancialPermission  string `json:"financial_permission"`  //财务结算权限
+	UsercenterPermission string `json:"usercenter_permission"` //用户中心权限
+	OperatePermission    string `json:"operate_permission"`    //运营中心权限
+}
+
+func NewJobShowRequest() *JobShowRequest {
+	return new(JobShowRequest)
+}
+func NewJobShowResponse() *CommonResponse {
+	resp := new(CommonResponse)
+	resp.Data = new(GetJobshowData)
+	return resp
+}

+ 20 - 0
model/http_model/subaccshowrequest.go

@@ -0,0 +1,20 @@
+package http_model
+
+type SubAccShowRequest struct {
+	SubaccountId string `json:"sub_account_id"`
+}
+
+type GetSubAccountData struct {
+	Phonenumber    string `json:"phonenumber"`
+	SubAccountName string `json:"sub_account_name"`
+	JobId          int    `json:"job_id"`
+}
+
+func NewSubAccShowRequest() *SubAccShowRequest {
+	return new(SubAccShowRequest)
+}
+func NewSubAccShowResponse() *CommonResponse {
+	resp := new(CommonResponse)
+	resp.Data = new(GetSubAccountData)
+	return resp
+}

+ 7 - 3
route/init.go

@@ -11,8 +11,8 @@ import (
 
 func InitRoute(r *gin.Engine) {
 
-	r.POST("/login", handler.WrapCodeLoginHandler)
-	r.GET("/getLoginUser", handler.WrapGetLoginUserHandler)
+	r.POST("/youngee/m/login", handler.WrapCodeLoginHandler)
+	r.GET("/youngee/m/getLoginUser", handler.WrapGetLoginUserHandler)
 	r.POST("/userInfo", handler.WrapGetUserInfoHandler)
 	r.GET("/test/ping", func(c *gin.Context) {
 		resp := http_model.CommonResponse{
@@ -331,7 +331,7 @@ func InitRoute(r *gin.Engine) {
 		w.POST("/takegoods", handler.WrapGetTakegoodsDataHandler) //查询时间内带货量
 	}
 	//运营中心相关接口
-	n := r.Group("/youngee/run")
+	n := r.Group("/youngee/m/run")
 	{
 		n.Use(middleware.LoginAuthMiddleware)
 		n.POST("/sendCode", handler.WrapSendCodeHandler)                         //发送验证码
@@ -340,13 +340,17 @@ func InitRoute(r *gin.Engine) {
 		n.POST("/addnewjob", handler.WrapCreateJobHandler)                       //创建岗位
 		n.POST("/editjob", handler.WrapEditJobHandler)                           //编辑岗位
 		n.POST("/subaccountdetail", handler.WrapSubAccountDetailHandler)         //查询子账号列表
+		n.POST("/subaccshow", handler.WrapSubAccShowHandler)                     //查询子账号详情
 		n.POST("/stopsubaccount", handler.WrapStopSubAccountHandler)             //停用子账号
 		n.POST("/deletesubaccount", handler.WrapDeleteSubAccountHandler)         //删除子账号
 		n.POST("/deletejob", handler.WrapDeleteJobHandler)                       //删除岗位
+		n.POST("/joblist", handler.WrapJobListHandler)                           //获取所有岗位,名称
 		n.POST("/jobdetail", handler.WrapJobDetailHandler)                       //岗位列表
+		n.POST("/jobshow", handler.WrapJobShowHandler)                           //岗位详情
 		n.POST("/addauthorization", handler.WrapAuthkuaishouHandler)             //新增快手授权
 		n.POST("/KSauthorizationlist", handler.WrapGetAuthorizationListHandler)  //查询授权结果
 		n.POST("/deleteksauthorization", handler.WrapDeleteauthorizationHandler) //删除授权
 		n.POST("/serveratio", handler.WrapSetServeratioHandler)                  //设置服务费率
+		n.POST("/getserveratio", handler.WrapGetServeratioHandler)               //获取服务费率
 	}
 }