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.HoEnterpriseMission;
import com.hzs.system.home.service.IHoEnterpriseMissionService;
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-18
 */
@RestController
@RequestMapping("/api/ho-enterprise-mission")
public class ApiHoEnterpriseMissionController extends BaseController {
    @Autowired
    private IHoEnterpriseMissionService enterpriseMissionService;

    /**
     * @description: 查询企业使命列表
     * @author: zhang jing
     * @date: 2022/8/30 10:20
     * @param: [enterpriseMission]
     * @return: com.hzs.common.core.web.page.TableDataInfo
     **/
    @GetMapping("/list")
    public TableDataInfo list(HoEnterpriseMissionExt enterpriseMission) {
        QueryWrapper<HoEnterpriseMission> queryWrapper = new QueryWrapper();
        if(null!=enterpriseMission.getLanguageType()){
            if(enterpriseMission.getLanguageType()!=1){
                queryWrapper.ne("PK_COUNTRY",enterpriseMission.getPkCountry());
            }else{
                queryWrapper.eq("PK_COUNTRY",enterpriseMission.getPkCountry());
            }
        }
        queryWrapper.lt("EFFECTIVE_DATE",new Date());
        queryWrapper.orderByAsc("SORT");
        List<HoEnterpriseMission> list = enterpriseMissionService.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) {
        HoEnterpriseMission enterpriseMission = enterpriseMissionService.getById(pkId);
        return AjaxResult.success(enterpriseMission);
    }



}
