常見問題

2019-03-30 14:35 更新

如何不登錄直接訪問

在 ShiroConfig 中設(shè)置filterChainDefinitionMap 配置url=anon

  1. /admins/**=anon # 表示該 uri 可以匿名訪問
  2. /admins/**=auth # 表示該 uri 需要認(rèn)證才能訪問
  3. /admins/**=authcBasic # 表示該 uri 需要 httpBasic 認(rèn)證
  4. /admins/**=perms[user:add:*] # 表示該 uri 需要認(rèn)證用戶擁有 user:add:* 權(quán)限才能訪問
  5. /admins/**=port[8080] # 表示該 uri 需要使用 8080 端口
  6. /admins/**=roles[admin] # 表示該 uri 需要認(rèn)證用戶擁有 admin 角色才能訪問
  7. /admins/**=ssl # 表示該 uri 需要使用 https 協(xié)議
  8. /admins/**=user # 表示該 uri 需要認(rèn)證或通過記住我認(rèn)證才能訪問
  9. /logout=logout # 表示注銷,可以當(dāng)作固定配置
  10. 注意:
  11. anon,authcBasic,authc,user 是認(rèn)證過濾器。
  12. perms,roles,ssl,rest,port 是授權(quán)過濾器。

如何使用多數(shù)據(jù)源

  1. 在 resources 目錄下修改application-druid.yml
    1. ## 從庫數(shù)據(jù)源
    2. slave:
    3. # 開啟從庫
    4. enabled: true
    5. url: 數(shù)據(jù)源
    6. username: 用戶名
    7. password: 密碼

  1. 在Service實(shí)現(xiàn)中添加DataSource注解
    1. @DataSource(value = DataSourceType.SLAVE)
    2. public List<User> selectUserList()
    3. {
    4. return mapper.selectUserList();
    5. }

日期插件精確到時(shí)分秒

datetimepicker日期控件可以設(shè)置format

  1. $('.input-group.date').datetimepicker({
  2. format: 'yyyy-mm-dd hh:ii:ss',
  3. autoclose: true,
  4. minView: 0,
  5. minuteStep:1
  6. });

laydate日期控件可以設(shè)置common.js 配置type=datetime

  1. layui.use('laydate', function() {
  2. var laydate = layui.laydate;
  3. var startDate = laydate.render({
  4. elem: '#startTime',
  5. max: $('#endTime').val(),
  6. theme: 'molv',
  7. trigger: 'click',
  8. type : 'datetime',
  9. done: function(value, date) {
  10. // 結(jié)束時(shí)間大于開始時(shí)間
  11. if (value !== '') {
  12. endDate.config.min.year = date.year;
  13. endDate.config.min.month = date.month - 1;
  14. endDate.config.min.date = date.date;
  15. } else {
  16. endDate.config.min.year = '';
  17. endDate.config.min.month = '';
  18. endDate.config.min.date = '';
  19. }
  20. }
  21. });
  22. var endDate = laydate.render({
  23. elem: '#endTime',
  24. min: $('#startTime').val(),
  25. theme: 'molv',
  26. trigger: 'click',
  27. type : 'datetime',
  28. done: function(value, date) {
  29. // 開始時(shí)間小于結(jié)束時(shí)間
  30. if (value !== '') {
  31. startDate.config.max.year = date.year;
  32. startDate.config.max.month = date.month - 1;
  33. startDate.config.max.date = date.date;
  34. } else {
  35. startDate.config.max.year = '';
  36. startDate.config.max.month = '';
  37. startDate.config.max.date = '';
  38. }
  39. }
  40. });
  41. });

代碼生成不顯示新建表

默認(rèn)條件需要表注釋,特殊情況可在GenMapper.xml去除table_comment條件

  1. <select id="selectTableByName" parameterType="String" resultMap="TableInfoResult">
  2. <include refid="selectGenVo"/>
  3. where table_comment <> '' and table_schema = (select database())
  4. </select>

提示您沒有數(shù)據(jù)的權(quán)限

這種情況都屬于權(quán)限標(biāo)識配置不對在菜單管理配置好權(quán)限標(biāo)識(菜單&按鈕)

  1. 確認(rèn)此用戶是否已經(jīng)配置角色
  2. 確認(rèn)此角色是否已經(jīng)配置菜單權(quán)限
  3. 確認(rèn)此菜單權(quán)限標(biāo)識是否和后臺(tái)代碼一致

如參數(shù)管理
后臺(tái)配置@RequiresPermissions("system:config:view")對應(yīng)參數(shù)管理權(quán)限標(biāo)識為system:config:view

注:如需要角色權(quán)限,配置角色權(quán)限字符 使用@RequiresRoles("admin")

富文本編輯器文件上傳

富文本控件采用的summernote,圖片上傳處理需要設(shè)置callbacks函數(shù)

  1. $('.summernote').summernote({
  2. height : '220px',
  3. lang : 'zh-CN',
  4. callbacks: {
  5. onImageUpload: function(files, editor, $editable) {
  6. var formData = new FormData();
  7. formData.append("file", files[0]);
  8. $.ajax({
  9. type: "POST",
  10. url: ctx + "common/upload",
  11. data: data,
  12. cache: false,
  13. contentType: false,
  14. processData: false,
  15. dataType: 'json',
  16. success: function(result) {
  17. if (result.code == web_status.SUCCESS) {
  18. $(obj).summernote('editor.insertImage', result.url, result.fileName);
  19. } else {
  20. $.modal.alertError(result.msg);
  21. }
  22. },
  23. error: function(error) {
  24. $.modal.alertWarning("圖片上傳失敗。");
  25. }
  26. });
  27. }
  28. }
  29. });

如何創(chuàng)建新的菜單頁簽

建新新的頁簽有以下兩種方式(js&html)

  1. // 方式1 js創(chuàng)建
  2. function dept() {
  3. var url = ctx + "system/dept";
  4. createMenuItem(url, "部門管理");
  5. }
  6. // 方式2 html創(chuàng)建
  7. <a class="menuItem" href="/system/dept">部門管理</a>

表格數(shù)據(jù)進(jìn)行匯總統(tǒng)計(jì)

對于某些數(shù)據(jù)需要對金額,數(shù)量等進(jìn)行匯總,可以配置showFootertrue表示尾部統(tǒng)計(jì)

  1. // options 選項(xiàng)中添加尾部統(tǒng)計(jì)
  2. showFooter: true,
  3. // columns 中添加
  4. {
  5. field : 'money',
  6. title : '金額',
  7. sortable: true,
  8. footerFormatter:function (value) {
  9. return "總金額:" + value;
  10. }
  11. },

如何去除數(shù)據(jù)監(jiān)控廣告

服務(wù)監(jiān)控中使用的Driud,默認(rèn)底部有阿里的廣告。如果是一個(gè)商業(yè)項(xiàng)目這個(gè)是很不雅也是不允許的

  1. 找到本地maven庫中的對應(yīng)的druid-1.1.xx.jar文件,用壓縮包軟件打開
  2. 找到support/http/resource/js/common.js, 打開找到 buildFooter 方法
    1. this.buildFooter();
    2. buildFooter : function() {
    3. var html ='此處省略一些相關(guān)JS代碼';
    4. $(document.body).append(html);
    5. },
  3. 刪除此函數(shù)和及初始方法后覆蓋文件
  4. 重啟項(xiàng)目后,廣告就會(huì)消失了

如何支持多類型數(shù)據(jù)庫

對于某些特殊需要支持不同數(shù)據(jù)庫,參考以下支持oracle mysql配置

  1. <!--oracle驅(qū)動(dòng)-->
  2. <dependency>
  3. <groupId>com.oracle</groupId>
  4. <artifactId>ojdbc6</artifactId>
  5. <version>11.2.0.3</version>
  6. </dependency>
  1. ## 數(shù)據(jù)源配置
  2. spring:
  3. datasource:
  4. type: com.alibaba.druid.pool.DruidDataSource
  5. druid:
  6. # 主庫數(shù)據(jù)源
  7. master:
  8. url: jdbc:mysql://127.0.0.1:3306/ry?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
  9. username: root
  10. password: password
  11. # 從庫數(shù)據(jù)源
  12. slave:
  13. # 從數(shù)據(jù)源開關(guān)/默認(rèn)關(guān)閉
  14. enabled: true
  15. url: jdbc:oracle:thin:@127.0.0.1:1521:oracle
  16. username: root
  17. password: password
以上內(nèi)容是否對您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號
微信公眾號

編程獅公眾號