2022.4.9-12工作总结

1.在原有表中插入列

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

2.疑问:

@getmapping,@deletemapping @postMaping @putMaping

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

1.GET 查询操作
2.DELETE 删除操作 get/delete 用法相同

3.POST 1.表单数据提交 2.新增操作 4.PUT 修改操作 post/put 用法相同

这个也不是绝对的,譬如,如果是带条件分页查询,这个时候我们必须要传DTO那就只能用PostMaping

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
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值