package org.springblade.party.feign;

import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor;
import javax.validation.Valid;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.tool.utils.Func;
import org.springblade.enterprise.feign.IStaffClient;
import org.springblade.party.service.IActivityEnrollService;
import org.springblade.party.service.IPartyMemberService;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestParam;
import org.springblade.party.entity.Activity;
import org.springblade.party.vo.ActivityVO;
import org.springblade.party.wrapper.ActivityWrapper;
import org.springblade.party.service.IActivityService;
import org.springblade.core.boot.ctrl.BladeController;
import java.util.List;
/**
 * 党内活动表 client
 *
 * @author lianghanqiang
 * @since 2021-04-19
 */

@AllArgsConstructor
@RestController
@RequestMapping("/feign/activity")

public class ActivityClient implements IActivityClient {

    private final IActivityService activityService;
	private IActivityEnrollService activityEnrollService;
	private IPartyMemberService partyMemberService;
	private IStaffClient staffClient;
        /**
     * 详情
     */
    @Override
    @GetMapping("/detail")
    public ActivityVO detail(Activity activity) {
        Activity detail = activityService.getOne(Condition.getQueryWrapper(activity));
        return ActivityWrapper.build(activityEnrollService,partyMemberService,staffClient).entityVO(detail);
        }

    /**
     * 查询 党内活动表
     */
    @Override
    @GetMapping("/list")
    public List<ActivityVO> list(Activity activity) {
        return ActivityWrapper.build(activityEnrollService,partyMemberService,staffClient).listVO(activityService.list(Condition.getQueryWrapper(activity)));
        }



    /**
     * 新增 党内活动表
     */
    @Override
    @PostMapping("/save")
    public boolean save(@Valid @RequestBody Activity activity) {
        return activityService.save(activity);
        }

    /**
     * 修改 党内活动表
     */
    @Override
    @PostMapping("/update")
    public boolean update(@Valid @RequestBody Activity activity) {
        return activityService.updateById(activity);
        }

    /**
     * 新增或修改 党内活动表
     */
    @Override
    @PostMapping("/submit")
    public boolean submit(@Valid @RequestBody Activity activity) {
        return activityService.saveOrUpdate(activity);
        }


    /**
     * 删除 党内活动表
     */
    @Override
    @PostMapping("/remove")
    public boolean remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) {
        return activityService.deleteLogic(Func.toLongList(ids));
        }


}
