From 9fa7cd49430bd0b5cb97a748ef76dbde8df4de5a Mon Sep 17 00:00:00 2001 From: liyongde <1419499670@qq.com> Date: Wed, 30 Oct 2024 19:51:01 +0800 Subject: [PATCH] =?UTF-8?q?refactor=EF=BC=9A=E5=8C=BA=E5=9F=9F=E7=AE=A1?= =?UTF-8?q?=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/SchBaseRegionController.java | 6 +- .../b_lms/sch/region/dao/SchBaseRegion.java | 22 +------ .../impl/SchBaseRegionServiceImpl.java | 61 ++++++++++++------- .../org/nl/wms/sch/rest/RegionController.java | 2 +- 4 files changed, 46 insertions(+), 45 deletions(-) diff --git a/lms/nladmin-system/src/main/java/org/nl/b_lms/sch/region/controller/SchBaseRegionController.java b/lms/nladmin-system/src/main/java/org/nl/b_lms/sch/region/controller/SchBaseRegionController.java index 9d4dbfa..8364609 100644 --- a/lms/nladmin-system/src/main/java/org/nl/b_lms/sch/region/controller/SchBaseRegionController.java +++ b/lms/nladmin-system/src/main/java/org/nl/b_lms/sch/region/controller/SchBaseRegionController.java @@ -26,7 +26,7 @@ import org.nl.b_lms.sch.region.service.IschBaseRegionService; */ @RestController @RequiredArgsConstructor -@RequestMapping("/api/schBaseRegion") +@RequestMapping("/api/region") @Slf4j public class SchBaseRegionController { @@ -56,7 +56,7 @@ public class SchBaseRegionController { */ @PostMapping @Log("新增区域基础表") - public ResponseEntity create(SchBaseRegion entity) { + public ResponseEntity create(@RequestBody SchBaseRegion entity) { schBaseRegionService.create(entity); return new ResponseEntity<>(HttpStatus.OK); } @@ -71,7 +71,7 @@ public class SchBaseRegionController { @PutMapping @Log("修改区域基础表") //@SaCheckPermission("@el.check(SchBaseRegion:edit')") - public ResponseEntity update(SchBaseRegion entity) { + public ResponseEntity update(@RequestBody SchBaseRegion entity) { schBaseRegionService.update(entity); return new ResponseEntity<>(HttpStatus.OK); } diff --git a/lms/nladmin-system/src/main/java/org/nl/b_lms/sch/region/dao/SchBaseRegion.java b/lms/nladmin-system/src/main/java/org/nl/b_lms/sch/region/dao/SchBaseRegion.java index 9b38a67..51f67a8 100644 --- a/lms/nladmin-system/src/main/java/org/nl/b_lms/sch/region/dao/SchBaseRegion.java +++ b/lms/nladmin-system/src/main/java/org/nl/b_lms/sch/region/dao/SchBaseRegion.java @@ -1,7 +1,5 @@ package org.nl.b_lms.sch.region.dao; -import java.io.Serializable; - import lombok.*; import com.baomidou.mybatisplus.annotation.*; import com.baomidou.mybatisplus.annotation.TableName; @@ -16,10 +14,6 @@ import com.baomidou.mybatisplus.extension.activerecord.Model; */ @Data -@Builder -@ToString -@AllArgsConstructor -@NoArgsConstructor @EqualsAndHashCode(callSuper = true) @TableName("sch_base_region") public class SchBaseRegion extends Model { @@ -73,7 +67,7 @@ public class SchBaseRegion extends Model { /** * 创建人 */ - private Long create_id; + private String create_id; /** @@ -92,13 +86,13 @@ public class SchBaseRegion extends Model { /** * 修改人 */ - private Long update_optid; + private String update_id; /** * 修改人 */ - private String update_optname; + private String update_name; /** @@ -108,16 +102,6 @@ public class SchBaseRegion extends Model { private String update_time; - /** - * 获取主键值 - * - * @return 主键值 - */ - @Override - protected Serializable pkVal() { - return this.region_id; - } - } diff --git a/lms/nladmin-system/src/main/java/org/nl/b_lms/sch/region/service/impl/SchBaseRegionServiceImpl.java b/lms/nladmin-system/src/main/java/org/nl/b_lms/sch/region/service/impl/SchBaseRegionServiceImpl.java index 8e2fc0d..4d7ce87 100644 --- a/lms/nladmin-system/src/main/java/org/nl/b_lms/sch/region/service/impl/SchBaseRegionServiceImpl.java +++ b/lms/nladmin-system/src/main/java/org/nl/b_lms/sch/region/service/impl/SchBaseRegionServiceImpl.java @@ -1,5 +1,9 @@ package org.nl.b_lms.sch.region.service.impl; +import cn.hutool.core.map.MapUtil; +import cn.hutool.core.util.IdUtil; +import cn.hutool.core.util.ObjectUtil; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import org.nl.b_lms.sch.region.dao.SchBaseRegion; import org.nl.b_lms.sch.region.dao.mapper.SchBaseRegionMapper; @@ -8,6 +12,7 @@ import cn.hutool.core.date.DateUtil; import org.nl.common.utils.SecurityUtils; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.nl.modules.common.exception.BadRequestException; import org.springframework.stereotype.Service; import com.baomidou.mybatisplus.core.metadata.IPage; import org.nl.common.domain.query.PageQuery; @@ -40,16 +45,14 @@ public class SchBaseRegionServiceImpl extends ServiceImpl queryAll(Map whereJson, PageQuery page) { - return schBaseRegionMapper.selectPage(new Page<>(page.getPage() + 1, page.getSize()), new QueryWrapper() - .lambda() - // .like(StringUtils.isNotBlank(form.name()), User::getName, form.name()) - // .between(form.beginTime != null && form.endTime != null, User::getCreateTime, beginTime, endTime) - // .in(form.Status != null, User::getStatus - // , UserStatusEnum.NOT_SUBMITTED - // , UserStatusEnum.TO_REVIEWED) - // .orderByDesc(User::getId) - //.eq(SchBaseRegion::getIs_delete, 0) - ); + String blurry = MapUtil.getStr(whereJson, "region_code"); + LambdaQueryWrapper lam = new LambdaQueryWrapper<>(); + lam.like(ObjectUtil.isNotEmpty(blurry), SchBaseRegion::getRegion_code, blurry) + .or(ObjectUtil.isNotEmpty(blurry), la -> la.like(SchBaseRegion::getRegion_name, blurry)) + .orderByAsc(SchBaseRegion::getRegion_code); + IPage pages = new Page<>(page.getPage() + 1, page.getSize()); + schBaseRegionMapper.selectPage(pages, lam); + return pages; } @@ -60,9 +63,19 @@ public class SchBaseRegionServiceImpl extends ServiceImpl lam = new LambdaQueryWrapper<>(); + lam.eq(SchBaseRegion::getRegion_code, regionCode); + return this.getOne(lam); + } + /** * 编辑 @@ -71,10 +84,13 @@ public class SchBaseRegionServiceImpl extends ServiceImpl