whycxzp
2021-10-12 d5cf76188ad37f062f37ebce3464097203b4db05
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
package com.whyc.controller;
 
import com.whyc.dto.ApplicationConfigDTO;
import com.whyc.dto.ApplicationDTO;
import com.whyc.dto.Response;
import com.whyc.pojo.Application;
import com.whyc.pojo.ApplicationConfig;
import com.whyc.service.ApplicationService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
 
import java.util.List;
 
/**
 * 应用管理
 */
@RestController
@RequestMapping("application")
@Api(tags = "应用管理")
public class ApplicationController {
 
    @Autowired
    private ApplicationService service;
 
    /*======应用管理======*/
    @PostMapping
    @ApiOperation(value = "应用-创建")
    public Response create(@RequestBody Application app){
        return service.insert(app);
    }
 
    @GetMapping("all")
    @ApiOperation(value = "应用-查询所有")
    public Response getAll(@RequestParam Integer userId){
        return service.getAll(userId);
    }
 
    /**
     * 如果更新的为默认布局,则复制默认布局为当前用户布局
     */
    @PutMapping
    @ApiOperation(value = "应用-更新名称")
    public Response update(@RequestBody Application app){
        return service.update(app);
    }
 
    @DeleteMapping
    @ApiOperation(value = "应用-删除")
    public Response delete(@RequestParam Integer appId){
        return service.delete(appId);
    }
 
    @PutMapping("active")
    @ApiOperation(value = "应用-设置激活")
    public Response updateActive(@RequestBody Application app){
        return service.updateActive(app);
    }
 
    /**
     * 针对每个用户的<默认应用布局>这一功能,查询时,如果没有激活的应用,则展示 默认应用布局
     */
    @GetMapping("active")
    @ApiOperation(value = "应用-查询当前激活")
    public Response getActive(@RequestParam Integer userId){
        return service.getActive(userId);
    }
 
    /*======应用配置======*/
    /**
     * 不允许appId=0的应用进行修改,需要先重命名应用
     * @param configDTO
     * @return
     */
    @PostMapping("config")
    @ApiOperation(value = "配置-保存当前应用的配置")
    public Response saveConfig(@RequestBody ApplicationConfigDTO configDTO){
        //TODO:处理fileData存储文件
        return service.saveConfig(configDTO);
    }
 
    @GetMapping("allConfig")
    @ApiOperation(value = "配置-查询当前应用的配置")
    public Response getAllConfig(@RequestParam Integer appId){
        return service.getAllConfig(appId);
    }
 
}