|
@@ -31,7 +31,7 @@ import java.util.List;
|
|
|
@Api(value = "家族园地", tags = "家族园地")
|
|
|
@RequiredArgsConstructor(onConstructor_ = @Autowired)
|
|
|
@RestController
|
|
|
-@RequestMapping("/app/garden" )
|
|
|
+@RequestMapping("/app/garden")
|
|
|
public class FamilyGardenController extends BaseController {
|
|
|
|
|
|
private final ITbFamilyGardenService iTbFamilyGardenService;
|
|
@@ -43,11 +43,9 @@ public class FamilyGardenController extends BaseController {
|
|
|
*/
|
|
|
@ApiOperation(value = "家族园地列表", notes = "家族园地列表")
|
|
|
@GetMapping("/list")
|
|
|
- public TableDataInfo list(TbFamilyGarden tbFamilyGarden)
|
|
|
- {
|
|
|
- startPage();
|
|
|
+ public AjaxResult list(TbFamilyGarden tbFamilyGarden) {
|
|
|
List<TbFamilyGarden> list = iTbFamilyGardenService.queryList(tbFamilyGarden);
|
|
|
- return getDataTable(list);
|
|
|
+ return AjaxResult.success(list);
|
|
|
}
|
|
|
|
|
|
|
|
@@ -55,8 +53,8 @@ public class FamilyGardenController extends BaseController {
|
|
|
* 获取家族园地详细信息
|
|
|
*/
|
|
|
@ApiOperation(value = "家族园地详细信息", notes = "家族园地详细信息")
|
|
|
- @GetMapping(value = "/{id}" )
|
|
|
- public AjaxResult detail(@PathVariable("id" ) Long id) {
|
|
|
+ @GetMapping(value = "/{id}")
|
|
|
+ public AjaxResult detail(@PathVariable("id") Long id) {
|
|
|
return AjaxResult.success(iTbFamilyGardenService.getFamilyGarden(id));
|
|
|
}
|
|
|
|
|
@@ -64,19 +62,18 @@ public class FamilyGardenController extends BaseController {
|
|
|
* 新增家族园地
|
|
|
*/
|
|
|
@ApiOperation("新增家族园地")
|
|
|
- @Log(title = "家族园地" , businessType = BusinessType.INSERT)
|
|
|
- @PostMapping("/add")
|
|
|
- public AjaxResult add(@RequestBody TbFamilyGarden tbFamilyGarden) {
|
|
|
- Date date = new Date();
|
|
|
- tbFamilyGarden.setCreateTime(date);
|
|
|
- List<TbGardenImg> imgList = tbFamilyGarden.getImgList();
|
|
|
- if (imgList.size() <= 0) {
|
|
|
- return AjaxResult.success();
|
|
|
- }
|
|
|
- imgList.forEach(item -> {
|
|
|
- item.setGardenId(tbFamilyGarden.getId());
|
|
|
- });
|
|
|
- if(gardenImgService.saveBatch(imgList)){
|
|
|
+ @Log(title = "家族园地", businessType = BusinessType.INSERT)
|
|
|
+ @PostMapping("/saveOrUpdate")
|
|
|
+ public AjaxResult saveOrUpdate(@RequestBody TbFamilyGarden tbFamilyGarden) {
|
|
|
+ tbFamilyGarden.setCreateTime(new Date());
|
|
|
+ if (iTbFamilyGardenService.saveOrUpdate(tbFamilyGarden)) {
|
|
|
+ List<TbGardenImg> imgList = tbFamilyGarden.getImgList();
|
|
|
+ imgList.forEach(item -> {
|
|
|
+ item.setGardenId(tbFamilyGarden.getId());
|
|
|
+ });
|
|
|
+ //先删除原本照片再新增
|
|
|
+ gardenImgService.deleteTbGardenImgByGardenId(tbFamilyGarden.getId());
|
|
|
+ gardenImgService.saveBatch(imgList);
|
|
|
return AjaxResult.success();
|
|
|
}
|
|
|
return AjaxResult.error("发表失败");
|
|
@@ -88,7 +85,7 @@ public class FamilyGardenController extends BaseController {
|
|
|
* 修改家族园地
|
|
|
*/
|
|
|
@ApiOperation("修改家族园地")
|
|
|
- @Log(title = "家族园地" , businessType = BusinessType.UPDATE)
|
|
|
+ @Log(title = "家族园地", businessType = BusinessType.UPDATE)
|
|
|
@PutMapping("/update")
|
|
|
public AjaxResult edit(@RequestBody TbFamilyGarden tbFamilyGarden) {
|
|
|
return toAjax(iTbFamilyGardenService.updateById(tbFamilyGarden) ? 1 : 0);
|
|
@@ -98,8 +95,8 @@ public class FamilyGardenController extends BaseController {
|
|
|
* 删除家族园地
|
|
|
*/
|
|
|
@ApiOperation("删除家族园地")
|
|
|
- @Log(title = "家族园地" , businessType = BusinessType.DELETE)
|
|
|
- @DeleteMapping("/del")
|
|
|
+ @Log(title = "家族园地", businessType = BusinessType.DELETE)
|
|
|
+ @DeleteMapping("/del/{ids}")
|
|
|
public AjaxResult remove(@PathVariable Long[] ids) {
|
|
|
return toAjax(iTbFamilyGardenService.removeByIds(Arrays.asList(ids)) ? 1 : 0);
|
|
|
}
|