// Path: IBServer/src/main/java/org/ironbrain/dao/AllDao.java
// public class AllDao {
//     @Autowired
//     protected SectionDao sectionDao;
// 
//     @Autowired
//     protected FieldDao fieldDao;
// 
//     @Autowired
//     protected TicketDao ticketDao;
// 
//     @Autowired
//     protected UserDao userDao;
// 
//     @Autowired
//     protected RemindDao remindDao;
// 
//     @Autowired
//     protected ExamDao examDao;
// 
//     @Autowired
//     protected TryDao tryDao;
// 
//     @Autowired
//     protected DirectionDao directionDao;
// 
//     @Autowired
//     protected SectionToFieldDao secToFDao;
// 
//     @Autowired
//     protected DirectionToFieldDao dirToFDao;
// }
// 
// Path: IBServer/src/main/java/org/ironbrain/utils/DateUtils.java
// public class DateUtils{
// 
//     public static String getNiceDate(long ms){
//         Date date = new Date(ms);
//         return new SimpleDateFormat("dd.MM.yyyy HH:mm:ss").format(date);
//     }
// 
//     public static String getUniqueFileName(){
//         return new SimpleDateFormat("yyyy_MM_dd__HH_mm_ss_SSS").format(new Date(System.currentTimeMillis()));
//     }
// }


import com.google.common.base.Joiner;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang3.mutable.Mutable;
import org.apache.commons.lang3.mutable.MutableObject;
import org.apache.commons.lang3.tuple.Pair;
import org.ironbrain.core.*;
import org.ironbrain.dao.AllDao;
import org.ironbrain.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.io.File;
import java.io.IOException;
import java.nio.file.Path;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
    }


    @RequestMapping(method = RequestMethod.GET, value = "/paste_section")
    @ResponseBody
    public Result pastSection(@RequestParam Integer parent) {
        Section section = sectionDao.getSection(data.getBufferSectionId());
        List<Section> parentPath = sectionDao.getPath(parent);

        if (parentPath.contains(section)) {
            return Result.getError("Рекурсивное добавление!");
        }

        section.setParent(parent);
        sectionDao.update(section);

        data.setBufferSectionId(null);

        return Result.getOk();
    }

    @RequestMapping(method = RequestMethod.POST, value = "/upload_file")
    @ResponseBody
    public Result uploadFileHandler(@RequestParam MultipartFile file) {
        String extension = FilenameUtils.getExtension(file.getOriginalFilename());

        try {
            File userHomeDir = data.getHomeDir();
            File userFilesDir = new File(userHomeDir, User.FILES_DIR);
            File userCommonsFir = new File(userFilesDir, User.COMMONS_DIR);
// Path: IBServer/src/main/java/org/ironbrain/dao/AllDao.java
// public class AllDao {
//     @Autowired
//     protected SectionDao sectionDao;
// 
//     @Autowired
//     protected FieldDao fieldDao;
// 
//     @Autowired
//     protected TicketDao ticketDao;
// 
//     @Autowired
//     protected UserDao userDao;
// 
//     @Autowired
//     protected RemindDao remindDao;
// 
//     @Autowired
//     protected ExamDao examDao;
// 
//     @Autowired
//     protected TryDao tryDao;
// 
//     @Autowired
//     protected DirectionDao directionDao;
// 
//     @Autowired
//     protected SectionToFieldDao secToFDao;
// 
//     @Autowired
//     protected DirectionToFieldDao dirToFDao;
// }
// 
// Path: IBServer/src/main/java/org/ironbrain/utils/DateUtils.java
// public class DateUtils{
// 
//     public static String getNiceDate(long ms){
//         Date date = new Date(ms);
//         return new SimpleDateFormat("dd.MM.yyyy HH:mm:ss").format(date);
//     }
// 
//     public static String getUniqueFileName(){
//         return new SimpleDateFormat("yyyy_MM_dd__HH_mm_ss_SSS").format(new Date(System.currentTimeMillis()));
//     }
// }


// Path: IBServer/src/main/java/org/ironbrain/APIController.java
import com.google.common.base.Joiner;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang3.mutable.Mutable;
import org.apache.commons.lang3.mutable.MutableObject;
import org.apache.commons.lang3.tuple.Pair;
import org.ironbrain.core.*;
import org.ironbrain.dao.AllDao;
import org.ironbrain.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.io.File;
import java.io.IOException;
import java.nio.file.Path;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

    }


    @RequestMapping(method = RequestMethod.GET, value = "/paste_section")
    @ResponseBody
    public Result pastSection(@RequestParam Integer parent) {
        Section section = sectionDao.getSection(data.getBufferSectionId());
        List<Section> parentPath = sectionDao.getPath(parent);

        if (parentPath.contains(section)) {
            return Result.getError("Рекурсивное добавление!");
        }

        section.setParent(parent);
        sectionDao.update(section);

        data.setBufferSectionId(null);

        return Result.getOk();
    }

    @RequestMapping(method = RequestMethod.POST, value = "/upload_file")
    @ResponseBody
    public Result uploadFileHandler(@RequestParam MultipartFile file) {
        String extension = FilenameUtils.getExtension(file.getOriginalFilename());

        try {
            File userHomeDir = data.getHomeDir();
            File userFilesDir = new File(userHomeDir, User.FILES_DIR);
            File userCommonsFir = new File(userFilesDir, User.COMMONS_DIR);
            File thisFile = new File(userCommonsFir, DateUtils.getUniqueFileName() + "." + extension);