Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

分享插件

价值源自分享!!! 一起来分享好用、实用的插件。

源码包

源码包目录结构

包含完整的业务代码,源码包需上传完整的src文件夹

如果已经发布中央库可以直接使用maven依赖坐标配置

升级包

ms-mpay 支付插件升级包结构参考

Store插件升级包

升级包需上传的包结构 如net.mingsoft.pay.upgrade.xxx,只需包含升级文件,其余方法不需要上传。

菜单 menu.json

业务包.upgrade,只能包含一个json菜单文件,可以通过代码生成器下载

Tip

菜单json只能导入顶级菜单,如果是子菜单需要编写业务代码导入,参考下方常见问题第一点

数据库 sql

业务包.upgrade,可以包含多个不同数据库 sql 脚本文件 可以存在多个sql文件

  • ddl.sql 执行优先级最高,编写对表结构操作的语句;
  • data.sql 初始化数据,编写对应插件的初始化数据;

Tip

也可以编写多个sql文件,与data.sql执行的效果一致,统一视为初始化数据sql

执行类 Upgrade.java

如果sql文件不能满足业务数据的初始化,可以通过升级类来进行业务数据的处理。

  • 可以包含多个 Upgrade*.java 文件,只需要提供 public 公共方法;
  • 类文件不能使用任何spring的注解;
  • 通过 SpringUtil.getBean 来获取对应业务对象,可以处理复杂的业务逻辑

范例:


package net.mingsoft.mpay.upgrade;

 /**
  * 支付升级业务
  * 这就是普通的类文件,唯一注意点是就是不能使用注解
  */
public class Upgrade {

    private static String menuJson = "菜单json";

    
    public void upgrade() {
        //获取业务对象
        IModelBiz modelBiz = SpringUtil.getBean(IModelBiz.class);
        
    }
}


打包导出插件

分别需要导出插件 源码包升级包

pom.xml 片段参考,注意注释部分,打包好会回分别生成 *-sources.zip*-upgrade.zip

<?xml version="1.0" encoding="UTF-8"?>
...
<build>
    ...
    <plugins>
        <!--增加对应-->
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-assembly-plugin</artifactId>
            <executions>
                <execution>
                    <phase>package</phase>
                    <goals>
                        <goal>single</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <descriptors>
                    <!--打包源码-->
                    <descriptor>assembly-source.xml</descriptor>
                    <!--打包升级包-->
                    <!-- <descriptor>assembly-upgrade.xml</descriptor> -->
                </descriptors>
            </configuration>
        </plugin>
    </plugins>
    ...
</build>
</project>
  • 打包源码脚本 assembly-source.xml
<!-- 源码包配置 -->
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3 http://maven.apache.org/xsd/assembly-1.1.3.xsd">
    <id>source</id>
    <includeBaseDirectory>false</includeBaseDirectory>
    <formats>
        <format>zip</format>
    </formats>
    <fileSets>
        <fileSet>
            <directory>src</directory>
            <outputDirectory>${file.separator}/src</outputDirectory>
            <excludes>
                <exclude>**/upgrade/**</exclude>
            </excludes>
        </fileSet>
    </fileSets>
</assembly>


  • 打包升级包 assembly-upgrade.xml
<!-- 升级包配置 -->
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3 http://maven.apache.org/xsd/assembly-1.1.3.xsd">
    <id>upgrade</id>
    <includeBaseDirectory>false</includeBaseDirectory>
    <formats>
        <format>zip</format>
    </formats>
    <fileSets>
        <fileSet>
            <directory>target${file.separator}classes</directory>
            <outputDirectory>${file.separator}</outputDirectory>
            <includes>
                <include>**/upgrade/**</include>
            </includes>
            <excludes>
                <exclude>**/upgrade/*.java</exclude>
            </excludes>
        </fileSet>
    </fileSets>
</assembly>

分享

将打包出来的插件分享到MStore

定价参考

条件价格(元)
只是简单基于模板插件(不存在新的业务表)+(10~50)
基于自定义模块+(50~100)
简单业务插件,存在3张表以内+(100~200)
复杂业务插件,大于3张表+(200~5000)

Tip

价格变动会第一时间更新次文档,如果上架模板不符合定价标准,系统将审核失败进行退回处理。

常见问题

二级菜单导入


// 资源引入 

public class Upgrade {

    // 菜单管理处 找到对应菜单 复制菜单json
    private static String menuJson = "...";

    public void upgrade() {
        IModelBiz modelBiz = (IModelBiz) SpringUtil.getBean(IModelBiz.class);
		LambdaQueryWrapper<ModelEntity> lqw = new LambdaQueryWrapper();
		lqw.eq(ModelEntity::getModelTitle, "所属父菜单标题 如 权限管理");
		ModelEntity model = (ModelEntity)modelBiz.getOne(lqw);
		ModelEntity modelEntity = (ModelEntity) JSONUtil.toBean(menuJson, ModelEntity.class);
		ManagerEntity manager = BasicUtil.getManager();
		modelBiz.importModel(modelEntity, manager.getRoleId(), (String)null, Integer.parseInt(model.getId()));
    }
}