例一、
1.角色分类表
create tablet_role_line
(
id bigint(11) not null auto_increment comment 'id',
role_line_type integer comment '角色线条类型(1一般,2行政)',
role_line varchar(20) comment '角色线条名称',
status integer not null default 1 comment '状态(1有效,0删除)',
created_at datetime not null default CURRENT_TIMESTAMP comment '创建时间',
deleted_at datetime comment '删除时间');
2. 角色表
create tablet_role
(
idbigint(11) not null auto_increment comment 'id',
role_codevarchar(20) comment '角色编码',
role_namevarchar(200) comment '角色名称',
role_line_idbigint comment '角色线条ID',
role_line_typeinteger comment '角色线条类型(1一般,2行政)',
qualificationsvarchar(1000) comment '角色需要的资质编码(JSON数组串 )',
statusinteger not null default 1 comment '状态(1有效,0删除)',
created_atdatetime not null default CURRENT_TIMESTAMP comment '创建时间',
deleted_atdatetime comment '删除时间',
last_update_atdatetime default CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP comment '上次操作时间',
last_update_byvarchar(50) comment '操作人',
last_update_bynamevarchar(50) comment '操作人姓名');
3. MyBatis 的DAO 或Mapper文件
3.1. RoleLineDAO.xml
id, role_line_type, role_line, status, created_at, deleted_at
selectfrom t_role_line t
where t.status=1 and t.role_line_type = #{rolelinetype,jdbcType=INTEGER}
3.2.RoleDAO.xml
id, role_code, role_name, role_line_id, role_line_type, qualifications, status, created_at,
deleted_at, last_update_at, last_update_by, last_update_byname
selectfrom t_role t
where t.status=1 and t.role_line_id = #{roleLineId,jdbcType=BIGINT}
4.实体类
4.1 Role
public classRole {privateLong id;privateString roleCode;privateString roleName;privateLong roleLineId;privateInteger roleLineType;privateString qualifications;privateInteger status;privateDate createdAt;privateDate deletedAt;privateDate lastUpdateAt;privateString lastUpdateBy;privateString lastUpdateByname;publicLong getId() {returnid;
}public voidsetId(Long id) {this.id =id;
}publicString getRoleCode() {returnroleCode;
}public voidsetRoleCode(String roleCode) {this.roleCode = roleCode == null ? null: roleCode.trim();
}publicString getRoleName() {returnroleName;
}public voidsetRoleName(String roleName) {this.roleName = roleName == null ? null: roleName.trim();
}publicLong getRoleLineId() {returnroleLineId;
}public voidsetRoleLineId(Long roleLineId) {this.roleLineId =roleLineId;
}publicInteger getRoleLineType() {returnroleLineType;
}public voidsetRoleLineType(Integer roleLineType) {this.roleLineType =roleLineType;
}publicString getQualifications() {returnqualifications;
}public voidsetQualifications(String qualifications) {this.qualifications = qualifications == null ? null: qualifications.trim();
}publicInteger getStatus() {returnstatus;
}public voidsetStatus(Integer status) {this.status =status;
}publicDate getCreatedAt() {returncreatedAt;
}public voidsetCreatedAt(Date createdAt) {this.createdAt =createdAt;
}publicDate getDeletedAt() {returndeletedAt;
}public voidsetDeletedAt(Date deletedAt) {this.deletedAt =deletedAt;
}publicDate getLastUpdateAt() {returnlastUpdateAt;
}public voidsetLastUpdateAt(Date lastUpdateAt) {this.lastUpdateAt =lastUpdateAt;
}publicString getLastUpdateBy() {returnlastUpdateBy;
}public voidsetLastUpdateBy(String lastUpdateBy) {this.lastUpdateBy = lastUpdateBy == null ? null: lastUpdateBy.trim();
}publicString getLastUpdateByname() {returnlastUpdateByname;
}public voidsetLastUpdateByname(String lastUpdateByname) {this.lastUpdateByname = lastUpdateByname == null ? null: lastUpdateByname.trim();
}
}
4.2.RoleLine
public classRoleLine {privateLong id;privateInteger roleLineType;privateString roleLine;privateInteger status;privateDate createdAt;privateDate deletedAt;private Listroles;publicLong getId() {returnid;
}public voidsetId(Long id) {this.id =id;
}publicInteger getRoleLineType() {returnroleLineType;
}public voidsetRoleLineType(Integer roleLineType) {this.roleLineType = roleLineType == null ? null: roleLineType.intValue();
}publicString getRoleLine() {returnroleLine;
}public voidsetRoleLine(String roleLine) {this.roleLine = roleLine == null ? null: roleLine.trim();
}publicInteger getStatus() {returnstatus;
}public voidsetStatus(Integer status) {this.status =status;
}publicDate getCreatedAt() {returncreatedAt;
}public voidsetCreatedAt(Date createdAt) {this.createdAt =createdAt;
}publicDate getDeletedAt() {returndeletedAt;
}public voidsetDeletedAt(Date deletedAt) {this.deletedAt =deletedAt;
}public ListgetRoles() {returnroles;
}public void setRoles(Listroles) {this.roles =roles;
}
}
5.DAO类
5.1.RoleDAO 类
@Repositorypublic interfaceRoleDAO {
List selectByRoleLineId(@Param("roleLineId")Long roleLineId);
}
5.2.RoleLineDAO类
@Repositorypublic interfaceRoleLineDAO {
List selectLineAndRolesByRoleType(@Param("rolelinetype")Integer rolelinetype);
}
例二、根据多字段级联
1.建表
create tablet_network_clazz
(
idbigint(11) not null auto_increment comment 'id',
service_linebigint(11) comment '业务线',
org_type_codenational varchar(20) not null comment '组织类型编码',
org_type_namevarchar(200) comment '组织类型名称',
parent_idbigint(11) not null comment '上级数据ID(顶级ID=0)',
parent_org_type_codenational varchar(20) comment '上级组织类型编码',
parent_org_type_namevarchar(200) comment '上级组织类型名称',
ref_service_linenational bigint(11) comment '参照业务线',
follow_typeinteger not null comment '订阅状态(1 follow , 0 unfollow)',
sync_allinteger not null comment '全量同步(1是,0否)',
level_codeinteger comment '层级',
statusinteger not null default 1 comment '状态(1有效,0删除)',
created_atdatetime not null default CURRENT_TIMESTAMP comment '创建时间',
deleted_atdatetime comment '删除时间');
create tablet_service_line
(
codebigint(11) not null auto_increment comment '编码',
namenational varchar(200) not null comment '名称',
abbreviationvarchar(100) comment '简称',
describesnational varchar(200) comment '描述',
ref_typeinteger not null comment '参考类型(1 新建,2 参照已有)',
ref_service_linevarchar(20) comment '参考业务线',
follow_flaginteger comment '是否有follow(1是,0否)',
created_atdatetime not null comment '创建时间',
created_bynational varchar(20) comment '创建人',
statusinteger not null default 1 comment '状态(1有效,0删除)',
deleted_atdatetime comment '删除时间',
deleted_bynational varchar(50) comment '删除人',
last_update_atdatetime comment '上次操作时间',
last_update_byvarchar(20) comment '操作人',
last_update_bynamevarchar(200) comment '操作人姓名');
create tablet_service_line_org_type
(
idbigint(11) not null auto_increment comment 'id',
service_linebigint(11) not null comment '业务线',
org_type_codenational varchar(20) not null comment '服务类型编码',
org_type_namevarchar(200) comment '服务类型名称',
has_assetinteger not null comment '是否关联资产(1是,0否)',
asset_typesvarchar(2000) comment '关联资产类型
format:
[{
"code":"xxxx"
}]',
statusinteger not null default 1 comment '状态(1有效,0删除)',
created_atdatetime not null default CURRENT_TIMESTAMP comment '创建时间',
deleted_atdatetime comment '删除时间',
last_update_atdatetime default CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP comment '上次操作时间',
last_update_byvarchar(20) comment '操作人',
last_update_bynamevarchar(200) comment '操作人姓名');
2. MyBatis的DAO或Mapper.xml
2.1.ServiceLineOrgTypeDAO.xml
id, service_line, org_type_code, org_type_name, has_asset, asset_types,
status, created_at, deleted_at, last_update_at, last_update_by, last_update_byname
select
count(t.id) c
from t_service_line_org_type t
where 1=1 and t.status=1 0 ">and t.service_line in#{item}
0 ">and t.org_type_code in#{item}
selectfrom t_service_line_org_type t
where 1=1 and t.status=1 0 ">and t.service_line in#{item}
0 ">and t.org_type_code in#{item}
order by last_update_at desc limit #{offset},#{pagesize}
selectfrom t_service_line_org_type t
where t.status=1 and t.id = #{id,jdbcType=BIGINT}
2.2.ServiceLineDAO.xml
code, name, abbreviation, describes, ref_type, ref_service_line, follow_flag, created_at, created_by,
status, deleted_at, deleted_by, last_update_at, last_update_by, last_update_byname
selectfrom t_service_line
where code = #{code,jdbcType=BIGINT}
2.3.NetworkClazzDAO.xml
id, service_line, org_type_code, org_type_name, parent_id, parent_org_type_code,
parent_org_type_name, level_code, ref_service_line, follow_type, sync_all, status, created_at, deleted_at
selectfrom t_network_clazz t
where t.status=1 and t.service_line=#{serviceLine}
and t.org_type_code=#{orgTypeCode}
3.实体类
3.1.ServiceLineOrgType
1 packagecom.xxx.xxx.entity;2
3 importjava.io.Serializable;4 importjava.util.Date;5 importjava.util.List;6
7 public class ServiceLineOrgType implementsSerializable{8 /**
9 *10 */
11 private static final long serialVersionUID = 1L;12
13 privateLong id;14
15 privateLong serviceLine;16
17 privateString orgType;18
19 privateString orgTypeCode;20
21 privateString orgTypeName;22
23 privateInteger hasAsset;24
25 privateString assetTypes;26
27 privateInteger status;28
29 privateDate createdAt;30
31 privateDate deletedAt;32
33 privateDate lastUpdateAt;34
35 privateString lastUpdateBy;36
37 privateString lastUpdateByname;38
39 privateServiceLine serviceLineObj;40
41 private ListnetworkClazzs;42
43 publicLong getId() {44 returnid;45 }46
47 public voidsetId(Long id) {48 this.id =id;49 }50
51 publicLong getServiceLine() {52 returnserviceLine;53 }54
55 public voidsetServiceLine(Long serviceLine) {56 this.serviceLine =serviceLine;57 }58
59 publicString getOrgType() {60 returnorgType;61 }62
63 public voidsetOrgType(String orgType) {64 this.orgType = orgType == null ? null: orgType.trim();65 }66
67 publicString getOrgTypeCode() {68 returnorgTypeCode;69 }70
71 public voidsetOrgTypeCode(String orgTypeCode) {72 this.orgTypeCode = orgTypeCode == null ? null: orgTypeCode.trim();73 }74
75 publicString getOrgTypeName() {76 returnorgTypeName;77 }78
79 public voidsetOrgTypeName(String orgTypeName) {80 this.orgTypeName = orgTypeName == null ? null: orgTypeName.trim();81 }82
83 publicInteger getHasAsset() {84 returnhasAsset;85 }86
87 public voidsetHasAsset(Integer hasAsset) {88 this.hasAsset =hasAsset;89 }90
91 publicString getAssetTypes() {92 returnassetTypes;93 }94
95 public voidsetAssetTypes(String assetTypes) {96 this.assetTypes = assetTypes == null ? null: assetTypes.trim();97 }98
99 publicInteger getStatus() {100 returnstatus;101 }102
103 public voidsetStatus(Integer status) {104 this.status =status;105 }106
107 publicDate getCreatedAt() {108 returncreatedAt;109 }110
111 public voidsetCreatedAt(Date createdAt) {112 this.createdAt =createdAt;113 }114
115 publicDate getDeletedAt() {116 returndeletedAt;117 }118
119 public voidsetDeletedAt(Date deletedAt) {120 this.deletedAt =deletedAt;121 }122
123 publicDate getLastUpdateAt() {124 returnlastUpdateAt;125 }126
127 public voidsetLastUpdateAt(Date lastUpdateAt) {128 this.lastUpdateAt =lastUpdateAt;129 }130
131 publicString getLastUpdateBy() {132 returnlastUpdateBy;133 }134
135 public voidsetLastUpdateBy(String lastUpdateBy) {136 this.lastUpdateBy = lastUpdateBy == null ? null: lastUpdateBy.trim();137 }138
139 publicString getLastUpdateByname() {140 returnlastUpdateByname;141 }142
143 public voidsetLastUpdateByname(String lastUpdateByname) {144 this.lastUpdateByname = lastUpdateByname == null ? null: lastUpdateByname.trim();145 }146
147 publicServiceLine getServiceLineObj() {148 returnserviceLineObj;149 }150
151 public voidsetServiceLineObj(ServiceLine serviceLineObj) {152 this.serviceLineObj =serviceLineObj;153 }154
155 public ListgetNetworkClazzs() {156 returnnetworkClazzs;157 }158
159 public void setNetworkClazzs(ListnetworkClazzs) {160 this.networkClazzs =networkClazzs;161 }162 }
View Code
3.2.ServiceLine
packagecom.xxx.xxx.entity;importjava.util.Date;public classServiceLine {privateLong code;privateString name;privateString abbreviation;privateString describes;privateInteger refType;privateString refServiceLine;privateInteger followFlag;privateDate createdAt;privateString createdBy;privateInteger status;privateDate deletedAt;privateString deletedBy;privateDate lastUpdateAt;privateString lastUpdateBy;privateString lastUpdateByname;privateString orgTypeCodes;privateString orgTypeNames;publicLong getCode() {returncode;
}public voidsetCode(Long code) {this.code =code;
}publicString getName() {returnname;
}public voidsetName(String name) {this.name = name == null ? null: name.trim();
}publicString getAbbreviation() {returnabbreviation;
}public voidsetAbbreviation(String abbreviation) {this.abbreviation = abbreviation == null ? null: abbreviation.trim();
}publicString getDescribes() {returndescribes;
}public voidsetDescribes(String describes) {this.describes = describes == null ? null: describes.trim();
}publicInteger getRefType() {returnrefType;
}public voidsetRefType(Integer refType) {this.refType =refType;
}publicString getRefServiceLine() {returnrefServiceLine;
}public voidsetRefServiceLine(String refServiceLine) {this.refServiceLine = refServiceLine == null ? null: refServiceLine.trim();
}publicInteger getFollowFlag() {returnfollowFlag;
}public voidsetFollowFlag(Integer followFlag) {this.followFlag =followFlag;
}publicDate getCreatedAt() {returncreatedAt;
}public voidsetCreatedAt(Date createdAt) {this.createdAt =createdAt;
}publicString getCreatedBy() {returncreatedBy;
}public voidsetCreatedBy(String createdBy) {this.createdBy = createdBy == null ? null: createdBy.trim();
}publicInteger getStatus() {returnstatus;
}public voidsetStatus(Integer status) {this.status =status;
}publicDate getDeletedAt() {returndeletedAt;
}public voidsetDeletedAt(Date deletedAt) {this.deletedAt =deletedAt;
}publicString getDeletedBy() {returndeletedBy;
}public voidsetDeletedBy(String deletedBy) {this.deletedBy = deletedBy == null ? null: deletedBy.trim();
}publicDate getLastUpdateAt() {returnlastUpdateAt;
}public voidsetLastUpdateAt(Date lastUpdateAt) {this.lastUpdateAt =lastUpdateAt;
}publicString getLastUpdateBy() {returnlastUpdateBy;
}public voidsetLastUpdateBy(String lastUpdateBy) {this.lastUpdateBy = lastUpdateBy == null ? null: lastUpdateBy.trim();
}publicString getLastUpdateByname() {returnlastUpdateByname;
}public voidsetLastUpdateByname(String lastUpdateByname) {this.lastUpdateByname = lastUpdateByname == null ? null: lastUpdateByname.trim();
}publicString getOrgTypeCodes() {returnorgTypeCodes;
}public voidsetOrgTypeCodes(String orgTypeCodes) {this.orgTypeCodes = orgTypeCodes == null ? null: orgTypeCodes.trim();
}publicString getOrgTypeNames() {returnorgTypeNames;
}public voidsetOrgTypeNames(String orgTypeNames) {this.orgTypeNames = orgTypeNames == null ? null: orgTypeNames.trim();
}
}
View Code
3.3.NetworkClazz
packagecom.xxx.xxx.entity;importjava.util.Date;public classNetworkClazz {privateLong id;privateLong serviceLine;privateString orgTypeCode;privateString orgTypeName;privateLong parentId;privateString parentOrgTypeCode;privateString parentOrgTypeName;privateInteger levelCode;privateString refServiceLine;privateInteger followType;privateInteger syncAll;privateInteger status;privateDate createdAt;privateDate deletedAt;publicLong getId() {returnid;
}public voidsetId(Long id) {this.id =id;
}publicLong getServiceLine() {returnserviceLine;
}public voidsetServiceLine(Long serviceLine) {this.serviceLine =serviceLine;
}publicString getOrgTypeCode() {returnorgTypeCode;
}public voidsetOrgTypeCode(String orgTypeCode) {this.orgTypeCode = orgTypeCode == null ? null: orgTypeCode.trim();
}publicString getOrgTypeName() {returnorgTypeName;
}public voidsetOrgTypeName(String orgTypeName) {this.orgTypeName = orgTypeName == null ? null: orgTypeName.trim();
}publicLong getParentId() {returnparentId;
}public voidsetParentId(Long parentId) {this.parentId =parentId;
}publicString getParentOrgTypeCode() {returnparentOrgTypeCode;
}public voidsetParentOrgTypeCode(String parentOrgTypeCode) {this.parentOrgTypeCode = parentOrgTypeCode == null ? null: parentOrgTypeCode.trim();
}publicString getParentOrgTypeName() {returnparentOrgTypeName;
}public voidsetParentOrgTypeName(String parentOrgTypeName) {this.parentOrgTypeName = parentOrgTypeName == null ? null: parentOrgTypeName.trim();
}publicInteger getLevelCode() {returnlevelCode;
}public voidsetLevelCode(Integer levelCode) {this.levelCode =levelCode;
}publicString getRefServiceLine() {returnrefServiceLine;
}public voidsetRefServiceLine(String refServiceLine) {this.refServiceLine = refServiceLine == null ? null: refServiceLine.trim();
}publicInteger getFollowType() {returnfollowType;
}public voidsetFollowType(Integer followType) {this.followType =followType;
}publicInteger getSyncAll() {returnsyncAll;
}public voidsetSyncAll(Integer syncAll) {this.syncAll =syncAll;
}publicInteger getStatus() {returnstatus;
}public voidsetStatus(Integer status) {this.status =status;
}publicDate getCreatedAt() {returncreatedAt;
}public voidsetCreatedAt(Date createdAt) {this.createdAt =createdAt;
}publicDate getDeletedAt() {returndeletedAt;
}public voidsetDeletedAt(Date deletedAt) {this.deletedAt =deletedAt;
}
}
View Code
4.DAO类
4.1.ServiceLineOrgTypeDAO
1 packagecom.xxx.xxx.dao;2
3 importjava.util.List;4
5 importorg.apache.ibatis.annotations.Param;6 importorg.springframework.stereotype.Repository;7
8 importcom.xxx.xxx.entity.ServiceLineOrgType;9
10 @Repository11 public interfaceServiceLineOrgTypeDAO {12 /*List selectListByPage(@Param("orgTypeCodes") String orgTypeCode,@Param("serviceLineCodes")String serviceLineCodes, RowBounds rowBounds);*/
13 Long findListByPageCount(@Param("orgTypeCodes") List orgTypeCode,@Param("serviceLineCodes")ListserviceLineCodes);14 List findListByPage(@Param("orgTypeCodes") List orgTypeCode,@Param("serviceLineCodes")List serviceLineCodes,@Param("offset")Long offset,@Param("pagesize")Integer pagesize);15 ServiceLineOrgType selectById(Long id);16
17 }
View Code
4.2.ServiceLineDAO
1 packagecom.xxx.xxx.dao;2
3 importcom.xxx.xxx.entity.ServiceLine;4
5 importorg.springframework.stereotype.Repository;6
7 @Repository8 public interfaceServiceLineDAO {9
10 ServiceLine selectByPrimaryKey(Long code);11 }
View Code
4.3.NetworkClazzDAO
1 packagecom.xxx.xxx.dao;2
3 importcom.xxx.xxx.entity.NetworkClazz;4
5 importjava.util.List;6
7 importorg.apache.ibatis.annotations.Param;8 importorg.springframework.stereotype.Repository;9
10 @Repository11 public interfaceNetworkClazzDAO {12 List selectByServiceLineAndOrgTypeCode(@Param("serviceLine")Long serviceLine,@Param("orgTypeCode")String orgTypeCode);13
14 }
View Code
5.BIZ层或Service层代码样例
5.1.ServiceLineOrgtypeBiz
1 packagecom.xxx.xxx.biz;2
3 importjava.util.ArrayList;4 importjava.util.Arrays;5 importjava.util.HashMap;6 importjava.util.HashSet;7 importjava.util.List;8 importjava.util.Map;9 importjava.util.Set;10
11 importorg.apache.commons.lang3.StringUtils;12 importorg.slf4j.Logger;13 importorg.slf4j.LoggerFactory;14 importorg.springframework.beans.factory.annotation.Autowired;15 importorg.springframework.stereotype.Service;16
17 importcom.xxx.xxx.dao.NetworkClazzDAO;18 importcom.xxx.xxx.dao.ServiceLineOrgTypeDAO;19 importcom.xxx.xxx.dao.UsergroupUserDAO;20 importcom.xxx.xxx.dto.PaginationDTO;21 importcom.xxx.xxx.dto.ServiceLineOrgTypeDTO;22 importcom.xxx.xxx.dto.UserDTO;23 importcom.xxx.xxx.entity.NetworkClazz;24 importcom.xxx.xxx.entity.ServiceLineOrgType;25 importcom.xxx.xxx.entity.Usergroup;26 importcom.xxx.xxx.entity.UsergroupAuthority;27 importcom.xxx.xxx.entity.UsergroupUser;28 importcom.xxx.xxx.transfer.ServiceLineOrgTypeTransfer;29 importcom.xxx.xxx.vo.OrgTypeVO;30
31 /**
32 * 服务类型管理service业务逻辑处理层33 *@authorv-mengjf34 *@since2019-05-1635 *@version1.036 */
37 @Service38 public classServiceLineOrgtypeBiz {39 private static Logger logger = LoggerFactory.getLogger(ServiceLineOrgtypeBiz.class);40 @Autowired41 privateNetworkClazzDAO networkClazzDAO;42 @Autowired43 privateServiceLineOrgTypeDAO serviceLineOrgTypeDAO;44 @Autowired45 privateUsergroupUserDAO usergroupUserDAO;46
47
48 public MaplistByPage(Integer pageno,Integer pagesize,String orgTypeCode,String serviceLine) {49 /*logger.debug("invoke method listByPage(),orgTypeCode="+orgTypeCode+",serviceLine="+serviceLine);*/
50 if (pageno <= 0) {51 pageno = 1;52 }53 if (pagesize <= 0) {54 pagesize = 50;55 }56
57 String[] orgTypeCodeArr = StringUtils.isNotBlank(orgTypeCode)?(StringUtils.contains(orgTypeCode, ",")?StringUtils.split(orgTypeCode, ","):new String[] {orgTypeCode}):null;58 String[] serviceLineArr = StringUtils.isNotBlank(serviceLine)?(StringUtils.contains(serviceLine, ",")?StringUtils.split(serviceLine, ","):new String[] {serviceLine}):null;59 List orgTypeCodes = null;60 List serviceLines = null;61
62 if(orgTypeCodeArr!=null) {63 orgTypeCodes =Arrays.asList(orgTypeCodeArr);64 }65 if(serviceLineArr!=null) {66 serviceLines =Arrays.asList(serviceLineArr);67 }68 Long offset = (long) ((pageno-1)*pagesize);69 /*RowBounds rowBounds = new RowBounds((pageno-1)*pagesize, pagesize);*/
70
71 List serviceLineOrgTypeList = null;72 Long totalRow = 0L;73 try{74 /*serviceLineOrgTypeList = serviceLineOrgTypeDAO.selectListByPage(orgTypeCode, serviceLine, rowBounds);*/
75 totalRow =serviceLineOrgTypeDAO.findListByPageCount(orgTypeCodes, serviceLines);76 serviceLineOrgTypeList =serviceLineOrgTypeDAO.findListByPage(orgTypeCodes, serviceLines, offset,pagesize);77 } catch(Exception e) {78 logger.error("分页查询服务范围类型出现异常", e);79 e.printStackTrace();80 throwe;81 }82 /*Integer totalRow = CountHelper.getTotalRow();*/
83 Integer pages = totalRow.intValue()/pagesize;84 if(pages*pagesize
88 List dataList = new ArrayList();89 if(serviceLineOrgTypeList!=null && serviceLineOrgTypeList.size()>0) {90 for(ServiceLineOrgType orgType : serviceLineOrgTypeList) {91 List ofNetworkClazzs =orgType.getNetworkClazzs();92 List ofParentNetworkClazzs = null;93 if(ofNetworkClazzs!=null && ofNetworkClazzs.size()>0) {94 ofParentNetworkClazzs =networkClazzDAO.selectByServiceLineAndNetworkClazzs(orgType.getServiceLine(), ofNetworkClazzs);95 }96 List ofChildrenNetworkClazzs =networkClazzDAO.selectByServiceLineAndParentOrgTypeCode(orgType.getServiceLine(), orgType.getOrgTypeCode());97
98 dataList.add(ServiceLineOrgTypeTransfer.transfer(orgType, ofParentNetworkClazzs, ofChildrenNetworkClazzs));99 }100 }101 PaginationDTO paginationDTO = newPaginationDTO();102 paginationDTO.setPage(pageno);103 paginationDTO.setLimit(pagesize);104 paginationDTO.setTotalPages(pages);105 paginationDTO.setTotalRecords(totalRow.intValue());106 Map result = new HashMap();107 result.put("pagination", paginationDTO);108 result.put("orgTypes", dataList);109
110 returnresult;111 }112
113 }
View Code
6.Junit Test
6.1.ServiceLineOrgtypeBIZTest
1 packagecom.xxx.xxx.biz;2
3 importjava.util.ArrayList;4 importjava.util.List;5 importjava.util.Map;6
7 importorg.junit.Test;8 importorg.springframework.beans.factory.annotation.Autowired;9
10
11 importorg.slf4j.Logger;12 importorg.slf4j.LoggerFactory;13 importorg.springframework.test.context.ContextConfiguration;14 importorg.springframework.test.context.junit4.AbstractJUnit4SpringContextTests;15
16 @ContextConfiguration(locations = { "classpath:test_config.xml", "classpath:test_cache.xml"})17 public class ServiceLineOrgtypeBIZTest extendsAbstractJUnit4SpringContextTests {18 protected final Logger logger =LoggerFactory.getLogger(getClass());19
20 @Autowired21 privateServiceLineOrgtypeBiz serviceLineOrgtypeBiz;22 @Test23 public voidtestListByPage() {24 Map result = serviceLineOrgtypeBiz.listByPage(1, 50, null, "200,300");25 logger.info(result.toString());26 }27
28 }
View Code