Commit b9e97de0 by 林冲

课程培训分页

1 parent 8cd0899f
package cn.com.glsx.dj.riskmanage.mapper.learningcenter; package cn.com.glsx.dj.riskmanage.mapper.learningcenter;
import cn.com.glsx.dj.riskmanage.dto.learningcenter.TrainingPlanDTO;
import cn.com.glsx.dj.riskmanage.model.learningcenter.LearningCenterTrainingPlan; import cn.com.glsx.dj.riskmanage.model.learningcenter.LearningCenterTrainingPlan;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.oreframework.datasource.mybatis.mapper.OreMapper; import org.oreframework.datasource.mybatis.mapper.OreMapper;
import java.util.List;
@Mapper @Mapper
public interface LearningCenterTrainingPlanMapper extends OreMapper<LearningCenterTrainingPlan> { public interface LearningCenterTrainingPlanMapper extends OreMapper<LearningCenterTrainingPlan> {
List<TrainingPlanDTO> listWithPage(TrainingPlanDTO condition);
} }
\ No newline at end of file \ No newline at end of file
...@@ -2,14 +2,27 @@ package cn.com.glsx.dj.riskmanage.remote.learningcenter; ...@@ -2,14 +2,27 @@ package cn.com.glsx.dj.riskmanage.remote.learningcenter;
import cn.com.glsx.dj.riskmanage.dto.learningcenter.TrainingPlanDTO; import cn.com.glsx.dj.riskmanage.dto.learningcenter.TrainingPlanDTO;
import cn.com.glsx.dj.riskmanage.remote.LearningCenterTrainingPlanRemote; import cn.com.glsx.dj.riskmanage.remote.LearningCenterTrainingPlanRemote;
import cn.com.glsx.dj.riskmanage.service.learningcenter.LearningCenterTrainingPlanService;
import cn.com.glsx.framework.core.beans.rpc.RpcPagination; import cn.com.glsx.framework.core.beans.rpc.RpcPagination;
import cn.com.glsx.framework.core.beans.rpc.RpcResponse; import cn.com.glsx.framework.core.beans.rpc.RpcResponse;
import cn.com.glsx.framework.core.exception.RpcServiceException;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboService; import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;
@Slf4j
@DubboService(retries = 0, timeout = 30000) @DubboService(retries = 0, timeout = 30000)
public class LearningCenterTrainingPlanRemoteImpl implements LearningCenterTrainingPlanRemote { public class LearningCenterTrainingPlanRemoteImpl implements LearningCenterTrainingPlanRemote {
@Autowired
private LearningCenterTrainingPlanService learningCenterTrainingPlanService;
@Override @Override
public RpcResponse<RpcPagination<TrainingPlanDTO>> listWithPage(RpcPagination<TrainingPlanDTO> pagination) { public RpcResponse<RpcPagination<TrainingPlanDTO>> listWithPage(RpcPagination<TrainingPlanDTO> pagination) {
return null; try {
return RpcResponse.success(RpcPagination.copyPage(learningCenterTrainingPlanService.listWithPage(pagination)));
} catch (RpcServiceException e) {
log.error(e.getMessage(), e);
return RpcResponse.error(e);
}
} }
} }
package cn.com.glsx.dj.riskmanage.service.learningcenter;
import cn.com.glsx.dj.riskmanage.dto.learningcenter.TrainingPlanDTO;
import cn.com.glsx.dj.riskmanage.mapper.learningcenter.LearningCenterTrainingPlanMapper;
import cn.com.glsx.dj.riskmanage.model.learningcenter.LearningCenterTrainingPlan;
import cn.com.glsx.framework.core.beans.rpc.RpcPagination;
import cn.com.glsx.framework.core.enums.DefaultErrorEnum;
import cn.com.glsx.framework.core.exception.RpcServiceException;
import cn.com.glsx.framework.core.util.RpcAssert;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
@Slf4j
@Service
@RequiredArgsConstructor
public class LearningCenterTrainingPlanService {
private final LearningCenterTrainingPlanMapper learningCenterTrainingPlanMapper;
public Page<TrainingPlanDTO> listWithPage(RpcPagination<TrainingPlanDTO> pagination) {
RpcAssert.assertNotNull(pagination, DefaultErrorEnum.DATA_NULL, "RpcPagination not be null");
try {
Page<TrainingPlanDTO> page = PageHelper.startPage(pagination.getPageNum(), pagination.getPageSize(),pagination.isNeedCount());
learningCenterTrainingPlanMapper.listWithPage(pagination.getCondition());
return page;
} catch (Exception e) {
log.info(e.getMessage(), e);
throw new RpcServiceException(DefaultErrorEnum.DATABASE_ERROR, e.getMessage());
}
}
}
\ No newline at end of file \ No newline at end of file
...@@ -22,6 +22,10 @@ ...@@ -22,6 +22,10 @@
<result column="updated_date" property="updatedDate" jdbcType="TIMESTAMP" /> <result column="updated_date" property="updatedDate" jdbcType="TIMESTAMP" />
<result column="deleted_flag" property="deletedFlag" jdbcType="CHAR" /> <result column="deleted_flag" property="deletedFlag" jdbcType="CHAR" />
</resultMap> </resultMap>
<resultMap id="DTOResultMap" extends="BaseResultMap" type="cn.com.glsx.dj.riskmanage.dto.learningcenter.TrainingPlanDTO">
<result column="course_num" property="courseNum" jdbcType="INTEGER" />
<result column="person_num" property="personNum" jdbcType="INTEGER" />
</resultMap>
<sql id="Base_Column_List" > <sql id="Base_Column_List" >
<!-- <!--
WARNING - @mbg.generated WARNING - @mbg.generated
...@@ -30,4 +34,34 @@ ...@@ -30,4 +34,34 @@
limit_time_param, white_list, status, creator, created_by, created_date, updated_by, updated_date, deleted_flag limit_time_param, white_list, status, creator, created_by, created_date, updated_by, updated_date, deleted_flag
</sql> </sql>
<sql id="whereCondition">
<where>
t.deleted_flag = 'N'
<if test="planName != null and planName != ''">
AND t.plan_name LIKE CONCAT('%', #{planName}, '%')
</if>
<if test="status != null">
AND t.status = #{status}
</if>
<if test="createdBy != null and createdBy != ''">
AND t.created_by LIKE CONCAT('%', #{createdBy}, '%')
</if>
<if test="startTime != null and startTime != ''">
AND t.created_date &gt;= #{startTime}
</if>
<if test="endTime != null and endTime != ''">
AND t.created_date &lt;= #{endTime}
</if>
</where>
</sql>
<select id="listWithPage" parameterType="cn.com.glsx.dj.riskmanage.dto.learningcenter.TrainingPlanDTO" resultMap="DTOResultMap">
SELECT
t.*,
(SELECT COUNT(1) FROM dj_car_life_learning_center_training_plan_course c WHERE c.plan_id = t.id AND c.deleted_flag = 'N') AS course_num,
(SELECT COUNT(1) FROM dj_car_life_learning_center_training_plan_person p WHERE p.plan_id = t.id AND p.deleted_flag = 'N') AS person_num
FROM dj_car_life_learning_center_training_plan t
<include refid="whereCondition"/>
ORDER BY t.created_date DESC
</select>
</mapper> </mapper>
\ No newline at end of file \ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!