|
@@ -1,23 +1,18 @@
|
|
|
package com.chuanghai.ihotel.controller;
|
|
package com.chuanghai.ihotel.controller;
|
|
|
|
|
|
|
|
-import java.util.Arrays;
|
|
|
|
|
-
|
|
|
|
|
|
|
+import com.chuanghai.ihotel.anno.AdminLoginCheck;
|
|
|
|
|
+import com.chuanghai.ihotel.anno.ParamCheck;
|
|
|
|
|
+import com.chuanghai.ihotel.common.utils.CommonResult;
|
|
|
|
|
+import com.chuanghai.ihotel.entity.SystemSettingEntity;
|
|
|
|
|
+import com.chuanghai.ihotel.service.SystemSettingService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.web.bind.annotation.DeleteMapping;
|
|
|
|
|
-import org.springframework.web.bind.annotation.PathVariable;
|
|
|
|
|
-import org.springframework.web.bind.annotation.PostMapping;
|
|
|
|
|
|
|
+import org.springframework.web.bind.annotation.GetMapping;
|
|
|
import org.springframework.web.bind.annotation.PutMapping;
|
|
import org.springframework.web.bind.annotation.PutMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
|
|
|
+import org.springframework.web.bind.annotation.RequestHeader;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
-import org.springframework.web.bind.annotation.GetMapping;
|
|
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
|
|
-import com.chuanghai.ihotel.entity.SystemSettingEntity;
|
|
|
|
|
-import com.chuanghai.ihotel.service.SystemSettingService;
|
|
|
|
|
-import com.chuanghai.ihotel.common.utils.PageUtils;
|
|
|
|
|
-import com.chuanghai.ihotel.common.utils.CommonResult;
|
|
|
|
|
-import com.chuanghai.ihotel.common.utils.PageParam;
|
|
|
|
|
-
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 系统设置
|
|
* 系统设置
|
|
@@ -29,45 +24,29 @@ import com.chuanghai.ihotel.common.utils.PageParam;
|
|
|
@RestController
|
|
@RestController
|
|
|
@RequestMapping("systemSetting")
|
|
@RequestMapping("systemSetting")
|
|
|
public class SystemSettingController {
|
|
public class SystemSettingController {
|
|
|
|
|
+
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private SystemSettingService systemSettingService;
|
|
private SystemSettingService systemSettingService;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * 列表
|
|
|
|
|
|
|
+ * 获取系统设置
|
|
|
|
|
+ * @param adminToken 管理员token
|
|
|
*/
|
|
*/
|
|
|
- @GetMapping("/list")
|
|
|
|
|
- public CommonResult<PageUtils<SystemSettingEntity>> list(PageParam pageParam){
|
|
|
|
|
- PageUtils page = systemSettingService.queryPage(pageParam);
|
|
|
|
|
|
|
+ @AdminLoginCheck
|
|
|
|
|
+ @GetMapping("/info")
|
|
|
|
|
+ public CommonResult<SystemSettingEntity> list(@RequestHeader("admin_token")String adminToken){
|
|
|
|
|
+ SystemSettingEntity systemSettingEntity = systemSettingService.get();
|
|
|
|
|
|
|
|
- return CommonResult.ok().setResult(page);
|
|
|
|
|
|
|
+ return CommonResult.ok().setResult(systemSettingEntity);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
/**
|
|
/**
|
|
|
- * 信息
|
|
|
|
|
- */
|
|
|
|
|
- @GetMapping("/info/{id}")
|
|
|
|
|
- public CommonResult<SystemSettingEntity> info(@PathVariable("id") Long id){
|
|
|
|
|
- SystemSettingEntity systemSetting = systemSettingService.getById(id);
|
|
|
|
|
-
|
|
|
|
|
- return CommonResult.ok().setResult(systemSetting);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- /**
|
|
|
|
|
- * 保存
|
|
|
|
|
- */
|
|
|
|
|
- @PostMapping("/save")
|
|
|
|
|
- public CommonResult<String> save(@RequestBody SystemSettingEntity systemSetting){
|
|
|
|
|
- systemSettingService.save(systemSetting);
|
|
|
|
|
-
|
|
|
|
|
- return CommonResult.ok();
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- /**
|
|
|
|
|
- * 修改
|
|
|
|
|
|
|
+ * 修改系统设置
|
|
|
*/
|
|
*/
|
|
|
|
|
+ @AdminLoginCheck
|
|
|
|
|
+ @ParamCheck
|
|
|
@PutMapping("/update")
|
|
@PutMapping("/update")
|
|
|
- public CommonResult<String> update(@RequestBody SystemSettingEntity systemSetting){
|
|
|
|
|
|
|
+ public CommonResult<String> update(@RequestHeader("admin_token")String adminToken, @RequestBody SystemSettingEntity systemSetting){
|
|
|
boolean flag = systemSettingService.updateById(systemSetting);
|
|
boolean flag = systemSettingService.updateById(systemSetting);
|
|
|
|
|
|
|
|
if (flag) {
|
|
if (flag) {
|
|
@@ -76,19 +55,4 @@ public class SystemSettingController {
|
|
|
return CommonResult.fail();
|
|
return CommonResult.fail();
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- /**
|
|
|
|
|
- * 删除
|
|
|
|
|
- */
|
|
|
|
|
- @DeleteMapping("/delete")
|
|
|
|
|
- public CommonResult<String> delete(@RequestBody Long[] ids){
|
|
|
|
|
- boolean flag = systemSettingService.removeByIds(Arrays.asList(ids));
|
|
|
|
|
-
|
|
|
|
|
- if (flag) {
|
|
|
|
|
- return CommonResult.ok();
|
|
|
|
|
- } else {
|
|
|
|
|
- return CommonResult.fail();
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
}
|
|
}
|