feat(项目管理产品需求重构): 完善产品中的需求规格功能开发

产品标识不允许重复

Signed-off-by: OTTO <731554297@qq.com>
This commit is contained in:
OTTO 2024-12-09 14:25:14 +08:00
parent 42b5dd4530
commit 95ad6b83b4
4 changed files with 17 additions and 4 deletions

View File

@ -44,6 +44,7 @@ public class PmsProductInputVo
@ApiModelProperty(value = "产品标识", required = true)
@NotNull
@Size(max = 50, message = "长度需要小于50")
private String productIdentifier;
public PmsProduct toPmsProduct(String pmsEnterpriseIdentifier) {

View File

@ -77,7 +77,7 @@ public interface PmsProductMapper
* 根据名称查找产品数量
*
* @param name
* @param pmsEnterpriseId
* @param pmsEnterpriseIdentifier
* @return
*/
Integer selectPmsProductByNameCount(@Param("name") String name, @Param("pmsEnterpriseIdentifier") String pmsEnterpriseIdentifier);
@ -89,4 +89,6 @@ public interface PmsProductMapper
* @return 产品数量
*/
Integer selectPmsProductCount(PmsProductSearchVo pmsProductSearchVo);
Integer selectPmsProductByIdentifierCount(@Param("identifier") String identifier, @Param("pmsEnterpriseIdentifier") String pmsEnterpriseIdentifier);
}

View File

@ -114,10 +114,13 @@ public class PmsProductServiceImpl implements IPmsProductService
* @return 结果
*/
@Override
public String insertPmsProduct(PmsProduct pmsProduct)
{
checkNameDuplicates(pmsProduct.getProductName(), pmsProduct.getPmsEnterpriseIdentifier());
public String insertPmsProduct(PmsProduct pmsProduct) {
PmsEnterprise pmsEnterprise = pmsEnterpriseService.selectPmsEnterpriseByIdentifier(pmsProduct.getPmsEnterpriseIdentifier());
checkNameDuplicates(pmsProduct.getProductName(), pmsProduct.getPmsEnterpriseIdentifier());
Integer count = pmsProductMapper.selectPmsProductByIdentifierCount(pmsProduct.getProductIdentifier(), pmsEnterprise.getEnterpriseIdentifier());
if (count > 0) {
throw new ServiceException("该产品标识在当前企业下已存在(产品标识[%s])", pmsProduct.getProductIdentifier());
}
pmsProduct.setPmsEnterpriseId(pmsEnterprise.getId());
String currentUsername=SecurityUtils.getUsername();
Date now=DateUtils.getNowDate();

View File

@ -109,6 +109,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
left join pms_enterprise as pe on ppd.pms_enterprise_id=pe.id
<include refid="selectWhere"/>
</select>
<select id="selectPmsProductByIdentifierCount" resultType="java.lang.Integer">
select count(0)
from pms_product ppd
left join pms_enterprise as pe on ppd.pms_enterprise_id = pe.id
where ppd.product_identifier = #{identifier}
and pe.enterprise_identifier = #{pmsEnterpriseIdentifier}
</select>
<insert id="insertPmsProduct" parameterType="PmsProduct" useGeneratedKeys="true" keyProperty="id">
insert into pms_product