2025-04-02 20:06:50 +08:00
|
|
|
package com.ruoyi.web.bst;
|
|
|
|
|
2025-04-15 18:16:16 +08:00
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
|
import org.springframework.web.bind.annotation.PathVariable;
|
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
|
import org.springframework.web.bind.annotation.PutMapping;
|
|
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
2025-04-02 20:06:50 +08:00
|
|
|
import com.ruoyi.bst.area.service.AreaService;
|
|
|
|
import com.ruoyi.bst.area.service.AreaValidator;
|
2025-04-27 15:07:02 +08:00
|
|
|
import com.ruoyi.bst.areaJoin.domain.enums.AreaJoinPermission;
|
2025-04-02 20:06:50 +08:00
|
|
|
import com.ruoyi.bst.customerService.domain.CustomerService;
|
|
|
|
import com.ruoyi.bst.customerService.domain.CustomerServiceQuery;
|
|
|
|
import com.ruoyi.bst.customerService.domain.CustomerServiceVO;
|
|
|
|
import com.ruoyi.bst.customerService.service.CustomerServiceService;
|
|
|
|
import com.ruoyi.bst.customerService.service.CustomerServiceValidator;
|
|
|
|
import com.ruoyi.common.annotation.Log;
|
|
|
|
import com.ruoyi.common.core.controller.BaseController;
|
|
|
|
import com.ruoyi.common.core.domain.AjaxResult;
|
|
|
|
import com.ruoyi.common.core.page.TableDataInfo;
|
|
|
|
import com.ruoyi.common.enums.BusinessType;
|
2025-04-22 12:00:46 +08:00
|
|
|
import com.ruoyi.common.enums.LogBizType;
|
2025-04-02 20:06:50 +08:00
|
|
|
import com.ruoyi.common.utils.poi.ExcelUtil;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 客服Controller
|
|
|
|
*
|
|
|
|
* @author ruoyi
|
|
|
|
* @date 2025-04-02
|
|
|
|
*/
|
|
|
|
@RestController
|
|
|
|
@RequestMapping("/bst/customerService")
|
|
|
|
public class CustomerServiceController extends BaseController
|
|
|
|
{
|
|
|
|
@Autowired
|
|
|
|
private CustomerServiceService customerServiceService;
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
private CustomerServiceValidator customerServiceValidator;
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
private AreaService areaService;
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
private AreaValidator areaValidator;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 查询客服列表
|
|
|
|
*/
|
|
|
|
@PreAuthorize("@ss.hasPermi('bst:customerService:list')")
|
|
|
|
@GetMapping("/list")
|
|
|
|
public TableDataInfo list(CustomerServiceQuery query)
|
|
|
|
{
|
|
|
|
startPage();
|
|
|
|
startOrderBy();
|
2025-04-03 19:56:03 +08:00
|
|
|
query.setScope(true);
|
2025-04-27 15:07:02 +08:00
|
|
|
query.addAreaPermission(AreaJoinPermission.CUSTOMER_SERVICE_VIEW.getCode());
|
2025-04-02 20:06:50 +08:00
|
|
|
List<CustomerServiceVO> list = customerServiceService.selectCustomerServiceList(query);
|
|
|
|
return getDataTable(list);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 导出客服列表
|
|
|
|
*/
|
|
|
|
@PreAuthorize("@ss.hasPermi('bst:customerService:export')")
|
|
|
|
@Log(title = "客服", businessType = BusinessType.EXPORT)
|
|
|
|
@PostMapping("/export")
|
|
|
|
public void export(HttpServletResponse response, CustomerServiceQuery query)
|
|
|
|
{
|
2025-04-15 18:16:16 +08:00
|
|
|
query.setScope(true);
|
2025-04-27 15:07:02 +08:00
|
|
|
query.addAreaPermission(AreaJoinPermission.CUSTOMER_SERVICE_VIEW.getCode());
|
2025-04-02 20:06:50 +08:00
|
|
|
List<CustomerServiceVO> list = customerServiceService.selectCustomerServiceList(query);
|
|
|
|
ExcelUtil<CustomerServiceVO> util = new ExcelUtil<CustomerServiceVO>(CustomerServiceVO.class);
|
|
|
|
util.exportExcel(response, list, "客服数据");
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 获取客服详细信息
|
|
|
|
*/
|
|
|
|
@PreAuthorize("@ss.hasPermi('bst:customerService:query')")
|
|
|
|
@GetMapping(value = "/{id}")
|
|
|
|
public AjaxResult getInfo(@PathVariable("id") Long id)
|
|
|
|
{
|
2025-04-15 18:16:16 +08:00
|
|
|
return success(customerServiceService.selectCustomerServiceById(id, true));
|
2025-04-02 20:06:50 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 新增客服
|
|
|
|
*/
|
|
|
|
@PreAuthorize("@ss.hasPermi('bst:customerService:add')")
|
2025-04-22 12:00:46 +08:00
|
|
|
@Log(title = "新增客服", businessType = BusinessType.INSERT, bizIdName = "arg0", bizType = LogBizType.CUSTOMER_SERVICE)
|
2025-04-02 20:06:50 +08:00
|
|
|
@PostMapping
|
|
|
|
public AjaxResult add(@RequestBody CustomerService customerService)
|
|
|
|
{
|
2025-04-15 18:16:16 +08:00
|
|
|
if (customerService.getAreaId() != null && !areaValidator.canAddCustomerService(customerService.getAreaId())) {
|
|
|
|
return error("无权为ID为" + customerService.getAreaId() + "的运营区新增客服");
|
2025-04-02 20:06:50 +08:00
|
|
|
}
|
|
|
|
return toAjax(customerServiceService.insertCustomerService(customerService));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 修改客服
|
|
|
|
*/
|
|
|
|
@PreAuthorize("@ss.hasPermi('bst:customerService:edit')")
|
2025-04-22 12:00:46 +08:00
|
|
|
@Log(title = "修改客服", businessType = BusinessType.UPDATE, bizIdName = "arg0", bizType = LogBizType.CUSTOMER_SERVICE)
|
2025-04-02 20:06:50 +08:00
|
|
|
@PutMapping
|
|
|
|
public AjaxResult edit(@RequestBody CustomerService customerService)
|
|
|
|
{
|
|
|
|
if (!customerServiceValidator.canEdit(customerService.getId())) {
|
2025-04-15 18:16:16 +08:00
|
|
|
return error("您没有权限修改ID为" + customerService.getId() + "的客服信息");
|
|
|
|
}
|
|
|
|
if (customerService.getAreaId() != null && !areaValidator.canAddCustomerService(customerService.getAreaId())) {
|
|
|
|
return error("无权修改ID为" + customerService.getAreaId() + "的运营区下的客服信息");
|
2025-04-02 20:06:50 +08:00
|
|
|
}
|
2025-04-03 19:56:03 +08:00
|
|
|
customerService.setStoreId(areaService.selectAreaById(customerService.getAreaId()).getUserId());
|
2025-04-02 20:06:50 +08:00
|
|
|
return toAjax(customerServiceService.updateCustomerService(customerService));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 删除客服
|
|
|
|
*/
|
|
|
|
@PreAuthorize("@ss.hasPermi('bst:customerService:remove')")
|
2025-04-22 12:00:46 +08:00
|
|
|
@Log(title = "删除客服", businessType = BusinessType.DELETE, bizIdName = "arg0", bizType = LogBizType.CUSTOMER_SERVICE)
|
2025-04-02 20:06:50 +08:00
|
|
|
@DeleteMapping("/{ids}")
|
|
|
|
public AjaxResult remove(@PathVariable List<Long> ids)
|
|
|
|
{
|
|
|
|
if (!customerServiceValidator.canDeleteAll(ids)) {
|
|
|
|
return AjaxResult.error("您没有权限删除ID为" + ids + "的客服信息");
|
|
|
|
}
|
|
|
|
return toAjax(customerServiceService.logicDel(ids));
|
|
|
|
}
|
|
|
|
}
|