From 0d05424b5df05f2e6ef478934cdaad9c71e5d91d Mon Sep 17 00:00:00 2001 From: Fancy <Fancy.fx@outlook.com> Date: 星期三, 18 九月 2024 09:34:56 +0800 Subject: [PATCH] product name and type --- pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoPlt/PltProductMapper.java | 2 +- pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/product/ProductSv.java | 10 +++++----- pms-parent/pms-global/src/main/resources/mapper/PltProductMapper.xml | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoPlt/PltProductMapper.java b/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoPlt/PltProductMapper.java index 8218e39..320cc00 100644 --- a/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoPlt/PltProductMapper.java +++ b/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoPlt/PltProductMapper.java @@ -27,7 +27,7 @@ String selectMaxCode(); - boolean exists(@Param("name") String name, @Param("id") Long id); + boolean exists(@Param("name") String name, @Param("type") String type , @Param("id") Long id); PltProduct selectByCode(String productCode); } \ No newline at end of file diff --git a/pms-parent/pms-global/src/main/resources/mapper/PltProductMapper.xml b/pms-parent/pms-global/src/main/resources/mapper/PltProductMapper.xml index ecd826b..255f549 100644 --- a/pms-parent/pms-global/src/main/resources/mapper/PltProductMapper.xml +++ b/pms-parent/pms-global/src/main/resources/mapper/PltProductMapper.xml @@ -211,7 +211,7 @@ select max(code) from plt_product </select> <select id="exists" resultType="java.lang.Boolean"> - select count(1) from plt_product where name = #{name} + select count(1) from plt_product where name = #{name} and type = #{type} <if test="id != null"> and id != #{id} </if> diff --git a/pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/product/ProductSv.java b/pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/product/ProductSv.java index c817ff9..67cfb88 100644 --- a/pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/product/ProductSv.java +++ b/pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/product/ProductSv.java @@ -76,9 +76,9 @@ @Transactional public int save(PltProduct p) { - //鍒ゆ柇浜у搧涓嶈兘閲嶅悕 - if (dao.exists(p.name, p.id)) { - throw new RuntimeException("浜у搧鍚嶇О閲嶅"); + //鍒ゆ柇浜у搧 鍚嶇О鍜屽瀷鍙� 涓嶈兘閲嶅悕 + if (dao.exists(p.name.trim(), p.type.trim() ,p.id)) { + throw new RuntimeException("宸茬粡瀛樺湪鐩稿悓鐨勪骇鍝佸悕绉�&鍨嬪彿"); } int flag=0; do { @@ -114,8 +114,8 @@ @Transactional public int update(PltProduct p) { - if (dao.exists(p.name, p.id)) { - throw new RuntimeException("浜у搧鍚嶇О閲嶅"); + if (dao.exists(p.name.trim(), p.type.trim(),p.id)) { + throw new RuntimeException("宸茬粡瀛樺湪鐩稿悓鐨勪骇鍝佸悕绉�&鍨嬪彿"); } int count = dao.updateByPrimaryKeySelective(p); //鍒犻櫎鏃ф暟鎹�,閲嶆柊鎻掑叆 -- Gitblit v1.8.0