0
点赞
收藏
分享

微信扫一扫

2022.4.9-12工作总结

云上笔记 2022-04-14 阅读 54
java

1.在原有表中插入列

alter table 表名 add 列名 varchar(30) unsigned NOT NULL DEFAULT '0' COMMENT '逻辑删除 1(true)已删除, 0(false)未删除',;

2.疑问:

@getmapping,@deletemapping @postMaping @putMaping

这些与@requestbody,@parthvariable @requestParam的关系

3.判断集合为空的方法:

idList==null&&idList.isEmpty()

图片为空:

images != null && images.size() > 0

4.JDK11新特性

(1)var,可以预判段类型,不是真的关键字

(2)List.of约等于Arrays.list(创建之后不能再添加)

5.sql文件没有保存到本地,这就使得在物理机挂了的时候,sql表格不一样又要重新输入

6.代码整洁与优化,Result分页加泛型;

7.报错:check the manual that corresponds to your MySQL server version for the right syntax to use near

因为列表中有列出现了sql的关键字,解决的方法如下:

    @TableField(value = "`key`")
    private String key;

8.beanUtils的替代方案

package com.weareint.entity;

import com.weareint.basic.entity.BasicEntity;
import com.weareint.basic.utils.DateUtil;
import com.weareint.dto.SysDicDTO;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

/**
 * 字典(SysDic)实体
 *
 * <p>weareint 2022-04-08 10:50:24
 */
@EqualsAndHashCode(callSuper = true)
@Data
@Accessors(chain = true)
public class SysDic extends BasicEntity {
    /** 字典名称 */
    private String name;
    /** 字典类型 */
    private String type;
    /** 描述 */
    private String description;
    /** 状态 */
    private Boolean status;
    /** 删除 */
    private Integer delFlag;

    public SysDicDTO toDTO() {
        SysDicDTO dto = new SysDicDTO();
        dto.setId(this.getId());
        dto.setName(this.getName());
        dto.setDelFlag(this.getDelFlag());
        dto.setStatus(this.getStatus());
        dto.setCreateTime(
                null == this.getCreateTime() ? "" : DateUtil.format(this.getCreateTime()));
        dto.setUpdateTime(
                null == this.getUpdateTime() ? "" : DateUtil.format(this.getUpdateTime()));
        dto.setCreateUserId(this.getCreateUserId());
        dto.setUpdateUserId(this.getUpdateUserId());
        dto.setType(this.getType());
        dto.setDescription(this.getDescription());
        return dto;
    }
}

9.saveorupdate的使用

它只传入一个实体对象,当你的实体中的主键为null时,他就会执行insert操作,当你的主键不为空时,它就会执行updata操作

10.校验参数异常

        if (id == null) {
            throw new IllegalArgumentException("参数为空,无法删除");
        }
举报

相关推荐

0 条评论