Commit 31a6528b authored by Quxl's avatar Quxl

x

parent 76bddaed
......@@ -11,9 +11,9 @@ public interface FilmGroupService {
List<Map<String, Object>> queryFilmListByGroupId(Integer film_group_id);
void updateFilmGroupId(Integer film_id, Integer group_id);
void updateFilmGroupId(Integer[] film_id, Integer group_id);
void removeFilmGroupById(Integer id);
void removeFilmGroupById(Integer[] id);
List<Map<String, Object>> queryFilmList(Integer enroll_type_id, String film_country, Page page);
......
......@@ -29,15 +29,23 @@ public class FilmGroupServiceImpl implements FilmGroupService {
}
@Override
public void updateFilmGroupId(Integer film_id, Integer group_id) {
jdbcTemplate.executeUpdate("update fc_member_film set film_group_id = ? where id = ?", group_id, film_id);
public void updateFilmGroupId(Integer[] film_id, Integer group_id) {
Integer[][] args = new Integer[film_id.length][];
for(int i = 0; i < film_id.length; i++) {
args[i] = new Integer[] {group_id, film_id[i]};
}
jdbcTemplate.batchUpdate("update fc_member_film set film_group_id = ? where id = ?", args);
}
@Override
@Transactional
public void removeFilmGroupById(Integer id) {
jdbcTemplate.executeUpdate("delete from fc_film_group where id = ?", id);
jdbcTemplate.executeUpdate("update fc_member_film set film_group_id = ? where film_group_id = ?", null, id);
public void removeFilmGroupById(Integer[] id) {
Integer[][] args = new Integer[id.length][];
for(int i = 0; i < id.length; i++) {
args[i] = new Integer[] {id[i]};
}
jdbcTemplate.batchUpdate("delete from fc_film_group where id = ?", args);
jdbcTemplate.batchUpdate("update fc_member_film set film_group_id = null where film_group_id = ?", args);
}
@Override
......
......@@ -5,6 +5,7 @@ import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
......@@ -42,22 +43,25 @@ public class FilmGroupController {
}
@ResponseBody
@Transactional
@PostMapping("saveOrUpdate")
@ApiOperation("保存或更新分类")
public Object saveOrUpdate(Integer id, String group_name, Integer parent_id, Integer order_num) {
public Object saveOrUpdate(Integer[] id, String[] group_name, Integer[] order_num, Integer[] parent_id) {
for(int i = 0; i < id.length; i++) {
Fc_film_group g = new Fc_film_group();
g.setId(id);
g.setGroup_name(group_name);
g.setParent_id(parent_id);
g.setOrder_num(order_num);
g.setId(id[i]);
g.setGroup_name(group_name[i]);
g.setParent_id(parent_id[i]);
g.setOrder_num(order_num[i]);
jdbcTemplate.merge(g);
return Rjx.jsonOk().setData(g);
}
return Rjx.jsonOk();
}
@ResponseBody
@PostMapping("delete")
@ApiOperation("删除分类")
public Object delete(Integer id) {
public Object delete(Integer[] id) {
filmGroupService.removeFilmGroupById(id);
return Rjx.jsonOk();
}
......@@ -81,7 +85,7 @@ public class FilmGroupController {
@ResponseBody
@PostMapping("updateFilmGroupId")
@ApiOperation("更新影片分类")
public Object updateFilmGroupId(Integer film_id, Integer group_id) {
public Object updateFilmGroupId(Integer[] film_id, Integer group_id) {
filmGroupService.updateFilmGroupId(film_id, group_id);
return Rjx.jsonOk();
}
......
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