whycxzp
2021-03-13 f40a97142e1e22fbfd86fb9d975822104dd18326
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
package com.whyc.service;
 
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.whyc.dto.ApplicationConfigDTO;
import com.whyc.dto.Response;
import com.whyc.mapper.ApplicationConfigMapper;
import com.whyc.mapper.ApplicationMapper;
import com.whyc.pojo.Application;
import com.whyc.pojo.ApplicationConfig;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestBody;
 
import javax.annotation.Resource;
import java.util.List;
 
@Service
public class ApplicationService {
 
    @Resource
    private ApplicationMapper mapper;
 
    @Resource
    private ApplicationConfigMapper configMapper;
 
    public Response insert(Application app) {
        mapper.insertApp(app);
        return new Response<>().set(1,app,"创建成功");
    }
 
    public Response getAll() {
        List<Application> applications = mapper.selectList(null);
        return new Response<>().set(1,applications);
    }
 
    public Response update(Application app) {
        int res = mapper.updateById(app);
        if(res==1){
            return new Response<>().setMsg(1,"更新成功");
        }else{
            return new Response<>().setMsg(0,"更新失败");
        }
    }
 
    /*======应用配置======*/
 
    public Response saveConfig(ApplicationConfigDTO configDTO) {
        try {
            configMapper.saveConfig(configDTO);
        }catch (Exception e){
            return new Response<>().setMsg(0,"保存失败");
        }
        return new Response<>().setCode(1);
    }
 
    /**查询应用和对应的配置模块*/
    public Response getAllConfig(int appId) {
        ApplicationConfigDTO applicationConfigDTO = configMapper.getAllConfig(appId);
        return new Response<>().set(1,applicationConfigDTO);
    }
}