Commit 31a6528b authored by Quxl's avatar Quxl

x

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