Explorar el Código

系统设置开发

wangzhengliang hace 3 años
padre
commit
a94a616641

+ 19 - 55
src/main/java/com/chuanghai/ihotel/controller/SystemSettingController.java

@@ -1,23 +1,18 @@
 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.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.RequestBody;
+import org.springframework.web.bind.annotation.RequestHeader;
 import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.GetMapping;
 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
 @RequestMapping("systemSetting")
 public class SystemSettingController {
+
     @Autowired
     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")
-    public CommonResult<String> update(@RequestBody SystemSettingEntity systemSetting){
+    public CommonResult<String> update(@RequestHeader("admin_token")String adminToken, @RequestBody SystemSettingEntity systemSetting){
 		boolean flag = systemSettingService.updateById(systemSetting);
 
 		if (flag) {
@@ -76,19 +55,4 @@ public class SystemSettingController {
 		    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();
-        }
-    }
-
 }

+ 19 - 0
src/main/java/com/chuanghai/ihotel/entity/SystemSettingEntity.java

@@ -4,6 +4,8 @@ import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
 import lombok.Data;
 
+import javax.validation.constraints.Min;
+import javax.validation.constraints.NotNull;
 import java.io.Serializable;
 import java.math.BigDecimal;
 
@@ -23,38 +25,55 @@ public class SystemSettingEntity implements Serializable {
 	 * id
 	 */
 	@TableId
+	@NotNull(message = "id不能为空")
 	private Long id;
 	/**
 	 * 押金 单位:元
 	 */
+	@Min(value = 0, message = "押金不能少于0")
+	@NotNull(message = "押金不能为空")
 	private BigDecimal deposit;
 	/**
 	 * 预定提前天数 单位:天
 	 */
+	@Min(value = 0, message = "预定提前天数不能少于0")
+	@NotNull(message = "预定提前天数不能为空")
 	private Integer preDay;
 	/**
 	 * 水费 单位:元/吨
 	 */
+	@Min(value = 0, message = "水费不能少于0")
+	@NotNull(message = "水费不能为空")
 	private BigDecimal priceOfWater;
 	/**
 	 * 电费 单位:元/度
 	 */
+	@Min(value = 0, message = "电费不能少于0")
+	@NotNull(message = "电费不能为空")
 	private BigDecimal priceOfElectric;
 	/**
 	 * 水免费额度 单位:吨
 	 */
+	@Min(value = 0, message = "水免费额度不能少于0")
+	@NotNull(message = "水免费额度不能为空")
 	private BigDecimal freeQuotaOfWater;
 	/**
 	 * 电免费额度 单位:度
 	 */
+	@Min(value = 0, message = "电免费额度不能少于0")
+	@NotNull(message = "电免费额度不能为空")
 	private BigDecimal freeQuotaOfElectric;
 	/**
 	 * 水电免费额度总金额 单位:元
 	 */
+	@Min(value = 0, message = "水电免费额度总金额不能少于0")
+	@NotNull(message = "水电免费额度总金额不能为空")
 	private BigDecimal freeTotal;
 	/**
 	 * 退房后断水断电时间 单位:分钟
 	 */
+	@Min(value = 0, message = "退房后断水断电时间不能少于0")
+	@NotNull(message = "退房后断水断电时间不能为空")
 	private Integer turnOffTime;
 
 }