package com.mortals.xhx.busiz.applets.web;


import com.mortals.framework.common.Rest;
import com.mortals.xhx.busiz.applets.req.NewsReq;
import com.mortals.xhx.module.company.model.CompanyLabelsQuery;
import com.mortals.xhx.module.company.model.CompanyQuery;
import com.mortals.xhx.module.company.service.CompanyLabelsService;
import com.mortals.xhx.module.company.service.CompanyService;
import com.mortals.xhx.module.labels.model.LabelsQuery;
import com.mortals.xhx.module.labels.service.LabelsService;
import com.mortals.xhx.module.news.model.NewsCategoryQuery;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;



/**
 * @author ZYW
 * @date 2023-10-09 9:39
 */
@RestController
@Slf4j
@RequestMapping("/api/v1/company")
public class CompanyApiController extends AbstractBaseController<NewsReq>{
    @Autowired
    private CompanyService companyService;
    @Autowired
    private LabelsService labelsService;

    /**
     * 公司标注列表
     */
    @PostMapping(value = "labelsList")
    public Rest<Object> categoryList(){
        String busiDesc = "公司标注";
        Rest<Object> rest = Rest.ok();
        try {
            rest.setData(labelsService.find(new LabelsQuery()));
        }catch (Exception e) {
            log.error(busiDesc, e);
            rest = Rest.fail(super.convertException(e));
        }
        return rest;
    }

    /**
     * 公司列表
     */
    @PostMapping(value = "companyList")
    public Rest<Object> companyList(){
        String busiDesc = "公司列表";
        Rest<Object> rest = Rest.ok();
        try {
            rest.setData(companyService.find(new CompanyQuery()));
        }catch (Exception e) {
            log.error(busiDesc, e);
            rest = Rest.fail(super.convertException(e));
        }
        return rest;
    }

}
