package com.goafanti.portal.controller;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.goafanti.activityUser.service.ActivityUserService;
import com.goafanti.common.bo.Result;
import com.goafanti.common.constant.ErrorConstants;
import com.goafanti.common.controller.CertifyApiController;
import com.goafanti.common.enums.AttachmentType;
import com.goafanti.core.shiro.token.TokenManager;

@RestController
@RequestMapping(value = "/api/user/portal/order")
public class PortalOrderApiController extends CertifyApiController {
	
	@Resource
	private ActivityUserService			activityUserService;

	@RequestMapping(value = "/activity", method = RequestMethod.GET)
	public Result getUserActivityList() {
		return res().data(activityUserService.selectUserActivities());
	}


	/**
	 * 附件上传
	 */
	@RequestMapping(value = "/demandUpload", method = RequestMethod.POST)
	public Result uploadTextFile(HttpServletRequest req, String sign) {
		Result res = new Result();

		AttachmentType attachmentType = AttachmentType.getField(sign);

		if (attachmentType == AttachmentType.DEMAND_ORDER_FILE) {
			res.setData(handleFiles(res, "/demandOrder/", false, req, sign, TokenManager.getUserId()));
		} else {
			res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "附件标示"));
		}
		return res;
	}



	

}
