文件上传时出现 Column “updated_by” 不能为空

文件上传时,文件可以上传到MinIo,但是数据库里面没有数据
Column “updated_by” cannot be null

img

以下是后台报错:
org.springframework.dao.DataIntegrityViolationException:

Error updating database. Cause: java.sql.SQLIntegrityConstraintViolationException: Column 'updated_by' cannot be null

The error may exist in cn/esky/backend/file/dao/FileMapper.java (best guess)

The error may involve cn.esky.backend.file.dao.FileMapper.insert-Inline

The error occurred while setting parameters

SQL: INSERT INTO c_file ( id, biz_type, file_type, storage_type, bucket, path, url, unique_file_name, original_file_name, content_type, suffix, size, update_time, updated_by, create_time, created_by ) VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )

Cause: java.sql.SQLIntegrityConstraintViolationException: Column 'updated_by' cannot be null

; Column 'updated_by' cannot be null; nested exception is java.sql.SQLIntegrityConstraintViolationException: Column 'updated_by' cannot be null
at org.springframework.jdbc.support.SQLExceptionSubclassTranslator.doTranslate(SQLExceptionSubclassTranslator.java:87)
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:70)

img

img

这个问题有以下几种方法:
1.在数据库表中设置非必填。
2.在程序中获取添加人,把这个字段添加进去
3.如果你是使用的mybatisplus的话你可以根据api写一个专门处理一些无关业务的字段比如添加时间,创建人等等字段来进行自动插入