package com.pqs9300.controller;

import com.njcn.pojo.commons.HttpResult;
import com.njcn.service.system.ThemeService;
import com.njcn.utils.PubUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

/**
 * @author hongawen
 * @date: 2019/9/27 10:47
 */
@Controller
@RequestMapping("theme")
public class ThemeController {

    private static final Logger logger = LoggerFactory.getLogger(ThemeController.class);

    @Resource
    private ThemeService themeService;


    /**
     * 获取主题色
     */
    @PostMapping("getColor")
    @ResponseBody
    public HttpResult getColor() {
        HttpResult result;
        String color;
        try{
            color=themeService.getThemeColor();
            result= PubUtils.assignmentResult(color,200,"获取主题色成功");
        }catch (Exception e){
            logger.error(e.toString());
            result= PubUtils.assignmentResult("#006565",500,"获取主题色失败");
        }

        return result;
    }
}
