|
|
@@ -0,0 +1,88 @@
|
|
|
+package com.linkwechat.controller.khgl;
|
|
|
+
|
|
|
+
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.linkwechat.common.core.controller.BaseController;
|
|
|
+import com.linkwechat.common.core.domain.AjaxResult;
|
|
|
+import com.linkwechat.common.core.page.TableDataInfo;
|
|
|
+import com.linkwechat.common.utils.StringUtils;
|
|
|
+import com.linkwechat.domain.kh.BehaviorType;
|
|
|
+import com.linkwechat.service.BehaviorTypeService;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 客户管理行为类型
|
|
|
+ *
|
|
|
+ * @author kewen
|
|
|
+ */
|
|
|
+@RestController
|
|
|
+@RequestMapping(value = "/behavior/type")
|
|
|
+public class BehaviorTypeController extends BaseController {
|
|
|
+
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private BehaviorTypeService behaviorTypeService;
|
|
|
+
|
|
|
+ @GetMapping(value = "/list")
|
|
|
+ public TableDataInfo list(BehaviorType behaviorType) {
|
|
|
+ startPage();
|
|
|
+ LambdaQueryWrapper<BehaviorType> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ if (behaviorType.getName() != null){
|
|
|
+ lambdaQueryWrapper.like(BehaviorType::getName, behaviorType.getName());
|
|
|
+ }
|
|
|
+ if (behaviorType.getDelFlag() != null){
|
|
|
+ lambdaQueryWrapper.eq(BehaviorType::getDelFlag, behaviorType.getDelFlag());
|
|
|
+ }
|
|
|
+ List<BehaviorType> list = behaviorTypeService.list(lambdaQueryWrapper);
|
|
|
+ return getDataTable(list);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @GetMapping(value = "/get")
|
|
|
+ public AjaxResult get(@RequestParam("id") Long id) {
|
|
|
+ return AjaxResult.success(behaviorTypeService.getById(id));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @PostMapping(value = "/add")
|
|
|
+ public AjaxResult add(@RequestBody BehaviorType behaviorType) {
|
|
|
+ behaviorType.setCode(getCode());
|
|
|
+ return AjaxResult.success(behaviorTypeService.save(behaviorType));
|
|
|
+ }
|
|
|
+
|
|
|
+ public String getCode(){
|
|
|
+ String code = behaviorTypeService.selectMaxCode();
|
|
|
+ if (StringUtils.isEmpty( code)){
|
|
|
+ return "ACT001";
|
|
|
+ }
|
|
|
+ // 提取前缀和数字部分
|
|
|
+ String prefix = code.replaceAll("\\d", "");
|
|
|
+ String numberStr = code.replaceAll("\\D", "");
|
|
|
+
|
|
|
+ // 递增数字并格式化
|
|
|
+ int number = Integer.parseInt(numberStr) + 1;
|
|
|
+ return prefix + String.format("%0" + numberStr.length() + "d", number);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @PostMapping(value = "/update")
|
|
|
+ public AjaxResult update(@RequestBody BehaviorType behaviorType) {
|
|
|
+ return AjaxResult.success(behaviorTypeService.updateById(behaviorType));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @GetMapping(value = "/disableEnable")
|
|
|
+ public AjaxResult disableEnable(@RequestParam("id") String id) {
|
|
|
+ BehaviorType behaviorType = behaviorTypeService.getById(id);
|
|
|
+ if (null == behaviorType){
|
|
|
+ return AjaxResult.error("数据不存在");
|
|
|
+ }
|
|
|
+ behaviorType.setDelFlag(behaviorType.getDelFlag() == 0 ? 1 : 0);
|
|
|
+ behaviorTypeService.updateById(behaviorType);
|
|
|
+ return AjaxResult.success(behaviorType.getDelFlag() == 0 ? "启用成功" : "禁用成功");
|
|
|
+ }
|
|
|
+
|
|
|
+}
|