文章目录
平台基类
Controller
ExtensionBaseController
- com.fsl.lcp.common.controllers.ExtensionBaseController,PC端访问控制器基类
属性
属性值 | 描述 |
---|---|
DEFAULT_PAGE | 分页查询时默认的页数;默认值为1 |
DEFAULT_PAGE_SIZE | 分页查询时默认每页显示的数量;默认值为10 |
validator | 通用校验器,SpringMVC使用JSR-303(javaEE6规范的一部分)校验规范,可以校验的范围有单个对象、List、对象中包含的 Children 元素 |
方法
返回值 | 方法 | 摘要 |
---|---|---|
void | initBinder(WebDataBinderdataBinder,HttpServletRequestrequest) | 数据绑定,在实际操作中经常会碰到表单中的日期字符串和Javabean中的日期类型的属性自动转换而springMVC默认不支持这个格式的转换,所以必须要手动配置,自定义数据类型的绑定才能实现这个功能 |
IExtensionRequest | createRequestContext(HttpServletRequestrequest) | 返回IExtensionRequest接口对象,包含session相关的数据,登录用户的相关数据 |
Object | exceptionHandler(Exceptionexception,HttpServletRequestrequest) | 处理控制层所有异常并返回异常信息 |
void | checkToken(HttpServletRequestrequest,Collection<?extendsBaseDTO>dtos)\ checkToken(HttpSessionsession,Collection<?extendsBaseDTO>dtos)\ checkToken(HttpServletRequestrequest,BaseDTObaseDTO)\ checkToken(HttpSessionsession,BaseDTObaseDTO) | 用于校验(BaseDTO的防篡改属性)的方法,用于发布webservice时做token校验校验不通过会抛出TokenException异常。工具类TokenUtils提供用于生成和校验_token方法,请参考工具类的使用 |
Long | getUserId(HttpServletRequestrequest) | 返回当前用户ID |
Long | getRoleId(HttpServletRequestrequest) | 返回当前用户角色ID |
String | getLanguage(HttpServletRequestrequest) | 返回当前语言编码 |
String | getErrorMessage(Errorserrors,HttpServletRequestrequest) | 用于获取异常消息。返回的是根据当前语言环境翻译后的错误消息,errors是包含错误的对象 |
String | nls(HttpServletRequestrequest,Stringcode,Object[]args)\ nls(HttpServletRequestrequest,Stringcode) | 用于获取描述维护中当前语言环境下的消息。通常用于自定义的是错误消息。code是描述维护中消息的代码 |
String | getStandardFieldErrorMessage(FieldErrorWithBeanfieldError,Localelocale) | 该方法用于获取DTO字段校验的标准错误消息,如非空验证等。FieldErrorWithBean可直接附加field所属的bean,fieldError可直接获取目标bean。local为当前语言环境 |
DingDingBaseController
- com.fsl.lcp.common.controllers.DingDingBaseController,DD端访问控制器基类
对比PC端基类,多了如下方法
方法
返回值 | 方法 | 摘要 |
---|---|---|
IExtensionRequest | createRequestContext(empCode) | 通过员工编码返回IExtensionRequest接口对象,包含session相关的数据,登录用户的相关数据 |
Service
- com.fsl.lcp.common.service.IExtensionBaseService
- com.fsl.lcp.common.service.impl.ExtensionBaseServiceImpl
返回值 | 方法 | 摘要 |
---|---|---|
List | select(IRequestrequest,Tcondition,intpageNum,intpageSize) | 查询分页列表信息T为查询的条件实体根据实体中的属性值进行查询,查询条件使用等号 |
T | insert(IRequestrequest,@StdWhoTrecord) | T为保存的实体保存一个实体,null的属性也会保存,不会使用数据库默认值,不会插入系统字段默认值。可通过实现IServiceListener接口或者ServiceListenerAdaptor类,并通过添加注解@ServiceListener实现beforeInsert、afterInsert方法(insert接口的AOP) |
T | insertSelective(IRequestrequest,@StdWhoTrecord) | T为保存的实体保存一个实体,null的属性不会保存,会使用数据库默认值,会插入系统字段默认值。可通过实现IServiceListener接口或者ServiceListenerAdaptor类,并通过添加注解@ServiceListener实现beforeInsert、afterInsert方法(insert接口的AOP) |
T | updateByPrimaryKey(IRequestrequest,@StdWhoTrecord) | 根据主键更新实体全部字段,null值会被更新,失败抛出UpdateFailedException异常可通过注册IServiceListener接口实现beforeUpdate、afterUpdate |
T | updateByPrimaryKeySelective(IRequestrequest,@StdWhoTrecord) | 根据主键更新属性不为null的值。失败抛出UpdateFailedException异常可通过注册IServiceListener接口实现beforeUpdate、afterUpdate |
T | updateByPrimaryKeyOptions(IRequestrequest,@StdWhoTrecord,Criteriacriteria) | 根据主键更新选定字段的值。失败抛出UpdateFailedException异常可通过注册IServiceListener接口实现beforeUpdate、afterUpdate |
T | selectByPrimaryKey(IRequestrequest,Trecord) | 根据主键字段进行查询,方法参数必须包含完整的主键属性,查询条件使用等号 |
int | deleteByPrimaryKey(Trecord) | 根据主键字段进行删除,方法参数必须包含完整的主键属性。失败抛出UpdateFailedException异常可通过注册IServiceListener接口实现beforeDelete、afterDelete |
List | selectAll() | 查询全部结果 |
List | selectAll(IRequestiRequest) | 查询全部结果 |
List | batchUpdate(IRequestrequest,@StdWhoListlist) | 可以实现批量新增、修改、删除。list参数T要求为BaseDTO或者其子类。根据T对象的__status属性值判定操作;__status值可以为DTOStatus.ADD、DTOStatus.UPDATE、DTOStatus.DELETE。新增将调用insertSelective方法,修改将调用updateByPrimaryKeySelective方法,删除将调用deleteByPrimaryKey方法 |
int | batchDelete(Listlist) | 批量删除功能。调用deleteByPrimaryKey方法 |
List | selectOptions(IRequestrequest,Trecord,Criteriacriteria) | 按条件查询,返回所有获得的数据 |
List | selectOptions(IRequestrequest,Trecord,Criteriacriteria,IntegerpageNum,IntegerpageSize) | 按条件查询,并分页 |
Mapper
- com.fsl.lcp.mybatis.common.ExtensionMapper
BaseMapper接口
返回值 | 方法 | 摘要 |
---|---|---|
T | selectOne(Trecord); | 根据实体中的属性进行查询,只能有一个返回值,有多个结果是抛出异常,查询条件使用等号 |
List | select(Trecord) | 根据实体中的属性值进行查询,查询条件使用等号 |
List | selectAll() | 查询全部结果 |
int | selectCount(Trecord) | 根据实体中的属性查询总数,查询条件使用等号 |
T | selectByPrimaryKey(Objectkey) | 根据主键字段进行查询,方法参数必须包含完整的主键属性,查询条件使用等号 |
T | selectOptionsByPrimaryKey(Trecord) | 按照主键有条件查询. |
List | selectOptions(@Param(BaseConstants.OPTIONS_DTO) Trecord, @Param(BaseConstants.OPTIONS_CRITERIA) Criteriacriteria) | 有条件查询 |
int | insert(Trecord) | 保存一个实体,null的属性也会保存,不会使用数据库默认值 |
int | insertSelective(Trecord) | 保存一个实体,null的属性不会保存,会使用数据库默认值 |
int | updateByPrimaryKey(Trecord) | 根据主键更新实体全部字段,null值会被更新 |
int | updateByPrimaryKeySelective(Trecord) | 根据主键更新属性不为null的值 |
int | updateByPrimaryKeyOptions(@Param(BaseConstants.OPTIONS_DTO) Trecord, @Param(BaseConstants.OPTIONS_CRITERIA) Criteriacriteria) | 根据主键更新选定字段的值 |
int | delete(Trecord) | 根据实体属性作为条件进行删除,查询条件使用等号 |
int | deleteByPrimaryKey(Objectkey) | 根据主键字段进行删除,方法参数必须包含完整的主键属性 |
ExampleMapper接口
返回值 | 方法 | 摘要 |
---|---|---|
List | selectByExample(Objectexample) | 根据Example条件进行查询 |
int | selectCountByExample(Objectexample) | 根据Example条件进行查询 |
int | deleteByExample(Objectexample) | 根据Example条件删除数据 |
int | updateByExample(@Param(“record”)Trecord,@Param(“example”)Objectexample) | 根据Example条件更新实体record 包含的全部属性,null值会被更新 |
int | updateByExampleSelective(@Param(“record”)Trecord,@Param(“example”)Objectexample) | 根据Example条件更新实体record 包含的不是null的属性值 |
RowBoundsMapper接口
返回值 | 方法 | 摘要 |
---|---|---|
List | selectByExampleAndRowBounds(Objectexample,RowBoundsrowBounds) | 根据example条件和RowBounds进行分页查询 |
List | selectByRowBounds(Trecord,RowBoundsrowBounds) | 根据实体属性和RowBounds进行分页查询 |
Example
- com.hand.hap.mybatis.entity.Example
mybatis的逆向工程中会生成实例及实例对应的Example子类,使用Java编程的方式为SQL查询提供where子句。
方法 | 说明 |
---|---|
example.setOrderByClause(“字段名ASC”); | 添加升序排列条件,DESC为降序 |
example.setDistinct(false) | 去除重复,boolean型,true为选择不重复的记录。 |
criteria.andXxxIsNull | 添加字段xxx为null的条件 |
criteria.andXxxIsNotNull | 添加字段xxx不为null的条件 |
criteria.andXxxEqualTo(value) | 添加xxx字段等于value条件 |
criteria.andXxxNotEqualTo(value) | 添加xxx字段不等于value条件 |
criteria.andXxxGreaterThan(value) | 添加xxx字段大于value条件 |
criteria.andXxxGreaterThanOrEqualTo(value) | 添加xxx字段大于等于value条件 |
criteria.andXxxLessThan(value) | 添加xxx字段小于value条件 |
criteria.andXxxLessThanOrEqualTo(value) | 添加xxx字段小于等于value条件 |
criteria.andXxxIn(List<?>) | 添加xxx字段值在List<?>条件 |
criteria.andXxxNotIn(List<?>) | 添加xxx字段值不在List<?>条件 |
criteria.andXxxLike("%"+value+"%") | 添加xxx字段值为value的模糊查询条件 |
criteria.andXxxNotLike("%"+value+"%") | 添加xxx字段值不为value的模糊查询条件 |
criteria.andXxxBetween(value1,value2) | 添加xxx字段值在value1和value2之间条件 |
criteria.andXxxNotBetween(value1,value2) | 添加xxx字段值不在value1和value2之间条件 |
DTO
- com.fsl.lcp.common.dto.ExtensionBaseDto
属性
类型 | 属性值 | 描述 | |
---|---|---|---|
标准字段 | |||
String | createdByUser | 创建人账户名 | |
String | createdUnitCode | 创建人员工所属组织编码 | |
String | createdDeptCode | 创建人员工所属部门编码 | |
String | createdOrg | 创建人员工主岗部门编码 | |
Date | creationDate | 创建时间 | 本字段被设置@JsonIgnore。前端使用_creationDate字段获取 |
String | lastUpdatedByUser | 修改人账户名 | |
Date | lastUpdateDate | 最后修改时间 | 本字段被设置@JsonIgnore。前端使用_lastUpdateDate字段获取 |
String | isDelete | 逻辑删除字段 | |
Long | objectVersionNumber | Record的版本号,每发生update则自增。用于实现乐观锁,无法替代数据库锁 | |
审计字段 | |||
Boolean | isAudit | 审计控制字段 | 非数据库字段 |
Long | relationId | 多表审计批次号字段 | 非数据库字段 |
String | manualExplain | 多表审计操作说明 | 非数据库字段 |
Boolean | openAuditNull | 多表审计修改操作对null字段得控制 | 非数据库字段 |
内部使用 | |||
String | __id | 数据标识字段 | |
String | __status | 数据状态字段.add,update,delete | |
Map<String,Map<String,String>> | __tls | 存放所有多语言字段的描述信息 | |
String | _token | 防篡改校验字段(非数据库字段) | |
String | sortname | 排序字段 | |
String | sortorder | 排序方式 | |
String | attributeCategory | 扩展属性分类 | |
String | attribute1-attribute15 | 扩展备用字段 | |
以下不建议在程序中使用 | |||
Long | createdBy | 创建人账户Id | |
Long | lastUpdatedBy | 修改人账户Id | |
Long | lastUpdateLogin | 最后登陆人账户Id,暂未使用 | |
Long | requestId | 对Record最后一次操作的系统内部请求Id,暂未使用 | |
Long | programId | 对Record最后一次操作的系统内部程序Id,暂未使用 |
一般注解
注解 | 描述 |
---|---|
@Id | 主键Id |
@Column | 数据库表字段 |
@Transient | 暂存字段(在数据当前dto对应的库表中不存在的字段) |
@JsonSerialize(using=ToStringSerializer.class) | 转换为字符串。 |
@AuditLcpEnabled | 审计功能开关。 |
@AuditLcpExplain | 审计字段描述。 |
@MultiLanguageField | 多语言字段 |
@DateTimeFormat(pattern = “yyyy-MM-dd HH:mm:ss”) | 日期格式化转换。是Spring框架自带的,用于格式化转换前台传来的日期。绿色部分位具体的日期格式,可根据需要填写 |
@JsonFormat(pattern=“yyyy-MM-dd HH:mm:ss”) | json日期格式转换 |
@NumberFormat(pattern="##,###.## ") | 数字格式化转换,绿色部分位具体的日期格式,可根据需要填写 |
@JsonIgnore | 标注序列化时需要忽略的属性。如serialVersionUID等。 |
@Table(name=“hss_task_orders_b”) | 标注当前dto对应的数据库表hss_task_orders_b为数据库表名称。 |
@JsonInclude(Include.NON_NULL) | 标注返回的json字符串中是否显示该字段,此处为not_null,需要显示;若是null则不需要显示。 |
@Children | 用于投行结构中在头dto中定义对应的行。方便操作头的时候同时操作对应的行。 |
二次扩展 | |
@ExtensionBaseEnabled | 是否启用扩展字段。默认启用。审计功能默认只对逻 |