提交 | 用户 | 时间
|
71e81e
|
1 |
package cn.stylefeng.guns.tenant.controller; |
懒 |
2 |
|
|
3 |
import cn.stylefeng.guns.base.db.entity.DatabaseInfo; |
|
4 |
import cn.stylefeng.guns.base.db.service.DatabaseInfoService; |
|
5 |
import cn.stylefeng.guns.base.pojo.page.LayuiPageInfo; |
|
6 |
import cn.stylefeng.guns.base.tenant.entity.TenantInfo; |
|
7 |
import cn.stylefeng.guns.base.tenant.model.params.TenantInfoParam; |
|
8 |
import cn.stylefeng.guns.base.tenant.service.TenantInfoService; |
|
9 |
import cn.stylefeng.roses.core.base.controller.BaseController; |
|
10 |
import cn.stylefeng.roses.core.util.SpringContextHolder; |
|
11 |
import cn.stylefeng.roses.kernel.model.exception.ServiceException; |
|
12 |
import cn.stylefeng.roses.kernel.model.response.ResponseData; |
|
13 |
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
14 |
import org.springframework.beans.factory.annotation.Autowired; |
|
15 |
import org.springframework.stereotype.Controller; |
|
16 |
import org.springframework.ui.Model; |
|
17 |
import org.springframework.web.bind.annotation.RequestMapping; |
|
18 |
import org.springframework.web.bind.annotation.ResponseBody; |
|
19 |
|
|
20 |
import java.util.List; |
|
21 |
|
|
22 |
|
|
23 |
/** |
|
24 |
* 租户表控制器 |
|
25 |
* |
|
26 |
* @author stylefeng |
|
27 |
* @Date 2019-06-16 20:57:22 |
|
28 |
*/ |
|
29 |
@Controller |
|
30 |
@RequestMapping("/tenantInfo") |
|
31 |
public class TenantInfoController extends BaseController { |
|
32 |
|
|
33 |
private String PREFIX = "/modular/tenantInfo"; |
|
34 |
|
|
35 |
@Autowired |
|
36 |
private TenantInfoService tenantInfoService; |
|
37 |
|
|
38 |
/** |
|
39 |
* 跳转到主页面 |
|
40 |
* |
|
41 |
* @author stylefeng |
|
42 |
* @Date 2019-06-16 |
|
43 |
*/ |
|
44 |
@RequestMapping("") |
|
45 |
public String index() { |
|
46 |
return PREFIX + "/tenantInfo.html"; |
|
47 |
} |
|
48 |
|
|
49 |
/** |
|
50 |
* 新增页面 |
|
51 |
* |
|
52 |
* @author stylefeng |
|
53 |
* @Date 2019-06-16 |
|
54 |
*/ |
|
55 |
@RequestMapping("/add") |
|
56 |
public String add(Model model) { |
|
57 |
|
|
58 |
//获取数据源信息 |
|
59 |
DatabaseInfoService databaseInfoService = null; |
|
60 |
try { |
|
61 |
databaseInfoService = SpringContextHolder.getBean(DatabaseInfoService.class); |
|
62 |
} catch (Exception e) { |
|
63 |
throw new ServiceException(500, "请先开启数据源容器模块!"); |
|
64 |
} |
|
65 |
|
|
66 |
List<DatabaseInfo> all = databaseInfoService.list(new QueryWrapper<>()); |
|
67 |
model.addAttribute("dataSources", all); |
|
68 |
|
|
69 |
return PREFIX + "/tenantInfo_add.html"; |
|
70 |
} |
|
71 |
|
|
72 |
/** |
|
73 |
* 编辑页面 |
|
74 |
* |
|
75 |
* @author stylefeng |
|
76 |
* @Date 2019-06-16 |
|
77 |
*/ |
|
78 |
@RequestMapping("/edit") |
|
79 |
public String edit(Model model) { |
|
80 |
|
|
81 |
//获取数据源信息 |
|
82 |
DatabaseInfoService databaseInfoService = null; |
|
83 |
try { |
|
84 |
databaseInfoService = SpringContextHolder.getBean(DatabaseInfoService.class); |
|
85 |
} catch (Exception e) { |
|
86 |
throw new ServiceException(500, "请先开启数据源容器模块!"); |
|
87 |
} |
|
88 |
|
|
89 |
List<DatabaseInfo> all = databaseInfoService.list(new QueryWrapper<>()); |
|
90 |
model.addAttribute("dataSources", all); |
|
91 |
|
|
92 |
return PREFIX + "/tenantInfo_edit.html"; |
|
93 |
} |
|
94 |
|
|
95 |
/** |
|
96 |
* 新增接口 |
|
97 |
* |
|
98 |
* @author stylefeng |
|
99 |
* @Date 2019-06-16 |
|
100 |
*/ |
|
101 |
@RequestMapping("/addItem") |
|
102 |
@ResponseBody |
|
103 |
public ResponseData addItem(TenantInfoParam tenantInfoParam) { |
|
104 |
this.tenantInfoService.add(tenantInfoParam); |
|
105 |
return ResponseData.success(); |
|
106 |
} |
|
107 |
|
|
108 |
/** |
|
109 |
* 编辑接口 |
|
110 |
* |
|
111 |
* @author stylefeng |
|
112 |
* @Date 2019-06-16 |
|
113 |
*/ |
|
114 |
@RequestMapping("/editItem") |
|
115 |
@ResponseBody |
|
116 |
public ResponseData editItem(TenantInfoParam tenantInfoParam) { |
|
117 |
this.tenantInfoService.update(tenantInfoParam); |
|
118 |
return ResponseData.success(); |
|
119 |
} |
|
120 |
|
|
121 |
/** |
|
122 |
* 删除接口 |
|
123 |
* |
|
124 |
* @author stylefeng |
|
125 |
* @Date 2019-06-16 |
|
126 |
*/ |
|
127 |
@RequestMapping("/delete") |
|
128 |
@ResponseBody |
|
129 |
public ResponseData delete(TenantInfoParam tenantInfoParam) { |
|
130 |
this.tenantInfoService.delete(tenantInfoParam); |
|
131 |
return ResponseData.success(); |
|
132 |
} |
|
133 |
|
|
134 |
/** |
|
135 |
* 查看详情接口 |
|
136 |
* |
|
137 |
* @author stylefeng |
|
138 |
* @Date 2019-06-16 |
|
139 |
*/ |
|
140 |
@RequestMapping("/detail") |
|
141 |
@ResponseBody |
|
142 |
public ResponseData detail(TenantInfoParam tenantInfoParam) { |
|
143 |
TenantInfo detail = this.tenantInfoService.getById(tenantInfoParam.getTenantId()); |
|
144 |
return ResponseData.success(detail); |
|
145 |
} |
|
146 |
|
|
147 |
/** |
|
148 |
* 查询列表 |
|
149 |
* |
|
150 |
* @author stylefeng |
|
151 |
* @Date 2019-06-16 |
|
152 |
*/ |
|
153 |
@ResponseBody |
|
154 |
@RequestMapping("/list") |
|
155 |
public LayuiPageInfo list(TenantInfoParam tenantInfoParam) { |
|
156 |
return this.tenantInfoService.findPageBySpec(tenantInfoParam); |
|
157 |
} |
|
158 |
|
|
159 |
/** |
|
160 |
* 获取租户列表 |
|
161 |
* |
|
162 |
* @author stylefeng |
|
163 |
* @Date 2019-06-16 |
|
164 |
*/ |
|
165 |
@ResponseBody |
|
166 |
@RequestMapping("/listTenants") |
|
167 |
public ResponseData listTenants() { |
|
168 |
List<TenantInfo> list = this.tenantInfoService.list(new QueryWrapper<TenantInfo>().select("name,code")); |
|
169 |
return ResponseData.success(list); |
|
170 |
} |
|
171 |
|
|
172 |
} |
|
173 |
|
|
174 |
|