|
@@ -1,7 +1,18 @@
|
|
|
package com.flyer.foster.controller;
|
|
|
|
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
-import org.springframework.web.bind.annotation.RestController;
|
|
|
+import cn.hutool.core.bean.BeanUtil;
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import com.flyer.foster.dto.*;
|
|
|
+import com.flyer.foster.entity.PosterLib;
|
|
|
+import com.flyer.foster.service.IPosterLibService;
|
|
|
+import com.flyer.util.R;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+
|
|
|
+import javax.validation.Valid;
|
|
|
+import java.util.List;
|
|
|
|
|
|
/**
|
|
|
* 海报库
|
|
@@ -12,5 +23,54 @@ import org.springframework.web.bind.annotation.RestController;
|
|
|
@RestController
|
|
|
@RequestMapping("/poster-lib")
|
|
|
public class PosterLibController {
|
|
|
+ @Autowired
|
|
|
+ private IPosterLibService iPosterLibService;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 海报列表-分页
|
|
|
+ *
|
|
|
+ * @param current 当前页
|
|
|
+ * @param size 当前页显示条数
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @GetMapping("/list/{current}/{size}")
|
|
|
+ public R getPageList(@PathVariable Integer current, @PathVariable Integer size, PosterLibQueryDTO queryDTO) {
|
|
|
+ return R.ok().result(iPosterLibService.getPageList(new Page<>(current, size), queryDTO));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 新增海报
|
|
|
+ *
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @PostMapping("")
|
|
|
+ public R addPosterLib(@Valid @RequestBody PosterLibAddDTO addDTO) {
|
|
|
+ PosterLib posterLib = new PosterLib();
|
|
|
+ BeanUtil.copyProperties(addDTO, posterLib);
|
|
|
+ return R.ok().result(iPosterLibService.save(posterLib));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 修改海报
|
|
|
+ */
|
|
|
+ @PutMapping("")
|
|
|
+ public R updatePosterLib(@Valid @RequestBody PosterLibUpdateDTO updateDTO) {
|
|
|
+ return R.ok().result(
|
|
|
+ iPosterLibService.lambdaUpdate()
|
|
|
+ .set(StrUtil.isNotBlank(updateDTO.getName()), PosterLib::getName, updateDTO.getName())
|
|
|
+ .set(StrUtil.isNotBlank(updateDTO.getUrl()), PosterLib::getUrl, updateDTO.getUrl())
|
|
|
+ .eq(PosterLib::getId, updateDTO.getId())
|
|
|
+ .update());
|
|
|
+ }
|
|
|
|
|
|
+ /**
|
|
|
+ * 批量删除
|
|
|
+ *
|
|
|
+ * @param idList
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @PostMapping("/delete")
|
|
|
+ public R deletePosterLib(@RequestBody List<Integer> idList) {
|
|
|
+ return R.ok().result(iPosterLibService.deleteByIdList(idList));
|
|
|
+ }
|
|
|
}
|