package com.yh.saas.plugin.news.controller;


import java.util.List;

import com.winsea.svc.base.security.util.AuthSecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
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 com.yh.saas.plugin.news.entity.AnnoReadUserLike;
import com.yh.saas.plugin.news.service.INewsAnnoReadUserLikeService;

/**
 * <p>
 * 职员新闻喜好类型 前端控制器
 * </p>
 *
 * @author Wangs
 * @since 2020-03-16
 */
@RestController
@RequestMapping("/annoReadUserLike")
public class NewsAnnoReadUserLikeController {

    @Autowired
    private INewsAnnoReadUserLikeService userLikeService;

    /**
     * 创建职员喜好新闻类型 （第一次登陆用）
     *
     * @param userLike
     * @return
     */
    @PostMapping("/api/createLikeList")
    public void createLikeList(@RequestBody AnnoReadUserLike userLike) {
        userLikeService.createLikeList(userLike.getId());
    }

    /**
     * 更新职员选中新闻类型
     *
     * @param userLikeList
     * @return
     */
    @PostMapping("/api/updateLikeList")
    public void updateLikeList(@RequestBody List<AnnoReadUserLike> userLikeList) {
        userLikeService.updateLikeList(userLikeList);
    }

    /**
     * 查询当前职员是否设置过新闻喜好类型
     *
     * @return
     */
    @GetMapping("/query/getReadUserLike")
    public Boolean getReadUserLike() {
        return userLikeService.getReadUserLike(AuthSecurityUtils.getCurrentUserInfo().getUserId());
    }

    /**
     * 查询当前职员的选中新闻类型
     *
     * @return
     */
    @GetMapping("/query/getReadUserLikeList")
    public List<AnnoReadUserLike> getReadUserLikeList() {
        return userLikeService.getReadUserLikeList(AuthSecurityUtils.getCurrentUserInfo().getUserId());
    }
}

