Skip to content

Commit

Permalink
lots of thread and user updates (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
MGZero authored Oct 8, 2024
1 parent deb6320 commit 61b6d7b
Show file tree
Hide file tree
Showing 26 changed files with 2,180 additions and 563 deletions.
Binary file added backend-assets/img/member-badges/star.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added backend-assets/img/member-badges/staradmin.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion src/main/database/views/CURRENT_MESSAGE_VIEW.sql
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ select m.message_id,
m.thread_id,
h.message_text,
h.message_history_id,
m.post_in_thread
m.post_in_thread,
h.created_ts
from zfgbb.message m
join zfgbb.message_history h on h.message_id = m.message_id and h.current_flag = true
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ private User createGuest() {
guest.setUserId(-1);
guestPerm.setId(2);
guestPerm.setPermissionCode("ZFGC_GUEST");

guest.getPermissions().add(guestPerm);

return guest;
Expand Down
36 changes: 36 additions & 0 deletions src/main/java/com/zfgc/zfgbb/controller/ContentController.java
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 src/main/java/com/zfgc/zfgbb/dao/core/ContentResourceDao.java
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);
}

}
Loading

0 comments on commit 61b6d7b

Please sign in to comment.