package com.qxueyou.scc.portal.expert.service.imp; import com.qxueyou.scc.base.model.Pager; import com.qxueyou.scc.base.model.Result; import com.qxueyou.scc.base.service.impl.CommonAppService; import com.qxueyou.scc.base.util.CollectionUtils; import com.qxueyou.scc.portal.expert.model.Expert; import com.qxueyou.scc.portal.expert.service.IExpertService; import com.qxueyou.scc.portal.expert.vo.ExpertVO; import com.qxueyou.scc.portal.information.dto.ArticleInfoDTO; import com.qxueyou.scc.portal.information.model.Information; import com.qxueyou.scc.portal.information.service.IInformationService; import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Service; import java.util.Date; import java.util.List; @Service public class ExpertService extends CommonAppService implements IExpertService { @Override public Result listExpert(ExpertVO vo) { String hql = "from Expert where deleteFlag=0 and nameExpert like ? order by createTime desc"; int count =findExpertCount( vo);//专家总条数 List list = findList(hql, new Pager(vo.getSize(), vo.getPage()), CollectionUtils.newList(vo.getKeyword().concat("%")), Expert.class); return new Result(true,"success", CollectionUtils.newObjectMap("list", list, "count", count)); } @Override public int findExpertCount(ExpertVO vo) { String hql = "from Expert where deleteFlag=0 and nameExpert like :nameExpert"; return findCountByComplexHql(hql, CollectionUtils.newObjectMap("nameExpert",vo.getKeyword().concat("%"))); } @Override public Result save(ExpertVO vo) { Expert expert = new Expert(); BeanUtils.copyProperties(vo, expert); expert.setDeleteFlag(0); expert.setCreateTime(new Date()); expert.setUpdateTime(new Date()); save(expert); return Result.SUCCESS; } @Override public Result delete(String ids) { Result result = new Result(true); String[] arrStr = ids.split(","); if (arrStr != null && arrStr.length > 0) { String hql = "update Expert set deleteFlag = 1 where Id=?"; result = bulkUpdateInLoop(hql, arrStr); } return result; } @Override public Result update(ExpertVO vo) { Expert expert = read(Expert.class, vo.getId()); BeanUtils.copyProperties(vo, expert); save(expert); return Result.SUCCESS; } @Override public Result getExpertById(String id) { Expert expert = read(Expert.class, id); return new Result(true, "expertDTO",expert); } }