Prechádzať zdrojové kódy

消息中心新增发布人数据返回;个人消息删除接口

fuyuchuan 1 týždeň pred
rodič
commit
e76ef05525

+ 28 - 18
base-modules/service-system/service-system-biz/src/main/java/com/usky/system/controller/web/MceReceiveController.java

@@ -8,6 +8,7 @@ import com.usky.common.log.enums.BusinessType;
 import com.usky.system.domain.MceReceive;
 import com.usky.system.service.MceReceiveService;
 import io.swagger.models.auth.In;
+import org.apache.ibatis.annotations.Param;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
@@ -45,11 +46,10 @@ public class MceReceiveController {
                                                  @RequestParam(value = "infoType", required = false) String infoType,
                                                  @RequestParam(value = "startTime", required = false) String startTime,
                                                  @RequestParam(value = "endTime", required = false) String endTime,
-                                                 @RequestParam(value = "id",required = false) Integer id,
+                                                 @RequestParam(value = "id", required = false) Integer id,
                                                  @RequestParam(value = "current", required = false, defaultValue = "1") Integer current,
-                                                 @RequestParam(value = "size", required = false, defaultValue = "10") Integer size)
-    {
-        return ApiResult.success(mceReceiveService.mceList(infoTitle, infoType,startTime, endTime, id,current, size));
+                                                 @RequestParam(value = "size", required = false, defaultValue = "10") Integer size) {
+        return ApiResult.success(mceReceiveService.mceList(infoTitle, infoType, startTime, endTime, id, current, size));
     }
 
     /**
@@ -68,9 +68,8 @@ public class MceReceiveController {
                                                        @RequestParam(value = "startTime", required = false) String startTime,
                                                        @RequestParam(value = "endTime", required = false) String endTime,
                                                        @RequestParam(value = "current", required = false, defaultValue = "1") Integer current,
-                                                       @RequestParam(value = "size", required = false, defaultValue = "10") Integer size)
-    {
-        return ApiResult.success(mceReceiveService.mceManageList(infoTitle, infoType,startTime, endTime, current, size));
+                                                       @RequestParam(value = "size", required = false, defaultValue = "10") Integer size) {
+        return ApiResult.success(mceReceiveService.mceManageList(infoTitle, infoType, startTime, endTime, current, size));
     }
 
     /**
@@ -83,9 +82,8 @@ public class MceReceiveController {
     @GetMapping("/mceManageById")
     public ApiResult<CommonPage<MceReceive>> mceManageById(@RequestParam(value = "id") Integer id,
                                                            @RequestParam(value = "current", required = false, defaultValue = "1") Integer current,
-                                                           @RequestParam(value = "size", required = false, defaultValue = "10") Integer size)
-    {
-        return ApiResult.success(mceReceiveService.mceManageById(id,current,size));
+                                                           @RequestParam(value = "size", required = false, defaultValue = "10") Integer size) {
+        return ApiResult.success(mceReceiveService.mceManageById(id, current, size));
     }
 
     /**
@@ -93,8 +91,7 @@ public class MceReceiveController {
      * @return
      */
     @GetMapping("/mceReceiveStatic")
-    public ApiResult<Map<String, Object>> mceReceiveStatic()
-    {
+    public ApiResult<Map<String, Object>> mceReceiveStatic() {
         return ApiResult.success(mceReceiveService.mceReceiveStatic());
     }
 
@@ -103,7 +100,7 @@ public class MceReceiveController {
      * @return
      */
     @PutMapping
-    ApiResult<Void> updateMceReceive(@RequestBody MceReceive mceReceive){
+    ApiResult<Void> updateMceReceive(@RequestBody MceReceive mceReceive) {
         mceReceiveService.updateMceReceive(mceReceive);
         return ApiResult.success();
     }
@@ -114,20 +111,33 @@ public class MceReceiveController {
      */
     @Log(title = "新增发布消息", businessType = BusinessType.INSERT)
     @PostMapping("/mceAdd")
-    ApiResult<Void> add(@RequestBody String mceReceive){
+    ApiResult<Void> add(@RequestBody String mceReceive) {
         mceReceiveService.add(mceReceive);
         return ApiResult.success();
     }
 
     /**
-     * 删除
+     * 删除消息及内容,并清空所有的消息接收表数据
      */
     @Log(title = "删除已发布消息", businessType = BusinessType.DELETE)
-    @DeleteMapping("/{id}")
-    public ApiResult<Void> removeById(@PathVariable("id") Integer id)
-    {
+    @DeleteMapping("/remove/{contentId}")
+    public ApiResult<Void> removeById(@PathVariable("contentId") Integer id) {
         mceReceiveService.removeById(id);
         return ApiResult.success();
     }
+
+    /**
+     * 删除一条消息
+     **/
+    @Log(title = "删除消息", businessType = BusinessType.DELETE)
+    @DeleteMapping("/{id}")
+    public ApiResult<Void> deleteById(@PathVariable("id") Integer id) {
+        boolean f = mceReceiveService.deleteById(id);
+        if (f) {
+            return ApiResult.success();
+        } else {
+            return ApiResult.error("删除失败");
+        }
+    }
 }
 

+ 2 - 0
base-modules/service-system/service-system-biz/src/main/java/com/usky/system/service/MceReceiveService.java

@@ -33,4 +33,6 @@ public interface MceReceiveService extends CrudService<MceReceive> {
 
     boolean removeById(Integer id);
 
+    boolean deleteById(Integer id);
+
 }

+ 24 - 1
base-modules/service-system/service-system-biz/src/main/java/com/usky/system/service/impl/MceReceiveServiceImpl.java

@@ -11,6 +11,7 @@ import com.baomidou.mybatisplus.core.toolkit.StringUtils;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.usky.common.core.bean.CommonPage;
+import com.usky.common.core.exception.BusinessException;
 import com.usky.common.security.utils.SecurityUtils;
 import com.usky.system.domain.*;
 import com.usky.system.mapper.MceReceiveMapper;
@@ -58,6 +59,9 @@ public class MceReceiveServiceImpl extends AbstractCrudService<MceReceiveMapper,
     @Autowired
     private MceSettingMapper mceSettingMapper;
 
+    @Autowired
+    private MceReceiveMapper mceReceiveMapper;
+
     @Override
     public CommonPage<Object> mceList(String infoTitle, String infoType, String startTime, String endTime, Integer id, Integer current, Integer size) {
         List<Object> list = new ArrayList<>();
@@ -76,7 +80,7 @@ public class MceReceiveServiceImpl extends AbstractCrudService<MceReceiveMapper,
             LambdaQueryWrapper<MceReceive> lambdaQuery = Wrappers.lambdaQuery();
             lambdaQuery.select(MceReceive::getId, MceReceive::getInfoType,
                             MceReceive::getContentId, MceReceive::getReadFlag, MceReceive::getCreateTime,
-                            MceReceive::getReceiverId, MceReceive::getModuleId)
+                            MceReceive::getReceiverId, MceReceive::getModuleId, MceReceive::getCreateBy)
                     .between(StringUtils.isNotBlank(startTime) && StringUtils.isNotBlank(endTime), MceReceive::getCreateTime,
                             startTime, endTime)
                     .eq(StringUtils.isNotBlank(infoType), MceReceive::getInfoType, infoType)
@@ -94,6 +98,7 @@ public class MceReceiveServiceImpl extends AbstractCrudService<MceReceiveMapper,
                     map.put("readFlag", page.getRecords().get(i).getReadFlag());
                     map.put("moduleId", page.getRecords().get(i).getModuleId());
                     map.put("createTime", page.getRecords().get(i).getCreateTime());
+                    map.put("createBy", page.getRecords().get(i).getCreateBy());
                     if (CollectionUtils.isNotEmpty(list1)) {
                         for (int j = 0; j < list1.size(); j++) {
                             if (page.getRecords().get(i).getContentId().equals(list1.get(j).getId())) {
@@ -584,4 +589,22 @@ public class MceReceiveServiceImpl extends AbstractCrudService<MceReceiveMapper,
         this.remove(lambdaQuery);
         return mceContentService.removeById(id);
     }
+
+    @Override
+    public boolean deleteById(Integer id) {
+        boolean f;
+        Integer userId = SecurityUtils.getUserId().intValue();
+        MceReceive mceReceive = mceReceiveMapper.selectOne(new LambdaQueryWrapper<MceReceive>().eq(MceReceive::getId, id));
+        if (mceReceive != null) {
+            if (userId.equals(mceReceive.getReceiverId())) {
+                mceReceiveMapper.deleteById(id);
+                f = true;
+            } else {
+                throw new BusinessException("您无权删除该条记录!");
+            }
+        } else {
+            throw new BusinessException("记录不存在,删除失败!");
+        }
+        return f;
+    }
 }