Open songhuiqing88 opened 7 years ago
在用户主表中增加要扩展的字段,例如:增加活动类型、是否记录学时,SQL如下。 ALTER TABLE `gt_class_basic` ADD COLUMN `ACTIVITY_STATE` tinyint(4) NULL, ADD COLUMN `IS_RECORD_SCORE` tinyint(4) NULL; 代码扩展 dao扩展 覆盖org.gtiles.components.gtclasses.classbasic.extension.dao.IClassBasicInfoExtensionDao.xml。 调整xml内容,增加扩展字段,代码如下。 <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <mapper namespace="org.gtiles.components.gtclasses.classbasic.extension.dao.IClassBasicInfoExtensionDao"> <!-- 班级查询结果 班级字段 --> <resultMap type="org.gtiles.components.gtclasses.classbasic.bean.ClassBasicInfoBean" id="classBasicInfo"> <!-- ...产品内容 --> <result column="ACTIVITY_STATE" jdbcType="INTEGER" property="activityState"/> <result column="IS_RECORD_SCORE" jdbcType="INTEGER" property="isRecordScore"/> </resultMap> <!-- 班级表字段 --> <sql id="queryFields"> <!-- ...产品内容 --> ACTIVITY_STATE,IS_RECORD_SCORE </sql> <!-- 字段值 --> <sql id="fieldValue"> <!-- ...产品内容 --> #{activityState},#{isRecordScore} </sql> <!-- 更新条件 --> <sql id="upateCommond"> <!-- ...产品内容 --> <if test="activityState != null">ACTIVITY_STATE = #{activityState},</if> <if test="isRecordScore != null">IS_RECORD_SCORE = #{isRecordScore},</if> </sql> <!-- 查询条件 --> <sql id="queryCommond"> <!-- ...产品内容 --> <if test="query.queryActivityState != null"> and ACTIVITY_STATE = #{query.queryActivityState}</if> <if test="query.queryIsRecordScore != null"> IS_RECORD_SCORE = #{query.queryIsRecordScore}</if> </sql> </mapper> 结果对象扩展 覆盖 org.gtiles.components.gtclasses.classbasic.bean.ClassBasicInfoBean public class ClassBasicInfoBean extends ClassBasicInfo { private Integer activityState; private Integer isRecordScore; public Integer getActivityState() { return activityState; } public void setActivityState(Integer activityState) { this.activityState = activityState; } public Integer getIsRecordScore() { return isRecordScore; } public void setIsRecordScore(Integer isRecordScore) { this.isRecordScore = isRecordScore; } public ClassBasicInfoBean() { super(); } public ClassBasicInfoBean(ClassBasicInfoEntity classBasicInfoEntity) { super(classBasicInfoEntity); } } 查询对象扩展 覆盖 org.gtiles.components.gtclasses.classbasic.bean.ClassBasicInfoQuery public class ClassBasicInfoQuery extends ClassBasicInfoAbstractQuery<ClassBasicInfoBean> { private Integer queryActivityState; private Integer queryIsRecordScore; public Integer getQueryActivityState() { return queryActivityState; } public void setQueryActivityState(Integer queryActivityState) { this.queryActivityState = queryActivityState; } public Integer getQueryIsRecordScore() { return queryIsRecordScore; } public void setQueryIsRecordScore(Integer queryIsRecordScore) { this.queryIsRecordScore = queryIsRecordScore; } } 界面扩展 覆盖html,在html中增加期望新增的字段、列表字段、查询条件。 班级列表所在包 org.gtiles.components.gtclasses.workbench.classinfo 班级详情所在包 org.gtiles.components.gtclasses.workbench.classinfodetail
在用户主表中增加要扩展的字段,例如:增加活动类型、是否记录学时,SQL如下。
ALTER TABLE `gt_class_basic` ADD COLUMN `ACTIVITY_STATE` tinyint(4) NULL, ADD COLUMN `IS_RECORD_SCORE` tinyint(4) NULL;
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <mapper namespace="org.gtiles.components.gtclasses.classbasic.extension.dao.IClassBasicInfoExtensionDao"> <!-- 班级查询结果 班级字段 --> <resultMap type="org.gtiles.components.gtclasses.classbasic.bean.ClassBasicInfoBean" id="classBasicInfo"> <!-- ...产品内容 --> <result column="ACTIVITY_STATE" jdbcType="INTEGER" property="activityState"/> <result column="IS_RECORD_SCORE" jdbcType="INTEGER" property="isRecordScore"/> </resultMap> <!-- 班级表字段 --> <sql id="queryFields"> <!-- ...产品内容 --> ACTIVITY_STATE,IS_RECORD_SCORE </sql> <!-- 字段值 --> <sql id="fieldValue"> <!-- ...产品内容 --> #{activityState},#{isRecordScore} </sql> <!-- 更新条件 --> <sql id="upateCommond"> <!-- ...产品内容 --> <if test="activityState != null">ACTIVITY_STATE = #{activityState},</if> <if test="isRecordScore != null">IS_RECORD_SCORE = #{isRecordScore},</if> </sql> <!-- 查询条件 --> <sql id="queryCommond"> <!-- ...产品内容 --> <if test="query.queryActivityState != null"> and ACTIVITY_STATE = #{query.queryActivityState}</if> <if test="query.queryIsRecordScore != null"> IS_RECORD_SCORE = #{query.queryIsRecordScore}</if> </sql> </mapper>
覆盖 org.gtiles.components.gtclasses.classbasic.bean.ClassBasicInfoBean
public class ClassBasicInfoBean extends ClassBasicInfo { private Integer activityState; private Integer isRecordScore; public Integer getActivityState() { return activityState; } public void setActivityState(Integer activityState) { this.activityState = activityState; } public Integer getIsRecordScore() { return isRecordScore; } public void setIsRecordScore(Integer isRecordScore) { this.isRecordScore = isRecordScore; } public ClassBasicInfoBean() { super(); } public ClassBasicInfoBean(ClassBasicInfoEntity classBasicInfoEntity) { super(classBasicInfoEntity); } }
覆盖 org.gtiles.components.gtclasses.classbasic.bean.ClassBasicInfoQuery
public class ClassBasicInfoQuery extends ClassBasicInfoAbstractQuery<ClassBasicInfoBean> { private Integer queryActivityState; private Integer queryIsRecordScore; public Integer getQueryActivityState() { return queryActivityState; } public void setQueryActivityState(Integer queryActivityState) { this.queryActivityState = queryActivityState; } public Integer getQueryIsRecordScore() { return queryIsRecordScore; } public void setQueryIsRecordScore(Integer queryIsRecordScore) { this.queryIsRecordScore = queryIsRecordScore; } }
覆盖html,在html中增加期望新增的字段、列表字段、查询条件。
班级基础信息字段扩展
数据库