记录一次 Mybatis plus使用baseMapper插入一条数据并返回id

实体类代码:

@Data
@TableName("T_***")
public class Flow*** implements Serializable {

    private static final long serialVersionUID = 1L;

    @TableId(value = "id", type = IdType.AUTO)
    private int id;

    @LengthForUtf8(max = 50)
    private String name;

    @NotNull
    @LengthForUtf8(max = 100)
    private String processDefinitionId;

service层代码:

@Service
public class FlowEntityServiceImpl extends ServiceImpl<FlowEntityMapper, FlowEntity> implements FlowEntityService{

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void save(){

        FlowEntity flowentity = new FlowEntity();
       
        flowentity.setCcToVos(listStrings);
        flowentity.setCreateBy(userId);
        flowentity.setCreateTime(new Date());
        baseMapper.insert(flowentity);
    }
}

猜你喜欢

转载自blog.csdn.net/Dengrz/article/details/120061985