package com.duowenlvshi.duowenlszp.model.Brief.controller;

import com.duowenlvshi.duowenlszp.model.Brief.entity.Brief;
import com.duowenlvshi.duowenlszp.model.Brief.server.BriefServer;
import com.duowenlvshi.duowenlszp.app.util.DeletEmoji;
import com.duowenlvshi.duowenlszp.app.util.TypeConversion;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Map;

/**
 * @author yang fang yu
 * @since 2019/8/30 14:31
 */
@Transactional
@Component
public class BriefController {
    @Autowired
    BriefServer briefServer;
    @Autowired
    DeletEmoji deletEmoji;
    /**
     * 新增或修改简介,荣誉信息
     * */
    public int insertBrief(Map<String,Object> map){
        Map map1 =(Map) map.get("brief");
        Brief brief =(Brief) TypeConversion.mapToObject(map1,Brief.class);
        brief.setHonor(deletEmoji.filterEmoji(brief.getHonor(),""));
        brief.setBrief(deletEmoji.filterEmoji(brief.getBrief(),""));
        int i =briefServer.save(brief);
        return i;
    }

    /**
     * 查询简介,荣誉信息
     * */
    public List selectBrief(Map<String,Object> map){
        String lawyerId =(String) map.get("lawyerId");
        List list = briefServer.selectByLawyerId(lawyerId);
        return list;
    }
}
