增加农场分区、菜地划分模块的建立者、建立时间、更新者、更新时间跟踪,统一在Controller中处理。

This commit is contained in:
jlt 2022-03-29 21:09:39 +08:00
parent f8622fc273
commit 458df8499b
4 changed files with 18 additions and 4 deletions

View File

@ -2,6 +2,8 @@ package com.jlt.csa.controller;
import java.util.List; import java.util.List;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
@ -21,6 +23,8 @@ import com.jlt.csa.service.IFarmZoneService;
import com.ruoyi.common.utils.poi.ExcelUtil; import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo; import com.ruoyi.common.core.page.TableDataInfo;
import static com.ruoyi.common.utils.SecurityUtils.getUsername;
/** /**
* 农场分区Controller * 农场分区Controller
* *
@ -77,6 +81,8 @@ public class FarmZoneController extends BaseController
@PostMapping @PostMapping
public AjaxResult add(@RequestBody FarmZone farmZone) public AjaxResult add(@RequestBody FarmZone farmZone)
{ {
farmZone.setCreateBy(getUsername());
farmZone.setCreateTime(DateUtils.getNowDate());
return toAjax(farmZoneService.insertFarmZone(farmZone)); return toAjax(farmZoneService.insertFarmZone(farmZone));
} }
@ -88,6 +94,8 @@ public class FarmZoneController extends BaseController
@PutMapping @PutMapping
public AjaxResult edit(@RequestBody FarmZone farmZone) public AjaxResult edit(@RequestBody FarmZone farmZone)
{ {
farmZone.setUpdateBy(getUsername());
farmZone.setUpdateTime(DateUtils.getNowDate());
return toAjax(farmZoneService.updateFarmZone(farmZone)); return toAjax(farmZoneService.updateFarmZone(farmZone));
} }

View File

@ -2,6 +2,8 @@ package com.jlt.csa.controller;
import java.util.List; import java.util.List;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
@ -77,6 +79,8 @@ public class GardenController extends BaseController
@PostMapping @PostMapping
public AjaxResult add(@RequestBody Garden garden) public AjaxResult add(@RequestBody Garden garden)
{ {
garden.setCreateBy(getUsername());
garden.setCreateTime(DateUtils.getNowDate());
return toAjax(gardenService.insertGarden(garden)); return toAjax(gardenService.insertGarden(garden));
} }
@ -88,6 +92,8 @@ public class GardenController extends BaseController
@PutMapping @PutMapping
public AjaxResult edit(@RequestBody Garden garden) public AjaxResult edit(@RequestBody Garden garden)
{ {
garden.setUpdateBy(getUsername());
garden.setUpdateTime(DateUtils.getNowDate());
return toAjax(gardenService.updateGarden(garden)); return toAjax(gardenService.updateGarden(garden));
} }
@ -99,6 +105,8 @@ public class GardenController extends BaseController
@PutMapping("/{ids}") @PutMapping("/{ids}")
public AjaxResult updateStatus(@RequestBody Garden garden, @PathVariable Long[] ids) public AjaxResult updateStatus(@RequestBody Garden garden, @PathVariable Long[] ids)
{ {
garden.setUpdateBy(getUsername());
garden.setUpdateTime(DateUtils.getNowDate());
return toAjax(gardenService.updateGardenStatus(garden, ids)); return toAjax(gardenService.updateGardenStatus(garden, ids));
} }

View File

@ -8,6 +8,8 @@ import com.jlt.csa.mapper.FarmZoneMapper;
import com.jlt.csa.domain.FarmZone; import com.jlt.csa.domain.FarmZone;
import com.jlt.csa.service.IFarmZoneService; import com.jlt.csa.service.IFarmZoneService;
import static com.ruoyi.common.utils.SecurityUtils.getUsername;
/** /**
* 农场分区Service业务层处理 * 农场分区Service业务层处理
* *
@ -53,7 +55,6 @@ public class FarmZoneServiceImpl implements IFarmZoneService
@Override @Override
public int insertFarmZone(FarmZone farmZone) public int insertFarmZone(FarmZone farmZone)
{ {
farmZone.setCreateTime(DateUtils.getNowDate());
return farmZoneMapper.insertFarmZone(farmZone); return farmZoneMapper.insertFarmZone(farmZone);
} }
@ -66,7 +67,6 @@ public class FarmZoneServiceImpl implements IFarmZoneService
@Override @Override
public int updateFarmZone(FarmZone farmZone) public int updateFarmZone(FarmZone farmZone)
{ {
farmZone.setUpdateTime(DateUtils.getNowDate());
return farmZoneMapper.updateFarmZone(farmZone); return farmZoneMapper.updateFarmZone(farmZone);
} }

View File

@ -66,7 +66,6 @@ public class GardenServiceImpl implements IGardenService
@Override @Override
public int updateGarden(Garden garden) public int updateGarden(Garden garden)
{ {
garden.setUpdateTime(DateUtils.getNowDate());
return gardenMapper.updateGarden(garden); return gardenMapper.updateGarden(garden);
} }
@ -78,7 +77,6 @@ public class GardenServiceImpl implements IGardenService
* @return 结果 * @return 结果
*/ */
public int updateGardenStatus(Garden garden, Long[] ids) { public int updateGardenStatus(Garden garden, Long[] ids) {
garden.setUpdateTime(DateUtils.getNowDate());
return gardenMapper.updateGardenStatus(garden, ids); return gardenMapper.updateGardenStatus(garden, ids);
} }