Explorar o código

IsCompanyUser

yuedefeng %!s(int64=6) %!d(string=hai) anos
pai
achega
5842ab4504

+ 4 - 4
src/dashoo.cn/backend/api/business/oilsupplier/suppliercert/oilsuppliercertService.go

@@ -6,7 +6,6 @@ import (
 	"dashoo.cn/backend/api/business/oilsupplier/suppliercertsub"
 	"dashoo.cn/backend/api/business/workflow"
 	. "dashoo.cn/backend/api/mydb"
-	"dashoo.cn/business2/parameter"
 	"dashoo.cn/business2/userRole"
 	"github.com/go-xorm/xorm"
 	"strconv"
@@ -101,11 +100,12 @@ func (s *OilSupplierCertService) SubmitOrgAudit(certId, wfName, wfNodeCode, user
 }
 
 //查询已经申请的准入记录
-func (s *OilSupplierCertService) IsCanApplyByExtOrganizeUser(applyType, departmentId, userId string) (bool){
+func (s *OilSupplierCertService) IsCanApplyByExtOrganizeUser(applyType, departmentId, userId string, isCompanyUser int) (bool){
 
-	parameterSvc := baseparameter.GetBaseparameterService(s.DBE) //取出外部门ID
+	/*parameterSvc := baseparameter.GetBaseparameterService(s.DBE) //取出外部门ID
 	extOrganizeId := parameterSvc.GetBaseparameterMessage("GFGL", "paramset", "ExtOrganizeId")
-	if extOrganizeId == departmentId {
+	if extOrganizeId == departmentId {*/
+	if isCompanyUser == 1 {
 		where := " SupplierTypeCode = '" + applyType +"'"
 		where += " and CreateUserId = '" + userId + "'"
 		var model OilSupplierCert

+ 1 - 0
src/dashoo.cn/backend/api/controllers/base.go

@@ -306,6 +306,7 @@ func (this *BaseController) Prepare() {
 		this.User.AccCode = usermodel.AccCode
 		this.User.Description = usermodel.Description
 		this.User.DepartmentId = usermodel.Departmentid
+		this.User.IsCompanyUser = usermodel.IsCompanyUser
 		this.User.Roles = utils.ToStr(usermodel.Roleid)
 		beego.Debug("User:", this.User)
 	}

+ 6 - 4
src/dashoo.cn/backend/api/controllers/oilsupplier/supplier.go

@@ -2,7 +2,6 @@ package oilsupplier
 
 import (
 	"dashoo.cn/backend/api/business/workflow"
-	"dashoo.cn/business/parameter"
 	"encoding/json"
 	"strconv"
 	"strings"
@@ -629,10 +628,13 @@ func (this *OilSupplierController) GetJoinCertEntityList() {
 	}
 
 	//企业用户只看自己的数据记录
-	parameterSvc := baseparameter.GetBaseparameterService(utils.DBE) //取出外部门ID
+	/*parameterSvc := baseparameter.GetBaseparameterService(utils.DBE) //取出外部门ID
 	extOrganizeId := parameterSvc.GetBaseparameterMessage("GFGL", "paramset", "ExtOrganizeId")
 	if extOrganizeId == this.User.DepartmentId {
 		where = where + " and a.CreateUserId = '" + this.User.Id + "'"
+	}*/
+	if this.User.IsCompanyUser == 1 {
+		where = where + " and a.CreateUserId = '" + this.User.Id + "'"
 	}
 
 	svc := supplier.GetOilSupplierService(utils.DBE)
@@ -1029,7 +1031,7 @@ func (this *OilSupplierController) AddEntity() {
 	json.Unmarshal(jsonBlob, &model)
 	json.Unmarshal(jsonBlob, &modelCertVM)
 	serviceCert := suppliercert.GetOilSupplierCertService(utils.DBE)
-	canApply := serviceCert.IsCanApplyByExtOrganizeUser(modelCertVM.SupplierTypeCode, this.User.DepartmentId, this.User.Id)
+	canApply := serviceCert.IsCanApplyByExtOrganizeUser(modelCertVM.SupplierTypeCode, this.User.DepartmentId, this.User.Id, this.User.IsCompanyUser)
 	var errinfo ErrorDataInfo
 	if !canApply {
 		errinfo.Message = "添加失败!供方用户只能申请一次"
@@ -1374,7 +1376,7 @@ func (this *OilSupplierController) IsCanApply() {
 	}
 
 	svc := suppliercert.GetOilSupplierCertService(utils.DBE)
-	canApply := svc.IsCanApplyByExtOrganizeUser(Type, this.User.DepartmentId, this.User.Id)
+	canApply := svc.IsCanApplyByExtOrganizeUser(Type, this.User.DepartmentId, this.User.Id, this.User.IsCompanyUser)
 
 	if canApply {
 		errinfo.Message = "无申请记录,可以申请"

+ 1 - 0
src/dashoo.cn/backend/api/models/token.go

@@ -43,6 +43,7 @@ type UserInfo struct {
 	Power        string
 	DepartmentId string
 	Description  string
+	IsCompanyUser int
 }
 
 // 建立JWT Token