1. 修改 mybatis plus 字段填充, insert 时添加 create 修改时添加 Update
This commit is contained in:
parent
a2fc42bfdf
commit
27f6a09c9b
|
|
@ -19,7 +19,7 @@ package com.chushang.common.core.config;
|
|||
import cn.hutool.core.date.DatePattern;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import com.chushang.common.core.jackson.JavaTimeModule;
|
||||
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigureBefore;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
|
|
|
|||
|
|
@ -1,49 +0,0 @@
|
|||
package com.chushang.common.core.jackson;
|
||||
|
||||
import com.fasterxml.jackson.databind.JavaType;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Slf4j
|
||||
public class JacksonUtils {
|
||||
|
||||
private static final ObjectMapper mapper = new ObjectMapper();
|
||||
|
||||
@SneakyThrows
|
||||
public static String toJSONString(Object data) {
|
||||
if (null == data) {
|
||||
return "";
|
||||
}
|
||||
return mapper.writeValueAsString(data);
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
public static <T> T json2Bean(String jsonData, Class<T> beanType) {
|
||||
if (null == jsonData) {
|
||||
return null;
|
||||
}
|
||||
return mapper.readValue(jsonData, beanType);
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
public static <T> List<T> json2List(String jsonData, Class<T> beanType) {
|
||||
if (null == jsonData) {
|
||||
return List.of();
|
||||
}
|
||||
JavaType javaType = mapper.getTypeFactory().constructParametricType(List.class, beanType);
|
||||
return mapper.readValue(jsonData, javaType);
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
public static <K, V> Map<K, V> json2Map(String jsonData, Class<K> keyType, Class<V> valueType) {
|
||||
if (null == jsonData) {
|
||||
return Map.of();
|
||||
}
|
||||
JavaType javaType = mapper.getTypeFactory().constructMapType(Map.class, keyType, valueType);
|
||||
return mapper.readValue(jsonData, javaType);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,64 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2020 pig4cloud Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.chushang.common.core.jackson;
|
||||
|
||||
import cn.hutool.core.date.DatePattern;
|
||||
import com.fasterxml.jackson.databind.module.SimpleModule;
|
||||
import com.fasterxml.jackson.datatype.jsr310.PackageVersion;
|
||||
import com.fasterxml.jackson.datatype.jsr310.deser.InstantDeserializer;
|
||||
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateDeserializer;
|
||||
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
|
||||
import com.fasterxml.jackson.datatype.jsr310.deser.LocalTimeDeserializer;
|
||||
import com.fasterxml.jackson.datatype.jsr310.ser.InstantSerializer;
|
||||
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateSerializer;
|
||||
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
|
||||
import com.fasterxml.jackson.datatype.jsr310.ser.LocalTimeSerializer;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
|
||||
public class JavaTimeModule extends SimpleModule {
|
||||
|
||||
public JavaTimeModule() {
|
||||
super(PackageVersion.VERSION);
|
||||
|
||||
// ======================= 时间序列化规则 ===============================
|
||||
// yyyy-MM-dd HH:mm:ss
|
||||
this.addSerializer(LocalDateTime.class,
|
||||
new LocalDateTimeSerializer(DateTimeFormatter.ofPattern(DatePattern.NORM_DATETIME_PATTERN)));
|
||||
// yyyy-MM-dd
|
||||
this.addSerializer(LocalDate.class, new LocalDateSerializer(DateTimeFormatter.ISO_LOCAL_DATE));
|
||||
// HH:mm:ss
|
||||
this.addSerializer(LocalTime.class, new LocalTimeSerializer(DateTimeFormatter.ISO_LOCAL_TIME));
|
||||
// Instant 类型序列化
|
||||
this.addSerializer(Instant.class, InstantSerializer.INSTANCE);
|
||||
|
||||
// ======================= 时间反序列化规则 ==============================
|
||||
// yyyy-MM-dd HH:mm:ss
|
||||
this.addDeserializer(LocalDateTime.class,
|
||||
new LocalDateTimeDeserializer(DateTimeFormatter.ofPattern(DatePattern.NORM_DATETIME_PATTERN)));
|
||||
// yyyy-MM-dd
|
||||
this.addDeserializer(LocalDate.class, new LocalDateDeserializer(DateTimeFormatter.ISO_LOCAL_DATE));
|
||||
// HH:mm:ss
|
||||
this.addDeserializer(LocalTime.class, new LocalTimeDeserializer(DateTimeFormatter.ISO_LOCAL_TIME));
|
||||
// Instant 反序列化
|
||||
this.addDeserializer(Instant.class, InstantDeserializer.INSTANT);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -11,10 +11,10 @@ package com.chushang.common.log.aspect;
|
|||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.core.util.URLUtil;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.chushang.common.core.constant.CommonConstants;
|
||||
import com.chushang.common.core.exception.ResultException;
|
||||
import com.chushang.common.core.jackson.JacksonUtils;
|
||||
import com.chushang.common.core.util.IPUtils;
|
||||
import com.chushang.common.core.util.ServletUtils;
|
||||
import com.chushang.common.log.annotation.SysLog;
|
||||
|
|
@ -122,7 +122,7 @@ public class SysLogAspect {
|
|||
Arrays.stream(args)
|
||||
.filter(arg -> !(arg instanceof MultipartFile) && !(arg instanceof HttpServletResponse) && !(arg instanceof HttpServletRequest) && !(arg instanceof MultipartFile[]))
|
||||
.collect(Collectors.toList());
|
||||
sysLogEntity.setParams(JacksonUtils.toJSONString(argList));
|
||||
sysLogEntity.setParams(JSON.toJSONString(argList));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -61,6 +61,18 @@ public class BaseEntity implements Serializable {
|
|||
)
|
||||
protected Long version;
|
||||
|
||||
/**
|
||||
* 创建人 存储用户user_id
|
||||
*/
|
||||
@TableField(value = "create_by", fill = FieldFill.INSERT)
|
||||
protected String createBy;
|
||||
|
||||
/**
|
||||
* 修改人 存储用户user_id
|
||||
*/
|
||||
@TableField(value = "update_by", fill = FieldFill.UPDATE)
|
||||
protected String updateBy;
|
||||
|
||||
@TableField(exist = false)
|
||||
@Condition(name = "dept_id", type = Condition.ConditionType.dataScope)
|
||||
private transient Map<String, Object> sqlParam;
|
||||
|
|
|
|||
|
|
@ -17,50 +17,34 @@ import java.time.LocalDateTime;
|
|||
*/
|
||||
@Slf4j
|
||||
public class MybatisPlusMetaObjectHandler implements MetaObjectHandler {
|
||||
|
||||
/**
|
||||
* 遵循严格填充
|
||||
* @param metaObject 元对象
|
||||
*/
|
||||
@Override
|
||||
public void insertFill(MetaObject metaObject) {
|
||||
if(log.isDebugEnabled()){
|
||||
log.debug("mybatis plus start insert fill ....");
|
||||
}
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
// 修改人, 创建人
|
||||
Long userId = SecurityContextHolder.getUserId();
|
||||
fillValIfNullByName("createBy", userId, metaObject, false);
|
||||
fillValIfNullByName("createTime", now, metaObject, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateFill(MetaObject metaObject) {
|
||||
log.debug("mybatis plus start update fill ....");
|
||||
fillValIfNullByName("updateTime", LocalDateTime.now(), metaObject, true);
|
||||
Long userId = SecurityContextHolder.getUserId();
|
||||
fillValIfNullByName("updateBy", userId, metaObject, true);
|
||||
// 用于填充 创建人以及修改人
|
||||
// String userName = SecurityContextHolder.getUserName();
|
||||
String userName = "system";
|
||||
this.strictInsertFill(metaObject, "createTime", LocalDateTime.class, LocalDateTime.now());
|
||||
this.strictInsertFill(metaObject, "createBy", String.class, userName);
|
||||
}
|
||||
|
||||
/**
|
||||
* 填充值,先判断是否有手动设置,优先手动设置的值,例如:job必须手动设置
|
||||
* @param fieldName 属性名
|
||||
* @param fieldVal 属性值
|
||||
* @param metaObject MetaObject
|
||||
* @param isCover 是否覆盖原有值,避免更新操作手动入参
|
||||
* 遵循严格填充
|
||||
* @param metaObject 元对象
|
||||
*/
|
||||
private static void fillValIfNullByName(String fieldName, Object fieldVal, MetaObject metaObject, boolean isCover) {
|
||||
// 1. 没有 get 方法
|
||||
if (!metaObject.hasSetter(fieldName)) {
|
||||
return;
|
||||
}
|
||||
// 2. 如果用户有手动设置的值
|
||||
Object userSetValue = metaObject.getValue(fieldName);
|
||||
String setValueStr = StrUtil.str(userSetValue, Charset.defaultCharset());
|
||||
if (StrUtil.isNotBlank(setValueStr) && !isCover) {
|
||||
return;
|
||||
}
|
||||
// 3. field 类型相同时设置
|
||||
Class<?> getterType = metaObject.getGetterType(fieldName);
|
||||
if (ClassUtils.isAssignableValue(getterType, fieldVal)) {
|
||||
metaObject.setValue(fieldName, fieldVal);
|
||||
}
|
||||
@Override
|
||||
public void updateFill(MetaObject metaObject) {
|
||||
log.debug("mybatis plus start update fill ....");
|
||||
// String userName = SecurityContextHolder.getUserName();
|
||||
String userName = "system";
|
||||
this.strictInsertFill(metaObject, "updateTime", LocalDateTime.class, LocalDateTime.now());
|
||||
this.strictInsertFill(metaObject, "updateBy", String.class, userName);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Accessors(chain = true)
|
||||
@TableName("sys_dept")
|
||||
@Builder
|
||||
|
|
@ -55,19 +55,4 @@ public class SysDept extends BaseEntity
|
|||
@TableField(exist = false)
|
||||
private List<SysDept> children = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
@TableField(
|
||||
value = "create_by"
|
||||
)
|
||||
private String createBy;
|
||||
/**
|
||||
* 修改人
|
||||
*/
|
||||
@TableField(
|
||||
value = "update_by"
|
||||
)
|
||||
private String updateBy;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -86,20 +86,6 @@ public class SysRole extends BaseEntity {
|
|||
|
||||
@TableField(exist = false)
|
||||
private Set<String> permissions;
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
@TableField(
|
||||
value = "create_by"
|
||||
)
|
||||
protected String createBy;
|
||||
/**
|
||||
* 修改人
|
||||
*/
|
||||
@TableField(
|
||||
value = "update_by"
|
||||
)
|
||||
protected String updateBy;
|
||||
/**
|
||||
* 是否为超管
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -76,17 +76,6 @@ public class SysUser extends BaseEntity {
|
|||
@TableField(value = "nick_name")
|
||||
private String nickName;
|
||||
|
||||
/**
|
||||
* 创建人角色
|
||||
*/
|
||||
@TableField(updateStrategy = FieldStrategy.NOT_NULL)
|
||||
private String createBy;
|
||||
|
||||
/**
|
||||
* 修改人
|
||||
*/
|
||||
@TableField(updateStrategy = FieldStrategy.NOT_NULL)
|
||||
private String updateBy;
|
||||
/**
|
||||
* 是否可以登录平台, true 可以, false 不可以, 默认true
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -37,6 +37,10 @@
|
|||
<groupId>com.chushang</groupId>
|
||||
<artifactId>chushang-common-mybatis-plugin</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>com.chushang</groupId>
|
||||
<artifactId>chushang-common-mq</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,53 @@
|
|||
package com.chushang.inspection.project.entity.dto;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.chushang.common.core.validator.Create;
|
||||
import com.chushang.common.core.validator.Update;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* @auther: zhao
|
||||
* @date: 2024/6/17 11:58
|
||||
*/
|
||||
@Data
|
||||
public class ContractDTO {
|
||||
/**
|
||||
* 合同Id
|
||||
*/
|
||||
@NotNull(message = "合同Id不能为空", groups = Update.class)
|
||||
private Long contractId;
|
||||
/**
|
||||
* 项目合同
|
||||
*/
|
||||
@NotNull(message = "项目合同不能为空", groups = Create.class)
|
||||
private String contractUrl;
|
||||
|
||||
/**
|
||||
* 合同有效期开始时间
|
||||
*/
|
||||
@NotNull(message = "项目合同开始时间不能为空", groups = Create.class)
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime contractStartTime;
|
||||
|
||||
/**
|
||||
* 合同有效期结束日期
|
||||
*/
|
||||
@TableField(value = "contract_end_time")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@NotNull(message = "项目合同结束时间不能为空", groups = Create.class)
|
||||
private LocalDateTime contractEndTime;
|
||||
/**
|
||||
* 合同金额
|
||||
*/
|
||||
@NotNull(message = "合同金额不能为空", groups = Create.class)
|
||||
private BigDecimal contractAmount;
|
||||
/**
|
||||
* 查询枚举 AuditStatusEnums , 最终以字典表中project_audit_status字典编码为准
|
||||
*/
|
||||
private Integer auditStatus;
|
||||
}
|
||||
|
|
@ -1,9 +1,13 @@
|
|||
package com.chushang.inspection.project.entity.dto;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.chushang.common.core.validator.Create;
|
||||
import com.chushang.common.core.validator.Update;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
|
|
@ -12,13 +16,25 @@ import javax.validation.constraints.NotNull;
|
|||
*/
|
||||
@Data
|
||||
public class ProjectDTO {
|
||||
/**
|
||||
* 项目Id
|
||||
*/
|
||||
@NotNull(message = "项目Id不能为空", groups = Update.class)
|
||||
private Long projectId;
|
||||
/**
|
||||
* 项目名称
|
||||
*/
|
||||
@NotNull(message = "项目名称不能为空", groups = Create.class)
|
||||
@NotNull(message = "项目名称不能为空", groups = Update.class)
|
||||
private String projectName;
|
||||
|
||||
/**
|
||||
* 项目合同
|
||||
*/
|
||||
@NotNull(message = "项目合同不能为空", groups = Create.class)
|
||||
@NotNull(message = "项目合同不能为空", groups = Update.class)
|
||||
@Valid
|
||||
private ContractDTO contract;
|
||||
|
||||
/**
|
||||
* 项目联系人
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -83,16 +83,4 @@ public class WrkAudit extends BaseEntity {
|
|||
*/
|
||||
@TableField(value = "remark")
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 创建人 存储用户user_id
|
||||
*/
|
||||
@TableField(value = "create_by")
|
||||
private String createBy;
|
||||
|
||||
/**
|
||||
* 修改人 存储用户user_id
|
||||
*/
|
||||
@TableField(value = "update_by")
|
||||
private String updateBy;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,7 @@
|
|||
package com.chushang.inspection.project.entity.po;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import com.chushang.common.dict.annotation.DictFormat;
|
||||
import com.chushang.common.mybatis.annotation.Condition;
|
||||
import com.chushang.common.mybatis.base.BaseEntity;
|
||||
import lombok.AllArgsConstructor;
|
||||
|
|
@ -59,13 +57,6 @@ public class WrkProject extends BaseEntity {
|
|||
@Condition(name = "dept_id", type = Condition.ConditionType.eq)
|
||||
private Long deptId;
|
||||
|
||||
/**
|
||||
* 审核状态 项目审核状态 待初审 待复审 初审驳回 复审驳回 初审通过=待复审 复审通过
|
||||
*/
|
||||
@TableField(value = "audit_status")
|
||||
@Condition(name = "audit_status", type = Condition.ConditionType.eq)
|
||||
private Integer auditStatus;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
|
|
@ -75,14 +66,14 @@ public class WrkProject extends BaseEntity {
|
|||
/**
|
||||
* 创建人 存储用户user_id
|
||||
*/
|
||||
@TableField(value = "create_by")
|
||||
@TableField(value = "create_by", fill = FieldFill.INSERT)
|
||||
@Condition(name = "create_by", type = Condition.ConditionType.eq)
|
||||
private String createBy;
|
||||
|
||||
/**
|
||||
* 修改人 存储用户user_id
|
||||
*/
|
||||
@TableField(value = "update_by")
|
||||
@TableField(value = "update_by", fill = FieldFill.UPDATE)
|
||||
@Condition(name = "update_by", type = Condition.ConditionType.eq)
|
||||
private String updateBy;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,16 +1,14 @@
|
|||
package com.chushang.inspection.project.entity.po;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import com.chushang.common.dict.annotation.DictFormat;
|
||||
import com.chushang.common.mybatis.annotation.Condition;
|
||||
import com.chushang.common.mybatis.base.BaseEntity;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Date;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import lombok.*;
|
||||
|
||||
/**
|
||||
* @auther: zhao
|
||||
|
|
@ -24,17 +22,20 @@ import lombok.NoArgsConstructor;
|
|||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@TableName(value = "wrk_project_contract")
|
||||
@Builder
|
||||
public class WrkProjectContract extends BaseEntity {
|
||||
/**
|
||||
* 合同Id 合同主键id, 雪花自增
|
||||
*/
|
||||
@TableId(value = "contract_id", type = IdType.ASSIGN_ID)
|
||||
@Condition(name = "contract_id", type = Condition.ConditionType.eq)
|
||||
private Long contractId;
|
||||
|
||||
/**
|
||||
* 项目id 项目id, 1个项目id 对应多个合同id
|
||||
*/
|
||||
@TableField(value = "project_id")
|
||||
@Condition(name = "project_id", type = Condition.ConditionType.eq)
|
||||
private Long projectId;
|
||||
|
||||
/**
|
||||
|
|
@ -53,13 +54,13 @@ public class WrkProjectContract extends BaseEntity {
|
|||
* 合同有效期开始时间
|
||||
*/
|
||||
@TableField(value = "contract_start_time")
|
||||
private Date contractStartTime;
|
||||
private LocalDateTime contractStartTime;
|
||||
|
||||
/**
|
||||
* 合同有效期结束日期
|
||||
*/
|
||||
@TableField(value = "contract_end_time")
|
||||
private Date contractEndTime;
|
||||
private LocalDateTime contractEndTime;
|
||||
|
||||
/**
|
||||
* 合同金额 合同金额数, 后台存储采用decimal(20,5)
|
||||
|
|
@ -68,32 +69,36 @@ public class WrkProjectContract extends BaseEntity {
|
|||
private BigDecimal contractAmount;
|
||||
|
||||
/**
|
||||
* 审核状态 smallInt(6) 合同审核状态
|
||||
* 审核状态 项目审核状态 待初审 待复审 初审驳回 复审驳回 初审通过=待复审 复审通过
|
||||
*/
|
||||
@TableField(value = "audit_status")
|
||||
private Short auditStatus;
|
||||
@Condition(name = "audit_status", type = Condition.ConditionType.eq)
|
||||
@DictFormat(dictType = "project_audit_status")
|
||||
private Integer auditStatus;
|
||||
|
||||
/**
|
||||
* 项目有效状态 合同有效期内的项目为有效项目
|
||||
*/
|
||||
@TableField(value = "project_effect")
|
||||
private Short projectEffect;
|
||||
@DictFormat(dictType = "project_effect")
|
||||
private Integer projectEffect;
|
||||
|
||||
/**
|
||||
* 回款状态 是否已经回款完成
|
||||
*/
|
||||
@TableField(value = "payment_state")
|
||||
private Short paymentState;
|
||||
@DictFormat(dictType = "payment_state")
|
||||
private Integer paymentState;
|
||||
|
||||
/**
|
||||
* 创建人 存储用户user_id
|
||||
*/
|
||||
@TableField(value = "create_by")
|
||||
@TableField(value = "create_by", fill = FieldFill.INSERT)
|
||||
private String createBy;
|
||||
|
||||
/**
|
||||
* 修改人 存储用户user_id
|
||||
*/
|
||||
@TableField(value = "update_by")
|
||||
@TableField(value = "update_by", fill = FieldFill.UPDATE)
|
||||
private String updateBy;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -82,16 +82,4 @@ public class WrkProjectPayment extends BaseEntity {
|
|||
*/
|
||||
@TableField(value = "remark")
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 创建人 存储用户user_id
|
||||
*/
|
||||
@TableField(value = "create_by")
|
||||
private String createBy;
|
||||
|
||||
/**
|
||||
* 修改人 存储用户user_id
|
||||
*/
|
||||
@TableField(value = "update_by")
|
||||
private String updateBy;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,9 @@
|
|||
package com.chushang.inspection.project.controller;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.chushang.common.core.exception.utils.AssertUtil;
|
||||
import com.chushang.common.core.validator.Create;
|
||||
import com.chushang.common.core.validator.Update;
|
||||
import com.chushang.common.core.web.AjaxResult;
|
||||
import com.chushang.common.log.annotation.SysLog;
|
||||
import com.chushang.common.log.enums.BusinessType;
|
||||
|
|
@ -9,17 +11,15 @@ import com.chushang.common.mybatis.page.CommonParam;
|
|||
import com.chushang.common.mybatis.utils.PageResult;
|
||||
import com.chushang.inspection.project.entity.dto.ProjectDTO;
|
||||
import com.chushang.inspection.project.entity.po.WrkProject;
|
||||
import com.chushang.inspection.project.entity.po.WrkProjectContract;
|
||||
import com.chushang.inspection.project.service.WrkProjectContractService;
|
||||
import com.chushang.inspection.project.service.WrkProjectService;
|
||||
import com.chushang.security.annotation.RequiresPermissions;
|
||||
import com.chushang.security.entity.vo.LoginUser;
|
||||
import com.chushang.security.utils.SecurityUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @auther: zhao
|
||||
|
|
@ -33,6 +33,7 @@ public class WrkProjectController {
|
|||
@Resource
|
||||
WrkProjectService projectService;
|
||||
|
||||
|
||||
/**
|
||||
* 获取项目列表
|
||||
*/
|
||||
|
|
@ -45,29 +46,29 @@ public class WrkProjectController {
|
|||
return AjaxResult.success(pageResult);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增项目 -- 暂存 + 提交审核
|
||||
*/
|
||||
@PostMapping(value = "/save")
|
||||
@RequiresPermissions("inspection:project:save")
|
||||
// @RequiresPermissions("inspection:project:save")
|
||||
@SysLog(value = "项目",businessType = BusinessType.INSERT)
|
||||
public AjaxResult save(@RequestBody @Validated(Create.class) ProjectDTO project){
|
||||
WrkProject wrkProject = new WrkProject();
|
||||
BeanUtil.copyProperties(project, wrkProject);
|
||||
Long deptId = SecurityUtils.getLoginUser().getSysUser().getDeptId();
|
||||
wrkProject.setDeptId(deptId);
|
||||
// 应该显示 未提交审核
|
||||
wrkProject.setAuditStatus(0);
|
||||
projectService.save(wrkProject);
|
||||
return AjaxResult.success(wrkProject.getProjectId());
|
||||
return AjaxResult.success(projectService.save(project));
|
||||
}
|
||||
|
||||
//
|
||||
// @SysLog(value = "岗位", businessType = BusinessType.EXPORT)
|
||||
// @RequiresPermissions("system:post:export")
|
||||
// @PostMapping("/export")
|
||||
// public void export(HttpServletResponse response, SysPost post)
|
||||
// {
|
||||
// CommonParam commonParam = CommonParam.buildAllRequest();
|
||||
// List<SysPost> list = postService.allPostList(post, commonParam);
|
||||
// ExcelUtils.exportList(response, SysPost.class,list, "岗位数据");
|
||||
// }
|
||||
/**
|
||||
* 修改 项目
|
||||
*/
|
||||
@PostMapping(value = "/update")
|
||||
// @RequiresPermissions("inspection:project:save")
|
||||
@SysLog(value = "项目",businessType = BusinessType.UPDATE)
|
||||
public AjaxResult update(@RequestBody @Validated(Update.class) ProjectDTO project){
|
||||
Long projectId = project.getProjectId();
|
||||
AssertUtil.invalidate(null == projectId, "修改项目时, 项目id 不能为空");
|
||||
return AjaxResult.success(projectService.update(project));
|
||||
}
|
||||
|
||||
// /**
|
||||
//
|
||||
// /**
|
||||
// * 根据岗位编号获取详细信息
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.chushang.inspection.project.service;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
|
@ -7,11 +8,17 @@ import com.chushang.common.mybatis.page.CommonParam;
|
|||
import com.chushang.common.mybatis.utils.PageResult;
|
||||
import com.chushang.common.mybatis.utils.WrapperUtils;
|
||||
import com.chushang.datascope.annotation.DataScope;
|
||||
import com.chushang.inspection.project.entity.dto.ProjectDTO;
|
||||
import com.chushang.inspection.project.entity.po.WrkProjectContract;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.chushang.inspection.project.entity.po.WrkProject;
|
||||
import com.chushang.inspection.project.mapper.WrkProjectMapper;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* @auther: zhao
|
||||
|
|
@ -20,6 +27,8 @@ import com.chushang.inspection.project.mapper.WrkProjectMapper;
|
|||
@Slf4j
|
||||
@Service
|
||||
public class WrkProjectService extends ServiceImpl<WrkProjectMapper, WrkProject> implements IService<WrkProject> {
|
||||
@Resource
|
||||
WrkProjectContractService contractService;
|
||||
|
||||
@DataScope
|
||||
public PageResult pageList(WrkProject project, CommonParam commonParam) {
|
||||
|
|
@ -30,4 +39,62 @@ public class WrkProjectService extends ServiceImpl<WrkProjectMapper, WrkProject>
|
|||
);
|
||||
return new PageResult(page);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存项目
|
||||
*/
|
||||
@Transactional
|
||||
public Long save(ProjectDTO project)
|
||||
{
|
||||
WrkProject wrkProject = new WrkProject();
|
||||
BeanUtil.copyProperties(project, wrkProject);
|
||||
// Long deptId = SecurityUtils.getLoginUser().getSysUser().getDeptId();
|
||||
Long deptId = 200L;
|
||||
wrkProject.setDeptId(deptId);
|
||||
this.save(wrkProject);
|
||||
|
||||
// 项目合同
|
||||
WrkProjectContract contract = WrkProjectContract.builder().build();
|
||||
BeanUtil.copyProperties(project.getContract(), contract);
|
||||
contract.setProjectId(wrkProject.getProjectId());
|
||||
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
// 在 之前 && 在 之后 无效
|
||||
if (now.isBefore(contract.getContractStartTime()) && now.isAfter(contract.getContractEndTime())) {
|
||||
contract.setProjectEffect(0);
|
||||
}else {
|
||||
contract.setProjectEffect(1);
|
||||
}
|
||||
// 未回款完成
|
||||
contract.setPaymentState(0);
|
||||
// 项目合同
|
||||
contractService.save(contract);
|
||||
return wrkProject.getProjectId();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改项目
|
||||
*/
|
||||
@Transactional
|
||||
public Long update(ProjectDTO project)
|
||||
{
|
||||
WrkProject wrkProject = new WrkProject();
|
||||
BeanUtil.copyProperties(project, wrkProject);
|
||||
this.updateById(wrkProject);
|
||||
// 项目合同
|
||||
WrkProjectContract contract = WrkProjectContract.builder().build();
|
||||
BeanUtil.copyProperties(project.getContract(), contract);
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
// 在 之前 && 在 之后 无效
|
||||
if (now.isBefore(contract.getContractStartTime()) && now.isAfter(contract.getContractEndTime())) {
|
||||
contract.setProjectEffect(0);
|
||||
}else {
|
||||
contract.setProjectEffect(1);
|
||||
}
|
||||
// 未回款完成
|
||||
contract.setPaymentState(0);
|
||||
// 项目合同 修改时不需要 项目id
|
||||
contractService.updateById(contract);
|
||||
return wrkProject.getProjectId();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -75,25 +75,12 @@ public class FileSourceInfo extends BaseEntity{
|
|||
*/
|
||||
@TableField("storage")
|
||||
private String storage;
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
@TableField(
|
||||
value = "create_by"
|
||||
)
|
||||
private String createBy;
|
||||
/**
|
||||
* 部门Id, 只能看到权限下的图片
|
||||
*/
|
||||
@TableField(value = "dept_id")
|
||||
private Long deptId;
|
||||
/**
|
||||
* 修改人
|
||||
*/
|
||||
@TableField(
|
||||
value = "update_by"
|
||||
)
|
||||
private String updateBy;
|
||||
|
||||
|
||||
|
||||
public FileSourceInfo(String fid){
|
||||
|
|
|
|||
|
|
@ -54,22 +54,4 @@ public class SysConfig extends BaseEntity
|
|||
@ExcelProperty(value = "系统内置", index = 4)
|
||||
private String configType;
|
||||
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
@TableField(
|
||||
value = "create_by"
|
||||
)
|
||||
@ExcelProperty(value = "创建人", index = 5)
|
||||
private String createBy;
|
||||
/**
|
||||
* 修改人
|
||||
*/
|
||||
@TableField(
|
||||
value = "update_by"
|
||||
)
|
||||
@ExcelProperty(value = "修改人", index = 6)
|
||||
private String updateBy;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -75,19 +75,4 @@ public class SysDictData extends BaseEntity {
|
|||
@ExcelProperty(value = "状态", index = 8)
|
||||
private Boolean status;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
@TableField(
|
||||
value = "create_by"
|
||||
)
|
||||
protected String createBy;
|
||||
/**
|
||||
* 修改人
|
||||
*/
|
||||
@TableField(
|
||||
value = "update_by"
|
||||
)
|
||||
protected String updateBy;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -56,22 +56,6 @@ public class SysDictType extends BaseEntity
|
|||
@ExcelProperty(value = "状态", index = 3)
|
||||
@Condition(name = "status", type = Condition.ConditionType.eq)
|
||||
private Boolean status;
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
@TableField(
|
||||
value = "create_by"
|
||||
)
|
||||
@ExcelProperty(value = "创建人", index = 4)
|
||||
protected String createBy;
|
||||
/**
|
||||
* 修改人
|
||||
*/
|
||||
@TableField(
|
||||
value = "update_by"
|
||||
)
|
||||
@ExcelProperty(value = "修改人", index = 5)
|
||||
protected String updateBy;
|
||||
/**
|
||||
* 查询区间
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -98,21 +98,6 @@ public class SysMenu extends BaseEntity {
|
|||
*/
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
@TableField(
|
||||
value = "create_by"
|
||||
)
|
||||
protected String createBy;
|
||||
/**
|
||||
* 修改人
|
||||
*/
|
||||
@TableField(
|
||||
value = "update_by"
|
||||
)
|
||||
protected String updateBy;
|
||||
|
||||
@TableField(exist = false)
|
||||
private List<SysMenu> children = new ArrayList<>();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -52,23 +52,6 @@ public class SysPost extends BaseEntity
|
|||
@ExcelProperty(value = "状态", index = 4)
|
||||
private Boolean status;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
@TableField(
|
||||
value = "create_by"
|
||||
)
|
||||
@ExcelProperty(value = "创建人", index = 4)
|
||||
protected String createBy;
|
||||
/**
|
||||
* 修改人
|
||||
*/
|
||||
@TableField(
|
||||
value = "update_by"
|
||||
)
|
||||
@ExcelProperty(value = "修改人", index = 5)
|
||||
protected String updateBy;
|
||||
|
||||
/** 用户是否存在此岗位标识 默认不存在 */
|
||||
@TableField(exist = false)
|
||||
private boolean flag = false;
|
||||
|
|
|
|||
|
|
@ -49,7 +49,6 @@ public interface ISysUserService extends IService<SysUser> {
|
|||
default boolean updatePassword(Long userId, String oldPassword, String newPassword){
|
||||
return this.update(SysUser.builder()
|
||||
.password(newPassword)
|
||||
.updateBy(SecurityUtils.getUsername())
|
||||
.build()
|
||||
,new LambdaQueryWrapper<SysUser>()
|
||||
.eq(SysUser::getUserId, userId)
|
||||
|
|
@ -60,7 +59,6 @@ public interface ISysUserService extends IService<SysUser> {
|
|||
default void updateUserStatus(SysUser user){
|
||||
this.update(SysUser.builder()
|
||||
.status(user.getStatus())
|
||||
.updateBy(user.getUpdateBy())
|
||||
.build(), new LambdaQueryWrapper<SysUser>()
|
||||
.eq(SysUser::getUserId, user.getUserId()));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -214,7 +214,6 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
|||
.userId(userId)
|
||||
.password(newPassword)
|
||||
.salt(salt)
|
||||
.updateBy(SecurityUtils.getUsername())
|
||||
.build());
|
||||
// 强退用户
|
||||
tokenService.forcedRetreat(userId);
|
||||
|
|
|
|||
|
|
@ -63,16 +63,6 @@ public class TaskInfo extends BaseEntity {
|
|||
@TableField(value = "task_type")
|
||||
@DictFormat(dictType = "task_type")
|
||||
private Integer taskType;
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
@TableField(value = "create_by")
|
||||
private String createBy;
|
||||
/**
|
||||
* 修改人
|
||||
*/
|
||||
@TableField(value = "update_by")
|
||||
private String updateBy;
|
||||
/**
|
||||
* 后台任务执行参数
|
||||
*/
|
||||
|
|
|
|||
Loading…
Reference in New Issue