中扬CRM客户关系管理系统
#
luxiaotao1123
2022-09-16 0a25f7ad9d76cb9a1fc0ab7cf92c70f589c41402
src/main/java/com/zy/crm/manager/controller/CstmrController.java
@@ -9,12 +9,16 @@
import com.core.common.Cools;
import com.core.common.DateUtils;
import com.core.common.R;
import com.core.exception.CoolException;
import com.zy.crm.common.web.BaseController;
import com.zy.crm.manager.entity.Cstmr;
import com.zy.crm.manager.service.CstmrService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.*;
@RestController
@@ -40,9 +44,24 @@
        EntityWrapper<Cstmr> wrapper = new EntityWrapper<>();
        excludeTrash(param);
        convert(param, wrapper);
        hostEq(wrapper);
        allLike(Cstmr.class, param.keySet(), wrapper, condition);
        if (!Cools.isEmpty(orderByField)){wrapper.orderBy(humpToLine(orderByField), "asc".equals(orderByType));}
        return R.ok(cstmrService.selectPage(new Page<>(curr, limit), wrapper));
        if (!Cools.isEmpty(orderByField)){wrapper.orderBy(humpToLine(orderByField), "asc".equals(orderByType));} else {
            wrapper.orderBy("create_time", false);
        }
        if (!Cools.isEmpty(param.get("dept_id"))) {
            return R.ok(cstmrService.getPage(new Page<>(curr, limit)
                    , getHostId()
                    , String.valueOf(param.get("dept_id"))
                    , condition)
            );
        } else {
            if (Cools.isEmpty(param.get("user_id"))) {
                wrapper.andNew();
                wrapper.eq("user_id", getUserId());
            }
            return R.ok(cstmrService.selectPage(new Page<>(curr, limit), wrapper));
        }
    }
    private <T> void convert(Map<String, Object> map, EntityWrapper<T> wrapper){
@@ -61,8 +80,12 @@
    @RequestMapping(value = "/cstmr/add/auth")
    @ManagerAuth
    public R add(Cstmr cstmr) {
        cstmr.setHostId(getHostId());
        cstmr.setUuid(cstmrService.getNextUuid());  // 客户代号
        Long hostId = getHostId();
        if (cstmrService.selectByUuid(hostId, cstmr.getUuid()) != null) {
            throw new CoolException("客户已存在");
        }
        cstmr.setHostId(hostId);
        cstmr.setUuid(cstmrService.getNextUuid(hostId));  // 客户代号
        cstmr.setDeptId(getDeptId());               // 所属部门
        cstmr.setUserId(getUserId());               // 所属人员
@@ -133,4 +156,25 @@
        return R.ok();
    }
    /*************************************** 数据相关 ***********************************************/
    /**
     * excel导入
     */
    @PostMapping(value = "/cstmr/excel/import/auth")
    @ManagerAuth
    public R cstmrExcelImport(MultipartFile file) throws IOException {
        return R.ok();
    }
    /**
     * excel导出
     */
    @PostMapping(value = "/cstmr/excel/export/auth")
    @ManagerAuth
    public void cstmrExcelExport(HttpServletResponse response) throws IOException {
    }
}