package org.jeecg.modules.apiService.impl;

import org.jeecg.common.api.vo.Result;
import org.jeecg.config.shiro.ShiroRealm;
import org.jeecg.modules.apiService.BannerService;
import org.jeecg.modules.apiService.FeedbackService;
import org.jeecg.modules.employFeedback.entity.EmployFeedback;
import org.jeecg.modules.employFeedback.service.IEmployFeedbackService;
import org.jeecg.modules.employJob.service.IEmployJobService;
import org.jeecg.modules.hanHaiMember.entity.HanHaiMember;
import org.jeecg.modules.hanHaiMember.service.IHanHaiMemberService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class FeedbackServiceImpl implements FeedbackService {
    /******************************************************************************************************************/
    //权限验证
    @Resource
    private ShiroRealm shiroRealm;

    @Resource
    private IEmployFeedbackService employFeedbackService;

    @Resource
    private IHanHaiMemberService hanHaiMemberService;
    /******************************************************************************************************************/

    //帮助反馈-帮助反馈
    @Override
    public Result<?> addFeedback(String token, EmployFeedback employFeedback) {
        //权限验证
        HanHaiMember hanHaiMember = shiroRealm.checkUserTokenIsEffectHanHaiOpenId(token);
        String message = "技工问题添加失败！";

        try{
            employFeedback.setUserId(hanHaiMember.getId());
            boolean result = employFeedbackService.save(employFeedback);

            if(result){
                message = "技工问题添加成功！";
            }else {
                message = "技工问题添加失败！";
            }

            return Result.OK(message);
        }catch (Exception e){
            e.printStackTrace();
            return Result.error(message);
        }
    }

}
