package com.gic.haoban.manage.web.controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.gic.api.base.commons.Page;
import com.gic.haoban.base.api.common.BasePageInfo;
import com.gic.haoban.common.utils.HaobanResponse;
import com.gic.haoban.manage.api.dto.DictDTO;
import com.gic.haoban.manage.api.dto.HelpDTO;
import com.gic.haoban.manage.api.service.DictApiService;
import com.gic.haoban.manage.api.service.HelpApiService;
import com.gic.haoban.manage.web.errCode.HaoBanErrCode;

@RestController
public class HelpController extends WebBaseController{
	private static Logger logger  = LoggerFactory.getLogger(HelpController.class);

	@Autowired
	private HelpApiService helpApiService;
	//获帮助列表
	@RequestMapping("get-help-list")
	public HaobanResponse getDictList(BasePageInfo pageInfo) {
		Page<HelpDTO> page = helpApiService.pageList(pageInfo);
		return resultResponse(HaoBanErrCode.ERR_1,page);
	}
	//保存帮助
	@RequestMapping("save-help")
	public HaobanResponse saveHelp(HelpDTO dto) {
		int i = helpApiService.saveHelp(dto);
		if(i == 8){
			return resultResponse(HaoBanErrCode.ERR_10006);
		}
		return resultResponse(HaoBanErrCode.ERR_1);
	}
	//查看帮助详情
	@RequestMapping("find-help-detail")
	public HaobanResponse findDictDetail(String  helpId) {
		HelpDTO helpDTO = helpApiService.findOneHelp(helpId);
		return resultResponse(HaoBanErrCode.ERR_1,helpDTO);
	}
	//删除帮助
	@RequestMapping("del-help")
	public HaobanResponse deleteDict(String  helpId) {
		helpApiService.deleteOne(helpId);
		return resultResponse(HaoBanErrCode.ERR_1);
	}
}
