package com.ruoyi.chargingPile.controller; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper; import com.ruoyi.chargingPile.api.dto.GetPermissionConfigurationDTO; import com.ruoyi.chargingPile.api.dto.PartnerListDTO; import com.ruoyi.chargingPile.api.model.Partner; import com.ruoyi.chargingPile.api.query.GetPartnerList; import com.ruoyi.chargingPile.api.query.SetPermissionConfiguration; import com.ruoyi.chargingPile.dto.ResetPassword; import com.ruoyi.chargingPile.service.IPartnerService; import com.ruoyi.common.core.domain.R; import com.ruoyi.common.core.web.domain.AjaxResult; import com.ruoyi.common.core.web.page.PageInfo; import com.ruoyi.common.log.annotation.Log; import com.ruoyi.common.log.enums.BusinessType; import com.ruoyi.common.security.utils.SecurityUtils; import com.ruoyi.system.api.domain.SysUser; import com.ruoyi.system.api.feignClient.SysUserClient; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import java.util.List; /** * @author zhibing.pu * @Date 2024/8/7 13:49 */ @RestController @RequestMapping("/partner") public class PartnerController { @Resource private IPartnerService partnerService; @Resource private SysUserClient sysUserClient; @ResponseBody @GetMapping("/getPartnerList") @ApiOperation(value = "获取合作商列表", tags = {"管理后台-合作商管理"}) public AjaxResult> getPartnerList(GetPartnerList partnerList){ PageInfo list = partnerService.getPartnerList(partnerList); return AjaxResult.success(list); } @ResponseBody @PostMapping("/addPartner") @ApiOperation(value = "添加合作商", tags = {"管理后台-合作商管理"}) @Log(title = "【合作商列表】添加合作商", businessType = BusinessType.INSERT) public AjaxResult addPartner(@RequestBody Partner partner){ return partnerService.addPartner(partner); } @ResponseBody @GetMapping("/getPartner/{id}") @ApiOperation(value = "获取合作商详情", tags = {"管理后台-合作商管理", "管理后台-充电桩信息"}) @ApiImplicitParams({ @ApiImplicitParam(value = "合作商id", name = "id", dataTypeClass = Integer.class, required = true) }) public AjaxResult getPartner(@PathVariable Integer id){ Partner partner = partnerService.getPartner(id); return AjaxResult.success(partner); } @ResponseBody @GetMapping("/getPartnerR/{id}") public R getPartnerR(@PathVariable("id") Integer id){ Partner partner = partnerService.getPartner(id); return R.ok(partner); } @ResponseBody @PostMapping("/editPartner") @ApiOperation(value = "编辑合作商", tags = {"管理后台-合作商管理"}) @Log(title = "【合作商列表】编辑合作商", businessType = BusinessType.UPDATE) public AjaxResult editPartner(@RequestBody Partner partner){ return partnerService.editPartner(partner); } @ResponseBody @DeleteMapping("/delPartner") @ApiOperation(value = "删除合作商", tags = {"管理后台-合作商管理"}) @ApiImplicitParams({ @ApiImplicitParam(value = "合作商id", name = "id", dataTypeClass = Integer.class, required = true) }) @Log(title = "【合作商列表】删除合作商", businessType = BusinessType.DELETE) public AjaxResult delPartner(@RequestParam("id") List id){ return partnerService.delPartner(id); } @ResponseBody @PostMapping("/resetPassword") @ApiOperation(value = "合作商重置密码", tags = {"管理后台-合作商管理"}) @Log(title = "【合作商列表】重置合作商密码", businessType = BusinessType.UPDATE) public AjaxResult resetPassword(@RequestBody ResetPassword resetPassword){ return partnerService.resetPassword(resetPassword); } @ResponseBody @GetMapping("/getPartner") @ApiOperation(value = "获取所有合作商", tags = {"管理后台-站点管理"}) public AjaxResult> getPartner(){ SysUser sysUser = sysUserClient.getSysUser(SecurityUtils.getUserId()).getData(); Integer roleType = sysUser.getRoleType(); Integer objectId = sysUser.getObjectId(); LambdaQueryWrapper wrapper = new LambdaQueryWrapper().eq(Partner::getDelFlag, 0); if(2 == roleType){ wrapper.eq(Partner::getId, objectId); } List list = partnerService.list(wrapper); return AjaxResult.success(list); } @ResponseBody @GetMapping("/getPermissionConfiguration/{siteId}") @ApiOperation(value = "获取合作商权限设置", tags = {"管理后台-站点管理"}) public AjaxResult getPermissionConfiguration(@PathVariable("siteId") Integer siteId, Integer partnerId){ GetPermissionConfigurationDTO permissionConfiguration = partnerService.getPermissionConfiguration(siteId, partnerId); return AjaxResult.success(permissionConfiguration); } @ResponseBody @PostMapping("/setPermissionConfiguration/{siteId}") @ApiOperation(value = "设置合作商权限", tags = {"管理后台-站点管理"}) @Log(title = "【合作商列表】设置合作商权限", businessType = BusinessType.OTHER) public AjaxResult setPermissionConfiguration(@RequestBody SetPermissionConfiguration req){ partnerService.setPermissionConfiguration(req); return AjaxResult.success(); } /** * 根据id获取合作商信息 * @param id * @return */ @PostMapping("/getPartnerById/{id}") public R getPartnerById(@PathVariable("id") Integer id){ Partner partner = partnerService.getPartner(id); return R.ok(partner); } }