146 lines
3.6 KiB
Go
146 lines
3.6 KiB
Go
package approval
|
|
|
|
import (
|
|
"context"
|
|
"dubbo.apache.org/dubbo-go/v3/common/logger"
|
|
"fmt"
|
|
api "github.com/fonchain_enterprise/fonchain-main/api/approval"
|
|
"github.com/fonchain_enterprise/fonchain-main/pkg/e"
|
|
"github.com/fonchain_enterprise/fonchain-main/pkg/serializer"
|
|
"github.com/fonchain_enterprise/fonchain-main/pkg/service"
|
|
"github.com/gin-gonic/gin"
|
|
"strings"
|
|
)
|
|
|
|
// PassCreateJob 通过 创建 招聘信息
|
|
func PassCreateJob(c *gin.Context, id uint64) error {
|
|
|
|
detailReq := api.DetailRequest{ID: id}
|
|
detail, err := service.ApprovalProvider.Detail(c, &detailReq)
|
|
|
|
if err != nil {
|
|
fmt.Println("查询失败", err)
|
|
return nil
|
|
}
|
|
|
|
if detail.Status != e.ApprovalWorkStatusOk {
|
|
return nil
|
|
}
|
|
|
|
// 人员增补申请
|
|
if strings.Contains(detail.Type, TypeStaffSupply) {
|
|
job := &api.Job{
|
|
ApprovalID: detail.ID,
|
|
PositionName: detail.StaffSupply.PositionName,
|
|
Num: int64(detail.StaffSupply.Num),
|
|
JobAsk: detail.StaffSupply.JobAsk,
|
|
JoinInTime: detail.StaffSupply.JoinInTime,
|
|
Poster: detail.SubmitterName,
|
|
DepartmentName: detail.StaffSupply.DepartmentName,
|
|
}
|
|
_, err = service.ApprovalProvider.CreateJob(context.Background(), job)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func JobList(c *gin.Context) {
|
|
var commonReq api.CommonRequest
|
|
if err := c.ShouldBind(&commonReq); err != nil {
|
|
logger.Errorf("JobList ShouldBind err", err)
|
|
service.ResponseMsg(c, e.InvalidParams, serializer.Response{
|
|
Msg: err.Error(),
|
|
Status: e.Failed,
|
|
})
|
|
return
|
|
}
|
|
|
|
jobList, err := service.ApprovalProvider.JobList(context.Background(), &commonReq)
|
|
if err != nil {
|
|
service.ResponseMsg(c, e.SUCCESS, serializer.Response{
|
|
Msg: err.Error(),
|
|
Status: e.Failed,
|
|
})
|
|
return
|
|
}
|
|
service.ResponseMsg(c, e.SUCCESS, serializer.Response{
|
|
Data: jobList,
|
|
Status: e.Ok,
|
|
})
|
|
}
|
|
|
|
func CloseJob(c *gin.Context) {
|
|
var commonReq api.UpdateJobStatusRequest
|
|
if err := c.ShouldBind(&commonReq); err != nil {
|
|
logger.Errorf("JobList ShouldBind err", err)
|
|
service.ResponseMsg(c, e.InvalidParams, serializer.Response{
|
|
Msg: err.Error(),
|
|
Status: e.Failed,
|
|
})
|
|
return
|
|
}
|
|
|
|
_, err := service.ApprovalProvider.CloseJob(context.Background(), &commonReq)
|
|
if err != nil {
|
|
service.ResponseMsg(c, e.SUCCESS, serializer.Response{
|
|
Msg: err.Error(),
|
|
Status: e.Failed,
|
|
})
|
|
return
|
|
}
|
|
service.ResponseMsg(c, e.SUCCESS, serializer.Response{
|
|
Status: e.Ok,
|
|
})
|
|
}
|
|
|
|
func CreateInterviewer(c *gin.Context) {
|
|
var commonReq api.SaveInterviewerInfo
|
|
if err := c.ShouldBind(&commonReq); err != nil {
|
|
logger.Errorf("JobList ShouldBind err", err)
|
|
service.ResponseMsg(c, e.InvalidParams, serializer.Response{
|
|
Msg: err.Error(),
|
|
Status: e.Failed,
|
|
})
|
|
return
|
|
}
|
|
|
|
_, err := service.ApprovalProvider.CreateInterviewer(context.Background(), &commonReq)
|
|
if err != nil {
|
|
service.ResponseMsg(c, e.SUCCESS, serializer.Response{
|
|
Msg: err.Error(),
|
|
Status: e.Failed,
|
|
})
|
|
return
|
|
}
|
|
service.ResponseMsg(c, e.SUCCESS, serializer.Response{
|
|
Status: e.Ok,
|
|
})
|
|
}
|
|
|
|
func UpdateInterviewer(c *gin.Context) {
|
|
var commonReq api.SaveInterviewerInfo
|
|
if err := c.ShouldBind(&commonReq); err != nil {
|
|
logger.Errorf("JobList ShouldBind err", err)
|
|
service.ResponseMsg(c, e.InvalidParams, serializer.Response{
|
|
Msg: err.Error(),
|
|
Status: e.Failed,
|
|
})
|
|
return
|
|
}
|
|
|
|
_, err := service.ApprovalProvider.UpdateInterviewer(context.Background(), &commonReq)
|
|
if err != nil {
|
|
service.ResponseMsg(c, e.SUCCESS, serializer.Response{
|
|
Msg: err.Error(),
|
|
Status: e.Failed,
|
|
})
|
|
return
|
|
}
|
|
service.ResponseMsg(c, e.SUCCESS, serializer.Response{
|
|
Status: e.Ok,
|
|
})
|
|
}
|