二次开发.docx

上传人:b****5 文档编号:6297090 上传时间:2023-01-05 格式:DOCX 页数:13 大小:20.06KB
下载 相关 举报
二次开发.docx_第1页
第1页 / 共13页
二次开发.docx_第2页
第2页 / 共13页
二次开发.docx_第3页
第3页 / 共13页
二次开发.docx_第4页
第4页 / 共13页
二次开发.docx_第5页
第5页 / 共13页
点击查看更多>>
下载资源
资源描述

二次开发.docx

《二次开发.docx》由会员分享,可在线阅读,更多相关《二次开发.docx(13页珍藏版)》请在冰豆网上搜索。

二次开发.docx

二次开发

Jspxcms无侵入式插件开发(二次开发)教程之一:

概述

Jspxcms支持无侵入式插件和二次开发,无需修改系统原有代码,即可无缝整合Entity、Service、Controller、功能菜单、权限、标签、国际化等功能。

系统中“插件--简历管理”就是以这种方式实现的,下面就以“简历管理”讲解Jspxcms插件和二次开发的方法。

本帖隐藏的内容需要回复才可以浏览

配置文件位置:

/WEB-INF/conf/plugin。

所有的配置文件都必须在这个目录,在该目录下的配置文件会自动加载。

在该目录下新建自己的文件夹,可以是任何名字,如:

abc、novel等,本例为plug。

即/WEB-INF/conf/plugin/plug

配置文件说明

application.properties:

功能菜单、权限、国际化、Entity都与这个文件相关。

context-dao.xml:

Dao的加载。

context-service.xml:

Service的加载。

controller-back.xml:

后台Controller的加载。

controller-fore.xml:

前台Controller的加载。

context-directive.xml:

标签的加载。

其他与插件开发相关的文件目录

/WEB-INF/messages/plugin/plug:

后台国际化文件位置

/WEB-INF/messages/plugin/plugfore:

前台国际化文件位置

/WEB-INF/views/plug:

后台jsp文件位置

/files/1/bluewise/plug_resume.html:

插件的前台模版

插件源代码包名:

com.jspxcms.plug

Jspxcms无侵入式插件开发(二次开发)教程之二:

菜单与权限

本帖隐藏的内容需要回复才可以浏览

菜单和权限配置文件:

/WEB-INF/conf/plugin/plug/application.properties

一级菜单配置(分号为分割符)

1.menu.650=navigation.plug;nav.do?

menuId=650;nav_plug

复制代码

650:

是后台导航一级菜单的编号,编号大小决定菜单的前后位置。

其值可以根据需要调整,如330、970,但不要与系统菜单或其他插件菜单重复。

系统菜单通常为menu.100,menu.200,menu.600等,系统菜单定义文件在/WEB-INF/conf/application.properties

navigation.plug:

菜单名称。

这里使用了国际化,也可以直接用中文,比如“我的插件”。

nav.do?

menuId=650:

菜单链接地址。

其中650需与前面的值一样。

nav_plug:

权限值。

其中plug通常与配置文件目录名称一样。

如目录为abc,则应为nav_abc。

也可不一样,但不能与其他一级菜单权限名称一样。

 

二级菜单配置(分号为分割符)

复制代码

650:

二级菜单所属的一级菜单编号。

100:

二级菜单编号。

其值的意义和一级菜单编号一样,用于确定二级菜单的前后位置。

resume.management:

二级菜单名称。

可以直接用中文,如“小说管理”。

plug/resume/list.do:

功能菜单的链接地址。

需与Controller中的地址对应,否则会找不到页面。

plug:

resume:

list:

功能菜单的权限。

需与Controller中list方法的权限对应,否则会报没有权限。

create@plug:

resume:

create:

新增按钮的权限值。

其中create是国际化,可以用直接用中文,如“新增@plug:

resume:

create”。

其中plug:

resume:

create是该按钮的权限值,需与Controller中对应的create方法权限值一致。

copy@plug:

resume:

copy:

意义和上面一样,后面的以此类推。

 

com.jspxcms代码片段

1.packagecom.jspxcms

2.@Controller

3.@RequestMapping("/plug/resume")

4.publicclassResumeController{

5.?

?

?

?

@RequiresPermissions("plug:

resume:

list")

6.?

?

?

?

@RequestMapping("list.do")

7.?

?

?

?

publicStringlist(......){

8.?

?

?

?

?

?

?

?

......

9.?

?

?

?

}

10.?

?

?

?

@RequiresPermissions("plug:

resume:

create")

11.?

?

?

?

@RequestMapping("create.do")

12.?

?

?

?

publicStringcreate(......){

13.?

?

?

?

?

?

?

?

......

14.?

?

?

?

}

15.?

?

?

?

......

16.}

Jspxcms无侵入式插件开发(二次开发)教程之三:

Entity

本帖隐藏的内容需要回复才可以浏览

实体类Entity配置文件:

/WEB-INF/conf/plugin/plug/application.properties

复制代码

plug:

通常与配置文件所在目录一样,也可不一样,但不能与其他相关配置同名。

Entity所在包名。

不使用主键自增策略,将主键放到数据库中的一个表里。

1.createtableplug_resume

2.(

3.?

?

f_resume_id?

?

?

?

?

?

intnotnull,

4.?

?

f_site_id?

?

?

?

?

?

?

?

intnotnull,

5.?

?

f_name?

?

?

?

?

?

?

?

?

?

varchar(100)notnullcomment'姓名',

6.?

?

f_post?

?

?

?

?

?

?

?

?

?

varchar(100)notnullcomment'应聘职位',

7.?

?

f_creation_date?

?

?

?

datetimenotnullcomment'投递日期',

8.?

?

f_gender?

?

?

?

?

?

?

?

char

(1)notnulldefault'M'comment'性别',

9.?

?

f_birth_date?

?

?

?

?

?

datetimecomment'出生日期',

10.?

?

f_mobile?

?

?

?

?

?

?

?

varchar(100)comment'手机',

11.?

?

f_email?

?

?

?

?

?

?

?

?

?

varchar(100)comment'邮箱',

12.?

?

f_expected_salary?

?

intcomment'期望薪水',

13.?

?

f_education_experiencelongtextcomment'教育经历',

14.?

?

f_work_experience?

?

longtextcomment'工作经历',

15.?

?

f_remark?

?

?

?

?

?

?

?

longtextcomment'备注',

16.?

?

primarykey(f_resume_id)

17.)

18.engine=innodb;

19.altertableplug_resumecomment'简历表';

20.altertableplug_resumeaddconstraintfk_plug_resume_siteforeignkey(f_site_id)

21.?

?

?

?

referencescms_site(f_site_id)ondeleterestrictonupdaterestrict;

复制代码

1.@Entity

2.@Table(name="plug_resume")

3.?

?

?

?

privateIntegerid;

4.?

?

?

?

……

5.?

?

?

?

@Id

6.?

?

?

?

@Column(name="f_resume_id",unique=true,nullable=false)

7.?

?

?

?

@TableGenerator(name="tg_plug_resume",pkColumnValue="plug_resume",table="t_id_table",pkColumnName="f_table",valueColumnName="f_id_value",initialValue=1,allocationSize=1)

8.?

?

?

?

@GeneratedValue(strategy=GenerationType.TABLE,generator="tg_plug_resume")

9.?

?

?

?

publicIntegergetId(){

10.?

?

?

?

?

?

?

?

returnthis.id;

11.?

?

?

?

}

12.?

?

?

?

publicvoidsetId(Integerid){

13.?

?

?

?

?

?

?

?

this.id=id;

14.?

?

?

?

}

15.?

?

?

?

……

16.}

复制代码

需注意以下三个值,其中plug_resume为表名:

1.name="tg_plug_resume",pkColumnValue="plug_resume"

2.generator="tg_plug_resume"

Jspxcms无侵入式插件开发(二次开发)教程之四:

Dao

本帖隐藏的内容需要回复才可以浏览

Dao配置文件:

/WEB-INF/conf/plugin/plug/context-dao.xml

1.?

?

transaction-manager-ref="transactionManager"?

2.?

?

entity-manager-factory-ref="entityManagerFactory"?

3.?

?

repository-impl-postfix="Impl">

4.

repositories>

复制代码

其中为dao接口所在包。

Dao使用了SpringDataJPA技术。

SpringDataJPA官网:

1.publicinterfaceResumeDaoextendsRepository,ResumeDaoPlus{

2.?

?

?

?

publicPagefindAll(Specificationspec,Pageablepageable);

3.?

?

?

?

publicListfindAll(Specificationspec,Limitablelimitable);

4.?

?

?

?

publicResumefindOne(Integerid);

5.?

?

?

?

publicResumesave(Resumebean);

6.?

?

?

?

publicvoiddelete(Resumebean);

7.}

复制代码

ResumeDao接口中的方法不用实现。

以下接口中的方法均可放到ResumeDao,且无需实现:

复制代码

需要实现的dao方法,放到ResumeDaoPlus接口中。

1.publicinterfaceResumeDaoPlus{

2.?

?

?

?

publicListgetList(Integer[]siteId,Limitablelimitable);

3.}

复制代码

1.publicclassResumeDaoImplimplementsResumeDaoPlus{

2.?

?

?

?

@SuppressWarnings("unchecked")

3.?

?

?

?

publicListgetList(Integer[]siteId,Limitablelimitable){

4.?

?

?

?

?

?

?

?

JpqlBuilderjpql=newJpqlBuilder();

5.?

?

?

?

?

?

?

?

jpql.append("fromResumebeanwhere1=1");

6.?

?

?

?

?

?

?

?

if(ArrayUtils.isNotEmpty(siteId)){

7.?

?

?

?

?

?

?

?

?

?

?

?

jpql.setParameter("siteId",Arrays.asList(siteId));

8.?

?

?

?

?

?

?

?

}

9.?

?

?

?

?

?

?

?

returnjpql.list(em,limitable);

10.?

?

?

?

}

11.?

?

?

?

privateEntityManagerem;

12.?

?

?

?

@PersistenceContext

13.?

?

?

?

publicvoidsetEm(EntityManagerem){

14.?

?

?

?

?

?

?

?

this.em=em;

15.?

?

?

?

}

16.}

复制代码

其中JpqlBuilder用于拼装jqpl语句、设置参数,并可处理分页问题。

Jspxcms无侵入式插件开发(二次开发)教程之五:

Service

本帖隐藏的内容需要回复才可以浏览

Service配置文件:

/WEB-INF/conf/plugin/plug/context-service.xml

1.

exclude-filtertype="annotation"?

2.

component-scan>

复制代码

其中为Service的实现类所在包。

1.@Service

2.@Transactional(readOnly=true)

3.publicclassResumeServiceImplimplementsResumeService{

4.?

?

?

?

publicPagefindAll(IntegersiteId,Mapparams,

5.?

?

?

?

?

?

?

?

?

?

?

?

Pageablepageable){

6.?

?

?

?

?

?

?

?

returndao.findAll(spec(siteId,params),pageable);

7.?

?

?

?

}

8.?

?

?

?

publicRowSidefindSide(IntegersiteId,

9.?

?

?

?

?

?

?

?

?

?

?

?

Mapparams,Resumebean,Integerposition,

10.?

?

?

?

?

?

?

?

?

?

?

?

Sortsort){

11.?

?

?

?

?

?

?

?

if(position==null){

12.?

?

?

?

?

?

?

?

?

?

?

?

returnnewRowSide();

13.?

?

?

?

?

?

?

?

}

14.?

?

?

?

?

?

?

?

Limitablelimit=RowSide.limitable(position,sort);

15.?

?

?

?

?

?

?

?

Listlist=dao.findAll(spec(siteId,params),limit);

16.?

?

?

?

?

?

?

?

returnRowSide.create(list,bean);

17.?

?

?

?

}

18.?

?

?

?

privateSpecificationspec(finalIntegersiteId,

19.?

?

?

?

?

?

?

?

?

?

?

?

Mapparams){

20.?

?

?

?

?

?

?

?

Collectionfilters=SearchFilter.parse(params).values();

21.?

?

?

?

?

?

?

?

finalSpecificationfsp=SearchFilter.spec(filters,

22.?

?

?

?

?

?

?

?

?

?

?

?

?

?

?

?

Resume.class);

23.?

?

?

?

?

?

?

?

Specificationsp=newSpecification(){

24.?

?

?

?

?

?

?

?

?

?

?

?

publicPredicatetoPredicate(Rootroot,

25.?

?

?

?

?

?

?

?

?

?

?

?

?

?

?

?

?

?

?

?

CriteriaQuery

>query,CriteriaBuildercb){

26.?

?

?

?

?

?

?

?

?

?

?

?

?

?

?

?

Predicatepred=fsp.toPredicate(root,query,cb);

27.?

?

?

?

?

?

?

?

?

?

?

?

?

?

?

?

if(siteId!

=null){

28.?

?

?

?

?

?

?

?

?

?

?

?

?

?

?

?

?

?

?

?

pred=cb.and(pred,cb.equal(root.get("site")

29.?

?

?

?

?

?

?

?

?

?

?

?

?

?

?

?

?

?

?

?

?

?

?

?

?

?

?

?

.get("id"),siteId));

30.?

?

?

?

?

?

?

?

?

?

?

?

?

?

?

?

}

31.?

?

?

?

?

?

?

?

?

?

?

?

?

?

?

?

returnpred;

32.?

?

?

?

?

?

?

?

?

?

?

?

}

33.?

?

?

?

?

?

?

?

};

34.?

?

?

?

?

?

?

?

returnsp;

35.?

?

?

?

}

36.?

?

?

?

privateResumeDaodao;

37.?

?

?

?

@Autowired

38.?

?

?

?

publicvoidsetDao(ResumeDaodao){

39.?

?

?

?

?

?

?

?

this.dao=dao;

40.?

?

?

?

}

41.?

?

?

?

......

42.}

复制代码

该类使用到JPA的Specification查询方式。

可实现后台列表点击表头,按任意列排序;列表页按任意字段查询;编辑页面上一条、下一条功能。

Jspxcms无侵入式插件开发(二次开发)教程之六:

Controller

本帖隐藏的内容需要回复才可以浏览

Controller后台配置文件:

/WEB-INF/conf/plugin/plug/controller-back.xml

1.

component-scan>

复制代码

其中为后台Controller包所在位置。

1.@Controller

2.@RequestMapping("/plug/resume")

3.publicclassResumeController{

4.?

?

?

?

@RequiresPermissions("plug:

resume:

list")

5.?

?

?

?

@RequestMapping("list.do")

6.?

?

?

?

publicStringlist(

7.?

?

?

?

?

?

?

?

?

?

?

?

@PageableDefaults(sort="id",sortDir=Direction.DESC)Pageablepageable,

8.?

?

?

?

?

?

?

?

IntegersiteId=Context.getCurrentSiteId(request);

9.?

?

?

?

?

?

?

?

Mapparams=Servlets.getParameterValuesMap(request,

10.?

?

?

?

?

?

?

?

?

?

?

?

?

?

?

?

Constants.SEARCH_PREFIX);

11.?

?

?

?

?

?

?

?

PagepagedList=service.findAll(siteId,params,pageable);

12.?

?

?

?

?

?

?

?

modelMap.addAttribute("pagedList",pagedList);

13.?

?

?

?

?

?

?

?

return"plug/resume/resume_list";

14.?

?

?

?

}

15.?

?

?

?

@RequiresPermissions("plug:

resume:

create")

16.?

?

?

?

@RequestMapping("create.do")

17.?

?

?

?

?

?

?

?

if(id!

=null){

18.?

?

?

?

?

?

?

?

?

?

?

?

Resumebean=service.get(id);

19.?

?

?

?

?

?

?

?

?

?

?

?

modelMap.addAttribute("bean",bean);

20.?

?

?

?

?

?

?

?

}

21.?

?

?

?

?

?

?

?

modelMap.addAttribute(OPRT,CREATE);

22.?

?

?

?

?

?

?

?

return"plug/resume/resume_form";

23.?

?

?

?

}

24.?

?

?

?

@Autowired

25.?

?

?

?

privateResumeServiceservice;

26.}

复制代码

其中RequestMapping为访问地址,RequiresPermissions为权限代码,需与/WEB-INF/conf/plugin/p

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > 党团工作 > 入党转正申请

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1