feat: 一些调整
This commit is contained in:
parent
dd3030050a
commit
0224018087
|
|
@ -55,7 +55,7 @@ public class FileController extends ControllerBase {
|
|||
,@Valid @NotNull @RequestParam("source") Byte source
|
||||
,@Valid @NotNull @RequestParam("sourceId") Integer sourceId) {
|
||||
try {
|
||||
String url=fileUploadService.upload(buildFilePath(file.getOriginalFilename()), file);
|
||||
String url=fileUploadService.upload(buildFilePath(file), file);
|
||||
fileUploadRecordService.save(buildFileUploadRecord(source,sourceId,file,url));
|
||||
return ApiResult.success(url);
|
||||
} catch (Exception ex) {
|
||||
|
|
@ -63,9 +63,13 @@ public class FileController extends ControllerBase {
|
|||
}
|
||||
}
|
||||
|
||||
private String buildFilePath(String fileName) {
|
||||
return StrUtil.format("admin/{}/{}/{}/{}", LocalDateTime.now().format(FORMATTER), AdminUserUtil.getUserId(),
|
||||
RandomUtil.randomString(4), fileName);
|
||||
private String buildFilePath(MultipartFile file) {
|
||||
return StrUtil.format("admin/{}/{}/{}{}", LocalDateTime.now().format(FORMATTER), AdminUserUtil.getUserId(),
|
||||
RandomUtil.randomString(6),getExtensions(file));
|
||||
}
|
||||
|
||||
private String getExtensions(MultipartFile file){
|
||||
return file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf("."));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -84,7 +88,7 @@ public class FileController extends ControllerBase {
|
|||
List<String> list = new ArrayList<>();
|
||||
List<FileUploadRecord> records = new ArrayList<>();
|
||||
for (MultipartFile f : files) {
|
||||
String url=fileUploadService.upload(buildFilePath(f.getOriginalFilename()), f);
|
||||
String url=fileUploadService.upload(buildFilePath(f), f);
|
||||
list.add(url);
|
||||
records.add(buildFileUploadRecord(source,sourceId,f,url));
|
||||
}
|
||||
|
|
@ -103,7 +107,7 @@ public class FileController extends ControllerBase {
|
|||
@PostMapping("uploadSingleFile1")
|
||||
public ApiResult<String> uploadSingleFile1(@Valid @NotNull @RequestParam("file") MultipartFile file) {
|
||||
try {
|
||||
String url=fileUploadService.upload(buildFilePath(file.getOriginalFilename()), file);
|
||||
String url=fileUploadService.upload(buildFilePath(file), file);
|
||||
return ApiResult.success(url);
|
||||
}catch (Exception ex){
|
||||
throw new NflgException(STATE.BusinessError,"上传文件失败:"+ex.getMessage());
|
||||
|
|
|
|||
|
|
@ -2,10 +2,13 @@ package com.nflg.mobilebroken.admin.controller;
|
|||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.nflg.mobilebroken.admin.annotation.ApiMark;
|
||||
import com.nflg.mobilebroken.common.constant.Constant;
|
||||
import com.nflg.mobilebroken.common.pojo.ApiResult;
|
||||
import com.nflg.mobilebroken.common.pojo.PageData;
|
||||
import com.nflg.mobilebroken.common.pojo.request.AdminMessageSearchRequest;
|
||||
import com.nflg.mobilebroken.common.pojo.request.MessageConfigRequest;
|
||||
import com.nflg.mobilebroken.common.pojo.vo.AdminMessageVO;
|
||||
import com.nflg.mobilebroken.common.pojo.vo.MessageConfigVO;
|
||||
import com.nflg.mobilebroken.common.util.AdminUserUtil;
|
||||
import com.nflg.mobilebroken.common.util.PageUtil;
|
||||
import com.nflg.mobilebroken.repository.entity.AppUser;
|
||||
|
|
@ -13,15 +16,16 @@ import com.nflg.mobilebroken.repository.entity.AppUserApplyfor;
|
|||
import com.nflg.mobilebroken.repository.entity.Ticket;
|
||||
import com.nflg.mobilebroken.repository.service.*;
|
||||
import com.nflg.mobilebroken.starter.annotation.MethodInfoMark;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.data.redis.core.HashOperations;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.Valid;
|
||||
import java.security.Principal;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
|
|
@ -48,6 +52,9 @@ public class MessageController extends ControllerBase {
|
|||
@Resource
|
||||
private IAppUserApplyforService appUserApplyforService;
|
||||
|
||||
@Resource
|
||||
private RedisTemplate<String, Object> redisTemplate;
|
||||
|
||||
/**
|
||||
* 搜索消息
|
||||
* @param request 请求参数
|
||||
|
|
@ -96,4 +103,44 @@ public class MessageController extends ControllerBase {
|
|||
adminMessageService.setNotRead(ids);
|
||||
return ApiResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取未读消息
|
||||
* @param num 获取未读消息的数量
|
||||
* @return 未读消息列表
|
||||
*/
|
||||
@GetMapping("getNotReadMessages")
|
||||
public ApiResult<PageData<AdminMessageVO>> getNotReadMessages(@RequestParam(defaultValue = "10") Integer num) {
|
||||
return ApiResult.success(adminMessageService.getNotReadMessage(AdminUserUtil.getUserId(), num));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取消息配置
|
||||
* @return 消息配置
|
||||
*/
|
||||
@GetMapping("getConfig")
|
||||
public ApiResult<MessageConfigVO> getConfig(){
|
||||
HashOperations<String, String, Object> hashOps = redisTemplate.opsForHash();
|
||||
Map<String, Object> maps = hashOps.entries("message:config:admin:" + AdminUserUtil.getUserId());
|
||||
return ApiResult.success(new MessageConfigVO()
|
||||
.setAppNotifyEnabled((Boolean) maps.getOrDefault(Constant.REDIS_KEY_MESSAGECONFIG_APP, true))
|
||||
.setEmailNotifyEnabled((Boolean) maps.getOrDefault(Constant.REDIS_KEY_MESSAGECONFIG_EMAIL, true))
|
||||
.setWxNotifyEnabled((Boolean) maps.getOrDefault(Constant.REDIS_KEY_MESSAGECONFIG_WX, true))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置消息配置
|
||||
* @param request 消息配置请求
|
||||
*/
|
||||
@PostMapping("setConfig")
|
||||
public ApiResult<Void> setConfig(@Valid @RequestBody MessageConfigRequest request) {
|
||||
Map<String, Object> maps = new HashMap<>();
|
||||
maps.put(Constant.REDIS_KEY_MESSAGECONFIG_WX, request.isWxNotifyEnabled());
|
||||
maps.put(Constant.REDIS_KEY_MESSAGECONFIG_EMAIL, request.isEmailNotifyEnabled());
|
||||
maps.put(Constant.REDIS_KEY_MESSAGECONFIG_APP, request.isAppNotifyEnabled());
|
||||
HashOperations<String, String, Object> operations = redisTemplate.opsForHash();
|
||||
operations.putAll("message:config:admin:" + AdminUserUtil.getUserId(), maps);
|
||||
return ApiResult.success();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ public class FileController extends ControllerBase {
|
|||
,@Valid @NotNull @RequestParam("source") Byte source
|
||||
,@Valid @NotNull @RequestParam("sourceId") Integer sourceId) {
|
||||
try {
|
||||
String url=fileUploadService.upload(buildFilePath(file.getOriginalFilename()), file);
|
||||
String url=fileUploadService.upload(buildFilePath(file), file);
|
||||
fileUploadRecordService.save(buildFileUploadRecord(source,sourceId,file,url));
|
||||
return ApiResult.success(url);
|
||||
}catch (Exception ex){
|
||||
|
|
@ -61,9 +61,13 @@ public class FileController extends ControllerBase {
|
|||
}
|
||||
}
|
||||
|
||||
private String buildFilePath(String fileName){
|
||||
return StrUtil.format("cfs/{}/{}/{}/{}", LocalDateTime.now().format(FORMATTER), AppUserUtil.getUserId(),
|
||||
RandomUtil.randomString(4),fileName);
|
||||
private String buildFilePath(MultipartFile file) {
|
||||
return StrUtil.format("cfs/{}/{}/{}{}", LocalDateTime.now().format(FORMATTER), AppUserUtil.getUserId(),
|
||||
RandomUtil.randomString(6),getExtensions(file));
|
||||
}
|
||||
|
||||
private String getExtensions(MultipartFile file){
|
||||
return file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf("."));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -81,7 +85,7 @@ public class FileController extends ControllerBase {
|
|||
List<String> list = new ArrayList<>();
|
||||
List<FileUploadRecord> records = new ArrayList<>();
|
||||
for (MultipartFile f : files) {
|
||||
String url=fileUploadService.upload(buildFilePath(f.getOriginalFilename()), f);
|
||||
String url=fileUploadService.upload(buildFilePath(f), f);
|
||||
list.add(url);
|
||||
records.add(buildFileUploadRecord(source,sourceId,f,url));
|
||||
}
|
||||
|
|
@ -100,7 +104,7 @@ public class FileController extends ControllerBase {
|
|||
@PostMapping("uploadSingleFile1")
|
||||
public ApiResult<String> uploadSingleFile1(@Valid @NotNull @RequestParam("file") MultipartFile file) {
|
||||
try {
|
||||
String url=fileUploadService.upload(buildFilePath(file.getOriginalFilename()), file);
|
||||
String url=fileUploadService.upload(buildFilePath(file), file);
|
||||
return ApiResult.success(url);
|
||||
}catch (Exception ex){
|
||||
throw new NflgException(STATE.BusinessError,"上传文件失败:"+ex.getMessage());
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@ public class MessageController extends ControllerBase {
|
|||
@GetMapping("getConfig")
|
||||
public ApiResult<MessageConfigVO> getConfig(){
|
||||
HashOperations<String, String, Object> hashOps = redisTemplate.opsForHash();
|
||||
Map<String, Object> maps = hashOps.entries("message:config:" + AppUserUtil.getUserId());
|
||||
Map<String, Object> maps = hashOps.entries("message:config:app:" + AppUserUtil.getUserId());
|
||||
return ApiResult.success(new MessageConfigVO()
|
||||
.setAppNotifyEnabled((Boolean) maps.getOrDefault(Constant.REDIS_KEY_MESSAGECONFIG_APP, true))
|
||||
.setEmailNotifyEnabled((Boolean) maps.getOrDefault(Constant.REDIS_KEY_MESSAGECONFIG_EMAIL, true))
|
||||
|
|
@ -101,7 +101,7 @@ public class MessageController extends ControllerBase {
|
|||
maps.put(Constant.REDIS_KEY_MESSAGECONFIG_EMAIL, request.isEmailNotifyEnabled());
|
||||
maps.put(Constant.REDIS_KEY_MESSAGECONFIG_APP, request.isAppNotifyEnabled());
|
||||
HashOperations<String, String, Object> operations = redisTemplate.opsForHash();
|
||||
operations.putAll("message:config:" + AppUserUtil.getUserId(), maps);
|
||||
operations.putAll("message:config:app:" + AppUserUtil.getUserId(), maps);
|
||||
return ApiResult.success();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@ package com.nflg.mobilebroken.repository.mapper;
|
|||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.nflg.mobilebroken.common.pojo.PageData;
|
||||
import com.nflg.mobilebroken.common.pojo.request.AdminMessageSearchRequest;
|
||||
import com.nflg.mobilebroken.common.pojo.vo.AdminMessageVO;
|
||||
import com.nflg.mobilebroken.repository.entity.AdminMessage;
|
||||
|
|
@ -17,4 +19,6 @@ import com.nflg.mobilebroken.repository.entity.AdminMessage;
|
|||
public interface AdminMessageMapper extends BaseMapper<AdminMessage> {
|
||||
|
||||
IPage<AdminMessageVO> search(Integer userId, AdminMessageSearchRequest request, IPage<AdminMessageVO> page);
|
||||
|
||||
PageData<AdminMessageVO> getNotReadMessage(Integer userId, Integer num, Page<?> page);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package com.nflg.mobilebroken.repository.service;
|
|||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.nflg.mobilebroken.common.pojo.PageData;
|
||||
import com.nflg.mobilebroken.common.pojo.request.AdminMessageSearchRequest;
|
||||
import com.nflg.mobilebroken.common.pojo.vo.AdminMessageVO;
|
||||
import com.nflg.mobilebroken.repository.entity.AdminMessage;
|
||||
|
|
@ -28,4 +29,6 @@ public interface IAdminMessageService extends IService<AdminMessage> {
|
|||
void addCQMNotify(Ticket ticket);
|
||||
|
||||
void add(AdminMessage message);
|
||||
|
||||
PageData<AdminMessageVO> getNotReadMessage(Integer userId, Integer num);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.nflg.mobilebroken.common.pojo.PageData;
|
||||
import com.nflg.mobilebroken.common.pojo.request.AdminMessageSearchRequest;
|
||||
import com.nflg.mobilebroken.common.pojo.vo.AdminMessageVO;
|
||||
import com.nflg.mobilebroken.repository.entity.AdminMessage;
|
||||
|
|
@ -79,4 +80,9 @@ public class AdminMessageServiceImpl extends ServiceImpl<AdminMessageMapper, Adm
|
|||
.eq(AdminMessage::getUserId, message.getUserId()));
|
||||
save(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageData<AdminMessageVO> getNotReadMessage(Integer userId, Integer num) {
|
||||
return baseMapper.getNotReadMessage(userId, num, new Page<>(1, num));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,4 +19,13 @@
|
|||
</if>
|
||||
ORDER BY m.id DESC
|
||||
</select>
|
||||
|
||||
<select id="getNotReadMessage" resultType="com.nflg.mobilebroken.common.pojo.vo.AdminMessageVO">
|
||||
SELECT m.id,m.no,m.source,m.source_id AS 'sourceId',m.type,m.sub_type AS 'subType',m.create_time AS 'createTime',
|
||||
u.user_name AS 'userName',m.is_read AS 'isRead'
|
||||
FROM admin_message m
|
||||
INNER JOIN admin_user u ON m.user_id=u.id
|
||||
WHERE m.is_read=0 AND m.user_id=#{userId}
|
||||
ORDER BY m.id DESC
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
|
|||
Loading…
Reference in New Issue