feat(dify): dify-service-starter与localDatetime不兼容,更换为Date
This commit is contained in:
parent
95f80df743
commit
d276340363
@ -20,4 +20,12 @@ public class JsonConfig {
|
||||
.serializationInclusion(JsonInclude.Include.NON_NULL)
|
||||
.serializationInclusion(JsonInclude.Include.NON_EMPTY);
|
||||
}
|
||||
|
||||
// @Bean
|
||||
// public ObjectMapper objectMapper() {
|
||||
// return new ObjectMapper()
|
||||
// .registerModule(new JavaTimeModule())
|
||||
// .setSerializationInclusion(JsonInclude.Include.NON_NULL)
|
||||
// .setSerializationInclusion(JsonInclude.Include.NON_EMPTY);
|
||||
// }
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.zsc.edu.dify.framework.mybatisplus;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
|
||||
import com.zsc.edu.dify.framework.security.SecurityUtil;
|
||||
import com.zsc.edu.dify.framework.security.UserDetailsImpl;
|
||||
@ -8,6 +9,7 @@ import org.apache.ibatis.reflection.MetaObject;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author Yao
|
||||
@ -20,16 +22,7 @@ public class MyMetaObjectHandler implements MetaObjectHandler {
|
||||
public void insertFill(MetaObject metaObject) {
|
||||
|
||||
UserDetailsImpl userInfo = SecurityUtil.getUserInfo();
|
||||
if (userInfo.getUsername() == null) {
|
||||
userInfo.setUsername("system");
|
||||
}
|
||||
if (userInfo.getDeptId() == null) {
|
||||
userInfo.setDeptId(2L);
|
||||
}
|
||||
if (userInfo.getCreateId() == null) {
|
||||
userInfo.setCreateId(1L);
|
||||
}
|
||||
this.strictInsertFill(metaObject, "createTime", LocalDateTime.class, LocalDateTime.now());
|
||||
this.strictInsertFill(metaObject, "createTime", Date.class, new Date());
|
||||
this.strictInsertFill(metaObject, "createBy", String.class, userInfo.getUsername());
|
||||
this.strictInsertFill(metaObject, "deptId", Long.class, userInfo.getDeptId());
|
||||
this.strictInsertFill(metaObject, "createId", Long.class, userInfo.getCreateId());
|
||||
@ -39,10 +32,7 @@ public class MyMetaObjectHandler implements MetaObjectHandler {
|
||||
@Override
|
||||
public void updateFill(MetaObject metaObject) {
|
||||
UserDetailsImpl userInfo = SecurityUtil.getUserInfo();
|
||||
if (userInfo.getUsername() == null) {
|
||||
userInfo.setUsername("system");
|
||||
}
|
||||
this.strictUpdateFill(metaObject, "updateTime", LocalDateTime::now, LocalDateTime.class);
|
||||
this.strictUpdateFill(metaObject, "updateTime", Date::new, Date.class);
|
||||
this.strictUpdateFill(metaObject, "updateBy", userInfo::getUsername, String.class);
|
||||
|
||||
}
|
||||
|
@ -20,6 +20,7 @@ public class MybatisPlusConfig {
|
||||
public MybatisPlusInterceptor mybatisPlusInterceptor() {
|
||||
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
|
||||
// 添加数据权限插件
|
||||
|
||||
DataPermissionInterceptor dataPermissionInterceptor = new DataPermissionInterceptor(new DataScopeHandler());
|
||||
// 添加自定义的数据权限处理器
|
||||
interceptor.addInnerInterceptor(dataPermissionInterceptor);
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.zsc.edu.dify.modules.message.service.impl;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
@ -34,7 +35,7 @@ import static com.zsc.edu.dify.modules.message.entity.Bulletin.State.*;
|
||||
@Service
|
||||
public class BulletinServiceImpl extends ServiceImpl<BulletinRepository, Bulletin> implements BulletinService {
|
||||
|
||||
private final BulletinMapper mapper;
|
||||
private final BulletinMapper bulletinMapper;
|
||||
private final BulletinRepository repo;
|
||||
private final UserRepository userRepository;
|
||||
private final BulletinAttachmentRepository bulletinAttachmentRepository;
|
||||
@ -69,7 +70,7 @@ public class BulletinServiceImpl extends ServiceImpl<BulletinRepository, Bulleti
|
||||
if(existsByName){
|
||||
throw new ConstraintException("title", dto.title, "标题已存在");
|
||||
}
|
||||
Bulletin bulletin = mapper.toEntity(dto);
|
||||
Bulletin bulletin = bulletinMapper.toEntity(dto);
|
||||
bulletin.setEditUserId(userDetails.getId());
|
||||
save(bulletin);
|
||||
if (dto.getAttachmentIds() != null) {
|
||||
@ -88,9 +89,9 @@ public class BulletinServiceImpl extends ServiceImpl<BulletinRepository, Bulleti
|
||||
public Boolean update(UserDetailsImpl userDetails,BulletinDto dto, Long id) {
|
||||
Bulletin bulletin = getById(id);
|
||||
bulletin.state.checkStatus(EnumSet.of(edit, publish));
|
||||
mapper.convert(dto, bulletin);
|
||||
bulletinMapper.convert(dto, bulletin);
|
||||
bulletin.setCreateBy(userDetails.getName());
|
||||
bulletin.setCreateTime(LocalDateTime.now());
|
||||
bulletin.setCreateTime(new Date());
|
||||
bulletin.state = edit;
|
||||
if (dto.getAttachmentIds() != null) {
|
||||
LambdaQueryWrapper<BulletinAttachment> queryWrapper = new LambdaQueryWrapper<>();
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.zsc.edu.dify.modules.system.entity;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
@ -11,6 +12,7 @@ import lombok.Setter;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author harry yao
|
||||
@ -41,7 +43,7 @@ public class BaseEntity implements Serializable {
|
||||
*/
|
||||
@TableField(value = "create_time", fill = FieldFill.INSERT)
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
public LocalDateTime createTime;
|
||||
public Date createTime;
|
||||
/*
|
||||
* 创建人
|
||||
* */
|
||||
@ -53,7 +55,7 @@ public class BaseEntity implements Serializable {
|
||||
*/
|
||||
@TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE)
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
public LocalDateTime updateTime;
|
||||
public Date updateTime;
|
||||
/*
|
||||
* 更新人
|
||||
*
|
||||
|
@ -1,6 +1,8 @@
|
||||
package com.zsc.edu.dify.domain.system;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic;
|
||||
|
||||
@ -10,14 +12,14 @@ import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic;
|
||||
public class BaseEntityBuilder {
|
||||
public Long id = -1L;
|
||||
public String remark;
|
||||
public LocalDateTime createAt;
|
||||
public LocalDateTime updateAt;
|
||||
public Date createAt;
|
||||
public Date updateAt;
|
||||
public Long createId;
|
||||
|
||||
public BaseEntityBuilder() {
|
||||
remark = randomAlphabetic(5);
|
||||
createAt = LocalDateTime.now();
|
||||
updateAt = LocalDateTime.now();
|
||||
createAt = new Date();
|
||||
updateAt = new Date();
|
||||
createId = 1L;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user