コード例 #1
0
 @RequestMapping(value = "hunter/addressbooks", method = RequestMethod.GET)
 public Object query(
     @RequestParam(required = false) Integer offset,
     @RequestParam(required = false) Integer limit,
     @RequestParam(required = false) String sort,
     @RequestParam(required = false) String order,
     @RequestParam(required = false) String search,
     @RequestParam(required = false) String filter,
     @RequestParam(required = false) Long accountid) {
   Query<Addressbook> q = new Query<Addressbook>();
   q.setOffset(offset);
   q.setLimit(limit);
   q.setSort(sort);
   q.setOrder(order);
   if (accountid != null) {
     q.setAccountid(accountid);
   }
   if (filter != null) {
     try {
       ObjectMapper objectMapper = new ObjectMapper();
       Addressbook c = objectMapper.readValue(filter, Addressbook.class);
       q.setE(c);
     } catch (Exception e) {
     }
   }
   return addressbookService.query(q);
 }
コード例 #2
0
 @RequestMapping(value = "hunter/addressbooks/resumes/{id}", method = RequestMethod.POST)
 public Object insertResumes(@PathVariable Long id, @RequestParam Long rid) {
   try {
     addressbookService.insertAddressbookResumes(id, rid);
   } catch (DuplicateKeyException e) {
     //
   }
   return true;
 }
コード例 #3
0
  @RequestMapping(value = "hunter/addressbooks/upload", method = RequestMethod.POST)
  public Object upload(
      @RequestParam Long id,
      @RequestParam String companyName,
      @RequestParam(required = false) MultipartFile file) {
    Addressbook book = new Addressbook();
    book.setId(id);

    String fileName = file.getOriginalFilename();
    book.setAttachmentName(fileName);
    String pathname = path + companyName + "/";
    book.setAttachmentPath(pathname);
    try {
      File directory = new File(pathname + fileName);
      if (!directory.exists()) {
        directory.mkdirs();
      }
      file.transferTo(directory);
    } catch (Exception e) {
      throw new RuntimeException(e);
    }
    addressbookService.update(book);
    return true;
  }
コード例 #4
0
 /**
  * @RequestMapping(value = "hunter/addressbooks", method = RequestMethod.POST) public Object
  * save(@RequestParam(required = false) MultipartFile file, @RequestParam String
  * companyName, @RequestParam(required = false) String address, @RequestParam(required = false)
  * String phone, @RequestParam(required = false) String tag, @RequestParam(required = false)
  * String intro, @RequestParam(required = false) String staffintro, @RequestParam(required =
  * false) String architecture, @RequestParam(required = false) String remark) { Addressbook book =
  * new Addressbook(); book.setCompanyName(companyName); book.setAddress(address);
  * book.setPhone(phone); book.setRemark(remark); book.setArchitecture(architecture);
  * book.setIntro(intro); book.setStaffintro(staffintro); book.setTag(tag);
  *
  * <p>String fileName = file.getOriginalFilename(); book.setAttachmentName(fileName); String
  * pathname = path + companyName + "/" + fileName; book.setAttachmentPath(pathname); try { File
  * directory = new File(pathname); if (!directory.exists()) { directory.mkdirs(); }
  * file.transferTo(directory); } catch (Exception e) { throw new RuntimeException(e); }
  * addressbookService.save(book); return true; }
  */
 @RequestMapping(value = "hunter/addressbooks", method = RequestMethod.POST)
 public Object save(@RequestBody Addressbook book) {
   addressbookService.save(book);
   return true;
 }
コード例 #5
0
 @RequestMapping(value = "hunter/addressbooks/{id}", method = RequestMethod.GET)
 public Object get(@PathVariable Long id) {
   return addressbookService.getById(id);
 }
コード例 #6
0
  @RequestMapping(value = "hunter/addressbooks/attachment/{id}", method = RequestMethod.GET)
  public Object getAttachments(@PathVariable Long id, @RequestParam String filename) {
    Addressbook book = addressbookService.getAttachment(id);
    int times = book.getDownloadtimes();
    String today = DateFormatUtils.format(new Date(), "yyyy-MM-dd");
    boolean isToday = today.equals(book.getDownloaddate());

    if (isToday && times == 10) {
      try {
        String msg = new String("此目标公司通讯录今天下载次数已达10次,不能继续下载".getBytes("UTF-8"), "iso-8859-1");
        return new ResponseEntity<>(msg, HttpStatus.OK);
      } catch (UnsupportedEncodingException e) {
        throw new RuntimeException(e);
      }
    }
    boolean downloadStatus = false;
    Map<String, Object> map = new HashMap<String, Object>();
    map.put("id", id);

    while (!isToday || (isToday && times <= 10)) {
      map.put("downloaddate", book.getDownloaddate());
      map.put("downloadtimes", times);
      if (!isToday) {
        map.put("newdate", today);
        map.put("newtimes", 1);
      } else {
        map.put("newtimes", times + 1);
      }
      if (addressbookService.updateDownloadtimes(map) > 0) {
        downloadStatus = true;
        break;
      }
      book = addressbookService.getAttachment(id);
      times = book.getDownloadtimes();
      isToday = today.equals(book.getDownloaddate());
    }
    if (!downloadStatus) {
      try {
        String msg = new String("此目标公司通讯录今天下载次数已达10次,不能继续下载".getBytes("UTF-8"), "iso-8859-1");
        return new ResponseEntity<>(msg, HttpStatus.OK);
      } catch (UnsupportedEncodingException e) {
        throw new RuntimeException(e);
      }
    }

    addressbookService.insertDownloadLog(id, filename, book.getCompanyName());

    String pathname = book.getAttachmentPath() + filename;
    File file = new File(pathname);
    HttpHeaders headers = new HttpHeaders();

    try {
      String fileName = new String(filename.getBytes("UTF-8"), "iso-8859-1"); // 为了解决中文名称乱码问题
      headers.setContentDispositionFormData("attachment", fileName);
      headers.setContentType(MediaType.APPLICATION_OCTET_STREAM);
      return new ResponseEntity<byte[]>(
          FileUtils.readFileToByteArray(file), headers, HttpStatus.OK);
    } catch (IOException e) {
      throw new RuntimeException(e);
    }
  }
コード例 #7
0
 @RequestMapping(value = "hunter/addressbooks/resumes/{id}", method = RequestMethod.PUT)
 public Object updateResumes(@PathVariable Long id, @RequestBody AddressbookResume ar) {
   ar.setAddressbookid(id);
   addressbookService.updateAddressbookResumes(ar);
   return true;
 }
コード例 #8
0
 @RequestMapping(value = "hunter/addressbooks/resumes/{id}", method = RequestMethod.GET)
 public Object getAddressbookResume(@PathVariable Long id) {
   AddressbookResume ar = new AddressbookResume();
   ar.setId(id);
   return addressbookService.getAddressbookResumeById(ar);
 }
コード例 #9
0
 @RequestMapping(value = "hunter/addressbooks/resumes/{id}", method = RequestMethod.DELETE)
 public Object deleteResumes(@PathVariable Long id, @RequestParam Long rid) {
   addressbookService.deleteAddressbookResumes(id, rid);
   return true;
 }
コード例 #10
0
 @RequestMapping(value = "hunter/addressbooks", method = RequestMethod.DELETE)
 public Object delete(@RequestBody Ids ids) {
   addressbookService.deleteByIds(ids);
   return true;
 }
コード例 #11
0
 @RequestMapping(value = "hunter/addressbooks/{id}", method = RequestMethod.PUT)
 public Object update(@PathVariable Long id, @RequestBody Addressbook book) {
   book.setId(id);
   addressbookService.update(book);
   return true;
 }