# lrdoc **Repository Path**: am2901/lrdoc ## Basic Information - **Project Name**: lrdoc - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2021-07-05 - **Last Updated**: 2021-09-23 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # 《平台后端培训》视频学习总结 #### 新建子项目 1. MvcConfig ```groovy @Configuration class DemoMvcConfig implements WebMvcConfigurer { @Autowired ServerConfig serverConfig @Override void configurePathMatch(PathMatchConfigurer configurer) { // "demo"是项目名,"com.longruan.ark.demo"是包名,平台只扫描带@RestController注解的类 // url组合规则:/api/应用名/controller配置的url/ configurer.addPathPrefix("/${serverConfig.prefix}/demo", HandlerTypePredicate.forAnnotation(RestController.class) .forBasePackage("com.longruan.ark.demo")) } } ``` 2. 怎样开发一个controller ```groovy @Slf4j @RestController // url尽量与表名保持一直,容易查找问题 @RequestMapping("test") // 继承平台的GeneralController,自动实现CRUD操作 class DemoController extends GeneralController { @PostConstruct def init() { // 业务的主表名 mainTable = "test" // 排序,冒号后为正序或者倒序 defaultSort = "t_create:d" // 子表 childrenTables = [ "auth_user_mapping", "auth_user_role" ] // 如果列名按规则命名,外键会自动识别,自定义的外键名需要放在foreignKeys中 foreignKeys = [ "auth_user_mapping": "id_at_auth_user", "auth_user_role": "id_at_auth_user" ] // left join joins << new Join( // 连接表名 "auth_user", // test表的列 "id", // auth_user表的列 "id") // 连接表需要查询的列 .addShowColumn( // auth_user的列 "v_username", // auth_user的列的别名,如果不加这个参数,平台自动提供按命名规则命名的别名 "v_username") // 是否关联删除子表数据 autoChildrenTableDelete = true // 视图 shadowList = "view_test" } // 导入文件 @Override Object imports(MultipartFile file) { return super.imports(file) } // 导出文件 @Override Object export(@RequestParam(required = false) Integer page, @RequestParam(required = false) Integer size, @RequestParam(required = false) Boolean noPage, @RequestParam(required = false) String condition, @RequestParam(required = false) String sort, @RequestParam(required = false) Boolean tree, @RequestParam(required = false) String treeRootID, @RequestParam(required = false) Boolean showMeInTree, @RequestParam(required = false) Boolean isBoxTree, @RequestParam(required = false) String treeLabelField, @RequestParam(required = false) Integer treeMaxLevel, @RequestParam(required = false) String query, @RequestBody Object headList) { return super.export(page, size, noPage, condition, sort, tree, treeRootID, showMeInTree, isBoxTree, treeLabelField, treeMaxLevel, query, headList) } } ``` 3. 建表规则 ```sql # 数据库字段命名规则 # 列名:字段类型首字母_列业务名,例如:v_name,i_age # “外键”名:字段名_at_表名__额外功能说明,例如:id_at_auth_user__create,创建人对应auth_user的id # 建表要继承平台基础表,纳入权限管理 create table demo.test ( v_name varchar, i_age int ) inherits (platform.basic_business); # id 主键 # n_order 排序 # t_create 创建时间 # t_update 修改时间 # id_at_auth_user__create 创建人id # id_at_auth_user__update 修改人id # v_remark 备注 # id_at_orga_organization__perm 机构id,perm都是权限相关字段 # id_at_orga_department__perm 部门id # id_at_auth_user__perm 权限人id,默认跟id_at_auth_user__create一致 # v_code_at_areacode 行政区划,目前不需要了 # id_at_areacode 行政区划,目前不需要了 # id_at_app_module 模块id,例如:不同模块都有上传文件,使用模块id做数据隔离 # v_name 自建字段 # i_age 自建字段 ``` 4. runner启动时执行一些前置操作 5. 通用用户id,白名单userid:0,超级管理员userid:1 #### 复杂数据库字段命名 1. 字典命名dict_字典类目名(小写),存储数据字典表的编码,平台自动关联字典表的其他字段,字段名_at_dict_字典类目名(小写) 2. 附件信息,单文件file_业务名,多文件files_业务名,平台自动关联name_file_业务名的文件名提供给前端 #### 增加数据库schema ```sql show search_path; alter database demo set search_path = xxx; # 需要注意的是:需要重启已经与数据库建立连接的客户端 ``` #### iPlatformClient公共数据 #### 动态表单 模块配置使用从/common开始的url