Junjie
1 天以前 66a9fc7a0065c4b1f0d488018659da98ee8594e7
src/main/java/com/zy/system/controller/ResourceController.java
@@ -8,6 +8,7 @@
import com.core.common.DateUtils;
import com.core.common.R;
import com.core.controller.AbstractBaseController;
import com.zy.common.i18n.I18nMessageService;
import com.zy.system.entity.Resource;
import com.zy.system.service.ResourceService;
import org.springframework.beans.factory.annotation.Autowired;
@@ -20,6 +21,8 @@
    @Autowired
    private ResourceService resourceService;
    @Autowired
    private I18nMessageService i18nMessageService;
    @RequestMapping(value = "/resource/{id}/auth")
    @ManagerAuth
@@ -117,7 +120,12 @@
        for (Resource resource : page.getRecords()){
            Map<String, Object> map = new HashMap<>();
            map.put("id", resource.getId());
            map.put("value", resource.getName().concat("(").concat(resource.getLevel$().substring(0, 2).concat(")")));
            String levelText = i18nMessageService.translateLegacy(Cools.isEmpty(resource.getLevel$()) ? "" : resource.getLevel$());
            String localizedName = i18nMessageService.resolveResourceText(resource.getName(), resource.getCode(), resource.getId());
            String shortLevelText = levelText.matches(".*[\\u4E00-\\u9FA5].*")
                    ? levelText.substring(0, Math.min(2, levelText.length()))
                    : levelText;
            map.put("value", localizedName.concat("(").concat(shortLevelText).concat(")"));
            result.add(map);
        }
        return R.ok(result);
@@ -137,7 +145,11 @@
        else {
            wrapper.orderBy("sort");
        }
        return R.parse("0-操作成功").add(resourceService.selectList(wrapper));
        List<Resource> resources = resourceService.selectList(wrapper);
        for (Resource resource : resources) {
            resource.setName(i18nMessageService.resolveResourceText(resource.getName(), resource.getCode(), resource.getId()));
        }
        return R.parse("0-操作成功").add(resources);
    }
}