Commit 7224614c by guojuxing

添加判断code不能重复

parent b8389d07
......@@ -155,5 +155,5 @@ public interface TabSysMenuMapper {
* @param menuCode

* @return int


 */
int countByMenuCode(@Param("menuCode") String menuCode);
int countByMenuCode(@Param("menuCode") String menuCode,@Param("menuId") Integer menuId);
}
\ No newline at end of file
......@@ -133,5 +133,5 @@ public interface MenuService {
* @param code

* @return boolean


 */
boolean isRepeatMenuCode(String code);
boolean isRepeatMenuCode(String code, Integer menuId);
}
......@@ -131,8 +131,8 @@ public class MenuServiceImpl implements MenuService {
}
@Override
public boolean isRepeatMenuCode(String code) {
int count = tabSysMenuMapper.countByMenuCode(code);
public boolean isRepeatMenuCode(String code, Integer menuId) {
int count = tabSysMenuMapper.countByMenuCode(code, menuId);
if (count > 0) {
return true;
}
......
......@@ -220,6 +220,11 @@ public class MenuApiServiceImpl implements MenuApiService {
if (!paramsValid.isSuccess()) {
return paramsValid;
}
//验证code是否重复
if (menuService.isRepeatMenuCode(menuDTO.getMenuCode(), menuDTO.getMenuId())) {
return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "code:" + menuDTO.getMenuCode() + "重复");
}
menuService.updatePage(menuDTO);
return ServiceResponse.success();
}
......@@ -408,7 +413,7 @@ public class MenuApiServiceImpl implements MenuApiService {
return paramsValid;
}
//验证code是否重复
if (menuService.isRepeatMenuCode(menuDTO.getMenuCode())) {
if (menuService.isRepeatMenuCode(menuDTO.getMenuCode(), null)) {
return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "code:" + menuDTO.getMenuCode() + "重复");
}
......@@ -428,7 +433,7 @@ public class MenuApiServiceImpl implements MenuApiService {
return paramsValid;
}
//验证code是否重复
if (menuService.isRepeatMenuCode(menuDTO.getMenuCode())) {
if (menuService.isRepeatMenuCode(menuDTO.getMenuCode(), null)) {
return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "code:" + menuDTO.getMenuCode() + "重复");
}
......@@ -475,6 +480,12 @@ public class MenuApiServiceImpl implements MenuApiService {
if (!paramsValid.isSuccess()) {
return paramsValid;
}
//验证code是否重复
if (menuService.isRepeatMenuCode(menuDTO.getMenuCode(), menuDTO.getMenuId())) {
return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "code:" + menuDTO.getMenuCode() + "重复");
}
menuDTO.setProject(record.getProject());
if (!MenuProjectConstants.DEFAULT_PROJECT.equals(menuDTO.getProject())) {
//如果是应用子页面、操作项
......
......@@ -396,5 +396,8 @@
SELECT count(1) from tab_sys_menu
where status = 1
menu_code = #{menuCode}
<if test="menuId != null">
menu_id &lt;&gt; #{menuId}
</if>
</select>
</mapper>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment