Commit 03391a59 authored by Quxl's avatar Quxl

x

parent 13077459
...@@ -9,6 +9,7 @@ import java.util.Date; ...@@ -9,6 +9,7 @@ import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.PreparedStatementCreator; import org.springframework.jdbc.core.PreparedStatementCreator;
...@@ -17,6 +18,7 @@ import org.springframework.jdbc.support.KeyHolder; ...@@ -17,6 +18,7 @@ import org.springframework.jdbc.support.KeyHolder;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import com.alibaba.fastjson.JSON;
import com.egolm.common.DateUtil; import com.egolm.common.DateUtil;
import com.egolm.common.StringUtil; import com.egolm.common.StringUtil;
import com.egolm.common.jdbc.JdbcTemplate; import com.egolm.common.jdbc.JdbcTemplate;
...@@ -223,6 +225,24 @@ public class FilmServiceImpl implements FilmService { ...@@ -223,6 +225,24 @@ public class FilmServiceImpl implements FilmService {
jdbcTemplate.executeUpdate(sql, args); jdbcTemplate.executeUpdate(sql, args);
} }
public static void main(String[] args) {
String str = "{\"member_film_id\":[\"4445\"],\"playactor_type\":[\"director\"],\"playactor_name\":[\"siddharth sinha\"],\"playactor_film_nums\":[\"null\"],\"playactor_country\":[\"null\"],\"playactor_birthday\":[\"null\"],\"playactor_intro\":[\"Siddharth Sinha,1978,Compieted his post grauduate aiproma in film direction form Film & Television Institute of India. Jis graduation short film with Indian title UDHERBUN has won SILVER BEAR AWARD at 2008 Berlin International film festival 2008.\"],\"is_play_shanghai\":[\"0\"],\"playactor_role_name\":[\"1) UDHERBUN\\n2) RANGBELA\"]}";
Map<?, ?> map = JSON.parseObject(str);
FilmService s = new FilmServiceImpl();
s.saveMemberFilmPlayactor(
1L,
((List<?>)map.get("playactor_type")).toArray(new String[0]),
((List<?>)map.get("playactor_role_name")).toArray(new String[0]),
((List<?>)map.get("playactor_name")).toArray(new String[0]),
((List<?>)map.get("playactor_film_nums")).toArray(new String[0]),
((List<?>)map.get("playactor_country")).toArray(new String[0]),
((List<?>)map.get("playactor_birthday")).toArray(new String[0]),
((List<?>)map.get("playactor_intro")).toArray(new String[0]),
((List<String>)map.get("is_play_shanghai")).stream().map(Integer::valueOf).collect(Collectors.toList()).toArray(new Integer[0])
);
}
@Override @Override
@Transactional @Transactional
public void saveMemberFilmPlayactor( public void saveMemberFilmPlayactor(
...@@ -236,14 +256,6 @@ public class FilmServiceImpl implements FilmService { ...@@ -236,14 +256,6 @@ public class FilmServiceImpl implements FilmService {
String[] playactor_intro, String[] playactor_intro,
Integer[] is_play_shanghai) { Integer[] is_play_shanghai) {
if(playactor_type.length == playactor_role_name.length &&
playactor_role_name.length == playactor_name.length &&
playactor_name.length == playactor_film_nums.length &&
playactor_film_nums.length == playactor_country.length &&
playactor_country.length == playactor_birthday.length &&
playactor_birthday.length == playactor_intro.length &&
playactor_intro.length == is_play_shanghai.length) {
Long create_time = System.currentTimeMillis()/1000; Long create_time = System.currentTimeMillis()/1000;
List<Object[]> playactors = new ArrayList<Object[]>(); List<Object[]> playactors = new ArrayList<Object[]>();
for(int i = 0; i < playactor_type.length; i++) { for(int i = 0; i < playactor_type.length; i++) {
...@@ -273,9 +285,6 @@ public class FilmServiceImpl implements FilmService { ...@@ -273,9 +285,6 @@ public class FilmServiceImpl implements FilmService {
+ "values " + "values "
+ "(?, ?, ?, ?, ?, ?, ?, ?, ?)"; + "(?, ?, ?, ?, ?, ?, ?, ?, ?)";
jdbcTemplate.batchUpdate(sql_playactor, playactors); jdbcTemplate.batchUpdate(sql_playactor, playactors);
} else {
throw new XException(messages.get("err.args_nums"));
}
} }
@Override @Override
......
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