FeignSysConfigBiz.java 2.6 KB
Newer Older
F
fengyw 已提交
1 2 3
package com.roncoo.education.system.feign.biz;


F
修改  
fengyw 已提交
4
import com.roncoo.education.common.core.aliyun.Aliyun;
F
fengyw 已提交
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
import com.roncoo.education.common.core.base.Page;
import com.roncoo.education.common.core.base.PageUtil;
import com.roncoo.education.common.core.tools.BeanUtil;
import com.roncoo.education.common.service.BaseBiz;
import com.roncoo.education.system.dao.SysConfigDao;
import com.roncoo.education.system.dao.impl.mapper.entity.SysConfig;
import com.roncoo.education.system.dao.impl.mapper.entity.SysConfigExample;
import com.roncoo.education.system.dao.impl.mapper.entity.SysConfigExample.Criteria;
import com.roncoo.education.system.feign.interfaces.qo.SysConfigEditQO;
import com.roncoo.education.system.feign.interfaces.qo.SysConfigPageQO;
import com.roncoo.education.system.feign.interfaces.qo.SysConfigSaveQO;
import com.roncoo.education.system.feign.interfaces.vo.SysConfigPageVO;
import com.roncoo.education.system.feign.interfaces.vo.SysConfigViewVO;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;

import javax.validation.constraints.NotNull;
F
修改  
fengyw 已提交
22 23 24
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
F
fengyw 已提交
25 26 27 28 29 30 31 32 33 34 35 36 37

/**
 * 系统配置
 *
 * @author wujing
 */
@Component
@RequiredArgsConstructor
public class FeignSysConfigBiz extends BaseBiz {

    @NotNull
    private final SysConfigDao dao;

F
fengyw 已提交
38
    public Page<SysConfigPageVO> page(SysConfigPageQO qo) {
F
fengyw 已提交
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
        SysConfigExample example = new SysConfigExample();
        Criteria c = example.createCriteria();
        example.setOrderByClause(" id desc ");
        Page<SysConfig> page = dao.page(qo.getPageCurrent(), qo.getPageSize(), example);
        return PageUtil.transform(page, SysConfigPageVO.class);
    }

    public int save(SysConfigSaveQO qo) {
        SysConfig record = BeanUtil.copyProperties(qo, SysConfig.class);
        return dao.save(record);
    }

    public int deleteById(Long id) {
        return dao.deleteById(id);
    }

    public int updateById(SysConfigEditQO qo) {
        SysConfig record = BeanUtil.copyProperties(qo, SysConfig.class);
        return dao.updateById(record);
    }

    public SysConfigViewVO getById(Long id) {
        SysConfig record = dao.getById(id);
        return BeanUtil.copyProperties(record, SysConfigViewVO.class);
    }
F
修改  
fengyw 已提交
64 65 66 67 68 69 70

    public Aliyun getAliyun() {
        SysConfigExample example = new SysConfigExample();
        List<SysConfig> sysConfigs = dao.listByExample(example);
        Map<String, String> map = sysConfigs.stream().collect(Collectors.toMap(SysConfig::getConfigKey, SysConfig::getConfigValue));
        return BeanUtil.objToBean(map, Aliyun.class);
    }
F
fengyw 已提交
71
}