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

属性管理

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