派生自 projectDept/qhighschool

EricsHu
2023-11-24 691f717df93c32d89b13f7f73f0678441d60c840
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
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<Expert> 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);
    }
}