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

import java.util.List;

import org.apache.commons.lang3.StringUtils;
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.haoban.common.utils.HaobanResponse;
import com.gic.haoban.manage.api.dto.MaidianDictDTO;
import com.gic.haoban.manage.api.dto.MaidianDictModuleDTO;
import com.gic.haoban.manage.api.dto.MaidianDictPageDTO;
import com.gic.haoban.manage.api.service.MaidianDictApiService;
import com.gic.haoban.manage.web.errCode.HaoBanErrCode;



@RequestMapping("/maidian")
@RestController
public class MaidianDictController extends WebBaseController{
	private static Logger logger  = LoggerFactory.getLogger(MaidianDictController.class);

	@Autowired
	private MaidianDictApiService maidianDictApiService;
	//保存模块
	@RequestMapping("save-module")
	public HaobanResponse saveModule(MaidianDictModuleDTO dto) {
		maidianDictApiService.saveModule(dto);
		return resultResponse(HaoBanErrCode.ERR_1);
	}
	//保存字典
	@RequestMapping("save-page")
	public HaobanResponse savePage(MaidianDictDTO dto) {
		if(StringUtils.isEmpty(dto.getModuleId())){
			return resultResponse(HaoBanErrCode.ERR_2);
		}
		maidianDictApiService.savePage(dto);
		return resultResponse(HaoBanErrCode.ERR_1);
	}
	//删除模块
	@RequestMapping("del-module")
	public HaobanResponse delModule(String  moduleId) {
		maidianDictApiService.delModule(moduleId);
		return resultResponse(HaoBanErrCode.ERR_1);
	}
	//删除字典
	@RequestMapping("del-page")
	public HaobanResponse delPage(String  dictId) {
		maidianDictApiService.delPage(dictId);
		return resultResponse(HaoBanErrCode.ERR_1);
	}
	
	//字典页面
	@RequestMapping("dict-page")
	public HaobanResponse dictPage( ) {
		List<MaidianDictPageDTO> result = maidianDictApiService.dictPage();
		return resultResponse(HaoBanErrCode.ERR_1,result);
	}
}
