Commit 648e5ce3 authored by yanzg's avatar yanzg

1.3版本修改,增加删除功能

parent 96f6d082
...@@ -39,18 +39,19 @@ public class DataDaoVoTest { ...@@ -39,18 +39,19 @@ public class DataDaoVoTest {
@Test @Test
public void testEn() { public void testEn() {
int id = 1; int id = 1;
Temp last = new Temp(id++, "产品3", "类型3", 4, 0);
List<Temp> his = Arrays.asList( List<Temp> his = Arrays.asList(
new Temp(id++,"产品1","类型1",1,0), new Temp(id++, "产品1", "类型1", 1, 0),
new Temp(id++,"产品1","类型1",2,1), new Temp(id++, "产品1", "类型1", 2, 1),
new Temp(id++,"产品1","类型1",3,1), new Temp(id++, "产品1", "类型1", 3, 1),
new Temp(id++,"产品1","类型1",4,1), new Temp(id++, "产品1", "类型1", 4, 1),
new Temp(id++,"产品2","类型2",4,0), new Temp(id++, "产品2", "类型2", 4, 0),
new Temp(id++,"产品3","类型3",4,0) last
); );
List<Temp> now = Arrays.asList( List<Temp> now = Arrays.asList(
new Temp(id++,"产品1","类型1",9,0), new Temp(id++, "产品1", "类型1", 9, 0),
new Temp(id++,"产品2","类型2",43,0), new Temp(id++, "产品2", "类型2", 43, 0),
new Temp(id++,"产品4","类型4",95,0) new Temp(id++, "产品4", "类型4", 95, 0)
); );
DataDaoVo<Temp> init = DataDaoVo.init(his, now, new DataDaoKey<Temp>() { DataDaoVo<Temp> init = DataDaoVo.init(his, now, new DataDaoKey<Temp>() {
@Override @Override
...@@ -58,8 +59,9 @@ public class DataDaoVoTest { ...@@ -58,8 +59,9 @@ public class DataDaoVoTest {
return StringHelper.getId(from.productId, from.productType); return StringHelper.getId(from.productId, from.productType);
} }
}); });
Assert.assertEquals(init.getCreates().size(),1); Assert.assertEquals(init.getCreates().size(), 1);
Assert.assertEquals(init.getUpdates().size(),2); Assert.assertEquals(init.getUpdates().size(), 2);
Assert.assertEquals(init.getRemoves().size(),4); Assert.assertEquals(init.getRemoves().size(), 4);
Assert.assertEquals(last.removeFlag, 1);
} }
} }
...@@ -141,7 +141,7 @@ public class DaoConst { ...@@ -141,7 +141,7 @@ public class DaoConst {
/** /**
* 更新字段模板参数 * 更新字段模板参数
*/ */
public static final String CODE_UPDATE_FIELD_REMOVE = ",a.%s=IFNULL(?,1)"; public static final String CODE_UPDATE_FIELD_REMOVE = ",a.%s=CASE WHEN a.%s THEN 0 AND IFNULL(?,0)=0 THEN 1 ELSE IFNULL(?,1) END";
/** /**
* 等于条件 * 等于条件
*/ */
......
...@@ -692,7 +692,7 @@ public class TableStruct { ...@@ -692,7 +692,7 @@ public class TableStruct {
// 设置删除标记可以通过前台传入 // 设置删除标记可以通过前台传入
if (remove != null) { if (remove != null) {
sql.addParaConst(remove.inputName, sql.addParaConst(remove.inputName,
CODE_FIELD, String.format(CODE_UPDATE_FIELD_REMOVE, remove.name)); CODE_FIELD, String.format(CODE_UPDATE_FIELD_REMOVE, remove.name, remove.name));
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment