/*
|
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
|
*
|
* Redistribution and use in source and binary forms, with or without
|
* modification, are permitted provided that the following conditions are met:
|
*
|
* Redistributions of source code must retain the above copyright notice,
|
* this list of conditions and the following disclaimer.
|
* Redistributions in binary form must reproduce the above copyright
|
* notice, this list of conditions and the following disclaimer in the
|
* documentation and/or other materials provided with the distribution.
|
* Neither the name of the dreamlu.net developer nor the names of its
|
* contributors may be used to endorse or promote products derived from
|
* this software without specific prior written permission.
|
* Author: Chill 庄骞 (smallchill@163.com)
|
*/
|
package org.springblade.modules.evaluate.wrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import org.springblade.core.mp.support.BaseEntityWrapper;
|
import org.springblade.core.tool.utils.BeanUtil;
|
import org.springblade.core.tool.utils.SpringUtil;
|
import org.springblade.modules.evaluate.entity.EvaluateCandidateEntity;
|
import org.springblade.modules.evaluate.entity.EvaluateResultEntity;
|
import org.springblade.modules.evaluate.service.IEvaluateResultService;
|
import org.springblade.modules.evaluate.vo.EvaluateCandidateVO;
|
|
import java.util.List;
|
import java.util.Objects;
|
|
/**
|
* 评优候选人 包装类,返回视图层所需的字段
|
*
|
* @author aix
|
* @since 2023-12-23
|
*/
|
public class EvaluateCandidateWrapper extends BaseEntityWrapper<EvaluateCandidateEntity, EvaluateCandidateVO> {
|
|
private static final IEvaluateResultService evaluateResultService;
|
|
static {
|
evaluateResultService = SpringUtil.getBean(IEvaluateResultService.class);
|
}
|
|
public static EvaluateCandidateWrapper build() {
|
return new EvaluateCandidateWrapper();
|
}
|
|
@Override
|
public EvaluateCandidateVO entityVO(EvaluateCandidateEntity evaluateCandidate) {
|
EvaluateCandidateVO evaluateCandidateVO = Objects.requireNonNull(BeanUtil.copy(evaluateCandidate, EvaluateCandidateVO.class));
|
|
//User createUser = UserCache.getUser(evaluateCandidate.getCreateUser());
|
//User updateUser = UserCache.getUser(evaluateCandidate.getUpdateUser());
|
//evaluateCandidateVO.setCreateUserName(createUser.getName());
|
//evaluateCandidateVO.setUpdateUserName(updateUser.getName());
|
|
return evaluateCandidateVO;
|
}
|
|
@Override
|
public IPage<EvaluateCandidateVO> pageVO(IPage<EvaluateCandidateEntity> pages) {
|
List<EvaluateCandidateVO> records = listVO(pages.getRecords());
|
|
for (EvaluateCandidateVO vo : records) {
|
QueryWrapper<EvaluateResultEntity> queryWrapper = new QueryWrapper<>();
|
queryWrapper.eq("be_id",vo.getUserId());
|
queryWrapper.eq("evaluate_task_id",vo.getEvaluateTaskId());
|
queryWrapper.eq("type", 2);
|
vo.setVoteNum(evaluateResultService.count(queryWrapper));
|
}
|
|
IPage<EvaluateCandidateVO> pageVo = new Page<>(pages.getCurrent(), pages.getSize(), pages.getTotal());
|
pageVo.setRecords(records);
|
return pageVo;
|
}
|
|
|
}
|