|
@@ -1,10 +1,9 @@
|
|
|
package com.kmall.admin.controller;
|
|
|
|
|
|
+import com.google.common.collect.ImmutableBiMap;
|
|
|
import com.kmall.admin.entity.AttributeEntity;
|
|
|
import com.kmall.admin.service.AttributeService;
|
|
|
-import com.kmall.common.utils.PageUtils;
|
|
|
-import com.kmall.common.utils.Query;
|
|
|
-import com.kmall.common.utils.R;
|
|
|
+import com.kmall.common.utils.*;
|
|
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
@@ -60,8 +59,16 @@ public class AttributeController {
|
|
|
@RequestMapping("/save")
|
|
|
@RequiresPermissions("attribute:save")
|
|
|
public R save(@RequestBody AttributeEntity attribute) {
|
|
|
- attributeService.save(attribute);
|
|
|
+ Map<String, Object> valideDate = MapBeanUtil.fromObject(attribute);
|
|
|
+ ImmutableBiMap.Builder builder = new ImmutableBiMap.Builder();
|
|
|
+ builder.put("name", "名称");
|
|
|
+ builder.put("attributeCategoryId", "所属分类");
|
|
|
+ R r = ValidatorUtil.isEmpty(builder.build(), valideDate);
|
|
|
+ if (Integer.valueOf(r.get("code").toString()) != 0) {
|
|
|
+ throw new RRException(r.get("msg").toString());
|
|
|
+ }
|
|
|
|
|
|
+ attributeService.save(attribute);
|
|
|
return R.ok();
|
|
|
}
|
|
|
|
|
@@ -71,8 +78,16 @@ public class AttributeController {
|
|
|
@RequestMapping("/update")
|
|
|
@RequiresPermissions("attribute:update")
|
|
|
public R update(@RequestBody AttributeEntity attribute) {
|
|
|
- attributeService.update(attribute);
|
|
|
+ Map<String, Object> valideDate = MapBeanUtil.fromObject(attribute);
|
|
|
+ ImmutableBiMap.Builder builder = new ImmutableBiMap.Builder();
|
|
|
+ builder.put("name", "名称");
|
|
|
+ builder.put("attributeCategoryId", "所属分类");
|
|
|
+ R r = ValidatorUtil.isEmpty(builder.build(), valideDate);
|
|
|
+ if (Integer.valueOf(r.get("code").toString()) != 0) {
|
|
|
+ throw new RRException(r.get("msg").toString());
|
|
|
+ }
|
|
|
|
|
|
+ attributeService.update(attribute);
|
|
|
return R.ok();
|
|
|
}
|
|
|
|