| | |
| | | v-if="item.type === 'select'" |
| | | slot="prepend" |
| | | v-model="row[item.prop]" |
| | | @change="roleChange" |
| | | > |
| | | <el-option |
| | | v-for="optionItem in roleList" |
| | |
| | | this.$emit('update:visible', false); |
| | | this.classifyAuthData = []; |
| | | }, |
| | | // è§è²æ¹åæ¶ |
| | | roleChange(roleId){ |
| | | console.log(roleId); |
| | | |
| | | }, |
| | | // å¢å è¡ |
| | | addClassifyAuth() { |
| | | if(this.roleList.length<=0){ |
¶Ô±ÈÐÂÎļþ |
| | |
| | | <template> |
| | | <el-dialog |
| | | v-dialogDrag |
| | | :close-on-click-modal="false" |
| | | :visible.sync="isShowDialog" |
| | | append-to-body |
| | | class="avue-dialog avue-dialog--top" |
| | | title="æ°æ®ææ" |
| | | top="-45px" @close="closeDialog"> |
| | | <el-table |
| | | ref="dataTable" |
| | | v-loading="isLoading" |
| | | :data="classifyAuthData" |
| | | :header-cell-style="{ background: '#FAFAFA', color: '#505050' }" |
| | | :height="tableHeight" |
| | | border |
| | | class="cus-table" |
| | | @select="handleSelection" |
| | | @row-click="handleRowClick" |
| | | @select-all="handleSelectionAll" |
| | | @selection-change="handleSelectionChange" |
| | | @sort-change="sortChange" |
| | | > |
| | | <el-table-column |
| | | type="selection" |
| | | width="55" |
| | | ></el-table-column> |
| | | <el-table-column |
| | | v-for="(item, index) in classifyAuthHeader" |
| | | v-if="classifyAuthHeader.length !== 0" |
| | | :key="index" |
| | | :label="item.label" |
| | | :prop="item.prop" |
| | | :show-overflow-tooltip="true" |
| | | :width="item.width" |
| | | align="center" |
| | | > |
| | | <template slot-scope="{ row }"> |
| | | <el-select |
| | | v-if="item.type === 'select'" |
| | | slot="prepend" |
| | | v-model="row[item.prop]" |
| | | @change="roleChange" |
| | | > |
| | | <el-option |
| | | v-for="optionItem in roleList" |
| | | :key="optionItem.id" |
| | | :label="optionItem.roleName" |
| | | :value="optionItem.id" |
| | | > |
| | | </el-option> |
| | | </el-select> |
| | | <el-input |
| | | v-if="item.type === 'text'" |
| | | v-model="row[item.prop]" |
| | | readonly |
| | | type="text" |
| | | > |
| | | </el-input> |
| | | <el-checkbox |
| | | v-if="item.type === 'checkbox'" |
| | | v-model="row[item.prop]"> |
| | | </el-checkbox> |
| | | </template> |
| | | </el-table-column> |
| | | </el-table> |
| | | <div slot="footer" class="dialog-footer"> |
| | | <el-button type="info" plain @click="selectAllButton">æé®å
¨é</el-button> |
| | | <el-button class="el-icon-plus" type="success" plain @click="addClassifyAuth"></el-button> |
| | | <el-button class="el-icon-minus" type="warning" plain @click="subClassifyAuth"></el-button> |
| | | <el-button type="primary" plain @click="submit">æ 交</el-button> |
| | | <el-button type="danger" plain @click="isShowDialog = false">å
³ é</el-button> |
| | | </div> |
| | | </el-dialog> |
| | | </template> |
| | | |
| | | <script> |
| | | import {getButtonByParentCode} from "@/api/system/menu" |
| | | import {getPage} from "@/api/system/role" |
| | | import {saveOrUpdate, getClassifyAuthList} from "@/api/system/classifyAuth" |
| | | import {v4 as uuidv4} from 'uuid'; |
| | | |
| | | export default { |
| | | name: "dataAuthDialog.vue", |
| | | props: { |
| | | classifyData: { |
| | | type: "Object", |
| | | default: "", |
| | | }, |
| | | /**å¯¹è¯æ¡æ¾ç¤ºéèæ§å¶*/ |
| | | visible: { |
| | | type: "Boolean", |
| | | default: false, |
| | | }, |
| | | }, |
| | | data() { |
| | | return { |
| | | // å¯¹è¯æ¡æ¾ç¤ºæ§å¶ |
| | | isShowDialog: this.visible, |
| | | isLoading: false, |
| | | tableHeight: 'calc(100vh - 550px)', |
| | | classifyAuthData: [], |
| | | //å头 |
| | | classifyAuthHeader: [], |
| | | //æé®æ°æ® |
| | | classifyAuthButton: [], |
| | | //è§è²å表 |
| | | roleList: [], |
| | | //å½åéä¸çè¡¨æ ¼è¡ |
| | | selectList: [], |
| | | }; |
| | | }, |
| | | watch: { |
| | | // çå¬ç¶ç»ä»¶ä¼ ççªå£æ¾ç¤ºéèçå¼ |
| | | visible() { |
| | | if (this.visible) { |
| | | this.isShowDialog = this.visible; |
| | | return new Promise((resolve, reject) => { |
| | | getButtonByParentCode({code: this.classifyData.attributes.id}).then(res => { |
| | | // è®°å½æé®æ°æ® |
| | | this.classifyAuthButton = res.data.data; |
| | | const list = res.data.data; |
| | | let tempData = []; |
| | | // è§è²å |
| | | tempData.push({ |
| | | label: "è§è²", |
| | | prop: "roleData", |
| | | type: "select", |
| | | width: 150, |
| | | }); |
| | | // ç¼ç 项åç±»ææ |
| | | tempData.push({ |
| | | label: "ç¼ç é¡¹æ°æ®ææ", |
| | | prop: "classifyItem", |
| | | type: "text", |
| | | width: 180, |
| | | }); |
| | | list.forEach(item => { |
| | | let columnItem = { |
| | | label: item.name, |
| | | prop: item.id, |
| | | type: "checkbox", |
| | | width: 180, |
| | | }; |
| | | tempData.push(columnItem); |
| | | }) |
| | | this.classifyAuthHeader = tempData |
| | | resolve(); |
| | | }).catch(err => { |
| | | reject(err) |
| | | }); |
| | | // è·åè§è²å表 |
| | | getPage(1, -1, null).then(res => { |
| | | this.roleList = res.data.data.records; |
| | | }); |
| | | // è·å该åç±»ä¸å·²ææçåç±»ææä¿¡æ¯ |
| | | getClassifyAuthList({classifyId: this.classifyData.oid,authType: "data_auth"}).then(res => { |
| | | //console.log(res.data.data); |
| | | let authDatas = res.data.data; |
| | | if (authDatas.length > 0) { |
| | | authDatas.forEach(authData => { |
| | | let item = { |
| | | oid: authData.oid, |
| | | roleData: authData.roleId, |
| | | classifyItem: this.classifyData.label, |
| | | uuid: uuidv4(),//çæå¯ä¸çid |
| | | } |
| | | //å°æé®è®¾ç½®è¿å» |
| | | authData.buttonIdList.forEach(data => { |
| | | Vue.set(item, data, true); |
| | | }); |
| | | //console.log(item) |
| | | this.classifyAuthData.push(item); |
| | | }) |
| | | } |
| | | }); |
| | | }); |
| | | } |
| | | }, |
| | | }, |
| | | computed: {}, |
| | | mounted() { |
| | | }, |
| | | created() { |
| | | }, |
| | | methods: { |
| | | // å
³éå¯¹è¯æ¡ |
| | | closeDialog() { |
| | | this.$emit('update:visible', false); |
| | | this.classifyAuthData = []; |
| | | }, |
| | | // è§è²æ¹åæ¶ |
| | | roleChange(roleId){ |
| | | console.log(roleId); |
| | | |
| | | }, |
| | | // å¢å è¡ |
| | | addClassifyAuth() { |
| | | if(this.roleList.length<=0){ |
| | | this.$message.warning("å½åç§æ·ä¸åå¨è§è²ä¿¡æ¯ï¼"); |
| | | return; |
| | | } |
| | | let item = { |
| | | roleData: this.roleList[0].id, |
| | | classifyItem: this.classifyData.label, |
| | | uuid: uuidv4(),//çæå¯ä¸çid |
| | | |
| | | } |
| | | //å°æé®è®¾ç½®è¿å» |
| | | this.classifyAuthButton.forEach(data => { |
| | | Vue.set(item, data.id, false); |
| | | }) |
| | | //console.log(item) |
| | | this.classifyAuthData.push(item) |
| | | // console.log(this.classifyAuthData); |
| | | }, |
| | | // å é¤è¡ |
| | | subClassifyAuth() { |
| | | for (let item of this.selectList) { |
| | | let index = this.classifyAuthData.findIndex(data => data.index === item.index); |
| | | if (index !== -1) { |
| | | this.classifyAuthData.splice(index, 1); |
| | | } |
| | | } |
| | | }, |
| | | handleRowClick(row, column) { |
| | | this.selectList.push(row); |
| | | this.$refs.dataTable.toggleRowSelection(row); |
| | | }, |
| | | // å¤é |
| | | handleSelectionChange(list) { |
| | | this.selectList = list; |
| | | //console.log("å¤é"); |
| | | }, |
| | | // éæ©å
¨é¨ |
| | | handleSelectionAll(list) { |
| | | this.selectList = list; |
| | | }, |
| | | // ä¿ååç±»ææä¿¡æ¯ |
| | | submit() { |
| | | if (this.classifyAuthData.length <= 0) { |
| | | this.$message.warning('ææå表为空ï¼') |
| | | return; |
| | | } |
| | | let isRepeat = false; |
| | | // éåæ°ç»ï¼æ¯è¾åé¢ç对象çroleDataæ¯å¦ä¸åé¢ç对象ç¸ç |
| | | for (let i = 0; i < this.classifyAuthData.length - 1; i++) { |
| | | let currentRoleId = this.classifyAuthData[i].roleData; |
| | | for (let j = i + 1; j < this.classifyAuthData.length; j++) { |
| | | if (currentRoleId === this.classifyAuthData[j].roleData) { |
| | | isRepeat = true; |
| | | break; |
| | | } |
| | | } |
| | | if (isRepeat) { |
| | | break; |
| | | } |
| | | } |
| | | if (isRepeat) { |
| | | this.$message.warning("è§è²åå类已ç»åå¨ï¼è¯·éæ°é
ç½®ï¼"); |
| | | return; |
| | | } |
| | | let form = []; |
| | | let flag = false; |
| | | this.classifyAuthData.forEach(item => { |
| | | let itemButtonList = []; |
| | | //çéåºæé®å¾é为trueçå |
| | | for (let key in item) { |
| | | if (item[key] === true) { |
| | | itemButtonList.push(key); |
| | | } |
| | | } |
| | | /**妿itemButtonListä¸ºç©ºè¯ææ¯ï¼ |
| | | æ·»å äºè§è²ä½æ¯æ²¡å¾éä»»ä½çæé®*/ |
| | | if (itemButtonList.length <= 0) { |
| | | flag = true; |
| | | return; |
| | | } |
| | | let data = { |
| | | oid: item.oid, |
| | | roleId: item.roleData, |
| | | classifyId: this.classifyData.oid, |
| | | buttonIds: itemButtonList.join(","), |
| | | authType: "data_auth", |
| | | } |
| | | form.push(data); |
| | | }); |
| | | if (flag) { |
| | | this.$message.warning('ææªå¾éæä½çæéï¼ä¸å
许ææ') |
| | | return; |
| | | } |
| | | // console.log(form) |
| | | // è°ç¨ä¿ååç±»ææçæ¥å£ |
| | | saveOrUpdate(form).then(res => { |
| | | this.$message({ |
| | | type: "success", |
| | | message: res.data.msg, |
| | | }); |
| | | // this.isShowDialog = false |
| | | }, (error) => { |
| | | window.console.log(error); |
| | | }) |
| | | }, |
| | | // å
¨éæé® |
| | | selectAllButton(){ |
| | | if(this.selectList.length!==1){ |
| | | this.$message.warning("请åªéæ©ä¸è¡éè¦å
¨éçæé®çæ°æ®è¡ï¼"); |
| | | return; |
| | | } |
| | | this.classifyAuthButton.forEach(item => { |
| | | //console.log("item",item); |
| | | Vue.set(this.selectList[0], item.id, true); |
| | | }); |
| | | //console.log("this.selectList",this.selectList); |
| | | }, |
| | | }, |
| | | }; |
| | | </script> |
| | | |
| | | <style lang="scss" scoped> |
| | | |
| | | // æ»å¨æ¡æ ·å¼ä¿®æ¹ |
| | | // æ»å¨æ¡ç宽度 |
| | | /deep/ .el-table__body-wrapper::-webkit-scrollbar { |
| | | height: 15px; // çºµåæ»å¨æ¡ å¿
å |
| | | background: white; |
| | | border: white; |
| | | width: 10px; |
| | | |
| | | } |
| | | |
| | | // æ»å¨æ¡çæ»å |
| | | /deep/ .el-table__body-wrapper::-webkit-scrollbar-thumb { |
| | | background-color: #ececec; |
| | | border-radius: 20px; |
| | | border: #ececec; |
| | | } |
| | | |
| | | /deep/ .el-table__body-wrapper { |
| | | height: calc(100% - 50px) !important; |
| | | } |
| | | |
| | | </style> |
| | |
| | | style="width: 56px;text-align: center;padding-left: 3px" type="primary" |
| | | @click="classifyAuthHandler">åç±»ææ |
| | | </el-button> |
| | | <el-button v-if="permissionList.classifyAuth" plain size="small" |
| | | style="width: 56px;text-align: center;padding-left: 3px" type="primary" |
| | | @click="dataAuthHandler">æ°æ®ææ |
| | | </el-button> |
| | | </div> |
| | | <!-- 左侧æ --> |
| | | |
| | |
| | | :classifyData="classifyData" |
| | | :visible.sync="classifyAuthVisible" |
| | | ></classify-auth-dialog> |
| | | <!-- æ°æ®ææå¯¹è¯æ¡ --> |
| | | <data-auth-dialog |
| | | :classifyData="classifyData" |
| | | :visible.sync="dataAuthVisible" |
| | | ></data-auth-dialog> |
| | | </basic-container> |
| | | </el-aside> |
| | | <el-main> |
| | |
| | | TreeAddFormVisible: false, |
| | | //åç±»ææå¯¹è¯æ¡ |
| | | classifyAuthVisible: false, |
| | | //æ°æ®ææå¯¹è¯æ¡ |
| | | dataAuthVisible: false, |
| | | //å½åç¹å»é¡¹ |
| | | nodeClickList: "", |
| | | ClonenodeClickList: "", |
| | |
| | | } |
| | | this.classifyData = this.nodeClickList; |
| | | this.classifyAuthVisible = true; |
| | | }, |
| | | // æ°æ®ææå¯¹è¯æ¡æå¼ |
| | | dataAuthHandler() { |
| | | if (this.nodeClickList.oid === '' || this.nodeClickList.oid === undefined) { |
| | | this.$message.warning('请è³å°éæ©ä¸æ¡æ°æ®ï¼') |
| | | return; |
| | | } |
| | | this.classifyData = this.nodeClickList; |
| | | this.dataAuthVisible = true; |
| | | }, |
| | | flowingDependHandler() { |
| | | if (this.nodeClickList.length <= 0) { |
| | |
| | | }, |
| | | //æ ç¹å»äºä»¶ |
| | | async nodeClick(data) { |
| | | getAuthButtonList({classifyId: data.oid}).then(res => { |
| | | getAuthButtonList({classifyId: data.oid,code: "classifyTree",authType: "classify_auth"}).then(res => { |
| | | this.btnAuthList = res.data.data; |
| | | }).catch(error => { |
| | | console.log(error) |
| | | window.console.log(error) |
| | | }) |
| | | //æä½æ°å¢åä¿®æ¹çä¸å¡ç±»åéè |
| | | this.TreeFlagCode = !data; |
| | |
| | | import classifyTrees from "@/components/Theme/ThemeClassifyTrees" |
| | | import classifyTreeform from "@/components/Theme/ThemeClassifyTreeform" |
| | | import classifyAuthDialog from "@/components/Theme/ClassifyAuthDialog" |
| | | import dataAuthDialog from "@/components/Theme/DataAuthDialog" |
| | | import TemplatePro from "@/components/Theme/ThemeTemplatePro" |
| | | import attrCrud from "@/components/Theme/ThemeAttrCrud" |
| | | import formulaEditor from "@/components/code-dialog-page/formulaEditor" |
| | |
| | | Vue.component('originalLink',originalLink) |
| | | Vue.component('classifyTrees',classifyTrees) |
| | | Vue.component('classifyAuthDialog',classifyAuthDialog) |
| | | Vue.component('dataAuthDialog',dataAuthDialog) |
| | | Vue.component('classifyTreeform',classifyTreeform) |
| | | Vue.component('TemplatePro',TemplatePro) |
| | | Vue.component('formulaEditor',formulaEditor) |
| | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * åç±»ææåæ°å¯¹è±¡ |
| | | * åç±»ææï¼æ°æ®ææåæ°å¯¹è±¡ |
| | | * @author ludc |
| | | * @date 2023/12/25 15:36 |
| | | */ |
| | |
| | | */ |
| | | private String buttonIds; |
| | | |
| | | /** |
| | | * ææç±»å |
| | | */ |
| | | private String authType; |
| | | |
| | | } |
| | |
| | | * @return List<Menu> |
| | | */ |
| | | @GetMapping(MENU_BUTTON) |
| | | R<List<Menu>> getMenuButtonByType(@RequestParam("btmType") String btmType); |
| | | R<List<Menu>> getMenuButtonByType(@RequestParam("classifyId") String classifyId,@RequestParam("btmType") String btmType,@RequestParam("authType") String authType); |
| | | |
| | | /** |
| | | * è·åé¨é¨ |
| | |
| | | } |
| | | |
| | | @Override |
| | | public R<List<Menu>> getMenuButtonByType(String btmType) { |
| | | public R<List<Menu>> getMenuButtonByType(String classifyId, String btmType, String authType) { |
| | | return R.fail("è·åæ°æ®å¤±è´¥"); |
| | | } |
| | | |
| | |
| | | @Override |
| | | public MdmUIInfoVO getUIInfoByClassifyOid(String codeClassifyOid, String functionId) { |
| | | VciBaseUtil.alertNotNull(codeClassifyOid, "主é¢åºå类主é®"); |
| | | |
| | | MdmUIInfoVO uiInfoVO = getTableDefineByTemplateVO(getUsedTemplateByClassifyOid(codeClassifyOid)); |
| | | uiInfoVO.setLeaf(classifyService.countChildrenByClassifyOid(codeClassifyOid) == 0); |
| | | if (StringUtils.isNotBlank(functionId) && !"~".equalsIgnoreCase(functionId)) { |
| | | List<Menu> buttonVOS = iSysClient.getMenuButtonByType(uiInfoVO.getTemplateVO().getBtmTypeId()).getData(); |
| | | List<Menu> buttonVOS = iSysClient.getMenuButtonByType(codeClassifyOid,uiInfoVO.getTemplateVO().getBtmTypeId(),"data_auth").getData(); |
| | | // List<SmOperationVO> operationVOS = operationService.listButtonByFunctionId(functionId); |
| | | // if (operationVOS == null) { |
| | | // operationVOS = new ArrayList<>(); |
| | |
| | | package com.vci.ubcs.system.controller; |
| | | |
| | | import com.vci.ubcs.system.entity.ClassifyAuth; |
| | | import com.vci.ubcs.system.entity.Menu; |
| | | import com.vci.ubcs.system.service.IClassifyAuthService; |
| | | import com.vci.ubcs.system.vo.ClassifyAuthVO; |
| | | import io.swagger.annotations.Api; |
| | |
| | | import org.springframework.web.bind.annotation.*; |
| | | import springfox.documentation.annotations.ApiIgnore; |
| | | |
| | | import javax.validation.Valid; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * åç±»ææ |
| | | * åç±»ææ,æ°æ®ææ |
| | | * @author ludc |
| | | * @date 2023/12/20 11:33 |
| | | */ |
| | |
| | | /** |
| | | * æ¥è¯¢è¯¥åç±»ä¸ï¼å½åç»å½çè§è²æåªäºæé®æé |
| | | * @param classifyId |
| | | * @param menuCode |
| | | * @param authType |
| | | * @return |
| | | */ |
| | | @GetMapping("/getAuthButtonList") |
| | | public R<Map<String,Boolean>> getAuthButtonList(@RequestParam("classifyId") String classifyId){ |
| | | return R.data(classifyAuthService.getAuthButtonList(classifyId)); |
| | | public R<Map<String,Boolean>> getAuthButtonList(@Valid @RequestParam("classifyId") String classifyId,@Valid @RequestParam("code") String menuCode,@Valid @RequestParam("authType") String authType){ |
| | | return R.data(classifyAuthService.getAuthButtonList(classifyId,menuCode,authType)); |
| | | } |
| | | |
| | | } |
| | |
| | | return menuService.cloneMenuButton(buttonCloneVO.getMenuId(), buttonCloneVO.getButtonIds()); |
| | | } |
| | | |
| | | /** |
| | | * æ ¹æ®è§è²idè·åå·²ææçæé®ä¿¡æ¯ |
| | | * @param roleId |
| | | * @return |
| | | */ |
| | | @GetMapping("/getButtonsByRoleId") |
| | | public R<List<Menu>> getButtonsByRoleId(@Valid @RequestParam("roleId") String roleId,@Valid @RequestParam("code") String menuCode){ |
| | | return R.data(menuService.getButtonsByRoleId(roleId,menuCode)); |
| | | } |
| | | |
| | | } |
| | |
| | | import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; |
| | | import com.vci.ubcs.system.cache.NacosConfigCache; |
| | | import com.vci.ubcs.system.cache.SysCache; |
| | | import com.vci.ubcs.system.entity.Menu; |
| | | import com.vci.ubcs.system.entity.Role; |
| | | import com.vci.ubcs.system.service.IRoleService; |
| | | import com.vci.ubcs.system.user.cache.UserCache; |
| | |
| | | |
| | | @Override |
| | | @GetMapping(MENU_BUTTON) |
| | | public R<List<Menu>> getMenuButtonByType(String btmType) { |
| | | return R.data(menuService.getMenuButtonByType(btmType, AuthUtil.getUserId())); |
| | | public R<List<Menu>> getMenuButtonByType(String classifyId,String btmType,String authType) { |
| | | return R.data(menuService.getMenuButtonByType(classifyId,btmType,authType)); |
| | | } |
| | | |
| | | @Override |
| | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * åç±»ææ,æ°æ®ææ |
| | | * @author ludc |
| | | * @date 2023/12/25 15:50 |
| | | */ |
| | |
| | | List<Menu> selectMenuChildByBtnType(String btmType,List<String> roleIds); |
| | | |
| | | /** |
| | | * æ ¹æ®ç¶èåcodeæ¥è¯¢èåçåæé® |
| | | * æ ¹æ®ç¶èåcodeåè§è²idè·åå·²ææçæé®ä¿¡æ¯ |
| | | * |
| | | * @return |
| | | */ |
| | | List<Menu> getButtonByParentCode(@Param("code") String code); |
| | | List<Menu> getButtonsByRoleIdAndCode(@Param("roleId") String roleId, @Param("code") String code); |
| | | |
| | | /** |
| | | * æ ¹æ®ç¶èåcodeåè§è²idè·åå·²ææçæé®ä¿¡æ¯ |
| | | * |
| | | * @return |
| | | */ |
| | | List<Menu> getButtonByIdsOrByParentCode(@Param("roleIds") String roleIds, @Param("code") String code,@Param("ids") List<String> ids); |
| | | |
| | | /** |
| | | * æéé
ç½®èå |
| | |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * åç±»ææ |
| | | * åç±»ææ,æ°æ®ææ |
| | | * @author ludc |
| | | * @date 2023/12/25 15:34 |
| | | */ |
| | |
| | | /** |
| | | * æ¥è¯¢è¯¥åç±»ä¸ï¼å½åç»å½çè§è²æåªäºæé®æé |
| | | * @param classifyId |
| | | * @param menuCode |
| | | * @param authType |
| | | * @return |
| | | */ |
| | | Map<String,Boolean> getAuthButtonList(String classifyId); |
| | | Map<String,Boolean> getAuthButtonList(String classifyId,String menuCode,String authType); |
| | | |
| | | /** |
| | | * æ¥è¯¢è¯¥ä¸»æ°æ®ä¸ï¼å½åç»å½çè§è²æåªäºæé®æé |
| | | * @param classifyId |
| | | * @param menuCode |
| | | * @param authType |
| | | * @return |
| | | */ |
| | | List<Menu> getAuthMenuButtonList(String classifyId,String menuCode,String authType); |
| | | |
| | | /** |
| | | * æ ¹æ®è§è²idæ¥çæåªäºåç±»å
·å¤æ¥çæé |
| | |
| | | |
| | | /** |
| | | * è·åèåä¸é¢çæé® |
| | | * @param btmType ä¸å¡ç±»å |
| | | * @return List<Menu> |
| | | * @param classifyId |
| | | * @param btmType |
| | | * @param authType |
| | | * @return |
| | | */ |
| | | List<Menu> getMenuButtonByType(String btmType,Long userId); |
| | | List<Menu> getMenuButtonByType(String classifyId,String btmType, String authType); |
| | | |
| | | /** |
| | | * æ ¹æ®codeåç¨æ·idæ¥è¯¢èåä¿¡æ¯ |
| | |
| | | /** |
| | | * æ ¹æ®ä¸»é®è·åèåä¿¡æ¯ |
| | | * @param ids |
| | | * @param menuCode |
| | | * @param roleIds |
| | | * @return |
| | | */ |
| | | List<Menu> getMenuListById(List<String> ids,String parentId); |
| | | List<Menu> getMenuListByCode(List<String> ids,String menuCode,String roleIds); |
| | | |
| | | /** |
| | | * æ ¹æ®è§è²idè·åå·²ææçæé®ä¿¡æ¯ |
| | | * @param roleId |
| | | * @param menuCode |
| | | * @return |
| | | */ |
| | | List<Menu> getButtonsByRoleId(String roleId, String menuCode); |
| | | |
| | | } |
| | |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.vci.ubcs.system.entity.Menu; |
| | | import com.vci.ubcs.system.entity.Role; |
| | | import com.vci.ubcs.system.vo.RoleVO; |
| | | import org.springblade.core.tool.api.R; |
| | |
| | | import org.springblade.core.secure.utils.AuthUtil; |
| | | import org.springblade.core.tool.api.R; |
| | | import org.springblade.core.tool.utils.Func; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.context.annotation.Lazy; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * åç±»ææ |
| | | * åç±»ææ,æ°æ®ææ |
| | | * @author ludc |
| | | * @date 2023/12/25 15:35 |
| | | */ |
| | |
| | | throw new ServiceException("缺å°å¿
ä¼ åæ°åç±»id"); |
| | | } |
| | | LambdaQueryWrapper<ClassifyAuth> wrapper = Wrappers.<ClassifyAuth>query() |
| | | .lambda().eq(ClassifyAuth::getClassifyId,classifyAuthVO.getClassifyId()); |
| | | .lambda().eq(ClassifyAuth::getClassifyId,classifyAuthVO.getClassifyId()) |
| | | .eq(ClassifyAuth::getAuthType,classifyAuthVO.getAuthType()); |
| | | List<ClassifyAuth> classifyAuths = this.classifyAuthMapper.selectList(wrapper); |
| | | if(classifyAuths.isEmpty()){ |
| | | return new ArrayList<ClassifyAuthVO>(); |
| | |
| | | /** |
| | | * æ¥è¯¢è¯¥åç±»ä¸ï¼å½åç»å½çè§è²æåªäºæé®æé |
| | | * @param classifyId |
| | | * @param menuCode |
| | | * @param authType |
| | | * @return |
| | | */ |
| | | public Map<String,Boolean> getAuthButtonList(String classifyId){ |
| | | public Map<String,Boolean> getAuthButtonList(String classifyId,String menuCode,String authType){ |
| | | List<Menu> menuList = this.getButtonList(classifyId, menuCode, authType); |
| | | if(menuList.isEmpty()){ |
| | | return new HashMap<>(); |
| | | } |
| | | Map<String, Boolean> buttonMaps = menuList.stream() |
| | | .collect(Collectors.toMap(Menu::getCode, menu -> true)); |
| | | return buttonMaps; |
| | | } |
| | | |
| | | /** |
| | | * æ¥è¯¢è¯¥ä¸»æ°æ®ä¸ï¼å½åç»å½çè§è²æåªäºæé®èåæé |
| | | * @param classifyId |
| | | * @param menuCode |
| | | * @param authType |
| | | * @return |
| | | */ |
| | | public List<Menu> getAuthMenuButtonList(String classifyId,String menuCode,String authType){ |
| | | List<Menu> buttonList = getButtonList(classifyId, menuCode, authType); |
| | | return buttonList; |
| | | } |
| | | |
| | | private List<Menu> getButtonList(String classifyId,String menuCode,String authType){ |
| | | if(Func.isBlank(classifyId)){ |
| | | throw new ServiceException("å¿
ä¼ åæ°åç±»oidä¸è½ä¸ºç©ºï¼"); |
| | | } |
| | |
| | | // å
æ¥è¯¢æé®idå表 |
| | | LambdaQueryWrapper<ClassifyAuth> wrapper = Wrappers.<ClassifyAuth>query() |
| | | .lambda().eq(ClassifyAuth::getClassifyId, classifyId) |
| | | .eq(ClassifyAuth::getAuthType,authType) |
| | | .in(ClassifyAuth::getRoleId, roleIds); |
| | | List<ClassifyAuth> classifyAuths = this.classifyAuthMapper.selectList(wrapper); |
| | | //妿å½ååç±»æ²¡ææ¾å°ææé
ç½®ï¼å°±ä¾æ¬¡ä»å½åèç¹å¾ä¸å±èç¹æ¾ææé
ç½®ï¼æ¾å°äºå°±åæ¢ï¼æ²¡æ¾å°å°±ä¸ç´æ¾å°æå |
| | |
| | | Boolean isAdmin = VciBaseUtil.checkAdminTenant(); |
| | | // æªé
ç½®æé®æé |
| | | if(!isAdmin && (classifyAuths.isEmpty() || Func.isBlank(classifyAuths.get(0).getButtonIds()))){ |
| | | return new HashMap<>(); |
| | | return new ArrayList<>(); |
| | | } |
| | | List<String> condition1 = new ArrayList<>(); |
| | | List<String> ids = new ArrayList<>(); |
| | | // 妿䏿¯è¶
ç®¡ç¨æ· |
| | | if(!isAdmin){ |
| | | condition1.addAll(Arrays.asList(classifyAuths.get(0).getButtonIds().split(","))); |
| | | ids.addAll(Arrays.asList(classifyAuths.get(0).getButtonIds().split(","))); |
| | | } |
| | | List<Menu> menuList = menuService.getMenuListById(condition1,"1648879284590858241"); |
| | | if(menuList.isEmpty()){ |
| | | return new HashMap<>(); |
| | | } |
| | | Map<String, Boolean> buttonMaps = menuList.stream() |
| | | .collect(Collectors.toMap(Menu::getCode, menu -> true)); |
| | | return buttonMaps; |
| | | return menuService.getMenuListByCode(ids,menuCode,roleIds); |
| | | } |
| | | |
| | | /** |
| | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.vci.ubcs.code.feign.ICodeClassifyClient; |
| | | import com.vci.ubcs.starter.util.MybatisParameterUtil; |
| | | import com.vci.ubcs.starter.web.util.VciBaseUtil; |
| | | import com.vci.ubcs.system.cache.NacosConfigCache; |
| | | import com.vci.ubcs.system.cache.SysCache; |
| | | import com.vci.ubcs.system.dto.MenuDTO; |
| | | import com.vci.ubcs.system.entity.*; |
| | | import com.vci.ubcs.system.mapper.ClassifyAuthMapper; |
| | | import com.vci.ubcs.system.service.*; |
| | | import com.vci.ubcs.system.vo.MenuVO; |
| | | import com.vci.ubcs.system.mapper.MenuMapper; |
| | | import com.vci.ubcs.system.service.IMenuService; |
| | | import com.vci.ubcs.system.service.IRoleMenuService; |
| | | import com.vci.ubcs.system.service.IRoleScopeService; |
| | | import com.vci.ubcs.system.service.ITopMenuSettingService; |
| | | import com.vci.ubcs.system.wrapper.MenuWrapper; |
| | | import lombok.AllArgsConstructor; |
| | | import org.springblade.core.log.exception.ServiceException; |
| | |
| | | private final IRoleScopeService roleScopeService; |
| | | private final MenuMapper menuMapper; |
| | | private final ITopMenuSettingService topMenuSettingService; |
| | | private final ICodeClassifyClient codeClassifyClient; |
| | | private final ClassifyAuthMapper classifyAuthMapper; |
| | | private final static String PARENT_ID = "parentId"; |
| | | private final static Integer MENU_CATEGORY = 1; |
| | | |
| | |
| | | } |
| | | |
| | | /** |
| | | * è·åèåä¸é¢çæé® |
| | | * è·åèåä¸é¢çæé®ï¼å«ä¹±è°ç¨ï¼è¿ä¸ªæ¹æ³æ¯éå¯¹ä¸»æ°æ®ç®¡çæé®æ¥è¯¢ç |
| | | * @param classifyId |
| | | * @param btmType ä¸å¡ç±»å |
| | | * @return List<Menu> |
| | | * @param authType |
| | | * @return |
| | | */ |
| | | @Override |
| | | //@Cacheable(cacheNames = MENU_CACHE, key = "'auth:menuButton:'+ #btmType +':'+ #userId ") |
| | | public List<Menu> getMenuButtonByType(String btmType,Long userId) { |
| | | List<String> roleIds = null; |
| | | if(!VciBaseUtil.checkAdminTenant()){ |
| | | roleIds = Arrays.asList(AuthUtil.getUser().getRoleId().split(",")); |
| | | public List<Menu> getMenuButtonByType(String classifyId,String btmType,String authType) { |
| | | // baseMapper.selectMenuChildByBtnType(btmType,roleIds); |
| | | if(Func.isBlank(classifyId)){ |
| | | throw new ServiceException("å¿
ä¼ åæ°åç±»oidä¸è½ä¸ºç©ºï¼"); |
| | | } |
| | | return baseMapper.selectMenuChildByBtnType(btmType,roleIds); |
| | | //æ¥è¯¢åç±»èç¹çææç¶çº§èç¹ |
| | | R<List<String>> listR = codeClassifyClient.selectAllParentOid(classifyId); |
| | | if (!listR.isSuccess() && !listR.getData().isEmpty()) { |
| | | throw new ServiceException("è·åå类信æ¯å¤±è´¥ï¼"); |
| | | } |
| | | // è¿åçåç±»oidæ¯å½åèç¹ä¸ºç¬¬ä¸ä¸ªï¼åé¢ä¾æ¬¡æ¯ä»çä¸å±èç¹ |
| | | List<String> classifyOidList = listR.getData(); |
| | | final String roleIds = AuthUtil.getUser().getRoleId(); |
| | | // å
æ¥è¯¢æé®idå表 |
| | | LambdaQueryWrapper<ClassifyAuth> wrapper = Wrappers.<ClassifyAuth>query() |
| | | .lambda().eq(ClassifyAuth::getClassifyId, classifyId) |
| | | .eq(ClassifyAuth::getAuthType,authType) |
| | | .in(ClassifyAuth::getRoleId, roleIds); |
| | | List<ClassifyAuth> classifyAuths = classifyAuthMapper.selectList(wrapper); |
| | | //妿å½ååç±»æ²¡ææ¾å°ææé
ç½®ï¼å°±ä¾æ¬¡ä»å½åèç¹å¾ä¸å±èç¹æ¾ææé
ç½®ï¼æ¾å°äºå°±åæ¢ï¼æ²¡æ¾å°å°±ä¸ç´æ¾å°æå |
| | | if(classifyAuths.isEmpty()){ |
| | | // 䏿 ä»1å¼å§å 为å½åèç¹0å·²ç»æ¥è¯¢è¿ |
| | | for (int i = 1; i < classifyOidList.size(); i++) { |
| | | classifyAuths = classifyAuthMapper.selectList( |
| | | Wrappers.<ClassifyAuth>query() |
| | | .lambda().eq(ClassifyAuth::getClassifyId, classifyOidList.get(i)) |
| | | .in(ClassifyAuth::getRoleId, roleIds) |
| | | ); |
| | | if(!classifyAuths.isEmpty()){ |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | //åºç°äºéè¯¯æ°æ®ï¼åä¸ä¸ªè§è²ååä¸ä¸ªåç±»idåå¨å¤æ¡ææè®°å½ |
| | | if(classifyAuths.size()>1){ |
| | | throw new ServiceException("è§è²ååç±»é
ç½®åå¨å¤æ¡è®°å½ï¼è¯·è系管çäººåæ¸
çé误é
ç½®ï¼"); |
| | | } |
| | | // æ¯å¦ä¸ºè¶
管 |
| | | Boolean isAdmin = VciBaseUtil.checkAdminTenant(); |
| | | // æªé
ç½®æé®æé |
| | | if(!isAdmin && (classifyAuths.isEmpty() || Func.isBlank(classifyAuths.get(0).getButtonIds()))){ |
| | | return new ArrayList<>(); |
| | | } |
| | | List<String> ids = new ArrayList<>(); |
| | | // 妿䏿¯è¶
ç®¡ç¨æ· |
| | | if(!isAdmin){ |
| | | ids.addAll(Arrays.asList(classifyAuths.get(0).getButtonIds().split(","))); |
| | | } |
| | | return this.getMenuListByCode(ids,btmType,roleIds); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | @Override |
| | | public List<Menu> getButtonByParentCode(String code) { |
| | | List<Menu> buttonList = menuMapper.getButtonByParentCode(code); |
| | | return buttonList; |
| | | return menuMapper.getButtonsByRoleIdAndCode(null,code); |
| | | } |
| | | |
| | | /** |
| | |
| | | /** |
| | | * æ ¹æ®ä¸»é®è·åèåä¿¡æ¯ |
| | | * @param ids |
| | | * @param menuCode |
| | | * @param roleIds |
| | | * @return |
| | | */ |
| | | @Override |
| | | public List<Menu> getMenuListById(List<String> ids,String parentId) { |
| | | LambdaQueryWrapper<Menu> wrapper = Wrappers.<Menu>query() |
| | | .lambda().eq(Menu::getCategory, "2") |
| | | .eq(Menu::getIsDeleted,BladeConstant.DB_NOT_DELETED); |
| | | public List<Menu> getMenuListByCode(List<String> ids,String menuCode,String roleIds){ |
| | | List<Menu> menuButtonList = null; |
| | | if(VciBaseUtil.checkAdminTenant()){ |
| | | wrapper.eq(Menu::getParentId,parentId); |
| | | // æ£å¸¸æ
åµä¸æ¥è¯´è¿ä¸ªä¸åå¨ä¸ºç©ºçæ
åµ |
| | | // æ¥è¯¢è¯¥èåä¸çæææé® |
| | | menuButtonList = menuMapper.getButtonByIdsOrByParentCode(null, menuCode, null); |
| | | }else { |
| | | wrapper.in(Menu::getId, ids); |
| | | menuButtonList = menuMapper.getButtonByIdsOrByParentCode(roleIds,null,ids); |
| | | } |
| | | List<Menu> menuList = this.list(wrapper); |
| | | return menuList; |
| | | return menuButtonList; |
| | | } |
| | | |
| | | /** |
| | | * æ ¹æ®è§è²idè·åå·²ææçæé®ä¿¡æ¯ |
| | | * @param roleId |
| | | * @return |
| | | */ |
| | | @Override |
| | | public List<Menu> getButtonsByRoleId(String roleId, String menuCode) { |
| | | return menuMapper.getButtonsByRoleIdAndCode(roleId,menuCode); |
| | | } |
| | | |
| | | } |
| | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.vci.ubcs.system.entity.Menu; |
| | | import com.vci.ubcs.system.mapper.RoleMapper; |
| | | import com.vci.ubcs.system.service.IMenuService; |
| | | import com.vci.ubcs.system.service.IRoleMenuService; |
| | |
| | | ) menu ORDER BY sort |
| | | </select> |
| | | |
| | | <select id="getButtonByParentCode" resultMap="menuResultMap"> |
| | | SELECT |
| | | id, |
| | | parent_id, |
| | | code, |
| | | name, |
| | | alias, |
| | | PATH, |
| | | SOURCE, |
| | | ACTION, |
| | | sort |
| | | FROM |
| | | PL_SYS_MENU |
| | | WHERE |
| | | "CATEGORY" = '2' |
| | | AND IS_DELETED = 0 |
| | | AND PARENT_ID IN ( |
| | | SELECT |
| | | ID |
| | | FROM |
| | | PL_SYS_MENU |
| | | WHERE |
| | | CODE = #{code}) |
| | | ORDER BY SORT |
| | | <select id="getButtonsByRoleIdAndCode" resultMap="menuResultMap"> |
| | | SELECT pm.* |
| | | FROM PL_SYS_MENU ps, |
| | | PL_SYS_MENU pm, |
| | | PL_ORG_ROLE_MENU prom |
| | | WHERE ps.ID = prom.MENU_ID |
| | | <if test="roleId != null and roleId != ''"> |
| | | AND prom.ROLE_ID = #{roleId} |
| | | </if> |
| | | AND ps."CATEGORY" = 1 |
| | | AND pm.IS_DELETED = 0 |
| | | <if test="code != null and code != ''"> |
| | | AND ps.ID = pm.PARENT_ID |
| | | AND ps.CODE = #{code} |
| | | </if> |
| | | ORDER BY pm.SORT ASC |
| | | </select> |
| | | |
| | | <select id="grantTree" resultMap="treeNodeResultMap"> |
| | |
| | | order by pm.sort asc |
| | | </select> |
| | | |
| | | <select id="getButtonByIdsOrByParentCode" resultMap="menuResultMap"> |
| | | SELECT pm.* |
| | | FROM PL_SYS_MENU ps, |
| | | PL_SYS_MENU pm, |
| | | PL_ORG_ROLE_MENU prom |
| | | WHERE ps.ID = prom.MENU_ID |
| | | <if test="roleIds != null and roleIds != ''"> |
| | | AND prom.ROLE_ID in (#{roleIds}) |
| | | </if> |
| | | AND ps."CATEGORY" = 1 |
| | | AND pm.IS_DELETED = 0 |
| | | <if test="code != null and code != ''"> |
| | | AND ps.ID = pm.PARENT_ID |
| | | AND ps.CODE = #{code} |
| | | </if> |
| | | <if test="ids != null and ids != ''"> |
| | | AND ps.ID IN ( |
| | | <foreach collection="ids" index="index" item="item" open="(" separator="," close=")"> |
| | | #{item} |
| | | </foreach> |
| | | ) |
| | | </if> |
| | | ORDER BY pm.SORT ASC |
| | | </select> |
| | | |
| | | </mapper> |