Commit 1623d626 by guojuxing

添加判断code不能重复

parent 4a7aad75
......@@ -146,4 +146,14 @@ public interface TabSysMenuMapper {
List<TabSysMenu> listMenuTree(@Param("project") String project);
List<TabSysMenu> selectByProjectList(@Param("projectList")List<String> projectList);
/**
* 相同code个数
* @Title: countByMenuCode

* @Description:

 * @author guojuxing
* @param menuCode

* @return int


 */
int countByMenuCode(@Param("menuCode") String menuCode);
}
\ No newline at end of file
......@@ -124,4 +124,14 @@ public interface MenuService {
* @return java.util.List<com.gic.auth.entity.TabSysMenu>


 */
List<TabSysMenu> selectByProjectList(List<String> projectList);
/**
* 是否重复页面code
* @Title: isRepeatMenuCode

* @Description:

 * @author guojuxing
* @param code

* @return boolean


 */
boolean isRepeatMenuCode(String code);
}
......@@ -130,6 +130,15 @@ public class MenuServiceImpl implements MenuService {
return tabSysMenuMapper.selectByProjectList(projectList);
}
@Override
public boolean isRepeatMenuCode(String code) {
int count = tabSysMenuMapper.countByMenuCode(code);
if (count > 0) {
return true;
}
return false;
}
private void updateSort(Integer sort, Integer id) {
TabSysMenu record = new TabSysMenu();
record.setMenuId(id);
......
......@@ -407,6 +407,11 @@ public class MenuApiServiceImpl implements MenuApiService {
if (!paramsValid.isSuccess()) {
return paramsValid;
}
//验证code是否重复
if (menuService.isRepeatMenuCode(menuDTO.getMenuCode())) {
return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "code:" + menuDTO.getMenuCode() + "重复");
}
setMenuVersion(menuDTO);
setNormalFieldValue(menuDTO);
menuService.savePage(menuDTO);
......@@ -422,6 +427,11 @@ public class MenuApiServiceImpl implements MenuApiService {
if (!paramsValid.isSuccess()) {
return paramsValid;
}
//验证code是否重复
if (menuService.isRepeatMenuCode(menuDTO.getMenuCode())) {
return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "code:" + menuDTO.getMenuCode() + "重复");
}
setNormalFieldValue(menuDTO, record);
if (!MenuProjectConstants.DEFAULT_PROJECT.equals(menuDTO.getProject())) {
//如果是应用子页面、操作项
......
......@@ -391,4 +391,10 @@
</foreach>
</if>
</select>
<select id="countByMenuCode" resultType="int">
SELECT count(1) from tab_sys_menu
where status = 1
menu_code = #{menuCode}
</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