Commit b8993768 by 朱瑞泽

代码调整

parent ce495f72
package com.gic.demo.project.dao.mapper; package com.gic.demo.project.dao.mapper;
import com.gic.demo.project.entity.TabGicDemoEnterprise; import com.gic.demo.project.entity.TabGicDemoEnterprise;
import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface DemoEnterpriseMapper { public interface DemoEnterpriseMapper {
int deleteByPrimaryKey(String enterpriseId); int deleteByPrimaryKey(String enterpriseId);
int insert(TabGicDemoEnterprise record); int insert(TabGicDemoEnterprise record);
int insertList(@Param("recordList") List<TabGicDemoEnterprise> recordList);
int insertSelective(TabGicDemoEnterprise record); int insertSelective(TabGicDemoEnterprise record);
TabGicDemoEnterprise selectByPrimaryKey(String enterpriseId); TabGicDemoEnterprise selectByPrimaryKey(String enterpriseId);
......
...@@ -12,7 +12,7 @@ public class TabGicDemoEnterprise { ...@@ -12,7 +12,7 @@ public class TabGicDemoEnterprise {
/** /**
* 企业id * 企业id
*/ */
@InjectId(InjectId.IdType.UUID) @InjectId(InjectId.IdType.SNOWFLAKE)
private String enterpriseId; private String enterpriseId;
/** /**
......
...@@ -47,6 +47,25 @@ ...@@ -47,6 +47,25 @@
#{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}, #{status,jdbcType=INTEGER} #{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}, #{status,jdbcType=INTEGER}
) )
</insert> </insert>
<insert id="insertList" parameterType="list">
insert into tab_gic_demo_enterprise (enterprise_id, enterprise_name, enterprise_code,
brand_name, logo_url, enterprise_description,
license_number, country_id, province_id,
city_id, area_id, register_address,
create_time, update_time, status
)
values
<foreach collection="recordList" item="record" separator=",">
(#{record.enterpriseId,jdbcType=CHAR}, #{record.enterpriseName,jdbcType=VARCHAR}, #{record.enterpriseCode,jdbcType=VARCHAR},
#{record.brandName,jdbcType=VARCHAR}, #{record.logoUrl,jdbcType=VARCHAR}, #{record.enterpriseDescription,jdbcType=VARCHAR},
#{record.licenseNumber,jdbcType=VARCHAR}, #{record.countryId,jdbcType=VARCHAR}, #{record.provinceId,jdbcType=VARCHAR},
#{record.cityId,jdbcType=VARCHAR}, #{record.areaId,jdbcType=VARCHAR}, #{record.registerAddress,jdbcType=VARCHAR},
#{record.createTime,jdbcType=TIMESTAMP}, #{record.updateTime,jdbcType=TIMESTAMP}, #{record.status,jdbcType=INTEGER}
)
</foreach>
</insert>
<insert id="insertSelective" parameterType="com.gic.demo.project.entity.TabGicDemoEnterprise"> <insert id="insertSelective" parameterType="com.gic.demo.project.entity.TabGicDemoEnterprise">
insert into tab_gic_demo_enterprise insert into tab_gic_demo_enterprise
<trim prefix="(" suffix=")" suffixOverrides=","> <trim prefix="(" suffix=")" suffixOverrides=",">
......
...@@ -13,6 +13,9 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -13,6 +13,9 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import java.util.ArrayList;
import java.util.List;
/** /**
* Unit test for simple App. * Unit test for simple App.
*/ */
...@@ -52,4 +55,21 @@ public class AppTest { ...@@ -52,4 +55,21 @@ public class AppTest {
} }
} }
@Test
public void test4() {
List<TabGicDemoEnterprise> list = new ArrayList<>();
for (int i = 0; i < 10; i++) {
System.out.println("insert >> " + i);
TabGicDemoEnterprise enterprise = new TabGicDemoEnterprise();
list.add(enterprise);
if (i % 2 == 0) {
enterprise.setEnterpriseId(RandomStringUtils.random(20, "abcdefghigklmn0123456789"));
}
enterprise.setEnterpriseName(RandomStringUtils.random(10, "abcdefghigklmn0123456789"));
enterprise.setStatus(1);
}
enterpriseMapper.insertList(list);
System.out.println(JSON.toJSONString(list, true));
}
} }
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