// 逻辑接口-公司项目模块
// 秒寻科技
// zt 2024-03-18

package projectlogic

import (
	"ipsomc/module/project/projectapi"
	"ipsomc/module/project/projectmodel"
	"strconv"
)

type ProjectLgc struct {
	projectApi projectapi.ProjectApi
}

// 增加公司项目
func (obj *ProjectLgc) AddProjectLgc(dataModel *projectmodel.Project) error {
	//生成项目编号
	projectId, err := obj.projectApi.GenerateProjectID()
	if err != nil {
		return err
	}

	//将字符串转成整数
	projectIdNum, err := strconv.ParseInt(projectId, 16, 32)
	if err != nil {
		return err
	}
	dataModel.ProjectID = int(projectIdNum) //填充项目编号

	//保存数据
	if err := obj.projectApi.AddProject(dataModel); err != nil {
		return err
	}

	return nil
}
