Skip to content

BD auth and directory creation added#26

Open
Rainboom7 wants to merge 2 commits intotypeundefined:masterfrom
Rainboom7:master
Open

BD auth and directory creation added#26
Rainboom7 wants to merge 2 commits intotypeundefined:masterfrom
Rainboom7:master

Conversation

@Rainboom7
Copy link
Copy Markdown

Second commit is just some ctrl+alt+l i forgot to press in first

Copy link
Copy Markdown
Owner

@typeundefined typeundefined left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Очень много "мусорных" правок, связанных с форматированием. Это только увеличивает дифф и ухудшает читаемость.
  2. Бизнес-логика не должна присутствовать в контроллере
  3. На мой взгляд, jpa здесь не очень оправдан, это как из пушки по воробьям. Но как бы и так можно, да)

DirectoryContents dirContents;
if (path == null) {
dirContents = explorerService.getRootContents();
System.out.println( path );
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Для логирования мы пользуемся логгером

if (path == null) {
dirContents = explorerService.getRootContents();
System.out.println( path );
if ( path == null || "/".equals( path ) ) {
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/, ./., //// будут резолвиться одинаково в один и тот же каталог. Эта проверка ненадежна

data.put("directory", dirContents);
return new ModelAndView("filesView", data);
dirContents = explorerService.getContentsFiltered( path, new NamePartialMatcher( search ) );
Map<String, Object> data = new HashMap<>( );
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

А зачем появился этот дифф? Значимых правок нет, форматирование странноватое и не соответствует форматированию остального файла

}

@RequestMapping(value = "/login", method = RequestMethod.GET)
public String loginPage(Model model) {
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Лучше вынести в отдельный контроллер



@RequestMapping(path = "/searchAll", method = RequestMethod.GET)
public ModelAndView searchAll(@RequestParam(name = "search") String search,
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Для search тоже лучше завести отдельный контроллер, кстати

@RequestMapping(value = "/createdir", method = RequestMethod.POST)
public String createDir(
@RequestParam("directory") String directory,
@RequestParam(name = "path", required = false) Optional<String> oPath,
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Можно облегчить себе жизнь и заменить Optional<String> на Optional<Path>

throws IOException {
String directoryPath;
String path = oPath.orElse( "" );
if ( path == null ) directoryPath = explorerService.getRootPath( ).resolve( directory ).toString( );
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

path здесь никогда не будет null

String path = oPath.orElse( "" );
if ( path == null ) directoryPath = explorerService.getRootPath( ).resolve( directory ).toString( );
else directoryPath = explorerService.getAbsolutePath( Paths.get( path ) ).resolve( directory ).toString( );
new File( directoryPath ).mkdir( );
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Это должно быть в FileSystemProvider. Контроллер не должен иметь бизнес-логики


return (AppUser) query.getSingleResult();
} catch (NoResultException e) {
return null;
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Зачем??


public class WebUtils {

public static String toString(User user) {
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

А зачем здесь этот метод, тем более статический?

import ru.amm.fileexplorer.server.config.entity.UserRole;

@Repository
@Transactional
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Кстати, транзакция на уровне Repository это почти всегда плохая идея

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants