朋友圈功能---动态发布、推存 dubbo 与 app 实现异步 controller

发布一下 0 0
import cn.hutool.core.util.StrUtil;import com.tanhua.server.service.QuanZiService;import com.tanhua.server.vo.PageResult;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.http.HttpStatus;import org.springframework.http.ResponseEntity;import org.springframework.web.bind.annotation.*;import org.springframework.web.multipart.MultipartFile;@RestController@RequestMapping("movements")public class QuanZiController {    /*    *  本类是 朋友圈动态数据 的controller层    *  用于朋友圈 页面 与 后端 数据传输的中转站    *  朋友圈 有很多动态数据  因此数据是要从中性数据库获取    * */    @Autowired    private QuanZiService quanZiService;    /**     * 查询好友动态     *     * @param page     * @param pageSize     * @return     */    @GetMapping    public PageResult queryPublishList(@RequestParam(value = "page", defaultValue = "1") Integer page,                                       @RequestParam(value = "pagesize", defaultValue = "10") Integer pageSize) {        return this.quanZiService.queryPublishList(page, pageSize);    }    //com.tanhua.server.controller.QuanZiController    /**     * 发送动态  朋友圈的发布动态功能     *记得将图片 上传的代码 提取成公用代码     * sso  dubbo-server 都要有自己的图片上转配置文件     * 在启动类扩大 package 的扫描范围     */    @PostMapping    public ResponseEntity<Void> savePublish(@RequestParam("textContent") String textContent,                                            @RequestParam(value = "location", required = false) String location,                                            @RequestParam(value = "latitude", required = false) String latitude,                                            @RequestParam(value = "longitude", required = false) String longitude,                                            @RequestParam(value = "imageContent", required = false) MultipartFile[] multipartFile) {        try {            String publishId = this.quanZiService.savePublish(textContent, location, latitude, longitude, multipartFile);            if (StrUtil.isNotEmpty(publishId)) {                return ResponseEntity.ok(null);            }        } catch (Exception e) {            e.printStackTrace();        }        return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build();    }    /**     * 查询推荐动态     *     * @param page     * @param pageSize     * @return     */    @GetMapping("recommend")    public PageResult queryRecommendPublishList(@RequestParam(value = "page", defaultValue = "1") Integer page,                                                @RequestParam(value = "pagesize", defaultValue = "10") Integer pageSize) {        return this.quanZiService.queryRecommendPublishList(page, pageSize);    }}



子工程中 启动类也要 标注 实现异步注解

@EnableAsync //异步传输

主要用在 dubbo子工程的 dubbo --- > dubbo-serivce

涉及四个数据表

发布、相册、时间线表、点赞表

有动态 与 静态 数据 合并传输操作

既要实现 dubbo中的服务功能 也要实现 app端的传输

import org.springframework.boot.SpringApplication;import org.springframework.boot.autoconfigure.SpringBootApplication;import org.springframework.scheduling.annotation.EnableAsync;@SpringBootApplication@EnableAsync  //异步传输数据 还的再 模块启动类  使用 @EnableAsyncpublic class DubboApplication {    public static void main(String[] args) {        SpringApplication.run(DubboApplication.class, args);    }}

版权声明:内容来源于互联网和用户投稿 如有侵权请联系删除

本文地址:http://0561fc.cn/113673.html