package com.yc.education.controller.admin;

import com.github.pagehelper.PageInfo;
import com.yc.education.model.About;
import com.yc.education.service.IAboutService;
import com.yc.education.util.AjaxMessage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;

/**
 * 后台
 * 关于好彩
 * @author Hickey
 * @create 2019-07-26 16:09
 */
@Controller
public class AboutManageController {

    @Autowired
    private IAboutService iAboutService;

    /**
     * 后台
     * 查询关于好彩的信息
     * @return
     */
    @RequestMapping("/admin/updateAbout.html")
    public ModelAndView listAbout(Integer id){

        ModelAndView  mav  =  new ModelAndView();

        About about  =  iAboutService.selectByKey(id);//根据id查询信息

        mav.addObject("about",about);


        return  mav;
    }



    /**
     * 后台
     * 修改信息
     * @param about
     * @return
     */
    @ResponseBody
    @RequestMapping("/admin/updateAboutDetail.html")
    public AjaxMessage<Object> updateAboutDetail(About about){

        AjaxMessage  am  =  new AjaxMessage();

        int rows  = iAboutService.updateNotNull(about);

        if( rows > 0 ){
            am.setIs(true);
            am.setMsg("修改成功");
        }else{
            am.setIs(false);
            am.setMsg("该条信息修改失败");
        }
        return  am;
    }
}
