| | |
| | | import com.ycl.platform.domain.form.RegionForm; |
| | | import com.ycl.platform.domain.vo.RegionVO; |
| | | import com.ycl.platform.domain.query.RegionQuery; |
| | | |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | import com.ycl.utils.DateUtils; |
| | |
| | | public Result add(RegionForm form) { |
| | | Region entity = RegionForm.getEntityByForm(form, null); |
| | | entity.setRegionLevel(RegionLevelEnum.STREET); |
| | | Date now = new Date(); |
| | | entity.setCreateTime(now); |
| | | entity.setUpdateTime(now); |
| | | if(baseMapper.insert(entity) > 0) { |
| | | return Result.ok("添加成功"); |
| | | } |
| | |
| | | public Result update(RegionForm form) { |
| | | |
| | | Region entity = baseMapper.selectById(form.getId()); |
| | | |
| | | // 为空抛IllegalArgumentException,做全局异常处理 |
| | | Assert.notNull(entity, "记录不存在"); |
| | | BeanUtils.copyProperties(form, entity); |
| | | Date now = new Date(); |
| | | entity.setUpdateTime(now); |
| | | if (baseMapper.updateById(entity) > 0) { |
| | | return Result.ok("修改成功"); |
| | | } |