package com.ruoyi.generator.controller;

import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.generator.domain.Community.CommunityArticle;
import com.ruoyi.generator.domain.Community.CommunityUserNotification;
import com.ruoyi.generator.domain.Community.CommunityUserPrivacy;
import com.ruoyi.generator.service.ICommunityArticleService;
import com.ruoyi.generator.service.ICommunityNotificationService;
import com.ruoyi.generator.service.ICommunityPrivacyService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 社区设置管理
 *
 * @author fangQing
 */
@Api(tags = "社区设置管理")
@RestController
@RequestMapping("/community/settings")
public class CommunitySettingsController {


    @Autowired
    private ICommunityNotificationService communityNotificationService;

    @Autowired
    private ICommunityPrivacyService communityPrivacyService;


    /**
     * 获取通知权限
     * @param
     * @return 获取通知权限
     */
    @ApiOperation("获取通知权限")
    @GetMapping("/userNotification")
    //@Anonymous
    public AjaxResult userNotification() {
        return AjaxResult.success(communityNotificationService.selectUserNotification(SecurityUtils.getLoginUser().getUserId()));
    }

    /**
     * 更新通知权限
     * @param communityUserNotification
     * @return 返回修改成功的对象
     */
    @ApiOperation("更新通知权限")
    @PostMapping("/modifyUserNotification")
    public AjaxResult modifyUserNotification(@RequestBody CommunityUserNotification communityUserNotification) {
        return AjaxResult.success(communityNotificationService.modifyUserNotification(communityUserNotification));
    }

    /**
     * 获取隐私权限
     * @param
     * @return 获取隐私权限
     */
    @ApiOperation("获取隐私权限")
    @GetMapping("/userPrivacy")
    //@Anonymous
    public AjaxResult userPrivacy() {
        return AjaxResult.success(communityPrivacyService.selectUserPrivacy(SecurityUtils.getLoginUser().getUserId()));
    }

    /**
     * 更新隐私权限
     * @param communityUserPrivacy
     * @return 返回修改成功的对象
     */
    @ApiOperation("更新通知权限")
    @PostMapping("/modifyUserPrivacy")
    public AjaxResult modifyUserNotification(@RequestBody CommunityUserPrivacy communityUserPrivacy) {
        return AjaxResult.success(communityPrivacyService.modifyUserPrivacy(communityUserPrivacy));
    }




}
