名称重复性校验

This commit is contained in:
mashuai 2024-04-18 18:14:09 +08:00
parent 03ae671f7b
commit 9e9fb2da60
10 changed files with 37 additions and 13 deletions

View File

@ -1,6 +1,5 @@
package com.bonus.sgzb.base.controller; package com.bonus.sgzb.base.controller;
import com.bonus.sgzb.base.domain.BmProjectInfo; import com.bonus.sgzb.base.domain.BmProjectInfo;
import com.bonus.sgzb.base.service.BmProjectInfoService; import com.bonus.sgzb.base.service.BmProjectInfoService;
import com.bonus.sgzb.common.core.utils.poi.ExcelUtil; import com.bonus.sgzb.common.core.utils.poi.ExcelUtil;
@ -89,7 +88,7 @@ public class BmProjectInfoController extends BaseController{
@PostMapping @PostMapping
public AjaxResult projectInfoAdd(@Validated @RequestBody BmProjectInfo bmProjectInfo) public AjaxResult projectInfoAdd(@Validated @RequestBody BmProjectInfo bmProjectInfo)
{ {
return toAjax(bmProjectInfoService.projectInfoAdd(bmProjectInfo)); return bmProjectInfoService.projectInfoAdd(bmProjectInfo);
} }
/** /**

View File

@ -1,7 +1,5 @@
package com.bonus.sgzb.base.controller; package com.bonus.sgzb.base.controller;
import com.bonus.sgzb.base.domain.BmProjectInfo;
import com.bonus.sgzb.base.domain.BmProjectLot; import com.bonus.sgzb.base.domain.BmProjectLot;
import com.bonus.sgzb.base.service.BmProjectLotService; import com.bonus.sgzb.base.service.BmProjectLotService;
import com.bonus.sgzb.common.core.utils.poi.ExcelUtil; import com.bonus.sgzb.common.core.utils.poi.ExcelUtil;
@ -65,7 +63,7 @@ public class BmProjectLotController extends BaseController {
@Log(title = "参数管理", businessType = BusinessType.INSERT) @Log(title = "参数管理", businessType = BusinessType.INSERT)
@PostMapping @PostMapping
public AjaxResult projectLotAdd(@Validated @RequestBody BmProjectLot bmProjectLot) { public AjaxResult projectLotAdd(@Validated @RequestBody BmProjectLot bmProjectLot) {
return toAjax(bmProjectLotService.projectLotAdd(bmProjectLot)); return bmProjectLotService.projectLotAdd(bmProjectLot);
} }
/** /**

View File

@ -20,4 +20,6 @@ public interface BmProjectInfoMapper {
public int updateBmProjectInfo(BmProjectInfo bmProjectInfo); public int updateBmProjectInfo(BmProjectInfo bmProjectInfo);
public int deleteProjectInfoById(Long proId); public int deleteProjectInfoById(Long proId);
int selectByName(String proName);
} }

View File

@ -19,4 +19,6 @@ public interface BmProjectLotMapper {
public int updateBmProjectLot(BmProjectLot bmProjectLot); public int updateBmProjectLot(BmProjectLot bmProjectLot);
public int deleteProjectLotById(Long lotId); public int deleteProjectLotById(Long lotId);
int selectByName(String lotName);
} }

View File

@ -1,6 +1,7 @@
package com.bonus.sgzb.base.service; package com.bonus.sgzb.base.service;
import com.bonus.sgzb.base.domain.BmProjectInfo; import com.bonus.sgzb.base.domain.BmProjectInfo;
import com.bonus.sgzb.common.core.web.domain.AjaxResult;
import java.util.List; import java.util.List;
@ -11,7 +12,7 @@ public interface BmProjectInfoService {
public List<BmProjectInfo> getProjectLot(); public List<BmProjectInfo> getProjectLot();
public int projectInfoAdd(BmProjectInfo bmProjectInfo); public AjaxResult projectInfoAdd(BmProjectInfo bmProjectInfo);
public void remove(Long[] proIds); public void remove(Long[] proIds);

View File

@ -2,6 +2,7 @@ package com.bonus.sgzb.base.service;
import com.bonus.sgzb.base.domain.BmProjectLot; import com.bonus.sgzb.base.domain.BmProjectLot;
import com.bonus.sgzb.common.core.web.domain.AjaxResult;
import java.util.List; import java.util.List;
@ -10,7 +11,7 @@ public interface BmProjectLotService {
public List<BmProjectLot> getProjectLot(BmProjectLot bmProjectLot); public List<BmProjectLot> getProjectLot(BmProjectLot bmProjectLot);
public int projectLotAdd(BmProjectLot bmProjectLot); public AjaxResult projectLotAdd(BmProjectLot bmProjectLot);
public void remove(Long[] proIds); public void remove(Long[] proIds);

View File

@ -5,6 +5,7 @@ import com.bonus.sgzb.base.mapper.BmProjectInfoMapper;
import com.bonus.sgzb.base.service.BmProjectInfoService; import com.bonus.sgzb.base.service.BmProjectInfoService;
import com.bonus.sgzb.common.core.exception.ServiceException; import com.bonus.sgzb.common.core.exception.ServiceException;
import com.bonus.sgzb.common.core.utils.StringUtils; import com.bonus.sgzb.common.core.utils.StringUtils;
import com.bonus.sgzb.common.core.web.domain.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -32,8 +33,12 @@ public class BmProjectInfoServiceImpl implements BmProjectInfoService {
} }
@Override @Override
public int projectInfoAdd(BmProjectInfo bmProjectInfo) { public AjaxResult projectInfoAdd(BmProjectInfo bmProjectInfo) {
return bmProjectInfoMapper.projectInfoAdd(bmProjectInfo); int count = bmProjectInfoMapper.selectByName(bmProjectInfo.getProName());
if (count != 0) {
return AjaxResult.error("新增工程项目名称重复,请重新提交!!!");
}
return AjaxResult.success(bmProjectInfoMapper.projectInfoAdd(bmProjectInfo));
} }
@Override @Override

View File

@ -4,6 +4,7 @@ package com.bonus.sgzb.base.service.impl;
import com.bonus.sgzb.base.domain.BmProjectLot; import com.bonus.sgzb.base.domain.BmProjectLot;
import com.bonus.sgzb.base.mapper.BmProjectLotMapper; import com.bonus.sgzb.base.mapper.BmProjectLotMapper;
import com.bonus.sgzb.base.service.BmProjectLotService; import com.bonus.sgzb.base.service.BmProjectLotService;
import com.bonus.sgzb.common.core.web.domain.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -28,8 +29,12 @@ public class BmProjectLotServiceImpl implements BmProjectLotService {
} }
@Override @Override
public int projectLotAdd(BmProjectLot bmProjectLot) { public AjaxResult projectLotAdd(BmProjectLot bmProjectLot) {
return bmProjectLotMapper.projectLotAdd(bmProjectLot); int count = bmProjectLotMapper.selectByName(bmProjectLot.getLotName());
if (count != 0) {
return AjaxResult.error("新增标段工程名称重复,请重新提交!!!");
}
return AjaxResult.success(bmProjectLotMapper.projectLotAdd(bmProjectLot));
} }
@Override @Override

View File

@ -138,9 +138,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
and a.company_id = #{companyId} and a.company_id = #{companyId}
</if> </if>
</select> </select>
<select id="selectByName" resultType="java.lang.Integer">
select count(*) from bm_project_info
where
1 = 1
<if test="proName != null and proName != ''">and pro_name = #{proName}</if>
</select>
<insert id="projectInfoAdd" parameterType="com.bonus.sgzb.base.domain.BmProjectInfo"> <insert id="projectInfoAdd" parameterType="com.bonus.sgzb.base.domain.BmProjectInfo">
insert into bm_project_info ( insert into bm_project_info (
<if test="proName != null and proName != '' ">pro_name,</if> <if test="proName != null and proName != '' ">pro_name,</if>

View File

@ -86,6 +86,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</if> </if>
ORDER BY a.lot_id DESC ORDER BY a.lot_id DESC
</select> </select>
<select id="selectByName" resultType="java.lang.Integer">
select count(*) from bm_project_lot
where
1 = 1
<if test="lotName != null and lotName != ''">and lot_name = #{lotName}</if>
</select>
<insert id="projectLotAdd" parameterType="com.bonus.sgzb.base.domain.BmProjectLot"> <insert id="projectLotAdd" parameterType="com.bonus.sgzb.base.domain.BmProjectLot">
insert into bm_project_lot ( insert into bm_project_lot (
<if test="lotName != null and lotName != '' ">lot_name,</if> <if test="lotName != null and lotName != '' ">lot_name,</if>