package com.goafanti.portal.controller;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.alibaba.fastjson.JSON;
import com.goafanti.common.bo.Result;
import com.goafanti.common.controller.BaseApiController;
import com.goafanti.member.bo.MemberGrade;
import com.goafanti.member.bo.MemberGradeBO;
import com.goafanti.member.service.MemberGradeService;
/**
 * 不用登录查询
 * @author Administrator
 *
 */
@RestController
@RequestMapping(value = "/api/portal/member")
public class PortalMemberController extends BaseApiController {
	@Autowired
	private MemberGradeService memberGradeService;

	/**
	 * 查询等级
	 * 
	 * @return
	 */
	@RequestMapping(value = "/selectMemberGradeFr", method = RequestMethod.GET)
	public Result selectMemberGradeFr() {
		List<MemberGrade> list = memberGradeService.selectMemberGrade();
		List<MemberGradeBO> result = new ArrayList<>();
		for (MemberGrade mg : list) {
			result.add(new MemberGradeBO(mg.getId(), mg.getGradeName(), JSON.parseObject(mg.getBusiness()),
					JSON.parseObject(mg.getCost()), mg.getMemberRank()));
		}
		return res().data(result);
	}
}
