feat(消息模块与部门模块): 修改了消息模块的bug并从新建消息接口中独立出添加附件接口,部门模块新添加了部门树返回接口

This commit is contained in:
zhuangtianxiang 2024-12-07 17:31:11 +08:00
parent 30338520cf
commit e535b745ea
11 changed files with 29 additions and 24 deletions

View File

@ -66,10 +66,10 @@ public class ApiExceptionHandler {
}
//TODO 跟全局security 冲突
// @ExceptionHandler(value = {Exception.class})
// public ResponseEntity<Object> handleException(Exception ex) throws JsonProcessingException {
// log.error("Exception: {}", objectMapper.writeValueAsString(Map.of("msg", ex.getMessage())));
// return new ResponseEntity<>(objectMapper.writeValueAsString(Map.of("msg", ex.getMessage())), HttpStatus.INTERNAL_SERVER_ERROR);
// }
@ExceptionHandler(value = {Exception.class})
public ResponseEntity<Object> handleException(Exception ex) throws JsonProcessingException {
log.error("Exception: {}", objectMapper.writeValueAsString(Map.of("msg", ex.getMessage())));
return new ResponseEntity<>(objectMapper.writeValueAsString(Map.of("msg", ex.getMessage())), HttpStatus.INTERNAL_SERVER_ERROR);
}
}

View File

@ -14,7 +14,7 @@ import lombok.NoArgsConstructor;
@NoArgsConstructor
public class ResponseResult<T> {
//TODO 返回封装处理
/**
* 状态码
*/

View File

@ -24,7 +24,7 @@ import javax.sql.DataSource;
* @author harry_yao
*/
@AllArgsConstructor
@EnableMethodSecurity
//@EnableMethodSecurity
//TODO 加入全局注解会报错
@Configuration
public class SpringSecurityConfig {

View File

@ -91,4 +91,11 @@ public class AttachmentController {
return attachments;
}
/**
* 根据附件ID删除附件信息
*/
@DeleteMapping("delete/{id}")
public Boolean delete(@PathVariable("id") String id) {
return service.delete(id);
}
}

View File

@ -2,6 +2,9 @@ package com.zsc.edu.gateway.modules.attachment.repo;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zsc.edu.gateway.modules.attachment.entity.Attachment;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
/**
* @author ftz

View File

@ -20,4 +20,6 @@ public interface AttachmentService extends IService<Attachment> {
Resource loadAsResource(String id);
Attachment.Wrapper loadAsWrapper(String id);
Boolean delete(String id);
}

View File

@ -1,6 +1,7 @@
package com.zsc.edu.gateway.modules.attachment.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zsc.edu.gateway.framework.storage.StorageProperties;
import com.zsc.edu.gateway.framework.storage.exception.StorageFileEmptyException;
@ -201,4 +202,11 @@ public class AttachmentServiceImpl extends ServiceImpl<AttachmentRepository, Att
return attachment;
}
@Override
public Boolean delete(String id) {
QueryWrapper<Attachment> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("id", id);
return remove(queryWrapper);
}
}

View File

@ -48,20 +48,6 @@ public class BulletinServiceImpl extends ServiceImpl<BulletinRepository, Bulleti
*/
@Override
public BulletinVo detail(UserDetailsImpl userDetails, Long id, Bulletin.State state) {
// List<BulletinVo> bulletins = repo.selectByBulletinId(id);
// if (bulletins.isEmpty()) {
// return Collections.emptyList();
// }
// for (BulletinVo bulletin : bulletins) {
// if (state != null) {
// bulletin.getState().checkStatus(state);
// }
// bulletin.setEditUsername(userRepository.selectNameById(bulletin.getEditUserId()));
// bulletin.setPublishUsername(userRepository.selectNameById(bulletin.getPublishUserId()));
// bulletin.setCloseUsername(userRepository.selectNameById(bulletin.getCloseUserId()));
// }
//
// return bulletins;
BulletinVo bulletinVo = repo.selectByBulletinId(id);
if (state != null) {
bulletinVo.getState().checkStatus(state);

View File

@ -18,7 +18,7 @@ import org.springframework.web.bind.annotation.*;
@RestController
@RequestMapping("/api/rest/authority")
public class AuthorityController {
//TODO 导入IOT
private AuthorityService service;
/**

View File

@ -31,7 +31,6 @@
</collection>
</resultMap>
<select id="selectByBulletinId" resultMap="BulletinMap">
//TODO 查询数据问题已经修改
SELECT sb.*, a.id as attachment_id, a.file_name as attachment_file_name, a.url as attachment_url
FROM sys_bulletin sb
LEFT JOIN

View File

@ -28,7 +28,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
@WebMvcTest(RoleController.class)
public class RoleControllerTest extends MockMvcConfigBase {
//TODO 公告部分测试
private static Role role1;
private static Role role2;