xuqiang vor 1 Jahr
Ursprung
Commit
a386277f47

+ 88 - 0
linkwe-api/src/main/java/com/linkwechat/controller/khgl/BehaviorTypeController.java

@@ -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 ? "启用成功" : "禁用成功");
+    }
+
+}

+ 44 - 0
linkwe-service/src/main/java/com/linkwechat/domain/kh/BehaviorType.java

@@ -0,0 +1,44 @@
+package com.linkwechat.domain.kh;
+
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.linkwechat.common.core.domain.BaseEntity;
+import lombok.Data;
+
+@TableName(value ="kh_behavior_type")
+@Data
+public class BehaviorType extends BaseEntity {
+
+    /**
+     * 主键id
+     */
+    @TableId(type = IdType.ASSIGN_ID)
+    private Long id;
+
+    /**
+     * 编码
+     */
+    private String code;
+
+    /**
+     * 名称
+     */
+    private String name;
+
+
+    /**
+     * 描述
+     */
+    private String description;
+
+    /**
+     * 0:正常;1:删除;
+     */
+    private Integer delFlag;
+
+
+
+
+}

+ 12 - 0
linkwe-service/src/main/java/com/linkwechat/mapper/BehaviorTypeMapper.java

@@ -0,0 +1,12 @@
+package com.linkwechat.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.linkwechat.domain.kh.BehaviorType;
+import org.apache.ibatis.annotations.Select;
+
+public interface BehaviorTypeMapper extends BaseMapper<BehaviorType> {
+
+    @Select("select max(code) from kh_behavior_type")
+    String selectMaxCode();
+
+}

+ 10 - 0
linkwe-service/src/main/java/com/linkwechat/service/BehaviorTypeService.java

@@ -0,0 +1,10 @@
+package com.linkwechat.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.linkwechat.domain.kh.BehaviorType;
+
+public interface BehaviorTypeService extends IService<BehaviorType> {
+
+    String selectMaxCode();
+
+}

+ 16 - 0
linkwe-service/src/main/java/com/linkwechat/service/impl/BehaviorTypeServiceImpl.java

@@ -0,0 +1,16 @@
+package com.linkwechat.service.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.linkwechat.domain.kh.BehaviorType;
+import com.linkwechat.mapper.BehaviorTypeMapper;
+import com.linkwechat.service.BehaviorTypeService;
+import org.springframework.stereotype.Service;
+
+
+@Service
+public class BehaviorTypeServiceImpl extends ServiceImpl<BehaviorTypeMapper, BehaviorType> implements BehaviorTypeService {
+    @Override
+    public String selectMaxCode() {
+        return baseMapper.selectMaxCode();
+    }
+}