Merge remote-tracking branch 'github/main'

This commit is contained in:
Liujian
2024-08-20 14:32:59 +08:00
30 changed files with 208 additions and 127 deletions
+12 -2
View File
@@ -81,6 +81,16 @@ jobs:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}
- name: build
run: cd scripts && ./docker_publish.sh ${{ secrets.DOCKER_USERNAME }} "backend"
- name: Setup qshell
uses: foxundermoon/setup-qshell@v5
with:
version: '2.9.0'
- name: build
env:
AccessKey: ${{ secrets.AK }}
SecretKey: ${{ secrets.SK }}
QINIU_BUCKET: ${{ secrets.QINIU_BUCKET }}
QINIU_NAME: ${{ secrets.QINIU_NAME }}
run: cd scripts && ./docker_publish.sh ${{ secrets.DOCKER_USERNAME }} "backend" "upload_qiniu"
+7 -3
View File
@@ -14,6 +14,10 @@ type imlTeamController struct {
module my_team.ITeamModule `autowired:""`
}
func (c *imlTeamController) SimpleTeams(ctx *gin.Context, keyword string) ([]*team_dto.SimpleTeam, error) {
return c.module.SimpleTeams(ctx, keyword)
}
func (c *imlTeamController) UpdateMemberRole(ctx *gin.Context, id string, input *team_dto.UpdateMemberRole) error {
return c.module.UpdateMemberRole(ctx, id, input)
}
@@ -23,7 +27,7 @@ func (c *imlTeamController) GetTeam(ctx *gin.Context, id string) (*team_dto.Team
}
func (c *imlTeamController) Search(ctx *gin.Context, keyword string) ([]*team_dto.Item, error) {
return c.module.Search(ctx, keyword)
}
@@ -31,8 +35,8 @@ func (c *imlTeamController) EditTeam(ctx *gin.Context, id string, team *team_dto
return c.module.Edit(ctx, id, team)
}
func (c *imlTeamController) SimpleTeams(ctx *gin.Context, keyword string) ([]*team_dto.SimpleTeam, error) {
return c.module.SimpleTeams(ctx, keyword)
func (c *imlTeamController) MySimpleTeams(ctx *gin.Context, keyword string) ([]*team_dto.SimpleTeam, error) {
return c.module.MySimpleTeams(ctx, keyword)
}
func (c *imlTeamController) AddMember(ctx *gin.Context, id string, users *team_dto.UserIDs) error {
+2 -1
View File
@@ -2,7 +2,7 @@ package my_team
import (
"reflect"
team_dto "github.com/APIParkLab/APIPark/module/my-team/dto"
"github.com/eolinker/go-common/autowire"
"github.com/gin-gonic/gin"
@@ -13,6 +13,7 @@ type ITeamController interface {
GetTeam(ctx *gin.Context, id string) (*team_dto.Team, error)
Search(ctx *gin.Context, keyword string) ([]*team_dto.Item, error)
EditTeam(ctx *gin.Context, id string, team *team_dto.EditTeam) (*team_dto.Team, error)
MySimpleTeams(ctx *gin.Context, keyword string) ([]*team_dto.SimpleTeam, error)
SimpleTeams(ctx *gin.Context, keyword string) ([]*team_dto.SimpleTeam, error)
AddMember(ctx *gin.Context, id string, users *team_dto.UserIDs) error
RemoveMember(ctx *gin.Context, id string, uuid string) error
Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.1 KiB

After

Width:  |  Height:  |  Size: 3.9 KiB

@@ -2,7 +2,8 @@ import {
ConfigProvider,
Dropdown,
MenuProps,
App} from 'antd';
App,
Button} from 'antd';
import Logo from '@common/assets/layout-logo.png';
import AvatarPic from '@common/assets/default-avatar.png'
import { routerKeyMap, TOTAL_MENU_ITEMS } from "./Navigation";
@@ -19,6 +20,8 @@ import { ResetPsw, ResetPswHandle } from './ResetPsw.tsx';
import { BasicResponse, STATUS_CODE } from '@common/const/const.ts';
import { UserInfoType, UserProfileHandle } from '@common/const/type.ts';
import { useFetch } from '@common/hooks/http.ts';
import { QuestionCircleOutlined } from '@ant-design/icons';
import { Icon } from '@iconify/react/dist/iconify.js';
const themeToken = {
bgLayout:'#17163E;',
@@ -125,18 +128,16 @@ const themeToken = {
{
key: '2',
label: (
<a target="_blank" rel="noopener noreferrer" onClick={()=>navigator('/userProfile/changepsw')}>
</a>
),
<Button key="changePsw" type="text" className="border-none p-0 flex items-center bg-transparent " onClick={()=>navigator('/userProfile/changepsw')}>
</Button>)
},
{
key: '3',
label: (
<a className="block leading-[32px]" target="_blank" rel="noopener noreferrer" onClick={logOut}>
退
</a>
),
<Button key="logout" type="text" className="border-none p-0 flex items-center bg-transparent " onClick={logOut}>
退
</Button>)
},
];
@@ -218,19 +219,19 @@ const themeToken = {
);
},
}}
// actionsRender={(props) => {
// if (props.isMobile) return [];
// if (typeof window === 'undefined') return [];
// return [
// <Button className="mr-[20px]">
// <span className='flex items-center'><QuestionCircleOutlined className="mr-[4px]" />帮助文档</span>
// </Button>
// ];
// }}
actionsRender={(props) => {
if (props.isMobile) return [];
if (typeof window === 'undefined') return [];
return [
<Button className=" text-[#ffffffb3] hover:text-[#fff] border-none" type="default" ghost onClick={()=>{window.open('https://docs.apipark.com','_blank')}}>
<span className='flex items-center gap-[8px]'> <Icon icon="ic:baseline-help" width="14" height="14"/></span>
</Button>
];
}}
headerTitleRender={() => (
<div className="w-[192px] flex items-center">
<img
className="h-[20px] cursor-pointer"
className="h-[20px] cursor-pointer "
src={Logo}
onClick={()=> navigator(mainPage)}
/>
@@ -73,7 +73,7 @@ export const ResetPsw = forwardRef<ResetPswHandle,ResetPswProps>((props,ref)=>{
layout='vertical'
form={form}
scrollToFirstError
className="mx-auto mt-mbase "
className="mx-auto mt-mbase ml-mbase"
name="resetPsw"
// labelCol={{ span: 8 }}
// wrapperCol={{ span: 10}}
@@ -109,17 +109,22 @@ export const GlobalProvider: FC<{children:ReactNode}> = ({ children }) => {
const [pluginAccessDictionary, setPluginAccessDictionary] = useState<{[k:string]:string}>({})
const [teamDataFlushed, setTeamDataFlushed] = useState<boolean>(false)
const [accessInit, setAccessInit] = useState<boolean>(false)
let getGlobalAccessPromise: Promise<BasicResponse<{ access:string[] }>> | null = null
const getGlobalAccessData = ()=>{
fetchData<BasicResponse<{ access:string[]}>>('profile/permission/system',{method:'GET'},).then(response=>{
getGlobalAccessPromise = new Promise((resolve, reject) => fetchData<BasicResponse<{ access:string[]}>>('profile/permission/system',{method:'GET'},).then(response=>{
const {code,data,msg} = response
if(code === STATUS_CODE.SUCCESS){
setAccessInit(true)
setAccessData(prevData => new Map(prevData).set('system', data.access))
resolve(data.response)
}else{
message.error(msg || '操作失败')
reject(data.msg || '操作失败')
}
})
)
return getGlobalAccessData
}
const getTeamAccessData = (teamId:string)=>{
@@ -149,7 +154,13 @@ export const GlobalProvider: FC<{children:ReactNode}> = ({ children }) => {
setPluginAccessDictionary({})
}
const checkPermission = (access:keyof typeof PERMISSION_DEFINITION[0] | Array<keyof typeof PERMISSION_DEFINITION[0]>)=>{
const checkPermission = async (access:keyof typeof PERMISSION_DEFINITION[0] | Array<keyof typeof PERMISSION_DEFINITION[0]>)=>{
if( !accessInit && getGlobalAccessPromise){
await getGlobalAccessPromise
}
if( !accessInit && !getGlobalAccessPromise){
await getGlobalAccessData()
}
let revs = false;
if (Array.isArray(access)) {
revs = access.some(item => checkAccess(item, accessData));
Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.1 KiB

After

Width:  |  Height:  |  Size: 6.7 KiB

+1 -1
View File
@@ -80,7 +80,7 @@
.apipark-layout-layout{
.apipark-layout-layout-bg-list{
background:#17163E;
background-image: radial-gradient(circle farthest-corner at 450px 350px, #050eb7, #17163e 500px);
}
.ant-layout-header.apipark-layout-layout-header{
backdrop-filter: unset !important;
+14 -6
View File
@@ -732,11 +732,17 @@ p{
}
}
.ant-drawer-footer{
padding:16px 20px !important
}
}
.ant-modal-body .pr-PAGE_INSIDE_X{
padding-right: 0 !important;
}
.g6-tooltip {
padding: 10px 6px;
color: #444;
@@ -849,9 +855,10 @@ p{
}
}
/* .ant-dropdown .ant-dropdown-menu{
border-radius: 10px;
padding: 10px;
.ant-dropdown .ant-dropdown-menu{
/* border-radius: 10px;
padding: 10px; */
li.ant-dropdown-menu-item{
padding:0 !important;
>button.ant-btn{
@@ -861,13 +868,14 @@ p{
}
>span.ant-dropdown-menu-title-content{
padding:0px !important;
min-width: 80px;
/* padding:0px 12px !important;
/* min-width: 80px; */
/* padding:0px 12px !important; */
height:32px !important;
line-height: 32px !important;
.ant-btn{
width:100%;
padding:0px 12px !important;
justify-content:flex-start;
}
.ant-btn-default:not(:disabled):not(.ant-btn-disabled):hover{
color:var(--text-color) !important;
@@ -875,7 +883,7 @@ p{
}
}
} */
}
.ant-dropdown-button{
.ant-btn-link{
color:var(--text-color) !important;
@@ -20,6 +20,7 @@ import { getImgBase64 } from "@common/utils/dataTransfer.ts";
import { CategorizesType } from "@market/const/serviceHub/type.ts";
import WithPermission from "@common/components/aoplatform/WithPermission.tsx";
import { Icon } from "@iconify/react/dist/iconify.js";
import { useGlobalContext } from "@common/contexts/GlobalStateContext.tsx";
const MAX_SIZE = 2 * 1024; // 1KB
@@ -38,6 +39,7 @@ const SystemConfig = forwardRef<SystemConfigHandle>((_,ref) => {
const [tagOptionList, setTagOptionList] = useState<DefaultOptionType[]>([])
const [serviceClassifyOptionList, setServiceClassifyOptionList] = useState<DefaultOptionType[]>()
const [uploadLoading, setUploadLoading] = useState<boolean>(false)
const {checkPermission} = useGlobalContext()
useImperativeHandle(ref, () => ({
save:onFinish
@@ -157,7 +159,8 @@ const SystemConfig = forwardRef<SystemConfigHandle>((_,ref) => {
const getTeamOptionList = ()=>{
setTeamOptionList([])
fetchData<BasicResponse<{ teams: SimpleTeamItem[] }>>('simple/teams/mine',{method:'GET',eoTransformKeys:['available_partitions']}).then(response=>{
fetchData<BasicResponse<{ teams: SimpleTeamItem[] }>>(!checkPermission('system.workspace.team.view_all') ?'simple/teams/mine' :'simple/teams',{method:'GET',eoTransformKeys:[]}).then(response=>{
const {code,data,msg} = response
if(code === STATUS_CODE.SUCCESS){
setTeamOptionList(data.teams?.map((x:MemberItem)=>{return {...x,
@@ -231,7 +234,7 @@ const SystemConfig = forwardRef<SystemConfigHandle>((_,ref) => {
labelAlign='left'
scrollToFirstError
form={form}
className="mx-auto pr-PAGE_INSIDE_X "
className="w-full pr-PAGE_INSIDE_X "
name="systemConfig"
onFinish={onFinish}
autoComplete="off"
@@ -256,7 +259,7 @@ const SystemConfig = forwardRef<SystemConfigHandle>((_,ref) => {
<Form.Item<SystemConfigFieldType>
label="API 调用前缀"
name="prefix"
extra="选填,作为服务内所有服务的API的前缀,比如host/{sys_name}/{service_name}/{api_path},一旦保存无法修改"
extra="选填,作为服务内所有API的前缀,比如host/{service_name}/{api_path},一旦保存无法修改"
rules={[
{
validator: validateUrlSlash,
@@ -55,7 +55,7 @@ const SystemList:FC = ()=>{
}
const getTeamsList = ()=>{
fetchData<BasicResponse<{teams:SimpleTeamItem[]}>>('simple/teams/mine',{method:'GET'}).then(response=>{
fetchData<BasicResponse<{ teams: SimpleTeamItem[] }>>(!checkPermission('system.workspace.team.view_all') ?'simple/teams/mine' :'simple/teams',{method:'GET',eoTransformKeys:[]}).then(response=>{
const {code,data,msg} = response
setTeamList(data.teams)
if(code === STATUS_CODE.SUCCESS){
@@ -1,5 +1,5 @@
import { forwardRef, useEffect, useImperativeHandle, useState} from "react";
import {App, Button, Divider, Form, Input, Row, Select} from "antd";
import {App, Button, Form, Input, Row, Select} from "antd";
import {Link, useLocation, useNavigate, useParams} from "react-router-dom";
import {RouterParams} from "@core/components/aoplatform/RenderRoutes.tsx";
import { v4 as uuidv4 } from 'uuid'
@@ -125,7 +125,6 @@ const TeamConfig= forwardRef<TeamConfigHandle,TeamConfigProps>((props,ref) => {
setOnEdit(false);
form.setFieldsValue({id:uuidv4()}); // 清空 initialValues
}
// setPageType(currentUrl.split('/')[1] === 'myteam'? 'myteam':'manage')
return (form.setFieldsValue({}))
}, [teamId]);
@@ -38,7 +38,7 @@ const ChangePsw= () => {
labelAlign='left'
name="changePsw"
scrollToFirstError
className="mx-auto "
className="mx-auto pl-[10px] "
autoComplete="off"
form={form}
onFinish={savePsw}
@@ -92,7 +92,7 @@ const ChangePsw= () => {
</Form.Item>
<Form.Item
className="border-none bg-transparent pt-btnrbase mb-0 pb-0"
className="border-none bg-transparent pt-btnrbase mb-0 pb-0 pl-0"
>
<WithPermission access=''><Button type="primary" htmlType="submit" >
@@ -11,12 +11,10 @@ import { EntityItem } from "@common/const/type.ts";
import { ApplyServiceModal } from "./ApplyServiceModal.tsx";
import ServiceHubApiDocument from "./ServiceHubApiDocument.tsx";
import { ApiFilled, ArrowLeftOutlined, LeftOutlined } from "@ant-design/icons";
import { Typography } from 'antd';
import { SimpleSystemItem } from "@core/const/system/type.ts";
import { Icon } from "@iconify/react/dist/iconify.js";
import DOMPurify from 'dompurify';
const { Title, Text } = Typography;
const ServiceHubDetail = ()=>{
const {serviceId} = useParams<RouterParams>();
@@ -19,7 +19,6 @@ export enum SERVICE_HUB_LIST_ACTIONS {
SET_SERVICES='SET_SERVICES',
SET_SELECTED_CATE = 'SET_SELECTED_CATE',
SET_SELECTED_TAG = 'SET_SELECTED_TAG',
SET_SELECTED_PARTITION = 'SET_SELECTED_PARTITION',
SET_KEYWORD = 'SET_KEYWORD',
LIST_LOADING = 'LIST_LOADING'
}
@@ -31,7 +30,6 @@ export type ServiceHubListActionType =
| { type: SERVICE_HUB_LIST_ACTIONS.SET_SERVICES, payload: ServiceHubTableListItem[] }
| { type: SERVICE_HUB_LIST_ACTIONS.SET_SELECTED_CATE, payload: string[] }
| { type: SERVICE_HUB_LIST_ACTIONS.SET_SELECTED_TAG, payload: string[] }
| { type: SERVICE_HUB_LIST_ACTIONS.SET_SELECTED_PARTITION, payload: string[] }
| { type: SERVICE_HUB_LIST_ACTIONS.SET_KEYWORD, payload: string }
| { type: SERVICE_HUB_LIST_ACTIONS.LIST_LOADING, payload: boolean }
@@ -42,10 +40,8 @@ export const initialServiceHubListState = {
showServicesList: [] as ServiceHubTableListItem[],
selectedCate: [] as string[],
selectedTag: [] as string[],
selectedPartition: [] as string[],
keyword: '',
getCateAndTagData:false,
getPartitionData:false,
listLoading:false,
};
@@ -63,8 +59,6 @@ export const initialServiceHubListState = {
return { ...state, selectedCate: action.payload };
case SERVICE_HUB_LIST_ACTIONS.SET_SELECTED_TAG:
return { ...state, selectedTag: action.payload };
case SERVICE_HUB_LIST_ACTIONS.SET_SELECTED_PARTITION:
return { ...state, selectedPartition: action.payload };
case SERVICE_HUB_LIST_ACTIONS.SET_KEYWORD:
return { ...state, keyword: action.payload };
case SERVICE_HUB_LIST_ACTIONS.LIST_LOADING:
@@ -75,7 +69,7 @@ export const initialServiceHubListState = {
}
export const filterServiceList = (dataSet: typeof initialServiceHubListState)=>{
if(!dataSet.getCateAndTagData || !dataSet.getPartitionData){
if(!dataSet.getCateAndTagData ){
return dataSet.servicesList
}else{
return dataSet.servicesList.filter((x)=>{
@@ -83,7 +77,6 @@ export const initialServiceHubListState = {
if(!dataSet.selectedTag || dataSet.selectedTag.length === 0) return false
if((!x.tags || !x.tags.length )&& dataSet.selectedTag.indexOf('empty') === -1) return false
if(x.tags && x.tags.length && !x.tags.some(tag => dataSet.selectedTag.includes(tag.id))) return false;
if(!dataSet.selectedPartition || dataSet.selectedPartition.length === 0) return false
if( dataSet.keyword && !x.name.includes(dataSet.keyword)) return false
return true
})
@@ -142,7 +142,6 @@ const ManagementConfig = forwardRef<ManagementConfigHandle,ManagementConfigProps
<Form.Item<ManagementConfigFieldType>
label="应用 ID"
name="id"
extra="应用IDapp_id)可用于检索服务或日志"
rules={[{ required: true, message: '必填项' ,whitespace:true }]}
>
<Input className="w-INPUT_NORMAL" placeholder="请输入" disabled={type === 'edit'}/>
@@ -51,7 +51,7 @@ const getServiceList = ()=>{
const getTeamsList = ()=>{
setPageLoading(true)
fetchData<BasicResponse<{teams:SimpleTeamItem[]}>>('simple/teams/mine',{method:'GET',eoTransformKeys:['app_num','subscribe_num']}).then(response=>{
fetchData<BasicResponse<{ teams: SimpleTeamItem[] }>>(!checkPermission('system.workspace.team.view_all') ?'simple/teams/mine' :'simple/teams',{method:'GET',eoTransformKeys:['app_num','subscribe_num']}).then(response=>{
const {code,data,msg} = response
if(code === STATUS_CODE.SUCCESS){
setTeamList(data.teams.map((x:SimpleTeamItem)=>({label:<div className="flex items-center justify-between "><span className="w-[calc(100%-42px)] truncate" title={x.name}>{x.name}</span><span className="bg-[#fff] rounded-[5px] h-[20px] w-[30px] flex items-center justify-center">{x.appNum || 0}</span></div>, key:x.id})))
+4 -3
View File
@@ -5,9 +5,9 @@ go 1.21
//toolchain go1.21.1
require (
github.com/eolinker/ap-account v1.0.8
github.com/eolinker/ap-account v1.0.9
github.com/eolinker/eosc v0.17.3
github.com/eolinker/go-common v1.0.2
github.com/eolinker/go-common v1.0.4
github.com/gabriel-vasile/mimetype v1.4.4
github.com/gin-gonic/gin v1.10.0
github.com/google/uuid v1.6.0
@@ -66,4 +66,5 @@ require (
gorm.io/driver/mysql v1.5.2 // indirect
)
replace github.com/eolinker/ap-account => ../../eolinker/ap-account
//replace github.com/eolinker/ap-account => ../../eolinker/ap-account
//replace github.com/eolinker/go-common => ../../eolinker/go-common
+4 -2
View File
@@ -23,10 +23,12 @@ github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/r
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc=
github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo=
github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
github.com/eolinker/ap-account v1.0.9 h1:tW345b1wsn0V8pfMMlZOMfpbjxQhMWBVfgsClFTJGLk=
github.com/eolinker/ap-account v1.0.9/go.mod h1:5lsZwkQfnHO5YJ3Cu6X1PZwZ0gbmJBUcix0hxG8aEsY=
github.com/eolinker/eosc v0.17.3 h1:sr2yT+v/AsqEdciRaaZZj0zL9pTufR5RvDW6+65hraQ=
github.com/eolinker/eosc v0.17.3/go.mod h1:xgq816hpanlMXFtZw7Ztdctb1eEk9UPHchY4NfFO6Cw=
github.com/eolinker/go-common v1.0.2 h1:rGxcrDdHr+mtMHVPdz3tx7oOsKLo0Msy6W0U1ZNsXaQ=
github.com/eolinker/go-common v1.0.2/go.mod h1:Kb/jENMN1mApnodvRgV4YwO9FJby1Jkt2EUjrBjvSX4=
github.com/eolinker/go-common v1.0.4 h1:F0akjnzJfIFOVmK30fD0SsCLU7DAKPXuY21MeyMmQ7w=
github.com/eolinker/go-common v1.0.4/go.mod h1:Kb/jENMN1mApnodvRgV4YwO9FJby1Jkt2EUjrBjvSX4=
github.com/gabriel-vasile/mimetype v1.4.4 h1:QjV6pZ7/XZ7ryI2KuyeEDE8wnh7fHP9YnQy+R0LnH8I=
github.com/gabriel-vasile/mimetype v1.4.4/go.mod h1:JwLei5XPtWdGiMFB5Pjle1oEeoSeEuJfJE+TtfvdB/s=
github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk=
+35 -1
View File
@@ -39,6 +39,40 @@ type imlTeamModule struct {
transaction store.ITransaction `autowired:""`
}
func (m *imlTeamModule) SimpleTeams(ctx context.Context, keyword string) ([]*team_dto.SimpleTeam, error) {
teams, err := m.teamService.Search(ctx, keyword, nil)
if err != nil {
return nil, err
}
projects, err := m.serviceService.Search(ctx, "", nil)
projectCount := make(map[string]int64)
appCount := make(map[string]int64)
for _, p := range projects {
if p.AsServer {
if _, ok := projectCount[p.Team]; !ok {
projectCount[p.Team] = 0
}
projectCount[p.Team]++
}
if p.AsApp {
if _, ok := appCount[p.Team]; !ok {
appCount[p.Team] = 0
}
appCount[p.Team]++
}
}
return utils.SliceToSlice(teams, func(s *team.Team) *team_dto.SimpleTeam {
return &team_dto.SimpleTeam{
Id: s.Id,
Name: s.Name,
Description: s.Description,
ServiceNum: projectCount[s.Id],
AppNum: appCount[s.Id],
}
}), nil
}
func (m *imlTeamModule) UpdateMemberRole(ctx context.Context, id string, input *team_dto.UpdateMemberRole) error {
_, err := m.teamService.Get(ctx, id)
if err != nil {
@@ -157,7 +191,7 @@ func (m *imlTeamModule) Edit(ctx context.Context, id string, input *team_dto.Edi
return m.GetTeam(ctx, id)
}
func (m *imlTeamModule) SimpleTeams(ctx context.Context, keyword string) ([]*team_dto.SimpleTeam, error) {
func (m *imlTeamModule) MySimpleTeams(ctx context.Context, keyword string) ([]*team_dto.SimpleTeam, error) {
userID := utils.UserId(ctx)
memberMap, err := m.teamMemberService.FilterMembersForUser(ctx, userID)
if err != nil {
+5 -3
View File
@@ -3,9 +3,9 @@ package my_team
import (
"context"
"reflect"
"github.com/eolinker/go-common/autowire"
team_dto "github.com/APIParkLab/APIPark/module/my-team/dto"
)
@@ -16,6 +16,8 @@ type ITeamModule interface {
Search(ctx context.Context, keyword string) ([]*team_dto.Item, error)
// Edit 编辑团队
Edit(ctx context.Context, id string, input *team_dto.EditTeam) (*team_dto.Team, error)
// MySimpleTeams 简易搜索团队
MySimpleTeams(ctx context.Context, keyword string) ([]*team_dto.SimpleTeam, error)
// SimpleTeams 简易搜索团队
SimpleTeams(ctx context.Context, keyword string) ([]*team_dto.SimpleTeam, error)
// AddMember 添加团队成员
@@ -26,7 +28,7 @@ type ITeamModule interface {
Members(ctx context.Context, id string, keyword string) ([]*team_dto.Member, error)
// SimpleMembers 获取团队成员简易列表
SimpleMembers(ctx context.Context, id string, keyword string) ([]*team_dto.SimpleMember, error)
// UpdateMemberRole 更新成员角色
UpdateMemberRole(ctx context.Context, id string, input *team_dto.UpdateMemberRole) error
}
+27 -26
View File
@@ -24,31 +24,32 @@ type imlTeamPermitModule struct {
func (m *imlTeamPermitModule) Permissions(ctx context.Context, teamId string) ([]string, error) {
uid := utils.UserId(ctx)
roleMembers, err := m.roleMemberService.List(ctx, role.TeamTarget(teamId), uid)
if err != nil {
return nil, err
}
roleIds := utils.SliceToSlice(roleMembers, func(rm *role.Member) string {
return rm.Role
})
if len(roleMembers) == 0 {
return []string{}, nil
}
roles, err := m.roleService.List(ctx, roleIds...)
if err != nil {
return nil, err
}
permits := make(map[string]struct{})
for _, r := range roles {
for _, p := range r.Permit {
permits[p] = struct{}{}
}
}
return utils.MapToSlice(permits, func(k string, v struct{}) string {
return k
}), nil
//uid := utils.UserId(ctx)
//roleMembers, err := m.roleMemberService.List(ctx, role.TeamTarget(teamId), uid)
//if err != nil {
// return nil, err
//}
//roleIds := utils.SliceToSlice(roleMembers, func(rm *role.Member) string {
// return rm.Role
//})
//if len(roleMembers) == 0 {
// return []string{}, nil
//}
//roles, err := m.roleService.List(ctx, roleIds...)
//if err != nil {
// return nil, err
//}
//permits := make(map[string]struct{})
//for _, r := range roles {
// for _, p := range r.Permit {
// permits[p] = struct{}{}
// }
//}
//
//return utils.MapToSlice(permits, func(k string, v struct{}) string {
// return k
//}), nil
return m.accesses(ctx, teamId)
}
func (m *imlTeamPermitModule) OnComplete() {
@@ -59,7 +60,7 @@ func (m *imlTeamPermitModule) accesses(ctx context.Context, teamId string) ([]st
// 判断是否是访客,如果是,直接返回访客权限
if utils.GuestAllow() && utils.IsGuest(ctx) {
return access.GuestAccess(role.SystemTarget()), nil
return access.GuestAccess(role.GroupTeam), nil
}
uid := utils.UserId(ctx)
roleMembers, err := m.roleMemberService.List(ctx, role.TeamTarget(teamId), uid)
+16 -17
View File
@@ -2,33 +2,33 @@ package core
import (
"net/http"
plugin_cluster "github.com/APIParkLab/APIPark/controller/plugin-cluster"
"github.com/APIParkLab/APIPark/controller/cluster"
"github.com/eolinker/ap-account/controller/role"
"github.com/APIParkLab/APIPark/controller/common"
dynamic_module "github.com/APIParkLab/APIPark/controller/dynamic-module"
"github.com/APIParkLab/APIPark/controller/release"
application_authorization "github.com/APIParkLab/APIPark/controller/application-authorization"
"github.com/APIParkLab/APIPark/controller/subscribe"
"github.com/APIParkLab/APIPark/controller/api"
"github.com/APIParkLab/APIPark/controller/upstream"
"github.com/APIParkLab/APIPark/controller/service"
"github.com/APIParkLab/APIPark/controller/catalogue"
"github.com/APIParkLab/APIPark/controller/my_team"
"github.com/APIParkLab/APIPark/controller/certificate"
"github.com/APIParkLab/APIPark/controller/team_manager"
"github.com/eolinker/go-common/autowire"
@@ -47,7 +47,7 @@ func (d *Driver) Access() map[string][]string {
}
func (d *Driver) Create() (pm3.IPlugin, error) {
p := new(plugin)
autowire.Autowired(p)
return p, nil
@@ -76,7 +76,6 @@ type plugin struct {
}
func (p *plugin) OnComplete() {
p.apis = append(p.apis, p.partitionApi()...)
p.apis = append(p.apis, p.certificateApi()...)
p.apis = append(p.apis, p.clusterApi()...)
p.apis = append(p.apis, p.TeamManagerApi()...)
@@ -89,7 +88,7 @@ func (p *plugin) OnComplete() {
p.apis = append(p.apis, p.projectAuthorizationApis()...)
p.apis = append(p.apis, p.releaseApis()...)
p.apis = append(p.apis, p.DynamicModuleApis()...)
p.apis = append(p.apis, p.PartitionPluginApi()...)
p.apis = append(p.apis, p.commonApis()...)
}
+2 -1
View File
@@ -10,7 +10,8 @@ func (p *plugin) MyTeamApi() []pm3.Api {
return []pm3.Api{
pm3.CreateApiWidthDoc(http.MethodGet, "/api/v1/team", []string{"context", "query:team"}, []string{"team"}, p.myTeamController.GetTeam),
pm3.CreateApiWidthDoc(http.MethodGet, "/api/v1/teams", []string{"context", "query:keyword"}, []string{"teams"}, p.myTeamController.Search),
pm3.CreateApiWidthDoc(http.MethodGet, "/api/v1/simple/teams/mine", []string{"context", "query:keyword"}, []string{"teams"}, p.myTeamController.SimpleTeams),
pm3.CreateApiWidthDoc(http.MethodGet, "/api/v1/simple/teams/mine", []string{"context", "query:keyword"}, []string{"teams"}, p.myTeamController.MySimpleTeams),
pm3.CreateApiWidthDoc(http.MethodGet, "/api/v1/simple/teams", []string{"context", "query:keyword"}, []string{"teams"}, p.myTeamController.SimpleTeams),
pm3.CreateApiWidthDoc(http.MethodGet, "/api/v1/team/members/simple", []string{"context", "query:team", "query:keyword"}, []string{"teams"}, p.myTeamController.SimpleMembers),
pm3.CreateApiWidthDoc(http.MethodPut, "/api/v1/team", []string{"context", "query:team", "body"}, []string{"team"}, p.myTeamController.EditTeam),
pm3.CreateApiWidthDoc(http.MethodPost, "/api/v1/team/member", []string{"context", "query:team", "body"}, nil, p.myTeamController.AddMember),
-17
View File
@@ -1,17 +0,0 @@
package core
import (
"github.com/eolinker/go-common/pm3"
)
func (p *plugin) partitionApi() []pm3.Api {
return []pm3.Api{
//pm3.CreateApiWidthDoc(http.MethodGet, "/api/v1/partitions", []string{"context", "query:keyword"}, []string{"partitions"}, p.partitionController.Search),
//pm3.CreateApiWidthDoc(http.MethodGet, "/api/v1/partition", []string{"context", "query:id"}, []string{"partition"}, p.partitionController.Info),
//pm3.CreateApiWidthDoc(http.MethodPost, "/api/v1/partition", []string{"context", "body"}, []string{"partition", "id", "update_time"}, p.partitionController.Create),
//pm3.CreateApiWidthDoc(http.MethodPut, "/api/v1/partition", []string{"context", "query:id", "body"}, []string{"partition"}, p.partitionController.Update),
//pm3.CreateApiWidthDoc(http.MethodDelete, "/api/v1/partition", []string{"context", "query:id"}, []string{"id"}, p.partitionController.Delete),
//pm3.CreateApiWidthDoc(http.MethodGet, "/api/v1/simple/partitions", []string{"context"}, []string{"partitions"}, p.partitionController.Simple),
//pm3.CreateApiWidthDoc(http.MethodGet, "/api/v1/simple/partitions/cluster", []string{"context"}, []string{"partitions"}, p.partitionController.SimpleWithCluster),
}
}
-2
View File
@@ -290,7 +290,6 @@ team:
cname: 管理
value: 'manager'
apis:
- "GET:/api/v1/service/info"
- "PUT:/api/v1/service/info"
- "POST:/api/v1/team/service"
- "DELETE:/api/v1/team/service"
@@ -342,7 +341,6 @@ team:
cname: 管理
value: 'manager'
apis:
- "GET:/api/v1/app/info"
- "PUT:/api/v1/app/info"
- "POST:/api/v1/team/app"
- "DELETE:/api/v1/app"
+5
View File
@@ -45,4 +45,9 @@ docker manifest annotate "${ImageName}:${Version}" "${ImageName}:${Version}-arm6
echo "Push manifest ${ImageName}:${Version}"
docker manifest push "${ImageName}:${Version}"
if [[ $3 == "upload_qiniu" ]];then
echo "Upload QINIU Cloud..."
./scripts/qiniu_publish.sh ${Version} ${ImageName} amd64
./scripts/qiniu_publish.sh ${Version} ${ImageName} arm64
fi
+28
View File
@@ -0,0 +1,28 @@
#!/bin/sh
set -e
Version=$1
ImageName=$2
APP="apipark"
ARCH=$3
if [ "$ARCH" == "" ];then
ARCH="amd64"
fi
Tar="${APP}.${Version}.${ARCH}.tar.gz"
docker tag ${ImageName}:${Version}-${ARCH} ${ImageName}:${Version}
echo "docker save -o ${Tar} ${ImageName}:${Version}"
docker save -o ${Tar} ${ImageName}:${Version}
echo "login qiniu..."
qshell account ${AccessKey} ${SecretKey} ${QINIU_NAME}
echo "qshell rput ${QINIU_BUCKET} \"${APP}/images/${Tar}\" ${Tar}"
qshell rput ${QINIU_BUCKET} "${APP}/images/${Tar}" ${Tar}
rm -f ${Tar}
docker rmi -f ${ImageName}:${Version}