package com.starry.admin.modules.weichat.controller;

import com.starry.admin.common.aspect.ClerkUserLogin;
import com.starry.admin.modules.personnel.module.entity.PlayPersonnelGroupInfoEntity;
import com.starry.admin.modules.personnel.service.IPlayPersonnelGroupInfoService;
import com.starry.admin.modules.weichat.entity.PlayGroupWagesQueryVo;
import com.starry.admin.modules.weichat.entity.PlayGroupWagesReturnVo;
import com.starry.common.result.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * 微信查询组长工资
 *
 * @author admin
 * @since 2024/7/6 下午3:46
 **/
@Api(tags = "微信分组管理", description = "微信端店员分组相关接口")
@Slf4j
@RestController
@RequestMapping("/wx/group")
public class WxPersonnelGroupInfoController {

    @Resource
    private IPlayPersonnelGroupInfoService playClerkGroupInfoService;

    /**
     * 查询组长公工资
     */
    @ApiOperation(value = "查询分组工资", notes = "获取所有店员分组的工资信息")
    @ApiResponses({
            @ApiResponse(code = 200, message = "操作成功", response = PlayGroupWagesReturnVo.class, responseContainer = "List")})
    @ClerkUserLogin
    @PostMapping("/wages/listAll")
    public R listGroupWagesAll(
            @ApiParam(value = "查询条件", required = true) @Validated @RequestBody PlayGroupWagesQueryVo vo) {
        List<PlayPersonnelGroupInfoEntity> list = playClerkGroupInfoService.selectAll();
        List<PlayGroupWagesReturnVo> data = new ArrayList<>();
        for (PlayPersonnelGroupInfoEntity entity : list) {
            PlayGroupWagesReturnVo bean = new PlayGroupWagesReturnVo();
            bean.setGroupName(entity.getGroupName());
            data.add(bean);
        }
        return R.ok(data);
    }

    @ApiOperation(value = "查询分组信息", notes = "获取所有店员分组")
    @ApiResponses({
            @ApiResponse(code = 200, message = "操作成功", response = PlayPersonnelGroupInfoEntity.class, responseContainer = "List")})
    @ClerkUserLogin
    @GetMapping("/group/listAll")
    public R findAllGroup() {
        List<PlayPersonnelGroupInfoEntity> list = playClerkGroupInfoService.selectAll();
        return R.ok(list);
    }

}
