Commit 03391a59 authored by Quxl's avatar Quxl

x

parent 13077459
......@@ -9,6 +9,7 @@ import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.PreparedStatementCreator;
......@@ -17,6 +18,7 @@ import org.springframework.jdbc.support.KeyHolder;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.alibaba.fastjson.JSON;
import com.egolm.common.DateUtil;
import com.egolm.common.StringUtil;
import com.egolm.common.jdbc.JdbcTemplate;
......@@ -223,6 +225,24 @@ public class FilmServiceImpl implements FilmService {
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
@Transactional
public void saveMemberFilmPlayactor(
......@@ -236,46 +256,35 @@ public class FilmServiceImpl implements FilmService {
String[] playactor_intro,
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;
List<Object[]> playactors = new ArrayList<Object[]>();
for(int i = 0; i < playactor_type.length; i++) {
playactors.add(new Object[]{
member_film_id,
playactor_name[i],
playactor_film_nums[i],
playactor_intro[i],
playactor_country[i],
playactor_birthday[i],
create_time,
playactor_type[i],
playactor_role_name[i]});
}
jdbcTemplate.executeUpdate("delete from fc_member_film_playactor where film_id = ?", member_film_id);
String sql_playactor = ""
+ "insert into fc_member_film_playactor("
+ "film_id, "
+ "playactor_name, "
+ "playactor_film_nums, "
+ "playactor_film_intro, "
+ "playactor_country, "
+ "playactor_birthday, "
+ "create_time, "
+ "playactor_type, "
+ "playactor_role_name)"
+ "values "
+ "(?, ?, ?, ?, ?, ?, ?, ?, ?)";
jdbcTemplate.batchUpdate(sql_playactor, playactors);
} else {
throw new XException(messages.get("err.args_nums"));
Long create_time = System.currentTimeMillis()/1000;
List<Object[]> playactors = new ArrayList<Object[]>();
for(int i = 0; i < playactor_type.length; i++) {
playactors.add(new Object[]{
member_film_id,
playactor_name[i],
playactor_film_nums[i],
playactor_intro[i],
playactor_country[i],
playactor_birthday[i],
create_time,
playactor_type[i],
playactor_role_name[i]});
}
jdbcTemplate.executeUpdate("delete from fc_member_film_playactor where film_id = ?", member_film_id);
String sql_playactor = ""
+ "insert into fc_member_film_playactor("
+ "film_id, "
+ "playactor_name, "
+ "playactor_film_nums, "
+ "playactor_film_intro, "
+ "playactor_country, "
+ "playactor_birthday, "
+ "create_time, "
+ "playactor_type, "
+ "playactor_role_name)"
+ "values "
+ "(?, ?, ?, ?, ?, ?, ?, ?, ?)";
jdbcTemplate.batchUpdate(sql_playactor, playactors);
}
@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