同步操作将从 Cmeet/anno-admin 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
Anno-Admin是一个基于Solon框架,PearAdmin,百度AMIS的开源项目,旨在通过注解生成后台管理系统。Solon框架是一个轻量级的Java Web框架,具有高性能、低内存占用、易于扩展等特点。Anno-Admin利用Solon框架的优势,通过注解的方式自动生成后台管理系统的各种功能,大大减少了开发者的工作量。使用Anno-Admin,开发者只需要关注业务逻辑的实现,无需手动编写大量的重复代码,从而提高了开发效率。同时,Anno-Admin也为想要学习注解和代码生成技术的开发者提供了一个很好的学习平台。总之,Anno-Admin是一个非常实用、易用、高效的后台管理系统开发工具,值得开发者们去尝试和使用。
通过注解生成后台管理系统 支持用户管理、权限管理、数据管理等功能 简化后台管理系统的开发流程 适合快速开发后台管理系统的开发者 适合想要学习注解和代码生成技术的开发者
在项目中添加Anno-Admin的依赖 在代码中添加注解,指定需要生成的后台管理系统功能
系统菜单:
系统菜单代码:
package site.sorghum.anno.modular.menu.entity.anno;
import com.alibaba.fastjson2.annotation.JSONField;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.noear.wood.annotation.Table;
import site.sorghum.anno.modular.anno.annotation.clazz.AnnoMain;
import site.sorghum.anno.modular.anno.annotation.clazz.AnnoPermission;
import site.sorghum.anno.modular.anno.annotation.clazz.AnnoTree;
import site.sorghum.anno.modular.anno.annotation.field.AnnoEdit;
import site.sorghum.anno.modular.anno.annotation.field.AnnoField;
import site.sorghum.anno.modular.anno.annotation.field.AnnoSearch;
import site.sorghum.anno.modular.anno.annotation.field.type.AnnoOptionType;
import site.sorghum.anno.modular.anno.enums.AnnoDataType;
import site.sorghum.anno.modular.base.model.BaseMetaModel;
/**
* 系统菜单
*
* @author Sorghum
* @since 2023/05/19
*/
@Data
@EqualsAndHashCode(callSuper = true)
@AnnoMain(name = "菜单管理",
annoTree = @AnnoTree(label = "title", parentKey = "parentId", key = "id", displayAsTree = true),
annoPermission = @AnnoPermission(enable = true, baseCode = "sys_anno_menu", baseCodeTranslate = "菜单管理"))
@Table("sys_anno_menu")
public class SysAnnoMenu extends BaseMetaModel {
@JSONField(name = "parentId")
@AnnoField(title = "父菜单", tableFieldName = "parent_id", edit = @AnnoEdit)
private String parentId;
@AnnoField(title = "菜单名称", tableFieldName = "title", edit = @AnnoEdit)
@JSONField(name = "title")
private String title;
@AnnoField(title = "菜单类型", tableFieldName = "type", search = @AnnoSearch(),
dataType = AnnoDataType.OPTIONS,
optionType = @AnnoOptionType(value = {
@AnnoOptionType.OptionData(label = "页面", value = "1"),
@AnnoOptionType.OptionData(label = "目录", value = "0")
}),
edit = @AnnoEdit(placeHolder = "请选择菜单类型", notNull = true))
@JSONField(name = "type")
private Integer type;
@AnnoField(title = "菜单排序", tableFieldName = "sort", edit = @AnnoEdit)
@JSONField(name = "sort")
private Integer sort;
@AnnoField(title = "打开方式", tableFieldName = "open_type", edit = @AnnoEdit, optionType = @AnnoOptionType(value = {
@AnnoOptionType.OptionData(label = "内置页", value = "_iframe"),
}), dataType = AnnoDataType.OPTIONS)
@JSONField(name = "openType")
private String openType;
@AnnoField(title = "菜单图标", tableFieldName = "icon", edit = @AnnoEdit)
@JSONField(name = "icon")
private String icon;
@AnnoField(title = "菜单链接", tableFieldName = "href", edit = @AnnoEdit)
@JSONField(name = "href")
private String href;
@AnnoField(title = "权限标识", tableFieldName = "permission_id", edit = @AnnoEdit,
dataType = AnnoDataType.OPTIONS,
optionType = @AnnoOptionType(sql = "select id as value, name as label from sys_permission where del_flag = 0 and parent_id is null order by id desc"))
@JSONField(name = "permissionId")
private String permissionId;
}
系统组织:
系统组织代码:
package site.sorghum.anno.modular.system.anno;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.noear.wood.annotation.Table;
import site.sorghum.anno.modular.anno.annotation.clazz.AnnoMain;
import site.sorghum.anno.modular.anno.annotation.clazz.AnnoPermission;
import site.sorghum.anno.modular.anno.annotation.field.AnnoButton;
import site.sorghum.anno.modular.anno.annotation.field.AnnoEdit;
import site.sorghum.anno.modular.anno.annotation.field.AnnoField;
import site.sorghum.anno.modular.anno.annotation.field.AnnoSearch;
import site.sorghum.anno.modular.base.model.BaseMetaModel;
/**
* 系统组织
*
* @author sorghum
* @since 2023/05/27
*/
@Data
@EqualsAndHashCode(callSuper = true)
@AnnoMain(name = "组织管理",
annoPermission = @AnnoPermission(enable = true, baseCode = "sys_org", baseCodeTranslate = "组织管理"))
@Table("sys_org")
public class SysOrg extends BaseMetaModel {
/**
* 部门名字
*/
@AnnoField(title = "部门名字", tableFieldName = "org_name",
search = @AnnoSearch(),
edit = @AnnoEdit(editEnable = true, addEnable = true, placeHolder = "请输入部门名字"))
private String orgName;
@AnnoButton(name = "组织用户",
o2mJoinButton = @AnnoButton.O2MJoinButton(joinAnnoMainClazz = SysUser.class, joinThisClazzField = "id", joinOtherClazzField = "orgId", enable = true))
private Object userButton;
@AnnoButton(name = "跳去百度", jumpUrl = "https://www.baidu.com/?tn=${clazz}&props=${props}")
private Object jump2BaiduButton;
@AnnoButton(name = "简单的JS命令", jsCmd = "alert('点击了按钮'); console.log(props);")
private Object jsCmd;
}
系统角色:
系统角色代码:
package site.sorghum.anno.modular.system.anno;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.noear.wood.annotation.Table;
import site.sorghum.anno.modular.anno.annotation.clazz.AnnoMain;
import site.sorghum.anno.modular.anno.annotation.clazz.AnnoPermission;
import site.sorghum.anno.modular.anno.annotation.field.AnnoButton;
import site.sorghum.anno.modular.anno.annotation.field.AnnoEdit;
import site.sorghum.anno.modular.anno.annotation.field.AnnoField;
import site.sorghum.anno.modular.anno.annotation.field.AnnoSearch;
import site.sorghum.anno.modular.anno.annotation.field.type.AnnoOptionType;
import site.sorghum.anno.modular.anno.enums.AnnoDataType;
import site.sorghum.anno.modular.base.model.BaseMetaModel;
import java.io.Serializable;
@Data
@EqualsAndHashCode(callSuper = true)
@AnnoMain(name = "角色管理",
annoPermission = @AnnoPermission(enable = true, baseCode = "sys_role", baseCodeTranslate = "角色管理"))
@Table("sys_role")
public class SysRole extends BaseMetaModel implements Serializable {
/**
* 角色名称
*/
@AnnoField(title = "角色名称", tableFieldName = "role_name",search = @AnnoSearch(),
edit = @AnnoEdit(placeHolder = "请输入角色名称",notNull = true))
String roleName;
/**
* 排序
*/
@AnnoField(title = "排序", tableFieldName = "sort",search = @AnnoSearch(),
edit = @AnnoEdit(placeHolder = "请输入排序",notNull = true))
Integer sort;
/**
* 状态 1 正常 0 封禁
*/
@AnnoField(title = "状态", tableFieldName = "enable", search = @AnnoSearch(),
dataType = AnnoDataType.OPTIONS,
optionType = @AnnoOptionType(value = {
@AnnoOptionType.OptionData(label = "正常", value = "1"),
@AnnoOptionType.OptionData(label = "封禁", value = "0")
}),
edit = @AnnoEdit(placeHolder = "请选择状态", notNull = true))
Integer enable;
/**
* 角色按钮
*/
@AnnoButton(name = "用户",m2mJoinButton = @AnnoButton.M2MJoinButton(
joinAnnoMainClazz = SysUser.class,
mediumTable = "sys_user_role",
mediumTableClass = SysUserRole.class,
mediumOtherField = "role_id",
mediumThisFiled = "user_id",
joinThisClazzField = "id"
))
private Object userButton;
/**
* 角色按钮
*/
@AnnoButton(name = "权限",m2mJoinButton = @AnnoButton.M2MJoinButton(
joinAnnoMainClazz = SysPermission.class,
mediumTableClass = SysRolePermission.class,
mediumOtherField = "role_id",
mediumThisFiled = "permission_id",
joinThisClazzField = "id"
))
private Object roleButton;
}
系统用户:
系统用户代码:
package site.sorghum.anno.modular.system.anno;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.noear.wood.annotation.PrimaryKey;
import org.noear.wood.annotation.Table;
import site.sorghum.anno.modular.anno.annotation.clazz.AnnoMain;
import site.sorghum.anno.modular.anno.annotation.clazz.AnnoPermission;
import site.sorghum.anno.modular.anno.annotation.clazz.AnnoProxy;
import site.sorghum.anno.modular.anno.annotation.field.AnnoButton;
import site.sorghum.anno.modular.anno.annotation.field.AnnoEdit;
import site.sorghum.anno.modular.anno.annotation.field.AnnoField;
import site.sorghum.anno.modular.anno.annotation.field.AnnoSearch;
import site.sorghum.anno.modular.anno.annotation.field.type.AnnoImageType;
import site.sorghum.anno.modular.anno.annotation.field.type.AnnoOptionType;
import site.sorghum.anno.modular.anno.enums.AnnoDataType;
import site.sorghum.anno.modular.auth.service.AuthService;
import site.sorghum.anno.modular.base.model.BaseOrgMetaModel;
import site.sorghum.anno.modular.system.proxy.SysUserProxy;
import java.io.Serializable;
@Data
@EqualsAndHashCode(callSuper = true)
@AnnoMain(name = "用户管理",
annoPermission = @AnnoPermission(enable = true, baseCode = "sys_user", baseCodeTranslate = "用户管理"),
annoProxy =@AnnoProxy(value = SysUserProxy.class))
@Table("sys_user")
public class SysUser extends BaseOrgMetaModel implements Serializable {
/**
* 用户头像
*/
@AnnoField(title = "用户头像",
tableFieldName = "avatar",
dataType = AnnoDataType.IMAGE,
edit = @AnnoEdit(placeHolder = "请上传用户头像"),
imageType = @AnnoImageType(thumbMode = AnnoImageType.ThumbMode.COVER,thumbRatio = AnnoImageType.ThumbRatio.RATE_ONE))
private String avatar;
/**
* 手机号
*/
@AnnoField(title = "手机号", tableFieldName = "mobile",search = @AnnoSearch(),
edit = @AnnoEdit(placeHolder = "请输入手机号",notNull = true))
private String mobile;
/**
* 密码
*/
@AnnoField(title = "密码", tableFieldName = "password",
edit = @AnnoEdit(placeHolder = "请输入密码",notNull = true,editEnable = false),show = false)
private String password;
/**
* 用户名
*/
@AnnoField(title = "用户名", tableFieldName = "name",search = @AnnoSearch(),
edit = @AnnoEdit(placeHolder = "请输入用户名",notNull = true))
private String name;
/**
* 状态 1 正常 0 封禁
*/
@AnnoField(title = "状态", tableFieldName = "enable", search = @AnnoSearch(),
dataType = AnnoDataType.OPTIONS,
optionType = @AnnoOptionType(value = {
@AnnoOptionType.OptionData(label = "正常", value = "1"),
@AnnoOptionType.OptionData(label = "封禁", value = "0")
}),
edit = @AnnoEdit(placeHolder = "请选择状态", notNull = true))
private Integer enable;
/**
* 角色按钮
*/
@AnnoButton(name = "角色",m2mJoinButton = @AnnoButton.M2MJoinButton(
joinAnnoMainClazz = SysRole.class,
mediumTable = "sys_user_role",
mediumTableClass = SysUserRole.class,
mediumOtherField = "user_id",
mediumThisFiled = "role_id",
joinThisClazzField = "id"
))
private Object roleButton;
/**
* 重置密码按钮
*/
@AnnoButton(name = "重置密码", javaCmd = @AnnoButton.JavaCmd(beanClass = AuthService.class, methodName = "resetPwd"))
private Object resetPwdButton;
}
@AnnoScan 启动类上增加
@AnnoMain
@Table
@AnnoRemove
@AnnoPreProxy
主要类: @AnnoField
@PrimaryKey
自定义逻辑 一对多 多对多的连表逻辑
@AnnoButton
如果您发现了任何问题或有任何建议,请随时提交issue或pull request。我们非常欢迎您的贡献!
Anno-Admin使用Apache 2.0许可证。详情请参阅LICENSE文件。
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。