5月29
一、在项目根目录下安装
npm install --save js-base64
npm install --save js-md5
1
2
二、在项目文件中引入
import md5 from 'js-md5';

let Base64 = require('js-base64').Base64;
1
2
3
三、在项目文件中使用
base64

Base64.encode('heckjj.com');  // aGVja2pqLmNvbQ==
Base64.encode( '大将军');    // 5aSn5bCG5Yab+
Base64.encodeURI('大将军'); // 5aSn5bCG5Yab-

Base64.decode(aGVja2pqLmNvbQ==');  // heckjj.com
Base64.decode('5aSn5bCG5Yab+');  // 大将军
// note .decodeURI() is unnecessary since it accepts both flavors
Base64.decode('5aSn5bCG5Yab-');  // 大将军

md5

md5(''); // d41d8cd98f00b204e9800998ecf8427e
md5('The quick brown fox jumps over the lazy dog'); // 9e107d9d372bb6826bd81d3542a419d6
md5('The quick brown fox jumps over the lazy dog.'); // e4d909c290d0fb1ca068ffaddf22cbd0

// It also supports UTF-8 encoding
md5('中文'); // a7bac2239fcdcb3a067903d8077c4a07

// It also supports byte `Array`, `Uint8Array`, `ArrayBuffer`
md5([]); // d41d8cd98f00b204e9800998ecf8427e
md5(new Uint8Array([])); // d41d8cd98f00b204e9800998ecf8427e

// Different output
md5(''); // d41d8cd98f00b204e9800998ecf8427e
md5.hex(''); // d41d8cd98f00b204e9800998ecf8427e
md5.array(''); // [212, 29, 140, 217, 143, 0, 178, 4, 233, 128, 9, 152, 236, 248, 66, 126]
md5.digest(''); // [212, 29, 140, 217, 143, 0, 178, 4, 233, 128, 9, 152, 236, 248, 66, 126]
md5.arrayBuffer(''); // ArrayBuffer
md5.buffer(''); // ArrayBuffer, deprecated, This maybe confuse with Buffer in node.js. Please use arrayBuffer instead.
Tags: , ,
5月28
Element UI Upload 上传文件上传文件一次 ,不论是上传成功之后修改文件再上传还是上传失败重新上传,再次点击上传均无反应。
方法一:利用 :on-success
ref=‘upload’
:on-success=“handleSuccess”

注意: ref='upload 一定要加上ref 不然不起作用

                <el-upload
                        class="upload-demo"
                        action=""
                        :limit="1"
                        :show-file-list="false"
                        :http-request="uploadLogo"
                        ref='upload'
                        :on-success="handleSuccess"
                >
                    <el-button style="width: 150px; height: 35px;line-height: 0;margin-left: 20px" size="medium"
                               type="primary">
                        {{$t('StaffManage.bulkImport')}}
                    </el-button>
                </el-upload>

        handleSuccess(res, file) {
            this.$refs.upload.clearFiles(); //上传成功之后清除历史记录
            // this.tableReload()
        },

方法二:利用if el-upload让移除文档流
                <el-upload
                        v-if="!form.contractFileUrl"
                        class="upload-demo"
                        action=""
                        :limit="1"
                        :show-file-list="false"
                        :http-request="uploadLogo"
                >
                    <el-button size="medium" type="primary">{{$t('AttendanceInformation.ClickUpload')}}</el-button>
                </el-upload>

            uploadLogo(param) {
                let _this = this
                _this.form.contractFileUrl = '1'
                let formData = new FormData();
                formData.append("file", param.file);
                _this.$send.post({url: '/contract/upload', data: formData}, res => {
                    if (res.code === 10000) {
                        _this.isdisabled = true
                        _this.form.contractFileUrl = res.data.url
                        _this.form.contractFileId = res.data.id
                    } else {
                        _this.form.contractFileUrl = null
                        _this.form.contractFileId = null
                        _this.$msg.error(res.message)
                    }

                })
            },
5月17
sql执行正常的,但是放到mybatisPlus中执行错误报: Failed to process, please exclude the tableName or statementId.

大概率是存在特殊字符使mybatis解析异常
1.在mapper.java中的方法上添加@SqlParser(filter=true)注解
点击在新窗口中浏览此图片

2.如果sql中有注释,删掉注释
点击在新窗口中浏览此图片
4月21
IS浏览器无法读取mp4视频怎么办?针对这个问题,今天总结了这篇文章,希望能帮助更多想解决这个问题的朋友找到更加简单易行的办法。

IIS7以上的不支持mp4的时候提示如下报错

有时候会报404找不到文件,可视频文件明明在,就是访问不到。
由于扩展配置问题而无法提供您请求的页面。如果该页面是脚本,请添加处理程序。如果应下载文件,请添加 MIME 映射。

原因:因为服务器IIS默认不支持mp4等一些文件类型,只要在IIS上添加MIME 类型即可。

iis6.0版本

打开iis管理器找到你要设置的站点,右键属性,找到http头,就可以看到mime类型的按钮了,我们点击进去
比如你要添加mp4的mime我们就输入,扩展名.mp4  类型video/mp4,然后点击确人完成后测试下

iis7.5设置

找到你要设置的站点,点击功能视图,找到MIME类型选项
进入mime类型功能之后点击右上角的添加按钮添加扩展名.mp4  类型video/mp4,然后点击确人完成后测试下


常见的mime类型后续更新Mime类型扩展名意义

application/msexcel*.xls *.xlaMicrosoft Excel Dateien

application/mshelp*.hlp *.chmMicrosoft Windows Hilfe Dateien

application/mspowerpoint*.ppt *.ppz *.pps *.potMicrosoft Powerpoint Dateien

application/msword*.doc *.dotMicrosoft Word Dateien

application/octet-stream*.exeexe

video/mp4*.mp4MP4

application/pdf*.pdfAdobe PDF-Dateien

application/postscript*.ai *.eps *.psAdobe Postscript-Dateien

application/rtf*.rtfMicrosoft RTF-Dateien

application/x-httpd-php*.php *.phtmlPHP-Dateien

application/x-javascript*.jsserverseitige JavaScript-Dateien

application/x-shockwave-flash*.swf *.cabFlash Shockwave-Dateien

application/zip*.zipZIP-Archivdateien

audio/basic*.au *.sndSound-Dateien

audio/mpeg*.mp3MPEG-Dateien

audio/x-midi*.mid *.midiMIDI-Dateien

audio/x-mpeg*.mp2MPEG-Dateien

audio/x-wav*.wavWav-Dateien

image/gif*.gifGIF-Dateien

image/jpeg*.jpeg *.jpg *.jpeJPEG-Dateien

image/x-windowdump*.xwdX-Windows Dump

text/css*.cssCSS Stylesheet-Dateien

text/html*.htm *.html *.shtml-Dateien

text/javascript*.jsJavaScript-Dateien

text/plain*.txtreine Textdateien

video/mpeg*.mpeg *.mpg *.mpeMPEG-Dateien

video/vnd.rn-realvideo*.rmvbrealplay-Dateien

video/quicktime*.qt *.movQuicktime-Dateien

video/vnd.vivo*viv *.vivoVivo-Dateien
4月7
(一)事务传播机制 7种

    Required (默认):

        如果当前没有事务,就新建一个事务,如果已存在一个事务中

        加入到这个事务中,这是最常见的选择。

    Supports :

        支持当前事务,如果没有当前事务,就以非事务方法执行。

    Mandatory :

        中文翻译为强制,支持使用当前事务,如果当前事务不存在,则抛出Exception。

    Requies_new :

        创建一个新事务,如果当前事务存在,把当前事务挂起。

    Not_Supported :

        无事务执行,如果当前事务存在,把当前事务挂起。

    Never :

         无事务执行,如果当前有事务则抛出Exception。

    Nested :

        嵌套事务,如果当前事务存在,那么在嵌套的事务中执行。

        如果当前事务不存在,则表现跟REQUIRED一样。



    注解配置时如:@Transactional(propagation=Propagation.REQUIRED)

    7种事务举例子可看此篇博客 感觉不错: https://www.cnblogs.com/myseries/p/10800430.html

(二)事务隔离级别


         事务隔离级别                       脏读              不可重复读          幻读
读未提交(Read-Uncommitted)      是                            是                    是
不可重复读(Read-Committed)      否                           是                    是
可重复读(Repeatable-Read)              否                         否                    是
串行化(Serializable)                      否                           否                    否
   注解配置时如:@Transactional(isolation = Isolation.READ_UNCOMMITTED)

  Mysql 默认 可重复读   ---repeatable-read

  事务的并发问题

    1、脏读:事务A读取了事务B更新的数据,然后B回滚操作,那么A读取到的数据是脏数据

    2、不可重复读:事务 A 多次读取同一数据,事务 B 在事务A多次读取的过程中,

       对数据作了更新并提交,导致事务A多次读取同一数据时,结果 不一致。

    3、幻读:系统管理员A将数据库中所有学生的成绩从具体分数改为ABCDE等级,

         但是系统管理员B就在这个时候插入了一条具体分数的记录,

        当系统管理员A改结束后发现还有一条记录没有改过来,就好像发生了幻觉一样,这就叫幻读。

    小结:不可重复读的和幻读很容易混淆,不可重复读侧重于修改,幻读侧重于新增或删除。

              解决不可重复读的问题只需锁住满足条件的行,解决幻读需要锁表

3月21

kendoGrid获取选中的行

13:43Web开发  From: 本站原创
                      var grid = $("#grid").kendoGrid({
                                            dataSource: dataSource,
                                            resizable: true,
                                            scrollable: true,
                                            navigatable: false,
                                            rownumber: true,
                                            selectable: 'multiple, rowbox',
                                            dataBound: function () {
                                                if (parent.autoResizeIframe) {
                                                    parent.autoResizeIframe('${RequestParameters.functionCode!}')
                                                }
                                            },
                                            columns: [

                                                {
                                                    field: "name",
                                                    title: '<@spring.message "物料名称"/>',
                                                    width: 80
                                                },
                                                {
                                                    field: "spc",
                                                    title: '<@spring.message "规格"/>',
                                                    width: 80
                                                },
                                                {
                                                    field: "num",
                                                    title: '<@spring.message "计划量"/>',
                                                    width: 60,
                                                    required: true
                                                },
                                                {
                                                    field: "unitCode",
                                                    title: '<@spring.message "单位"/>',
                                                    width: 60
                                                },
                                                {
                                                    field: "prdNoSup",
                                                    title: '<@spring.message "货号"/>',
                                                    width: 80
                                                },
                                                {
                                                    field: "planMoney",
                                                    title: "计划单价",
                                                    width: 80,
                                                    format: "{0:c}",
                                                },
                                                {
                                                    field: "startingPrice",
                                                    title: "起拍价",
                                                    width: 80,
                                                    format: "{0:c}",
                                                },
                                                {
                                                    field: "minPriceCut",
                                                    title: "最低降价幅度",
                                                    width: 120,
                                                    format: "{0:c}",
                                                },
                                                {
                                                    field: "productId",
                                                    title: '<@spring.message "ERP物料名称"/>',
                                                    width: 80,
                                                    hidden: true,
                                                },
                                                {
                                                    field: "purcNo",
                                                    title: 'ERP物料编码',
                                                    width: 120,
                                                    editor: function (container, options) {
                                                        $('<input name="' + options.field + '"/>')
                                                            .appendTo(container)
                                                            .kendoLov($.extend(<@lov"LOV_SELECT_PRODUCT"/>, {
                                                            textField: 'prdNo',
                                                            model: options.model,
                                                            select: function (e) {
                                                                options.model.set('purcNo', e.item.prdNo)
                                                                options.model.set('productId', e.item.productId)
                                                                options.model.set('proName', e.item.name)
                                                                options.model.set('proUnitCode', e.item.unitCode)
                                                                options.model.set('currentMoney', e.item.currentMoney)
                                                            }
                                                        }
                                                    ));
                                                    }
                                                },
                                                {
                                                    field: "proName",
                                                    title: '<@spring.message "ERP物料名称"/>',
                                                    width: 100
                                                },
                                                {
                                                    field: "proUnitCode",
                                                    title: '<@spring.message "ERP主单位"/>',
                                                    width: 120
                                                },
                                                {
                                                    field: "currentMoney",
                                                    title: '<@spring.message "最新价格"/>',
                                                    width: 80
                                                },
                                            ],
                                            editable: true
                                        }).data('kendoGrid');  
以下是获取当前选中行的方法,在网上找了很多个都不管用,还是使用以下方法新测可用
         var grid =$("#grid").data('kendoGrid');
            var items = grid.selectedDataItems();
3月14
项目中的一些依赖由于需要手动添加,很多时候都会创建一个私服仓库,比如nexus,将第三方jar添加到私服中,然后在pom中引用。刚来公司接手一个3年前的一个项目,该项目之前下过依赖,这些依赖本地依旧存在,如今重新导入该项目,由于没了私服,于是删去私服地址后,执行mvn package后项目会重新到配置的仓库中找这些依赖下载。

此时会报错"was cached in the local repository..." 或者 " Could not resolve dependencies for project"

解决方法,找到该依赖本地资源库位置,删去_remote.repositories文件 和 xx.lastUpdated文件
2月22

js正则匹配任意字符

16:03Web开发  From: 本站原创
js正则匹配任意字符使用正则
^0]* 或者 [^]* 即可

除空格外,其他任意字符都可以的正则表达
\S即可
2月16
(1)  配置自动跳转前,请先用https访问您的网站,确认网站正常显示。
(2)  编辑server.xml:
<Connector port="80" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" />
蓝色部分8443修改为443,修改后:
    <Connector port="80" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="443" />

<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
蓝色部分8443修改为443,修改后如图所示:
<Connector port="8009" protocol="AJP/1.3" redirectPort="443" />

(3)  编辑web.xml
搜索</welcome-file-list>节点,后面加上这段配置:
    <login-config>
        <!-- Authorization setting for SSL -->
        <auth-method>CLIENT-CERT</auth-method>
        <realm-name>Client Cert Users-only Area</realm-name>
    </login-config>
    <security-constraint>
        <!-- Authorization setting for SSL -->
        <web-resource-collection >
            <web-resource-name >SSL</web-resource-name>
            <url-pattern>/*</url-pattern>
        </web-resource-collection>
        <user-data-constraint>
            <transport-guarantee>CONFIDENTIAL</transport-guarantee>
        </user-data-constraint>
    </security-constraint>

(4)  重启Tomcat服务,输入http://域名,观察是否自动跳转到https://域名。
1月19
mysql分区后每个分区成了独立的文件,虽然从逻辑上还是一张表其实已经分成了多张独立的表,从“information_schema.INNODB_SYS_TABLES”系统表可以看到每个分区都存在独立的TABLE_ID,由于Innodb数据和索引都是保存在".ibd"文件当中(从INNODB_SYS_INDEXES系统表中也可以得到每个索引都是对应各自的分区(primary key和unique也不例外)),所以分区表的索引也是随着各个分区单独存储。

在INNODB_SYS_INDEXES系统表中type代表索引的类型;

0:一般的索引,

1:(GEN_CLUST_INDEX)不存在主键索引的表,会自动生成一个6个字节的标示值,

2:unique索引,

3:primary索引;

所以当我们在分区表中创建索引时其实也是在每个分区中创建索引,每个分区维护各自的索引(其实也就是local index);对于一般的索引(非主键或者唯一)没什么问题由于索引树中只保留了索引key和主键key(如果存在主键则是主键的key否则就是系统自动生成的6个的key)不受分区的影响;但是如果表中存在主键就不一样了,虽然在每个分区文件中都存在主键索引但是主键索引需要保证全局的唯一性就是所有分区中的主键的值都必须唯一(唯一键也是一样的道理),所以在创建分区时如果表中存在主键或者唯一键那么分区列必须包含主键或者唯一键的部分或者全部列(全部列还好理解,部分列也可以个人猜测是为了各个分区和主键建立关系),由于需要保证全局性又要保证插入数据更新数据到具体的分区所以就需要将分区和主键建立关系,由于通过一般的索引进行查找其它非索引字段需要通过主键如果主键不能保证全局唯一性的话那么就需要去每个分区查找了,这样性能可想而知。

To enforce the uniqueness we only allow mapping of each unique/primary key value to one partition.If we removed this limitation it would mean that for every insert/update we need to check in every partition to verify that it is unique. Also PK-only lookups would need to look into every partition.

索引方式:
性能依次降低
1.主键分区

主键分区即字段是主键同时也是分区字段,性能最好

2. 部分主键+分区索引

使用组合主键里面的部分字段作为分区字段,同时将分区字段建索引(见下面详细说明)

3.分区索引

没有主键,只有分区字段且分区字段建索引

4.分区+分区字段没有索引

只建了分区,但是分区字段没有建索引

总结

因为每一个表都需要有主键这样可以减少很多锁的问题,由于上面讲过主键需要解决全局唯一性并且在插入和更新时可以不需要去扫描全部分区,造成主键和分区列必须存在关系;所以最好的分区效果是使用主键作为分区字段其次是使用部分主键作为分区字段且创建分区字段的索引,其它分区方式都建议不采取。


MYSQL的分区字段,必须包含在主键字段内
在对表进行分区时,如果分区字段没有包含在主键字段内,如表A的主键为ID,分区字段为createtime ,按时间范围分区,代码如下:

CREATE TABLE T1 (
     id int(8) NOT NULL AUTO_INCREMENT,
     createtime datetime NOT NULL,
      PRIMARY KEY (id)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8
PARTITION BY RANGE(TO_DAYS (createtime))
(
PARTITION p0 VALUES LESS THAN (TO_DAYS('2010-04-15')),
PARTITION p1 VALUES LESS THAN (TO_DAYS('2010-05-01')),
PARTITION p2 VALUES LESS THAN (TO_DAYS('2010-05-15')),
PARTITION p3 VALUES LESS THAN (TO_DAYS('2010-05-31')),
PARTITION p4 VALUES LESS THAN (TO_DAYS('2010-06-15')),
PARTITION p19 VALUES LESS ThAN  MAXVALUE);
复制代码
错误提示:#1503

MySQL主键的限制,每一个分区表中的公式中的列,必须在主键/unique key 中包括,在MYSQL的官方文档里是这么说明的
18.5.1. Partitioning Keys, Primary Keys, and Unique Keys
This section discusses the relationship of partitioning keys with primary keys and unique keys. The rule governing this relationship can be expressed as follows: All columns used in the partitioning expression for a partitioned table must be part of every unique key that the table may have.

In other words,every unique key on the table must use every columnin the table's partitioning expression. (This also includes the table's primary key, since it is by definition a unique key. This particular case is discussed later in this section.) For example, each of the following table creation statements is invalid:
分区字段必须包含在主键字段内,至于为什么MYSQL会这样考虑,我觉得是这样的:为了确保主键的效率。否则同一主键区的东西一个在A分区,一个在B分区,显然会比较麻烦。

下面讨论解决办法,毕竟在一张表里,日期做主键的还是不常见。
方法1:
顺应MYSQL的要求,就把分区字段加入到主键中,组成复合主键
CREATE TABLE T1 (
     id int(8) NOT NULL AUTO_INCREMENT,
     createtime datetime NOT NULL,
      PRIMARY KEY (id,createtime)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8
PARTITION BY RANGE(TO_DAYS (createtime))
(
PARTITION p0 VALUES LESS THAN (TO_DAYS('2010-04-15')),
PARTITION p1 VALUES LESS THAN (TO_DAYS('2010-05-01')),
PARTITION p2 VALUES LESS THAN (TO_DAYS('2010-05-15')),
PARTITION p3 VALUES LESS THAN (TO_DAYS('2010-05-31')),
PARTITION p4 VALUES LESS THAN (TO_DAYS('2010-06-15')),
PARTITION p19 VALUES LESS ThAN  MAXVALUE);
测试通过,分区成功。
分页: 2/60 第一页 上页 1 2 3 4 5 6 7 8 9 10 下页 最后页 [ 显示模式: 摘要 | 列表 ]