提交 cebd7c16 authored 作者: 吴德鹏's avatar 吴德鹏

属性管理

上级 0a1c16a2
...@@ -86,7 +86,7 @@ public class AttributesController { ...@@ -86,7 +86,7 @@ public class AttributesController {
@RequestMapping("/save") @RequestMapping("/save")
@RequiresPermissions("attributes:save") @RequiresPermissions("attributes:save")
@ResponseBody @ResponseBody
public R save(@RequestBody AttributesExtends attributes) { public R save(@RequestBody AttributesEntity attributes) {
attributesService.save(attributes); attributesService.save(attributes);
return R.ok(); return R.ok();
...@@ -98,7 +98,7 @@ public class AttributesController { ...@@ -98,7 +98,7 @@ public class AttributesController {
@RequestMapping("/update") @RequestMapping("/update")
@RequiresPermissions("attributes:update") @RequiresPermissions("attributes:update")
@ResponseBody @ResponseBody
public R update(@RequestBody AttributesExtends attributes) { public R update(@RequestBody AttributesEntity attributes) {
attributesService.update(attributes); attributesService.update(attributes);
return R.ok(); return R.ok();
......
...@@ -44,7 +44,7 @@ public interface AttributesService { ...@@ -44,7 +44,7 @@ public interface AttributesService {
* @param attributes 实体 * @param attributes 实体
* @return 保存条数 * @return 保存条数
*/ */
int save(AttributesExtends attributes); int save(AttributesEntity attributes);
/** /**
* 根据主键更新实体 * 根据主键更新实体
...@@ -52,7 +52,7 @@ public interface AttributesService { ...@@ -52,7 +52,7 @@ public interface AttributesService {
* @param attributes 实体 * @param attributes 实体
* @return 更新条数 * @return 更新条数
*/ */
int update(AttributesExtends attributes); int update(AttributesEntity attributes);
/** /**
* 根据主键删除 * 根据主键删除
......
...@@ -43,7 +43,7 @@ public class AttributesServiceImpl implements AttributesService { ...@@ -43,7 +43,7 @@ public class AttributesServiceImpl implements AttributesService {
} }
@Override @Override
public int save(AttributesExtends attributes) { public int save(AttributesEntity attributes) {
//属性 //属性
String id = IdUtil.createIdbyUUID(); String id = IdUtil.createIdbyUUID();
attributes.setId(id); attributes.setId(id);
...@@ -53,30 +53,38 @@ public class AttributesServiceImpl implements AttributesService { ...@@ -53,30 +53,38 @@ public class AttributesServiceImpl implements AttributesService {
int res1 = attributesDao.save(attributes); int res1 = attributesDao.save(attributes);
//属性描述 //属性描述
AttributesDescEntity descEntity = new AttributesDescEntity(); List<AttributesDescEntity> descs = attributes.getDescs();
descEntity.setAttrDescId(IdUtil.createIdbyUUID()); descs.forEach(desc -> {
descEntity.setAttrId(id); AttributesDescEntity descEntity = new AttributesDescEntity();
descEntity.setAttrValue(attributes.getAttrValue()); descEntity.setAttrDescId(IdUtil.createIdbyUUID());
descEntity.setAttrDesc(attributes.getAttrDesc()); descEntity.setAttrId(id);
descEntity.setStatus(1); descEntity.setAttrValue(desc.getAttrValue());
descEntity.setCreateTime(date); descEntity.setAttrDesc(desc.getAttrDesc());
descEntity.setUpdateTime(date); descEntity.setStatus(1);
int res2 = attributesDescDao.save(descEntity); descEntity.setCreateTime(date);
descEntity.setUpdateTime(date);
attributesDescDao.save(descEntity);
});
return (res1 > 0 && res2 > 0) ? 1 : 0;
return res1;
} }
@Override @Override
public int update(AttributesExtends attributes) { public int update(AttributesEntity attributes) {
Date date = new Date(); Date date = new Date();
attributes.setUpdateTime(date); attributes.setUpdateTime(date);
int res1 = attributesDao.update(attributes); int res1 = attributesDao.update(attributes);
AttributesDescEntity descEntity = attributesDescDao.queryObject(attributes.getAttrDescId()); List<AttributesDescEntity> descs = attributes.getDescs();
descEntity.setAttrValue(attributes.getAttrValue()); descs.forEach(attr -> {
descEntity.setAttrDesc(attributes.getAttrDesc()); AttributesDescEntity descEntity = attributesDescDao.queryObject(attr.getAttrDescId());
descEntity.setUpdateTime(date); descEntity.setAttrValue(attr.getAttrValue());
int res2 = attributesDescDao.update(descEntity); descEntity.setAttrDesc(attr.getAttrDesc());
return (res1 > 0 && res2 > 0) ? 1 : 0; descEntity.setUpdateTime(date);
attributesDescDao.update(descEntity);
});
return res1;
} }
@Override @Override
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论