fix:平均分接口开发

dev
wangxy 12 months ago
parent b80d83cd8f
commit 36d7fd9570

@ -10,6 +10,7 @@ import com.hyp.common.utils.StringUtils;
import com.hyp.system.domain.RewApplyInfoList; import com.hyp.system.domain.RewApplyInfoList;
import com.hyp.system.domain.RewScoreInfo; import com.hyp.system.domain.RewScoreInfo;
import com.hyp.system.domain.dto.ScoreInfoSaveDTO; import com.hyp.system.domain.dto.ScoreInfoSaveDTO;
import com.hyp.system.domain.vo.RewScoreInfoVO;
import com.hyp.system.service.RewApplyInfoListService; import com.hyp.system.service.RewApplyInfoListService;
import com.hyp.system.service.RewScoreInfoService; import com.hyp.system.service.RewScoreInfoService;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@ -69,17 +70,23 @@ public class ScoreInfoManager {
* @param applyId * @param applyId
* @return java.util.List<com.hyp.system.domain.RewScoreInfo> * @return java.util.List<com.hyp.system.domain.RewScoreInfo>
*/ */
public List<RewScoreInfo> getScoreInfo(String applyId){ public RewScoreInfoVO getScoreInfo(String applyId){
RewScoreInfoVO rewScoreInfoVO = new RewScoreInfoVO();
LambdaQueryWrapper<RewScoreInfo> queryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<RewScoreInfo> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(RewScoreInfo::getApplyId,applyId); queryWrapper.eq(RewScoreInfo::getApplyId,applyId);
if (!SysUser.isAdmin(SecurityUtils.getUserId())){ if (!SysUser.isAdmin(SecurityUtils.getUserId())){
queryWrapper.eq(RewScoreInfo::getCreateId, SecurityUtils.getUserId()); queryWrapper.eq(RewScoreInfo::getCreateId, SecurityUtils.getUserId());
}else {
rewScoreInfoVO.setAvgScore(avgRewScore(applyId));
} }
return scoreInfoService.list(queryWrapper); List<RewScoreInfo> list = scoreInfoService.list(queryWrapper);
rewScoreInfoVO.setRewScoreInfos(list);
return rewScoreInfoVO;
} }
/** /**
* *
* *
@ -95,4 +102,16 @@ public class ScoreInfoManager {
} }
/**
*
*
* @param applyId
* @return java.lang.String
*/
public String avgRewScore(String applyId){
return scoreInfoService.avgRewScore(applyId);
}
} }

@ -0,0 +1,29 @@
package com.hyp.system.domain.vo;
import com.hyp.system.domain.RewScoreInfo;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
/**
* packageName com.hyp.system.domain.vo
*
* @author wangxy
* @version JDK 8
* @className RewScoreInfoVO
* @date 2024/4/23
* @description
*/
@Data
public class RewScoreInfoVO implements Serializable {
private List<RewScoreInfo> rewScoreInfos;
/**
*
*
*/
private String avgScore;
}

@ -3,8 +3,12 @@ package com.hyp.system.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.hyp.system.domain.RewScoreInfo; import com.hyp.system.domain.RewScoreInfo;
import com.hyp.system.domain.dto.ApplyInfoListDTO;
import com.hyp.system.domain.vo.ApplyInfoListVO;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import java.util.List;
/** /**
* @author wangxy * @author wangxy
* @description rew_score_info()Mapper * @description rew_score_info()Mapper
@ -14,6 +18,9 @@ import org.apache.ibatis.annotations.Mapper;
@Mapper @Mapper
public interface RewScoreInfoMapper extends BaseMapper<RewScoreInfo> { public interface RewScoreInfoMapper extends BaseMapper<RewScoreInfo> {
String avgRewScore(String applyId);
} }

@ -11,4 +11,7 @@ import com.hyp.system.domain.RewScoreInfo;
*/ */
public interface RewScoreInfoService extends IService<RewScoreInfo> { public interface RewScoreInfoService extends IService<RewScoreInfo> {
String avgRewScore(String applyId);
} }

@ -2,10 +2,16 @@ package com.hyp.system.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hyp.system.domain.RewScoreInfo; import com.hyp.system.domain.RewScoreInfo;
import com.hyp.system.domain.dto.ApplyInfoListDTO;
import com.hyp.system.domain.vo.ApplyInfoListVO;
import com.hyp.system.mapper.RewApplyInfoListMapper;
import com.hyp.system.mapper.RewScoreInfoMapper; import com.hyp.system.mapper.RewScoreInfoMapper;
import com.hyp.system.service.RewScoreInfoService; import com.hyp.system.service.RewScoreInfoService;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
/** /**
* @author wangxy * @author wangxy
* @description rew_score_info()Service * @description rew_score_info()Service
@ -15,6 +21,23 @@ import org.springframework.stereotype.Service;
public class RewScoreInfoServiceImpl extends ServiceImpl<RewScoreInfoMapper, RewScoreInfo> public class RewScoreInfoServiceImpl extends ServiceImpl<RewScoreInfoMapper, RewScoreInfo>
implements RewScoreInfoService { implements RewScoreInfoService {
@Resource
private RewScoreInfoMapper rewScoreInfoMapper;
/**
*
*
* @param applyId
* @return java.util.List<com.hyp.system.domain.vo.ApplyInfoListVO>
*/
@Override
public String avgRewScore(String applyId)
{
return rewScoreInfoMapper.avgRewScore(applyId);
}
} }

@ -21,4 +21,7 @@
create_id,create_by,create_time, create_id,create_by,create_time,
update_by,update_time,remark update_by,update_time,remark
</sql> </sql>
<select id="avgRewScore" resultType="java.lang.String" parameterType="String">
SELECT AVG(t.score) as avgScore from rew_score_info t where t.apply_id = #{applyId}
</select>
</mapper> </mapper>

Loading…
Cancel
Save