whyclxw
2024-03-01 4590d3e29c14869fb1f1933102c96923159b23b0
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
package com.whyc.service;
 
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.whyc.dto.Response;
import com.whyc.mapper.NjHomeConfigMapper;
import com.whyc.pojo.NjHomeConfig;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
 
import javax.annotation.Resource;
import java.util.List;
 
@Service
public class NjHomeConfigService {
    @Resource
    private NjHomeConfigMapper mapper;
 
    //获取首页配置信息
    public Response getAllConfig() {
        QueryWrapper wrapper=new QueryWrapper();
        wrapper.lt("config_type",10);
        wrapper.orderByAsc("num");
        List list=mapper.selectList(wrapper);
        return new Response().setII(1,list!=null,list,"获取首页配置信息");
    }
    //编辑首页配置信息
    @Transactional
    public Response alterConfig(List<NjHomeConfig> list) {
        if (list != null && list.size() > 0) {
            for (NjHomeConfig hc : list) {
                UpdateWrapper wrapper = new UpdateWrapper();
                //wrapper.set("config_name", hc.getConfigName());
                //wrapper.set("config_value", hc.getConfigValue());
               // wrapper.set("config_type", hc.getConfigType());
                wrapper.set("config_flag", hc.getConfigFlag());
                //wrapper.set("config_class", hc.getConfigClass());
                wrapper.eq("num", hc.getNum());
                mapper.update(null, wrapper);
            }
        }
        return new Response().set(1,true);
    }
}