瀏覽代碼

1、listMenus即可roleId可传可不传 2、countByCondition转义问题

shiqian 4 年之前
父節點
當前提交
9f0ef1dcb4

+ 1 - 1
boman-modules/boman-system/src/main/java/com/boman/system/controller/SysMenuController.java

@@ -137,7 +137,7 @@ public class SysMenuController extends BaseController
      * @return com.boman.common.core.web.domain.AjaxResult
      */
     @GetMapping(value = "/listMenus/roleId/{roleId}/menuId/{menuId}")
-    public AjaxResult listMenus(@PathVariable("roleId") Long roleId, @PathVariable("menuId") Long menuId) {
+    public AjaxResult listMenus(@PathVariable("roleId") Long roleId, @PathVariable(value = "menuId", required = false) Long menuId) {
         return AjaxResult.success(menuService.listMenus(roleId, menuId));
     }
 

+ 5 - 1
boman-modules/boman-system/src/main/resources/mapper/system/SysRoleMenuMapper.xml

@@ -23,10 +23,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 	</select>
 
 	<select id="listByRoleIdMenuIdList" resultMap="SysRoleMenuResult">
-		select * from sys_role_menu where role_id = #{roleId} and menu_id in
+		select * from sys_role_menu where menu_id in
 		<foreach collection="menuIdList" item="menuId" open="(" separator="," close=")">
 			#{menuId}
 		</foreach>
+
+		<if test="roleId != null and roleId != ''">
+			and role_id = #{roleId}
+		</if>
 	</select>
 
 	<delete id="deleteRoleMenuByRoleId" parameterType="Long">

+ 7 - 7
boman-web-core/src/main/java/com/boman/web/core/mapper/StandardlyMapper.java

@@ -632,7 +632,7 @@ public interface StandardlyMapper {
                 Object valueObj = entry.getValue();
                 List<String> types = ((List<String>) valueObj);
                 /** {@link com.boman.web.core.utils.ColumnUtils.packColCondition} 这里是拼参数的地方 **/
-                String value = types.get(0);
+                Object value = types.get(0);
                 String queryType = types.get(1);
                 String columnType = types.get(2);
                 conditionSql.append(key).append(covert(queryType, columnType, key, value)).append(" and ");
@@ -656,24 +656,24 @@ public interface StandardlyMapper {
             Object value;
             switch (queryType) {
                 case EQ:
-                    value = needEscape ? escapeStr((String) valueObj) : valueObj;
+                    value = needEscape ? escapeStr(String.valueOf(valueObj)) : valueObj;
                     return " = " + value;
                 case LIKE:
                     return " like concat('%', #{condition." + key + "}, '%')";
                 case NE:
-                    value = needEscape ? escapeStr((String) valueObj) : valueObj;
+                    value = needEscape ? escapeStr(String.valueOf(valueObj)) : valueObj;
                     return " != " + value;
                 case GT:
-                    value = needEscape ? escapeStr((String) valueObj) : valueObj;
+                    value = needEscape ? escapeStr(String.valueOf(valueObj)) : valueObj;
                     return " &gt; " + value;
                 case GTE:
-                    value = needEscape ? escapeStr((String) valueObj) : valueObj;
+                    value = needEscape ? escapeStr(String.valueOf(valueObj)) : valueObj;
                     return " &gt;= " + value;
                 case LT:
-                    value = needEscape ? escapeStr((String) valueObj) : valueObj;
+                    value = needEscape ? escapeStr(String.valueOf(valueObj)) : valueObj;
                     return " &lt; " + value;
                 case LTE:
-                    value = needEscape ? escapeStr((String) valueObj) : valueObj;
+                    value = needEscape ? escapeStr(String.valueOf(valueObj)) : valueObj;
                     return " &lt;= " + value;
                 default:
                     // in

+ 1 - 1
boman-web-core/src/main/java/com/boman/web/core/utils/ColumnUtils.java

@@ -261,7 +261,7 @@ public class ColumnUtils {
                 // long string collection 暂时只作此三种类型判断
                 if (column.getColumnName().equalsIgnoreCase(key) && ObjectUtils.isNotEmpty(value)) {
                     // columnType 作为判断需不需要转义的一个标准,防止索引失效
-                    packColCondition.put(key, Lists.newArrayList(String.valueOf(value), column.getQueryType(), column.getColumnType()));
+                    packColCondition.put(key, Lists.newArrayList(value, column.getQueryType(), column.getColumnType()));
                     break;
                 }
             }