| | |
| | | package com.ruoyi.web.controller.api; |
| | | |
| | | |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.ruoyi.common.annotation.Log; |
| | | import com.ruoyi.common.basic.PageInfo; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.domain.entity.SysUser; |
| | | import com.ruoyi.common.enums.BusinessType; |
| | | import com.ruoyi.system.dto.TCrmSupplierDTO; |
| | | import com.ruoyi.system.model.TCrmBranch; |
| | | import com.ruoyi.system.model.TCrmChangePoints; |
| | | import com.ruoyi.system.model.TCrmSalesperson; |
| | | import com.ruoyi.system.model.TCrmSupplier; |
| | | import com.ruoyi.system.query.TCrmSupplierQuery; |
| | | import com.ruoyi.system.service.*; |
| | | import com.ruoyi.system.vo.TCrmSupplierVO; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | * @author xiaochen |
| | | * @since 2025-08-20 |
| | | */ |
| | | @Api(tags = "crm供应商管理") |
| | | @RestController |
| | | @RequestMapping("/t-crm-supplier") |
| | | public class TCrmSupplierController { |
| | | |
| | | private final TCrmSupplierService crmSupplierService; |
| | | private final ISysUserService sysUserService; |
| | | @Autowired |
| | | public TCrmSupplierController(TCrmSupplierService crmSupplierService, ISysUserService sysUserService) { |
| | | this.crmSupplierService = crmSupplierService; |
| | | this.sysUserService = sysUserService; |
| | | } |
| | | |
| | | /** |
| | | * 获取crm供应商管理管理列表 |
| | | */ |
| | | @ApiOperation(value = "获取crm供应商管理分页列表") |
| | | @PostMapping(value = "/pageList") |
| | | public R<PageInfo<TCrmSupplierVO>> pageList(@RequestBody TCrmSupplierQuery query) { |
| | | return R.ok(crmSupplierService.pageList(query)); |
| | | } |
| | | |
| | | /** |
| | | * 获取crm供应商管理管理列表 |
| | | */ |
| | | @ApiOperation(value = "获取crm供应商管理列表") |
| | | @PostMapping(value = "/list") |
| | | public R<List<TCrmSupplier>> list() { |
| | | return R.ok(crmSupplierService.list(Wrappers.lambdaQuery(TCrmSupplier.class) |
| | | .eq(TCrmSupplier::getStatus,1) |
| | | .orderByDesc(TCrmSupplier::getCreateTime))); |
| | | } |
| | | |
| | | /** |
| | | * 添加crm供应商管理管理 |
| | | */ |
| | | @Log(title = "crm供应商管理信息-新增crm供应商管理", businessType = BusinessType.INSERT) |
| | | @ApiOperation(value = "添加crm供应商管理") |
| | | @PostMapping(value = "/add") |
| | | public R<Boolean> add(@Validated @RequestBody TCrmSupplierDTO dto) { |
| | | return crmSupplierService.addSupplier(dto); |
| | | } |
| | | |
| | | /** |
| | | * 修改crm供应商管理 |
| | | */ |
| | | @Log(title = "crm供应商管理信息-修改crm供应商管理", businessType = BusinessType.UPDATE) |
| | | @ApiOperation(value = "修改crm供应商管理") |
| | | @PostMapping(value = "/update") |
| | | public R<Boolean> update(@Validated @RequestBody TCrmSupplierDTO dto) { |
| | | return crmSupplierService.updateSupplier(dto); |
| | | } |
| | | |
| | | /** |
| | | * 查看crm供应商管理详情 |
| | | */ |
| | | @ApiOperation(value = "查看crm供应商管理详情") |
| | | @GetMapping(value = "/getDetailById") |
| | | public R<TCrmSupplierVO> getDetailById(@RequestParam String id) { |
| | | TCrmSupplier crmSupplier = crmSupplierService.getById(id); |
| | | TCrmSupplierVO crmSupplierVO = new TCrmSupplierVO(); |
| | | BeanUtils.copyProperties(crmSupplier, crmSupplierVO); |
| | | return R.ok(crmSupplierVO); |
| | | } |
| | | |
| | | /** |
| | | * 删除crm供应商管理 |
| | | */ |
| | | @Log(title = "crm供应商管理信息-删除crm供应商管理", businessType = BusinessType.DELETE) |
| | | @ApiOperation(value = "删除crm供应商管理") |
| | | @DeleteMapping(value = "/deleteById") |
| | | public R<Boolean> deleteById(@RequestParam String id) { |
| | | // 删除账号 |
| | | TCrmSupplier crmBranch = crmSupplierService.getById(id); |
| | | sysUserService.deleteUserById(crmBranch.getUserId()); |
| | | return R.ok(crmSupplierService.removeById(id)); |
| | | } |
| | | |
| | | /** |
| | | * 批量删除crm供应商管理 |
| | | */ |
| | | @Log(title = "crm供应商管理信息-删除crm供应商管理", businessType = BusinessType.DELETE) |
| | | @ApiOperation(value = "批量删除crm供应商管理") |
| | | @DeleteMapping(value = "/deleteByIds") |
| | | public R<Boolean> deleteByIds(@RequestBody List<String> ids) { |
| | | // 删除账号 |
| | | List<TCrmSupplier> crmSupplierList = crmSupplierService.list(Wrappers.lambdaQuery(TCrmSupplier.class).in(TCrmSupplier::getId, ids)); |
| | | List<Long> userIds = crmSupplierList.stream().map(TCrmSupplier::getUserId).collect(Collectors.toList()); |
| | | sysUserService.deleteUserByIds(userIds); |
| | | return R.ok(crmSupplierService.removeByIds(ids)); |
| | | } |
| | | |
| | | /** |
| | | * 批量删除crm供应商管理 |
| | | */ |
| | | @Log(title = "crm供应商管理信息-供应商管理解冻冻结", businessType = BusinessType.UPDATE) |
| | | @ApiOperation(value = "供应商管理解冻冻结",notes = "状态 1=使用中 2=冻结") |
| | | @PutMapping(value = "/thawOrFreeze") |
| | | public R<Boolean> thawOrFreeze(@RequestParam(value = "id")String id, |
| | | @RequestParam(value = "status")Integer status) { |
| | | TCrmSupplier crmSupplier = crmSupplierService.getById(id); |
| | | crmSupplier.setStatus(status); |
| | | crmSupplierService.updateById(crmSupplier); |
| | | // 查询用户 |
| | | SysUser sysUser = sysUserService.selectUserById(crmSupplier.getUserId()); |
| | | switch (status){ |
| | | case 1: |
| | | // 解冻 |
| | | sysUser.setStatus("0"); |
| | | sysUserService.updateUser(sysUser); |
| | | break; |
| | | case 2: |
| | | // 冻结 |
| | | sysUser.setStatus("1"); |
| | | sysUserService.updateUser(sysUser); |
| | | break; |
| | | } |
| | | return R.ok(); |
| | | } |
| | | |
| | | } |
| | | |