| | |
| | | @Autowired |
| | | private UserService userService; |
| | | |
| | | protected Long getUserId(){ |
| | | protected Long getUserId() { |
| | | return Long.parseLong(String.valueOf(request.getAttribute("userId"))); |
| | | } |
| | | |
| | | protected User getUser(){ |
| | | protected User getUser() { |
| | | User user = userService.selectById(getUserId()); |
| | | if (null == user) { |
| | | throw new CoolException(BaseRes.DENIED); |
| | |
| | | return user; |
| | | } |
| | | |
| | | protected String getComment(Class<?> cls, String fieldName){ |
| | | protected String getComment(Class<?> cls, String fieldName) { |
| | | Field[] fields = Cools.getAllFields(cls); |
| | | for (Field field : fields){ |
| | | if (fieldName.equals(field.getName())){ |
| | | for (Field field : fields) { |
| | | if (fieldName.equals(field.getName())) { |
| | | return field.getAnnotation(ApiModelProperty.class).value(); |
| | | } |
| | | } |
| | |
| | | * @param set 排除字段集合 |
| | | * @param condition 搜索内容 |
| | | */ |
| | | protected <T> void allLike(Class<T> cls, Set<String> set, EntityWrapper<T> wrapper, String condition){ |
| | | protected <T> void allLike(Class<T> cls, Set<String> set, EntityWrapper<T> wrapper, String condition) { |
| | | if (Cools.isEmpty(condition)) { |
| | | return; |
| | | } |
| | | List<String> columns = new ArrayList<>(); |
| | | for (Field field :Cools.getAllFields(cls)){ |
| | | for (Field field : Cools.getAllFields(cls)) { |
| | | if (Modifier.isFinal(field.getModifiers()) |
| | | || Modifier.isStatic(field.getModifiers()) |
| | | || Modifier.isTransient(field.getModifiers())){ |
| | | || Modifier.isTransient(field.getModifiers())) { |
| | | continue; |
| | | } |
| | | String column = null; |
| | |
| | | if (columns.isEmpty()) { |
| | | return; |
| | | } |
| | | for (int i=0;i<columns.size();i++){ |
| | | if (i==0){ |
| | | for (int i = 0; i < columns.size(); i++) { |
| | | if (i == 0) { |
| | | wrapper.andNew(); |
| | | } else { |
| | | wrapper.or(); |