-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
lots of thread and user updates (#23)
- Loading branch information
Showing
26 changed files
with
2,180 additions
and
563 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
src/main/java/com/zfgc/zfgbb/controller/ContentController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package com.zfgc.zfgbb.controller; | ||
|
||
import java.net.MalformedURLException; | ||
|
||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.core.io.Resource; | ||
import org.springframework.http.HttpHeaders; | ||
import org.springframework.http.MediaType; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.PathVariable; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import com.zfgc.zfgbb.services.core.ContentService; | ||
|
||
@RestController | ||
@RequestMapping("/content") | ||
public class ContentController extends BaseController { | ||
|
||
@Autowired | ||
private ContentService contentService; | ||
|
||
@GetMapping("image/{resourceId}") | ||
public ResponseEntity getImageResource(@PathVariable("resourceId") Integer resourceId) throws MalformedURLException { | ||
return prepareResource(contentService.getImageResource(resourceId)); | ||
} | ||
|
||
private ResponseEntity prepareResource(Resource resource) { | ||
return ResponseEntity.ok() | ||
.contentType(MediaType.IMAGE_GIF) | ||
.header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"" + resource.getFilename() + "\"") | ||
.body(resource); | ||
} | ||
|
||
} |
41 changes: 41 additions & 0 deletions
41
src/main/java/com/zfgc/zfgbb/dao/core/ContentResourceDao.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package com.zfgc.zfgbb.dao.core; | ||
|
||
import java.util.List; | ||
|
||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Repository; | ||
|
||
import com.zfgc.zfgbb.dao.AbstractDao; | ||
import com.zfgc.zfgbb.dbo.ContentResourceDbo; | ||
import com.zfgc.zfgbb.dbo.ContentResourceDboExample; | ||
import com.zfgc.zfgbb.mappers.ContentResourceDboMapper; | ||
|
||
@Repository | ||
public class ContentResourceDao extends AbstractDao<ContentResourceDboExample, ContentResourceDboMapper, ContentResourceDbo>{ | ||
|
||
@Autowired | ||
public ContentResourceDao(ContentResourceDboMapper mapper) { | ||
super(mapper); | ||
} | ||
|
||
@Override | ||
public ContentResourceDbo get(Integer id) { | ||
return mapper.selectByPrimaryKey(id); | ||
} | ||
|
||
@Override | ||
public List<ContentResourceDbo> get(ContentResourceDboExample ex) { | ||
return mapper.selectByExample(ex); | ||
} | ||
|
||
@Override | ||
protected void update(ContentResourceDbo toSave) { | ||
mapper.updateByPrimaryKey(toSave); | ||
} | ||
|
||
@Override | ||
protected void create(ContentResourceDbo toCreate) { | ||
mapper.insert(toCreate); | ||
} | ||
|
||
} |
Oops, something went wrong.