作者 yangfu

Merge remote-tracking branch 'origin/test'

# Conflicts:
#	deploy/k8s/prd/allied-creation-gateway.yaml
... ... @@ -121,6 +121,8 @@ spec:
value: "http://cost-structured-dev.fjmaimaimai.com"
- name: SUPLUS_SALE_APP
value: "http://suplus-sale-app-gateway-test.fjmaimaimai.com"
- name: ALLIED_CREATION_REPORTING_SYSTEM
value: "https://allied-creation-reporting-system-dev.fjmaimaimai.com"
# - name: REDIS_HOST
# valueFrom:
# configMapKeyRef:
... ...
... ... @@ -123,10 +123,12 @@ spec:
value: "https://sms.fjmaimaimai.com:9897"
- name: COST_STRUCTURED
value: "http://cost-structured-prd.fjmaimaimai.com"
- name: ALLIED_CREATION_REPORTING_SYSTEM
value: "https://allied-creation-reporting-system-prd.fjmaimaimai.com"
- name: MANUFACTURE_WEIGH_DEFAULT_COMPANYID
value: "4"
- name: MANUFACTURE_WEIGH_DEFAULT_ORGID
value: "44"
value: "44"
# - name: REDIS_HOST
# valueFrom:
# configMapKeyRef:
... ...
... ... @@ -127,6 +127,8 @@ spec:
value: "http://cost-structured-test.fjmaimaimai.com"
- name: SUPLUS_SALE_APP
value: "http://suplus-sale-app-gateway-test.fjmaimaimai.com"
- name: ALLIED_CREATION_REPORTING_SYSTEM
value: "https://allied-creation-reporting-system-test.fjmaimaimai.com"
- name: MANUFACTURE_WEIGH_DEFAULT_COMPANYID
value: "23"
- name: MANUFACTURE_WEIGH_DEFAULT_ORGID
... ...
package command
import (
"fmt"
"github.com/beego/beego/v2/core/validation"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
)
type CheckModuleAccessCommand struct {
// 操作人
Operator domain.Operator `json:"-"`
// 模块
Module string `json:"module"`
// 参数
Options []string `json:"options"`
}
func (cmd *CheckModuleAccessCommand) Valid(validation *validation.Validation) {
}
func (cmd *CheckModuleAccessCommand) ValidateCommand() error {
valid := validation.Validation{}
b, err := valid.Valid(cmd)
if err != nil {
return err
}
if !b {
for _, validErr := range valid.Errors {
return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
}
}
return nil
}
... ...
package dto
// 数控中心报表
type ModuleAccessToDigitalControlCentreDto struct {
// 用户的角色权限列表
UserRoles []string `json:"userRoles"`
// 列表
Allows []*ModuleAccessAllowItem `json:"modules"`
}
type ModuleAccessAllowItem struct {
Allow bool `json:"allow"`
SettingCode string `json:"settingCode"`
ConfigRoles []string `json:"configRoles"`
}
... ...
package service
import (
"fmt"
"github.com/linmadan/egglib-go/core/application"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/auth/command"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/auth/dto"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_basic"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_user"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/log"
"strings"
)
func (svr AuthService) CheckModuleAccess(cmd *command.CheckModuleAccessCommand) (interface{}, error) {
var (
result interface{}
err error
)
switch cmd.Module {
case "DigitalControlCentre":
result, err = svr.digitalControlCentreModuleAccess(cmd)
break
default:
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "unknown module "+cmd.Module)
}
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
return result, nil
}
func (svr AuthService) digitalControlCentreModuleAccess(cmd *command.CheckModuleAccessCommand) (interface{}, error) {
if len(cmd.Options) == 0 {
return nil, fmt.Errorf("options is empty")
}
alliedCreationBasic := allied_creation_basic.NewHttplibAlliedCreationBasic(cmd.Operator)
response := dto.ModuleAccessToDigitalControlCentreDto{
Allows: make([]*dto.ModuleAccessAllowItem, 0),
}
var mapAllowItem = make(map[string]*dto.ModuleAccessAllowItem)
for i := range cmd.Options {
allow := &dto.ModuleAccessAllowItem{
SettingCode: cmd.Options[i],
Allow: false,
ConfigRoles: []string{},
}
response.Allows = append(response.Allows, allow)
mapAllowItem[allow.SettingCode] = allow
}
alliedCreationUser := allied_creation_user.NewHttplibAlliedCreationUser(cmd.Operator)
user, err := alliedCreationUser.UserGet(allied_creation_user.ReqGetUser{
UserId: int(cmd.Operator.UserId),
})
if err != nil {
log.Logger.Error(err.Error())
return nil, fmt.Errorf("user get fail")
}
roles := make([]string, 0)
for i := range user.UserRole {
role := user.UserRole[i]
roles = append(roles, role.RoleName)
}
if len(roles) == 0 {
return response, nil
}
response.UserRoles = roles
for _, code := range cmd.Options {
settingCode := code
if len(settingCode) == 0 {
return nil, fmt.Errorf("setting code is empty")
}
result, err := alliedCreationBasic.SystemSettingGet(allied_creation_basic.ReqSystemSettingGet{
SettingCode: settingCode,
})
if err != nil {
//log.Logger.Error(err.Error(), map[string]interface{}{"company": cmd.Operator.CompanyId})
//return nil, fmt.Errorf("system setting get fail")
continue
}
configRoles := strings.Split(result.Value, ";")
if len(configRoles) == 0 {
continue
}
var allow bool = false
for _, vi := range configRoles {
for _, vj := range roles {
if vi == vj {
allow = true
break
}
}
if allow {
break
}
}
if v, ok := mapAllowItem[settingCode]; ok {
v.Allow = allow
v.ConfigRoles = configRoles
}
}
return response, nil
}
... ...
... ... @@ -48,7 +48,8 @@ func (svr AuthService) AuthLogin(loginCommand *command.LoginCommand) (interface{
Phone: loginCommand.Phone,
})
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
log.Logger.Error("refresh im error:" + err.Error()) // 只做提示继续进行登录
//return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
switch loginCommand.GrantType {
case domain.LoginPwd:
... ...
... ... @@ -13,6 +13,7 @@ type GetLatestVersionQuery struct {
DeviceType string `json:"-"`
VersionNo int `json:"versionNo,string"`
Channel int `json:"channel"`
AppName string `json:"appName"`
Request *http.Request `json:"-"`
}
... ...
... ... @@ -51,6 +51,21 @@ func (srv *CommonService) GetDictionaryByCode(getDictionaryQuery *query.GetDicti
//LatestVersionInfo 版本升级
func (srv *CommonService) LatestVersionInfo(q *query.GetLatestVersionQuery) (interface{}, error) {
vs := version_server.NewHttpLibVersionServer()
// TODO:版本管理系统按应用名称查询相应版本信息,目前维护人没在,此处先写死手动维护
if len(q.AppName) != 0 && q.AppName == "com.mmm.manufacture-weigh.pad" {
return map[string]interface{}{
"version": map[string]interface{}{
"versionName": "版本 v1.0.1",
"content": "版本升级",
"title": "版本升级",
"versionNo": "100001",
"downloadFile": "upgrade",
"downloadPage": "http://fir.fjmaimaimai.com/ben1",
"updateType": 0,
"channel": 1,
},
}, nil
}
data, err := vs.GetLatestVersion(q.Request, version_server.ReqLatestVersion{
VersionNo: q.VersionNo,
Channel: q.Channel,
... ...
... ... @@ -321,10 +321,10 @@ func (srv ExcelDataService) ImportCost(importDataCommand *command.ImportDataComm
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "上传图片失败")
}
ossFile = append(ossFile,ossFile1)
ossFile = append(ossFile, ossFile1)
}
//图片2
_,mBytes2,err := f.GetPicture(f.GetSheetName(index), "F"+fmt.Sprintf("%v", excelImport.RowBegin+key+1))
_, mBytes2, err := f.GetPicture(f.GetSheetName(index), "F"+fmt.Sprintf("%v", excelImport.RowBegin+key+1))
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "读取图片失败")
}
... ... @@ -333,10 +333,10 @@ func (srv ExcelDataService) ImportCost(importDataCommand *command.ImportDataComm
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "上传图片失败")
}
ossFile = append(ossFile,ossFile2)
ossFile = append(ossFile, ossFile2)
}
//图片3
_,mBytes3,err := f.GetPicture(f.GetSheetName(index), "G"+fmt.Sprintf("%v", excelImport.RowBegin+key+1))
_, mBytes3, err := f.GetPicture(f.GetSheetName(index), "G"+fmt.Sprintf("%v", excelImport.RowBegin+key+1))
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "读取图片失败")
}
... ... @@ -345,7 +345,7 @@ func (srv ExcelDataService) ImportCost(importDataCommand *command.ImportDataComm
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "上传图片失败")
}
ossFile = append(ossFile,ossFile3)
ossFile = append(ossFile, ossFile3)
}
//choiceId, err := strconv.Atoi(v["choiceId"])
choiceId := domain.NodeType{}.GetIdByName(strings.TrimSpace(v["choiceId"]))
... ... @@ -382,7 +382,7 @@ func (srv ExcelDataService) ImportCost(importDataCommand *command.ImportDataComm
YesterdayActual: strings.TrimSpace(v["yesterdayActual"]),
Types: importCostCommand.Types,
}
if len(ossFile) >0 {
if len(ossFile) > 0 {
item.Urls = ossFile
} else {
item.Urls = []string{}
... ... @@ -398,15 +398,15 @@ func (srv ExcelDataService) ImportCost(importDataCommand *command.ImportDataComm
"successCount": 0,
"fail": map[string]interface{}{
"header": map[string]string{
"failReason": "错误详情",
"projectCode": "项目编码",
"itemName": "细项名称",
"failReason": "错误详情",
"projectCode": "项目编码",
"itemName": "细项名称",
},
"body": []map[string]interface{}{
{"failReason":result.Msg,"projectCode":"","itemName":""},
"body": []map[string]interface{}{
{"failReason": result.Msg, "projectCode": "", "itemName": ""},
},
},
"successData":nil,
"successData": nil,
}, nil
} else {
return result.Data, nil
... ... @@ -451,7 +451,7 @@ func (srv ExcelDataService) fieldValueAllEmpty(param map[string]string) bool {
// FileImportTemplate 导入模板
func (srv ExcelDataService) FileImportTemplate(importDataCommand *command.ImportDataCommand) (interface{}, error) {
var mapTemplate = map[string]string{
domain.ImportCompanyUser: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/opportunity/dev_online/20220222/object/1645495589_cFNDGRTfCxYMZ5hPYzfKxThYd3ywARRz.xlsx",
domain.ImportCompanyUser: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/opportunity/dev_online/20220427/object/1651040510_YxpaeFBaZfGKxs6dERrsKeZY5ha7ByrQ.xlsx",
domain.ImportOrganization: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/dev_online/20210916/object/1631807490_r2XWhGmbWWmpbeePBkZ3EJQFKcZEMpEm.xlsx",
domain.ImportDividendsOrders: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/dev_online/20210927/object/1632743206_NPYTKw6RGhXn4TpYNEQhGGdCkXKXTnxM.xlsx",
domain.ImportCooperationUser: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/dev_online/20210926/object/1632635345_SbfzmkXjQHhCwPw4MB7zb5EBBtdp2MSE.xlsx",
... ...
... ... @@ -46,8 +46,12 @@ var EnableBlockChain = true
// 天联共创 成本结构化
var COST_STRUCTURED = "http://cost-structured-dev.fjmaimaimai.com"
//var COST_STRUCTURED = "http://localhost:8085"
// 天联共创 生产制造模块
var ALLIED_CREATION_REPORTING_SYSTEM = "https://allied-creation-reporting-system-test.fjmaimaimai.com"
func init() {
if os.Getenv("LOG_LEVEL") != "" {
LOG_LEVEL = os.Getenv("LOG_LEVEL")
... ... @@ -88,4 +92,7 @@ func init() {
if os.Getenv("COST_STRUCTURED") != "" {
COST_STRUCTURED = os.Getenv("COST_STRUCTURED")
}
if os.Getenv("ALLIED_CREATION_REPORTING_SYSTEM") != "" {
ALLIED_CREATION_REPORTING_SYSTEM = os.Getenv("ALLIED_CREATION_REPORTING_SYSTEM")
}
}
... ...
... ... @@ -372,6 +372,7 @@ type (
ParentPath string `json:"parentPath"`
Remark string `json:"remark"`
Sort int `json:"sort"`
Link string `json:"link"`
} `json:"menus"`
}
)
... ...
package chart_editor
import (
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/constant"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway"
"time"
)
//HttpLibAlliedCreationManufacture 生产制造模块
type HttpLibAlliedChartEditor struct {
service_gateway.BaseServiceGateway
baseUrL string
}
func NewHttpLibAlliedChartEditor(operator domain.Operator) *HttpLibAlliedChartEditor {
return &HttpLibAlliedChartEditor{
BaseServiceGateway: service_gateway.BaseServiceGateway{
ConnectTimeout: 100 * time.Second,
ReadWriteTimeout: 100 * time.Second,
CompanyId: operator.CompanyId,
OrgId: operator.OrgId,
InOrgIds: operator.OrgIds,
UserId: operator.UserId,
UserBaseId: operator.UserBaseId,
},
baseUrL: constant.ALLIED_CREATION_REPORTING_SYSTEM,
}
}
func (gateway HttpLibAlliedChartEditor) BaseUrl() string {
return gateway.baseUrL
}
... ...
... ... @@ -4,6 +4,7 @@ import (
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_manufacture"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_user"
chart_editor "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/chart-editor"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/cost_structured"
"net/http"
"os"
... ... @@ -70,6 +71,8 @@ func init() {
web.InsertFilter("/v1/manufacture/*", web.BeforeRouter, middleware.RedirectInternalService("/v1/manufacture", allied_creation_manufacture.NewHttpLibAlliedCreationManufacture(domain.Operator{})))
web.InsertFilter("/v1/cost/*", web.BeforeRouter, middleware.CheckAccessToken())
web.InsertFilter("/v1/cost/*", web.BeforeRouter, middleware.RedirectInternalService("/v1/cost", cost_structured.NewHttpLibCostStructured(domain.Operator{})))
web.InsertFilter("/v1/chart-editor/*", web.BeforeRouter, middleware.CheckAccessToken())
web.InsertFilter("/v1/chart-editor/*", web.BeforeRouter, middleware.RedirectInternalService("/chart-editor", chart_editor.NewHttpLibAlliedChartEditor(domain.Operator{})))
}
func AllowCors() func(ctx *context.Context) {
... ...
... ... @@ -225,3 +225,16 @@ func (controller *AuthController) CaptchaInit() {
data, err := authService.CaptchaInit(cmd)
controller.Response(data, err)
}
func (controller *AuthController) CheckModuleAccessCommand() {
authService := service.AuthService{}
cmd := &command.CheckModuleAccessCommand{}
err := controller.Unmarshal(cmd)
if err != nil {
controller.Response(nil, err)
return
}
cmd.Operator = controller.GetOperator()
data, err := authService.CheckModuleAccess(cmd)
controller.Response(data, err)
}
... ...
... ... @@ -21,4 +21,6 @@ func init() {
web.Router("/v1/auth/user-sign-up", &controllers.AuthController{}, "Post:UserSignUp")
web.Router("/v1/auth/reset-password", &controllers.AuthController{}, "Post:ResetPassword") //公司重置密码
web.Router("/v1/auth/org-switch", &controllers.AuthController{}, "Post:OrgSwitch")
web.Router("/v1/auth/check-module-access", &controllers.AuthController{}, "Post:CheckModuleAccessCommand")
}
... ...