caipin 4 years ago
parent
commit
08906d2d7f

+ 56 - 0
services/backstage_service.go

@@ -26,6 +26,10 @@ type BackstageService interface {
 	ValidRuleProject(ctx iris.Context) (viewmodels.Project, error)
 	ValidRuleProject(ctx iris.Context) (viewmodels.Project, error)
 	ValidRuleProjectAdd(ctx iris.Context) (viewmodels.Project, error)
 	ValidRuleProjectAdd(ctx iris.Context) (viewmodels.Project, error)
 	ValidRuleProjectSave(ctx iris.Context) (viewmodels.Project, error)
 	ValidRuleProjectSave(ctx iris.Context) (viewmodels.Project, error)
+	ValidRuleAccountAdd(ctx iris.Context) (viewmodels.ProjectAccount, error)
+	ValidRuleAccountSave(ctx iris.Context) (viewmodels.ProjectAccount, error)
+	ValidRuleAccountEnable(ctx iris.Context) (viewmodels.ProjectAccount, error)
+
 	GetCldByCategoryId(categoryId string) (map[string]interface{}, error)
 	GetCldByCategoryId(categoryId string) (map[string]interface{}, error)
 	Out(ctx iris.Context) error
 	Out(ctx iris.Context) error
 }
 }
@@ -95,6 +99,7 @@ func (s *backstageService) ValidRuleProjectAdd(ctx iris.Context) (viewmodels.Pro
 	return projectVaild, nil
 	return projectVaild, nil
 }
 }
 
 
+// 项目保存
 func (s *backstageService) ValidRuleProjectSave(ctx iris.Context) (viewmodels.Project, error) {
 func (s *backstageService) ValidRuleProjectSave(ctx iris.Context) (viewmodels.Project, error) {
 	projectVaild := viewmodels.Project{}
 	projectVaild := viewmodels.Project{}
 	err := ctx.ReadJSON(&projectVaild)
 	err := ctx.ReadJSON(&projectVaild)
@@ -111,6 +116,57 @@ func (s *backstageService) ValidRuleProjectSave(ctx iris.Context) (viewmodels.Pr
 	return projectVaild, nil
 	return projectVaild, nil
 }
 }
 
 
+// 验证账号新增
+func (s *backstageService) ValidRuleAccountAdd(ctx iris.Context) (viewmodels.ProjectAccount, error) {
+	projectVaild := viewmodels.ProjectAccount{}
+	err := ctx.ReadJSON(&projectVaild)
+	if err != nil {
+		log.Println("ReadForm转换异常, error=", err)
+		return projectVaild, err
+	}
+
+	err = projectVaild.ValidateAddBs()
+	if err != nil {
+		log.Println("添加账号验证, error=", err)
+		return projectVaild, err
+	}
+	return projectVaild, nil
+}
+
+// 验证账号编辑
+func (s *backstageService) ValidRuleAccountSave(ctx iris.Context) (viewmodels.ProjectAccount, error) {
+	projectVaild := viewmodels.ProjectAccount{}
+	err := ctx.ReadJSON(&projectVaild)
+	if err != nil {
+		log.Println("ReadForm转换异常, error=", err)
+		return projectVaild, err
+	}
+
+	err = projectVaild.ValidateSaveBs()
+	if err != nil {
+		log.Println("编辑账号验证, error=", err)
+		return projectVaild, err
+	}
+	return projectVaild, nil
+}
+
+// 验证账号启用
+func (s *backstageService) ValidRuleAccountEnable(ctx iris.Context) (viewmodels.ProjectAccount, error) {
+	accounttVaild := viewmodels.ProjectAccount{}
+	err := ctx.ReadForm(&accounttVaild)
+	if err != nil {
+		log.Println("ReadForm转换异常, error=", err)
+		return accounttVaild, err
+	}
+
+	err = accounttVaild.ValidateEnableBs()
+	if err != nil {
+		log.Println("编辑账号验证, error=", err)
+		return accounttVaild, err
+	}
+	return accounttVaild, nil
+}
+
 // 验证项目用户登陆相关
 // 验证项目用户登陆相关
 func (s *backstageService) ValidCldStaff(loginData viewmodels.StaffCld, writer http.ResponseWriter) (*viewmodels.ResultCld, error) {
 func (s *backstageService) ValidCldStaff(loginData viewmodels.StaffCld, writer http.ResponseWriter) (*viewmodels.ResultCld, error) {
 
 

+ 68 - 0
services/contract_section_tree_service.go

@@ -93,6 +93,74 @@ func (s *contractService) SetSection(templateNumber int, bidsectionId int, proje
 }
 }
 
 
 // 新增项目节
 // 新增项目节
+func (s *contractService) ContractSectionAdd(sectionData *viewmodels.TreeSectionContract, bidsectionId int, projectId int, treeType int) (*models.CmTreeContracts, error) {
+	// 1.验证项目节ID
+	treeId, err := utils.GetDecryptId(sectionData.Id)
+	if err != nil {
+		return nil, err
+	}
+	sectionFather := s.treeContractDao.Get(treeId, bidsectionId, projectId, treeType)
+	if sectionFather.Id == 0 {
+		return nil, errors.New("未找到合同项目节")
+	}
+
+	// 1-1 深度为>=2才能新增项目节
+	// if sectionFather.Depth < 3 {
+	// 	return errors.New("请在项目节第三层开始编辑")
+	// }
+	// 1-2 项目节是否有合同
+	if sectionFather.ContractId != 0 {
+		return nil, errors.New("该项目节已存在合同")
+	}
+
+	// 2 获得最大序号
+	// 2-1 孩子节点
+	childrenList := s.treeContractDao.GetChildren(treeId, bidsectionId, projectId, treeType)
+
+	// 2-2.检查是否可以添加项目节
+	// 新建合同,项目层级必须在第二层以下,当第一层没有孩子可以添加合同
+	if sectionFather.Depth == 0 {
+		if len(childrenList) != 0 {
+			return nil, errors.New("该项目节不允许添加合同")
+		}
+	}
+
+	// 2-1 最大序号
+	serial := 1
+	if len(childrenList) != 0 {
+		serial = childrenList[len(childrenList)-1].Serial + 1
+	}
+	// 2-2 归属
+	attribution := fmt.Sprintf("%s%d-", sectionFather.Attribution, sectionFather.Serial)
+	code := fmt.Sprintf("%s%d", attribution, serial)
+	// 2-3获得新增ID
+	lastId := s.treeContractDao.GetLastId()
+	// 新增项目节
+	sectionCM := &models.CmTreeContracts{}
+	sectionCM.Id = lastId.Id + 1
+	sectionCM.TreeId = lastId.Id + 1
+	sectionCM.TreeType = treeType
+	sectionCM.ParentId = sectionFather.TreeId
+	sectionCM.Name = sectionData.Name
+	sectionCM.Depth = sectionFather.Depth + 1
+	sectionCM.Serial = serial
+	sectionCM.Attribution = attribution
+	sectionCM.Code = code
+
+	sectionCM.ProjectId = projectId
+	sectionCM.BidsectionId = bidsectionId
+	sectionCM.ContractPrice = "0"
+	sectionCM.ContractReturned = "0"
+	sectionCM.ContractsPaid = "0"
+
+	data, err := s.treeContractDao.Create(sectionCM)
+	if err != nil {
+		return nil, err
+	}
+	return data, nil
+}
+
+// 新增项目节
 func (s *contractService) SectionAdd(sectionData *viewmodels.TreeSectionContract, bidsectionId int, projectId int, treeType int) (*models.CmTreeContracts, error) {
 func (s *contractService) SectionAdd(sectionData *viewmodels.TreeSectionContract, bidsectionId int, projectId int, treeType int) (*models.CmTreeContracts, error) {
 	// 1.验证项目节ID
 	// 1.验证项目节ID
 	treeId, err := utils.GetDecryptId(sectionData.Id)
 	treeId, err := utils.GetDecryptId(sectionData.Id)

+ 1 - 0
services/contract_service.go

@@ -49,6 +49,7 @@ type ContractService interface {
 	GetSecionTree(bidsectionId int, projectId int, treeType int) *viewmodels.TreeSectionContract
 	GetSecionTree(bidsectionId int, projectId int, treeType int) *viewmodels.TreeSectionContract
 	SetSection(templateNumber int, bidsectionId int, projectIdInt int, treeType int) error
 	SetSection(templateNumber int, bidsectionId int, projectIdInt int, treeType int) error
 	SectionAdd(sectionData *viewmodels.TreeSectionContract, bidsectionId int, projectId int, treeType int) (*models.CmTreeContracts, error)
 	SectionAdd(sectionData *viewmodels.TreeSectionContract, bidsectionId int, projectId int, treeType int) (*models.CmTreeContracts, error)
+	ContractSectionAdd(sectionData *viewmodels.TreeSectionContract, bidsectionId int, projectId int, treeType int) (*models.CmTreeContracts, error)
 	SectionSave(sectionData *viewmodels.TreeSectionContract, bidsectionId int, projectId int, treeType int) error
 	SectionSave(sectionData *viewmodels.TreeSectionContract, bidsectionId int, projectId int, treeType int) error
 	UpdateSerial(sectionData *viewmodels.TreeSectionContract, bidsectionId int, projectId int, treeType int) error
 	UpdateSerial(sectionData *viewmodels.TreeSectionContract, bidsectionId int, projectId int, treeType int) error
 	SectionDelete(treeId int, bidsectionId int, projectId int, treeType int) error
 	SectionDelete(treeId int, bidsectionId int, projectId int, treeType int) error

+ 26 - 0
services/project_account_service.go

@@ -37,6 +37,7 @@ type ProjectAccountService interface {
 	GetAll(projectId int) []viewmodels.ProjectAccount
 	GetAll(projectId int) []viewmodels.ProjectAccount
 	GetBidAccount(bidsectionId int, projectId int, projectAccountId int, name string) []viewmodels.ProjectAccount
 	GetBidAccount(bidsectionId int, projectId int, projectAccountId int, name string) []viewmodels.ProjectAccount
 	Search(name string, projectId int) []viewmodels.ProjectAccount
 	Search(name string, projectId int) []viewmodels.ProjectAccount
+	AddBs(viewAccount viewmodels.ProjectAccount, projectId int) error
 	Add(viewAccount viewmodels.ProjectAccount, projectId int) error
 	Add(viewAccount viewmodels.ProjectAccount, projectId int) error
 	Save(viewAccount viewmodels.ProjectAccount, id int, projectId int) error
 	Save(viewAccount viewmodels.ProjectAccount, id int, projectId int) error
 	SaveAccount(viewAccount viewmodels.ProjectAccount, id int, projectId int) error
 	SaveAccount(viewAccount viewmodels.ProjectAccount, id int, projectId int) error
@@ -288,6 +289,31 @@ func (s *projectAccountService) Search(name string, projectId int) []viewmodels.
 	return accountListVM
 	return accountListVM
 }
 }
 
 
+// 新增账号-后台
+func (s *projectAccountService) AddBs(viewAccount viewmodels.ProjectAccount, projectId int) error {
+
+	// 验证该项目下是否有同名账号
+	accountValid := s.dao.GetAccount(viewAccount.Account)
+	if accountValid.Id != 0 {
+		return errors.New("已存在相同的账号")
+	}
+
+	account := models.CmProjectAccount{}
+	account.ProjectId = projectId
+	account.Account = viewAccount.Account
+	account.Password = comm.CreatePasswordSign(viewAccount.Password, viewAccount.Account)
+	account.Name = viewAccount.Name
+	account.Company = viewAccount.Company
+	account.Position = viewAccount.Position
+	account.Mobile = viewAccount.Mobile
+	account.Telephone = viewAccount.Telephone
+	account.Enable = 1
+	// account.IsAdmin = viewAccount.IsAdmin
+	account.CreateTime = time.Now()
+	err := s.dao.Add(&account)
+	return err
+}
+
 // 新增账号
 // 新增账号
 func (s *projectAccountService) Add(viewAccount viewmodels.ProjectAccount, projectId int) error {
 func (s *projectAccountService) Add(viewAccount viewmodels.ProjectAccount, projectId int) error {
 
 

+ 3 - 1
web/api/contract_api.go

@@ -238,10 +238,12 @@ func (c *ContractApi) PostIncomeCreate() {
 
 
 	// 可优化-事务问题
 	// 可优化-事务问题
 	// 先添加项目节
 	// 先添加项目节
+	// 1.新建合同,项目层级必须在第二层以下,当第一层没有孩子可以添加合同
+
 	sectionData := &viewmodels.TreeSectionContract{}
 	sectionData := &viewmodels.TreeSectionContract{}
 	sectionData.Id = contractData.TreeId
 	sectionData.Id = contractData.TreeId
 	sectionData.Name = " "
 	sectionData.Name = " "
-	sectionResult, err := c.ServiceContract.SectionAdd(sectionData, bidsectionId, projectIdInt, 0)
+	sectionResult, err := c.ServiceContract.ContractSectionAdd(sectionData, bidsectionId, projectIdInt, 0)
 	if err != nil {
 	if err != nil {
 		c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
 		c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
 		return
 		return

+ 21 - 29
web/backstage/project_account_bs.go

@@ -116,7 +116,7 @@ func (c *ProjectAccountBs) GetSearch() {
 }
 }
 
 
 // @Summary 创建账号
 // @Summary 创建账号
-// @Tags 项目设置-管理员
+// @Tags 后台 - 项目账号
 // @Description 新增账号
 // @Description 新增账号
 // @Accept  json
 // @Accept  json
 // @Produce  json
 // @Produce  json
@@ -130,25 +130,18 @@ func (c *ProjectAccountBs) GetSearch() {
 // @Param   position     body    string     true        "职位"
 // @Param   position     body    string     true        "职位"
 // @Param   mobile     body    string     true        "手机"
 // @Param   mobile     body    string     true        "手机"
 // @Param   telephone     body    string     true        "座机"
 // @Param   telephone     body    string     true        "座机"
-// @Param   accountGroup     body    int     true        "账号组"
 // @Success 200 {string} string "{code:0成功,-1参数类错误,data:viewmodels.ProjectAccount,msg:错误信息}"
 // @Success 200 {string} string "{code:0成功,-1参数类错误,data:viewmodels.ProjectAccount,msg:错误信息}"
 // @Router /backstage/account/create [post]
 // @Router /backstage/account/create [post]
 func (c *ProjectAccountBs) PostCreate() {
 func (c *ProjectAccountBs) PostCreate() {
-	ErrMsg := ""
 	// 验证内容
 	// 验证内容
-	AccountData, err := c.ServiceProjectAccount.ValidRule(c.Ctx)
-
+	accountData, err := c.ServiceBackstage.ValidRuleAccountAdd(c.Ctx)
 	if err != nil {
 	if err != nil {
-		ErrMsg = utils.FormValidError(err)
-		c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", ErrMsg)})
+		c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
 		return
 		return
 	}
 	}
 
 
 	// 项目ID
 	// 项目ID
-	if AccountData.ProjectId == "" {
-		c.Ctx.JSON(iris.Map{"code": -1, "msg": "项目ID必填"})
-	}
-	projectId, err := utils.GetDecryptId(AccountData.ProjectId)
+	projectId, err := utils.GetDecryptId(accountData.ProjectId)
 	if err != nil {
 	if err != nil {
 		c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
 		c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
 		return
 		return
@@ -161,7 +154,7 @@ func (c *ProjectAccountBs) PostCreate() {
 	}
 	}
 
 
 	// 新增账号信息
 	// 新增账号信息
-	err = c.ServiceProjectAccount.Add(AccountData, projectId)
+	err = c.ServiceProjectAccount.AddBs(accountData, projectId)
 	if err != nil {
 	if err != nil {
 		c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
 		c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
 		return
 		return
@@ -171,46 +164,44 @@ func (c *ProjectAccountBs) PostCreate() {
 }
 }
 
 
 // @Summary 编辑账号
 // @Summary 编辑账号
-// @Tags 项目设置-管理员
+// @Tags 后台 - 项目账号
 // @Description 编辑账号
 // @Description 编辑账号
 // @Accept  json
 // @Accept  json
 // @Produce  json
 // @Produce  json
 // @Security ApiKeyAuth
 // @Security ApiKeyAuth
 // @Param   id     body    string     true        "账号ID" default(PcqqGsn1O0jBSmLqkuOTwQ)
 // @Param   id     body    string     true        "账号ID" default(PcqqGsn1O0jBSmLqkuOTwQ)
 // @Param   projectId     body    string     true        "项目ID"
 // @Param   projectId     body    string     true        "项目ID"
-// @Param   role     body    int     true        "角色ID"
 // @Param   name     body    string     true        "姓名"
 // @Param   name     body    string     true        "姓名"
 // @Param   company     body    string     true        "公司"
 // @Param   company     body    string     true        "公司"
 // @Param   position     body    string     true        "职位"
 // @Param   position     body    string     true        "职位"
+// @Param   mobile     body    string     true        "手机"
 // @Param   telephone     body    string     true        "座机"
 // @Param   telephone     body    string     true        "座机"
-// @Param   accountGroup     body    int     true        "账号组"
 // @Param   X-CSRF-Token      header    string     true        "csrf"
 // @Param   X-CSRF-Token      header    string     true        "csrf"
 // @Success 200 {string} string "{code:0成功,-1参数类错误,data:viewmodels.ProjectAccount,msg:错误信息}"
 // @Success 200 {string} string "{code:0成功,-1参数类错误,data:viewmodels.ProjectAccount,msg:错误信息}"
 // @Router /backstage/account/save [post]
 // @Router /backstage/account/save [post]
 func (c *ProjectAccountBs) PostSave() {
 func (c *ProjectAccountBs) PostSave() {
 
 
-	// TODO
-
 	// 验证内容
 	// 验证内容
-	AccountData, err := c.ServiceProjectAccount.ValidRule(c.Ctx)
+	accountData, err := c.ServiceBackstage.ValidRuleAccountSave(c.Ctx)
 	if err != nil {
 	if err != nil {
-		ErrMsg := utils.FormValidError(err)
-		c.Ctx.JSON(iris.Map{"code": -1, "msg": ErrMsg})
+		c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
 		return
 		return
 	}
 	}
+
 	// 获得更新账号ID
 	// 获得更新账号ID
-	id, err := utils.GetDecryptId(AccountData.Id)
+	id, err := utils.GetDecryptId(accountData.Id)
 	if err != nil {
 	if err != nil {
 		c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
 		c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
 		return
 		return
 	}
 	}
-	projectId, err := utils.GetProjectId(c.Ctx)
+	// 项目ID
+	projectId, err := utils.GetDecryptId(accountData.ProjectId)
 	if err != nil {
 	if err != nil {
 		c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
 		c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
 		return
 		return
 	}
 	}
 
 
-	err = c.ServiceProjectAccount.Save(AccountData, id, projectId)
+	err = c.ServiceProjectAccount.Save(accountData, id, projectId)
 	if err != nil {
 	if err != nil {
 		c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
 		c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
 		return
 		return
@@ -226,20 +217,21 @@ func (c *ProjectAccountBs) PostSave() {
 // @Produce  json
 // @Produce  json
 // @Security ApiKeyAuth
 // @Security ApiKeyAuth
 // @Param   id     body    string     true        "账号ID" default(PcqqGsn1O0jBSmLqkuOTwQ)
 // @Param   id     body    string     true        "账号ID" default(PcqqGsn1O0jBSmLqkuOTwQ)
+// @Param   projectId     body    string     true        "项目ID"
 // @Param   enable     body    int     true        "启用/禁用"
 // @Param   enable     body    int     true        "启用/禁用"
 // @Success 200 {string} string "{code:0成功,-1参数类错误,data:viewmodels.ProjectAccount,msg:错误信息}"
 // @Success 200 {string} string "{code:0成功,-1参数类错误,data:viewmodels.ProjectAccount,msg:错误信息}"
 // @Router /backstage/account/enable [post]
 // @Router /backstage/account/enable [post]
 func (c *ProjectAccountBs) PostEnable() {
 func (c *ProjectAccountBs) PostEnable() {
-	// 修改验证方式——TODO
-	accountVaild := viewmodels.ProjectAccount{}
-	err := c.Ctx.ReadJSON(&accountVaild)
+
+	// 验证内容
+	accountData, err := c.ServiceBackstage.ValidRuleAccountEnable(c.Ctx)
 	if err != nil {
 	if err != nil {
-		c.Ctx.JSON(iris.Map{"code": -1, "msg": "参数错误"})
+		c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
 		return
 		return
 	}
 	}
 
 
 	// 账号ID校验
 	// 账号ID校验
-	id, err := utils.GetDecryptId(accountVaild.Id)
+	id, err := utils.GetDecryptId(accountData.Id)
 	if err != nil {
 	if err != nil {
 		c.Ctx.JSON(iris.Map{"code": -1, "msg": "账号异常"})
 		c.Ctx.JSON(iris.Map{"code": -1, "msg": "账号异常"})
 		return
 		return
@@ -251,7 +243,7 @@ func (c *ProjectAccountBs) PostEnable() {
 		return
 		return
 	}
 	}
 
 
-	err = c.ServiceProjectAccount.Enable(id, projectId, accountVaild.Enable)
+	err = c.ServiceProjectAccount.Enable(id, projectId, accountData.Enable)
 	if err != nil {
 	if err != nil {
 		c.Ctx.JSON(iris.Map{"code": -1, "msg": err})
 		c.Ctx.JSON(iris.Map{"code": -1, "msg": err})
 		return
 		return

+ 28 - 1
web/viewmodels/project_account.go

@@ -47,11 +47,38 @@ func (l ProjectAccount) Validate() error {
 		validation.Field(&l.Name, validation.Required.Error("姓名不能为空")),
 		validation.Field(&l.Name, validation.Required.Error("姓名不能为空")),
 		validation.Field(&l.Company, validation.Required.Error("单位不能为空")),
 		validation.Field(&l.Company, validation.Required.Error("单位不能为空")),
 		validation.Field(&l.Position, validation.Required.Error("职位不能为空")),
 		validation.Field(&l.Position, validation.Required.Error("职位不能为空")),
-		validation.Field(&l.Mobile, validation.Required.Error("手机不能为空"), validation.Match(regexp.MustCompile("^([1][3,4,5,6,7,8,9])\\d{9}$")).Error("只支持英文数字组合")),
+		validation.Field(&l.Mobile, validation.Required.Error("手机不能为空"), validation.Match(regexp.MustCompile("^([1][3,4,5,6,7,8,9])\\d{9}$")).Error("手机号码错误")),
 		validation.Field(&l.AccountGroup, validation.Required.Error("账号组不能为空")),
 		validation.Field(&l.AccountGroup, validation.Required.Error("账号组不能为空")),
 	)
 	)
 }
 }
 
 
+func (l ProjectAccount) ValidateAddBs() error {
+	return validation.ValidateStruct(&l,
+		validation.Field(&l.ProjectId, validation.Required.Error("项目ID不能为空")),
+		validation.Field(&l.Account, validation.Required.Error("账号不能为空"), validation.Match(regexp.MustCompile("^[A-Za-z0-9]+$")).Error("只支持英文数字组合")),
+		validation.Field(&l.Password, validation.Required.Error("密码不能为空"), validation.Length(6, 18).Error("密码位数6~18之间")),
+		validation.Field(&l.Name, validation.Required.Error("姓名不能为空")),
+		validation.Field(&l.Company, validation.Required.Error("单位不能为空")),
+	)
+}
+
+func (l ProjectAccount) ValidateSaveBs() error {
+	return validation.ValidateStruct(&l,
+		validation.Field(&l.Id, validation.Required.Error("ID不能为空")),
+		validation.Field(&l.ProjectId, validation.Required.Error("项目ID不能为空")),
+		validation.Field(&l.Name, validation.Required.Error("姓名不能为空")),
+		validation.Field(&l.Company, validation.Required.Error("单位不能为空")),
+	)
+}
+
+func (l ProjectAccount) ValidateEnableBs() error {
+	return validation.ValidateStruct(&l,
+		validation.Field(&l.Id, validation.Required.Error("ID不能为空")),
+		validation.Field(&l.ProjectId, validation.Required.Error("项目ID不能为空")),
+		validation.Field(&l.Enable, validation.In(0, 1).Error("启用或停用值不正确")),
+	)
+}
+
 func (l ProjectAccount) ValidateUpdate() error {
 func (l ProjectAccount) ValidateUpdate() error {
 	return validation.ValidateStruct(&l,
 	return validation.ValidateStruct(&l,
 		validation.Field(&l.Name, validation.Required.Error("姓名不能为空")),
 		validation.Field(&l.Name, validation.Required.Error("姓名不能为空")),