package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.system.domain.ServiceGoods;
import com.ruoyi.system.domain.Users;
import com.ruoyi.system.service.IUsersService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.WechatTransfer;
import com.ruoyi.system.service.IWechatTransferService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * wechat_transferController
 * 
 * @author ruoyi
 * @date 2025-05-15
 */
@RestController
@RequestMapping("/system/transfer")
public class WechatTransferController extends BaseController
{
    @Autowired
    private IWechatTransferService wechatTransferService;


    @Autowired
    private IUsersService  usersService;

    /**
     * 查询wechat_transfer列表
     */
    @PreAuthorize("@ss.hasPermi('system:transfer:list')")
    @GetMapping("/list")
    public TableDataInfo list(WechatTransfer wechatTransfer)
    {
        startPage();
        List<WechatTransfer> list = wechatTransferService.selectWechatTransferList(wechatTransfer);

        for(WechatTransfer  dd: list){
            Users users=usersService.selectUsersById(dd.getUid());
            if (users!=null){
                dd.setUname(users.getName());
            }
        }

        return getDataTable(list);
    }

    /**
     * 获取项目报价--工艺分类详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:transfer:query')")
    @GetMapping(value = "/getUsersDataList/{type}")
    public AjaxResult getUsersDataList(@PathVariable("type") String type)
    {
        Users users=new Users();
        if(type!=null){
            users.setType(type);
        }
        return success(usersService.selectUsersList(users));
    }
    /**
     * 导出wechat_transfer列表
     */
    @PreAuthorize("@ss.hasPermi('system:transfer:export')")
    @Log(title = "wechat_transfer", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WechatTransfer wechatTransfer)
    {
        List<WechatTransfer> list = wechatTransferService.selectWechatTransferList(wechatTransfer);
        ExcelUtil<WechatTransfer> util = new ExcelUtil<WechatTransfer>(WechatTransfer.class);
        util.exportExcel(response, list, "wechat_transfer数据");
    }

    /**
     * 获取wechat_transfer详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:transfer:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(wechatTransferService.selectWechatTransferById(id));
    }

    /**
     * 新增wechat_transfer
     */
    @PreAuthorize("@ss.hasPermi('system:transfer:add')")
    @Log(title = "wechat_transfer", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WechatTransfer wechatTransfer)
    {
        return toAjax(wechatTransferService.insertWechatTransfer(wechatTransfer));
    }

    /**
     * 修改wechat_transfer
     */
    @PreAuthorize("@ss.hasPermi('system:transfer:edit')")
    @Log(title = "wechat_transfer", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WechatTransfer wechatTransfer)
    {
        return toAjax(wechatTransferService.updateWechatTransfer(wechatTransfer));
    }

    /**
     * 删除wechat_transfer
     */
    @PreAuthorize("@ss.hasPermi('system:transfer:remove')")
    @Log(title = "wechat_transfer", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(wechatTransferService.deleteWechatTransferByIds(ids));
    }
}
