package com.hzs.system.home.controller.api;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.hzs.common.core.utils.StringUtils;
import com.hzs.common.core.web.controller.BaseController;
import com.hzs.common.core.web.domain.AjaxResult;
import com.hzs.common.core.web.page.TableDataInfo;
import com.hzs.common.domain.system.ext.HoEnterpriseMissionExt;
import com.hzs.common.domain.system.home.HoEnterpriseStyle;
import com.hzs.system.home.service.IHoEnterpriseStyleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Date;
import java.util.List;

/**
 * <p>
 * 公司风采 前端控制器
 * </p>
 *
 * @author hzs
 * @since 2022-11-19
 */
@RestController
@RequestMapping("/api/ho-enterprise-style")
public class ApiHoEnterpriseStyleController extends BaseController {
    @Autowired
    private IHoEnterpriseStyleService enterpriseStyleService;

    /**
     * @description: 查询企业使命列表
     * @author: zhang jing
     * @date: 2022/8/30 10:20
     * @param: [enterpriseStyle]
     * @return: com.hzs.common.core.web.page.TableDataInfo
     **/
    @GetMapping("/list")
    public TableDataInfo list(HoEnterpriseMissionExt enterpriseStyle) {
        QueryWrapper<HoEnterpriseStyle> queryWrapper = new QueryWrapper();
        if(null!=enterpriseStyle.getLanguageType()){
            if(enterpriseStyle.getLanguageType()!=1){
                queryWrapper.ne("PK_COUNTRY",enterpriseStyle.getPkCountry());
            }else{
                queryWrapper.eq("PK_COUNTRY",enterpriseStyle.getPkCountry());
            }
        }
        queryWrapper.lt("EFFECTIVE_DATE",new Date());
        queryWrapper.orderByAsc("SORT");
        List<HoEnterpriseStyle> list = enterpriseStyleService.list(queryWrapper);
        return getDataTable(list);
    }


    /**
     * @description: 查询单条个企业使命
     * @author: zhang jing
     * @date: 2022/8/30 10:21
     * @param: [pkId]
     * @return: com.hzs.common.core.web.domain.AjaxResult
     **/
    @GetMapping("/getOne/{pkId}")
    public AjaxResult getOne(@PathVariable Long pkId) {
        HoEnterpriseStyle enterpriseStyle = enterpriseStyleService.getById(pkId);
        return AjaxResult.success(enterpriseStyle);
    }



}
