AI一键生成增删改查代码
在线体验:体验地址
使用教程
1. 描述需求
准确清晰的描述你的需求,如:基于RBAC模型的权限管理系统,点击AI图标
2. AI生成SQL语句
AI将根据你的需求描述生成SQL语句
CREATE TABLE users (
id INT AUTO_INCREMENT PRIMARY KEY,
username VARCHAR(50) NOT NULL COMMENT '用户名',
password VARCHAR(255) NOT NULL COMMENT '密码(加密后的值)',
email VARCHAR(100) COMMENT '电子邮箱',
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='用户表';
CREATE TABLE roles (
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(50) NOT NULL COMMENT '角色名称',
description TEXT COMMENT '角色描述',
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='角色表';
CREATE TABLE permissions (
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(50) NOT NULL COMMENT '权限名称',
description TEXT COMMENT '权限描述',
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='权限表';
CREATE TABLE user_roles (
user_id INT,
role_id INT,
PRIMARY KEY (user_id, role_id),
FOREIGN KEY (user_id) REFERENCES users(id),
FOREIGN KEY (role_id) REFERENCES roles(id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='用户角色关联表';
CREATE TABLE role_permissions (
role_id INT,
permission_id INT,
PRIMARY KEY (role_id, permission_id),
FOREIGN KEY (role_id) REFERENCES roles(id),
FOREIGN KEY (permission_id) REFERENCES permissions(id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='角色权限关联表';
3. 自定义生成配置
配置包名、作者名、要生成的方法及方法配置、代码模板、ORM框架、要集成的依赖等配置项,也可直接使用默认配置,点击一键生成
4. 生成代码
生成的部分内容如下,完整代码可在线体验:体验地址
Users.java:
package com.tool4j.entity;
import java.io.Serializable;
import java.util.Date;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* =
*
* @author system
* @since 2023-12-13 13:26:31
*/
@Data
@TableName("users")
@ApiModel(value = "Users", description = "=")
public class Users implements Serializable{
private static final long serialVersionUID=1L;
/**
*
*/
@ApiModelProperty(" ")
private Integer id;
/**
* 用户名
*/
@ApiModelProperty("用户名")
private String username;
/**
* 密码(加密后的值)
*/
@ApiModelProperty("密码(加密后的值)")
private String password;
/**
* 电子邮箱
*/
@ApiModelProperty("电子邮箱")
private String email;
/**
* 创建时间
*/
@ApiModelProperty("创建时间")
private Date createdAt;
/**
* 更新时间
*/
@ApiModelProperty("更新时间")
private Date updatedAt;
}
Roles.java
package com.tool4j.entity;
import java.io.Serializable;
import java.util.Date;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* =
*
* @author system
* @since 2023-12-13 13:26:31
*/
@Data
@TableName("roles")
@ApiModel(value = "Roles", description = "=")
public class Roles implements Serializable{
private static final long serialVersionUID=1L;
/**
*
*/
@ApiModelProperty(" ")
private Integer id;
/**
* 角色名称
*/
@ApiModelProperty("角色名称")
private String name;
/**
* 角色描述
*/
@ApiModelProperty("角色描述")
private String description;
/**
* 创建时间
*/
@ApiModelProperty("创建时间")
private Date createdAt;
/**
* 更新时间
*/
@ApiModelProperty("更新时间")
private Date updatedAt;
}
Permissions.java
package com.tool4j.entity;
import java.io.Serializable;
import java.util.Date;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* =
*
* @author system
* @since 2023-12-13 13:26:31
*/
@Data
@TableName("permissions")
@ApiModel(value = "Permissions", description = "=")
public class Permissions implements Serializable{
private static final long serialVersionUID=1L;
/**
*
*/
@ApiModelProperty(" ")
private Integer id;
/**
* 权限名称
*/
@ApiModelProperty("权限名称")
private String name;
/**
* 权限描述
*/
@ApiModelProperty("权限描述")
private String description;
/**
* 创建时间
*/
@ApiModelProperty("创建时间")
private Date createdAt;
/**
* 更新时间
*/
@ApiModelProperty("更新时间")
private Date updatedAt;
}
UserRoles.java
package com.tool4j.entity;
import java.io.Serializable;
import java.util.Date;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* =
*
* @author system
* @since 2023-12-13 13:26:31
*/
@Data
@TableName("user_roles")
@ApiModel(value = "UserRoles", description = "=")
public class UserRoles implements Serializable{
private static final long serialVersionUID=1L;
/**
*
*/
@ApiModelProperty(" ")
private Integer userId;
/**
*
*/
@ApiModelProperty(" ")
private Integer roleId;
}
RolePermissions.java
package com.tool4j.entity;
import java.io.Serializable;
import java.util.Date;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* =
*
* @author system
* @since 2023-12-13 13:26:31
*/
@Data
@TableName("role_permissions")
@ApiModel(value = "RolePermissions", description = "=")
public class RolePermissions implements Serializable{
private static final long serialVersionUID=1L;
/**
*
*/
@ApiModelProperty(" ")
private Integer roleId;
/**
*
*/
@ApiModelProperty(" ")
private Integer permissionId;
}