|
|
@@ -0,0 +1,170 @@
|
|
|
+package com.fs.company.controller.crm;
|
|
|
+
|
|
|
+import com.fs.common.annotation.Log;
|
|
|
+import com.fs.common.core.controller.BaseController;
|
|
|
+import com.fs.common.core.domain.AjaxResult;
|
|
|
+import com.fs.common.core.domain.R;
|
|
|
+import com.fs.common.enums.BusinessType;
|
|
|
+import com.fs.common.utils.ServletUtils;
|
|
|
+import com.fs.common.utils.poi.ExcelUtil;
|
|
|
+import com.fs.crm.domain.CrmCustomerProperty;
|
|
|
+import com.fs.crm.service.ICrmCustomerPropertyService;
|
|
|
+import com.fs.framework.security.LoginUser;
|
|
|
+import com.fs.framework.service.TokenService;
|
|
|
+import io.swagger.annotations.Api;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
+import io.swagger.annotations.ApiParam;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+@Api(tags = "客户属性标签管理")
|
|
|
+@RestController
|
|
|
+@RequestMapping("/crm/customerProperty")
|
|
|
+public class CrmCustomerPropertyController extends BaseController {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ICrmCustomerPropertyService crmCustomerPropertyService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private TokenService tokenService;
|
|
|
+
|
|
|
+ @ApiOperation("根据客户 ID 查询属性标签列表")
|
|
|
+ @PreAuthorize("@ss.hasPermi('crm:customer:query')")
|
|
|
+ @GetMapping("/list/{customerId}")
|
|
|
+ public R listByCustomerId(@PathVariable("customerId") Long customerId) {
|
|
|
+ List<CrmCustomerProperty> list = crmCustomerPropertyService.selectCrmCustomerPropertyByCustomerId(customerId);
|
|
|
+ return R.ok().put("data", list);
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation("查询单个属性标签详情")
|
|
|
+ @PreAuthorize("@ss.hasPermi('crm:customer:query')")
|
|
|
+ @GetMapping("/{id}")
|
|
|
+ public R getInfo(@PathVariable("id") Long id) {
|
|
|
+ CrmCustomerProperty property = crmCustomerPropertyService.selectCrmCustomerPropertyById(id);
|
|
|
+ return R.ok().put("data", property);
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation("为客户添加属性标签")
|
|
|
+ @PreAuthorize("@ss.hasPermi('crm:customer:edit')")
|
|
|
+ @Log(title = "客户属性标签", businessType = BusinessType.INSERT)
|
|
|
+ @PostMapping("/add")
|
|
|
+ public AjaxResult add(@RequestBody CrmCustomerProperty property) {
|
|
|
+ LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
|
|
|
+ property.setCreateBy(loginUser.getUsername());
|
|
|
+ return toAjax(crmCustomerPropertyService.insertCrmCustomerProperty(property));
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation("为客户添加或更新属性标签")
|
|
|
+ @PreAuthorize("@ss.hasPermi('crm:customer:edit')")
|
|
|
+ @Log(title = "客户属性标签", businessType = BusinessType.UPDATE)
|
|
|
+ @PostMapping("/addOrUpdate")
|
|
|
+ public AjaxResult addOrUpdate(@RequestBody CrmCustomerProperty property) {
|
|
|
+ LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
|
|
|
+ return toAjax(crmCustomerPropertyService.addOrUpdateCustomerPropertyWithExtra(
|
|
|
+ property.getCustomerId(),
|
|
|
+ property.getPropertyId(),
|
|
|
+ property.getPropertyName(),
|
|
|
+ property.getPropertyValue(),
|
|
|
+ property.getPropertyValueType(),
|
|
|
+ property.getTradeType(),
|
|
|
+ property.getIntention(),
|
|
|
+ property.getLikeRatio(),
|
|
|
+ loginUser.getUsername()
|
|
|
+ ));
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation("批量为客户添加属性标签")
|
|
|
+ @PreAuthorize("@ss.hasPermi('crm:customer:edit')")
|
|
|
+ @Log(title = "客户属性标签", businessType = BusinessType.INSERT)
|
|
|
+ @PostMapping("/batchAdd/{customerId}")
|
|
|
+ public AjaxResult batchAdd(
|
|
|
+ @PathVariable("customerId") Long customerId,
|
|
|
+ @RequestBody List<CrmCustomerProperty> properties) {
|
|
|
+ LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
|
|
|
+ for (CrmCustomerProperty property : properties) {
|
|
|
+ property.setCreateBy(loginUser.getUsername());
|
|
|
+ }
|
|
|
+ return toAjax(crmCustomerPropertyService.batchAddCustomerProperties(customerId, properties));
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation("通过属性模板 ID 为客户添加标签")
|
|
|
+ @PreAuthorize("@ss.hasPermi('crm:customer:edit')")
|
|
|
+ @Log(title = "客户属性标签", businessType = BusinessType.INSERT)
|
|
|
+ @PostMapping("/addByTemplateId")
|
|
|
+ public AjaxResult addByTemplateId(
|
|
|
+ @ApiParam(required = true, name = "customerId", value = "客户 ID") @RequestParam Long customerId,
|
|
|
+ @ApiParam(required = true, name = "templateId", value = "属性模板 ID") @RequestParam Long templateId,
|
|
|
+ @ApiParam(required = true, name = "propertyValue", value = "属性值") @RequestParam String propertyValue) {
|
|
|
+ LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
|
|
|
+ return toAjax(crmCustomerPropertyService.addPropertyByTemplateId(customerId, templateId, propertyValue, loginUser.getUsername()));
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation("通过属性模板 ID 为客户添加或更新标签")
|
|
|
+ @PreAuthorize("@ss.hasPermi('crm:customer:edit')")
|
|
|
+ @Log(title = "客户属性标签", businessType = BusinessType.UPDATE)
|
|
|
+ @PostMapping("/addOrUpdateByTemplateId")
|
|
|
+ public AjaxResult addOrUpdateByTemplateId(
|
|
|
+ @ApiParam(required = true, name = "customerId", value = "客户 ID") @RequestParam Long customerId,
|
|
|
+ @ApiParam(required = true, name = "templateId", value = "属性模板 ID") @RequestParam Long templateId,
|
|
|
+ @ApiParam(required = true, name = "propertyValue", value = "属性值") @RequestParam String propertyValue) {
|
|
|
+ LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
|
|
|
+ return toAjax(crmCustomerPropertyService.addOrUpdatePropertyByTemplateId(customerId, templateId, propertyValue, loginUser.getUsername()));
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation("批量通过属性模板 ID 为客户添加标签")
|
|
|
+ @PreAuthorize("@ss.hasPermi('crm:customer:edit')")
|
|
|
+ @Log(title = "客户属性标签", businessType = BusinessType.INSERT)
|
|
|
+ @PostMapping("/batchAddByTemplateIds/{customerId}")
|
|
|
+ public AjaxResult batchAddByTemplateIds(
|
|
|
+ @PathVariable("customerId") Long customerId,
|
|
|
+ @RequestBody Map<Long, String> propertyMap) {
|
|
|
+ LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
|
|
|
+ return toAjax(crmCustomerPropertyService.batchAddPropertiesByTemplateIds(customerId, propertyMap, loginUser.getUsername()));
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation("修改客户属性标签")
|
|
|
+ @PreAuthorize("@ss.hasPermi('crm:customer:edit')")
|
|
|
+ @Log(title = "客户属性标签", businessType = BusinessType.UPDATE)
|
|
|
+ @PutMapping
|
|
|
+ public AjaxResult edit(@RequestBody CrmCustomerProperty property) {
|
|
|
+ LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
|
|
|
+ property.setUpdateBy(loginUser.getUsername());
|
|
|
+ return toAjax(crmCustomerPropertyService.updateCrmCustomerProperty(property));
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation("删除客户属性标签")
|
|
|
+ @PreAuthorize("@ss.hasPermi('crm:customer:edit')")
|
|
|
+ @Log(title = "客户属性标签", businessType = BusinessType.DELETE)
|
|
|
+ @DeleteMapping("/{ids}")
|
|
|
+ public AjaxResult remove(@PathVariable Long[] ids) {
|
|
|
+ return toAjax(crmCustomerPropertyService.deleteCrmCustomerPropertyByIds(ids));
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation("删除客户单个属性标签")
|
|
|
+ @PreAuthorize("@ss.hasPermi('crm:customer:edit')")
|
|
|
+ @Log(title = "客户属性标签", businessType = BusinessType.DELETE)
|
|
|
+ @DeleteMapping("/deleteByPropertyId")
|
|
|
+ public AjaxResult deleteByPropertyId(
|
|
|
+ @ApiParam(required = true, name = "customerId", value = "客户 ID") @RequestParam Long customerId,
|
|
|
+ @ApiParam(required = true, name = "propertyId", value = "属性模板 ID") @RequestParam Long propertyId) {
|
|
|
+ return toAjax(crmCustomerPropertyService.lambdaUpdate()
|
|
|
+ .eq(CrmCustomerProperty::getCustomerId, customerId)
|
|
|
+ .eq(CrmCustomerProperty::getPropertyId, propertyId)
|
|
|
+ .remove());
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation("导出客户属性标签")
|
|
|
+ @PreAuthorize("@ss.hasPermi('crm:customer:export')")
|
|
|
+ @Log(title = "客户属性标签", businessType = BusinessType.EXPORT)
|
|
|
+ @GetMapping("/export")
|
|
|
+ public AjaxResult export(CrmCustomerProperty crmCustomerProperty) {
|
|
|
+ LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
|
|
|
+ List<CrmCustomerProperty> list = crmCustomerPropertyService.selectCrmCustomerPropertyList(crmCustomerProperty);
|
|
|
+ ExcelUtil<CrmCustomerProperty> util = new ExcelUtil<CrmCustomerProperty>(CrmCustomerProperty.class);
|
|
|
+ return util.exportExcel(list, "客户属性标签数据");
|
|
|
+ }
|
|
|
+}
|