中扬CRM客户关系管理系统
#
luxiaotao1123
2022-11-19 0d15a761181fded7a6512e4146e5156725fde1f7
src/main/java/com/zy/crm/manager/controller/PlanController.java
@@ -7,7 +7,6 @@
import com.core.annotations.ManagerAuth;
import com.core.common.BaseRes;
import com.core.common.Cools;
import com.core.common.DateUtils;
import com.core.common.R;
import com.core.domain.KeyValueVo;
import com.zy.crm.common.web.BaseController;
@@ -33,33 +32,19 @@
        return R.ok(planService.selectById(String.valueOf(id)));
    }
    @RequestMapping(value = "/plan/list/auth")
    @RequestMapping(value = "/plan/page/auth")
    @ManagerAuth
    public R list(@RequestParam(defaultValue = "1")Integer curr,
                  @RequestParam(defaultValue = "10")Integer limit,
                  @RequestParam(required = false)String orderByField,
                  @RequestParam(required = false)String orderByType,
                  @RequestParam(required = false)String condition,
                  @RequestParam Map<String, Object> param){
        EntityWrapper<Plan> wrapper = new EntityWrapper<>();
        excludeTrash(param);
        convert(param, wrapper);
        allLike(Plan.class, param.keySet(), wrapper, condition);
        if (!Cools.isEmpty(orderByField)){wrapper.orderBy(humpToLine(orderByField), "asc".equals(orderByType));}
        return R.ok(planService.selectPage(new Page<>(curr, limit), wrapper));
    }
    private <T> void convert(Map<String, Object> map, EntityWrapper<T> wrapper){
        for (Map.Entry<String, Object> entry : map.entrySet()){
            String val = String.valueOf(entry.getValue());
            if (val.contains(RANGE_TIME_LINK)){
                String[] dates = val.split(RANGE_TIME_LINK);
                wrapper.ge(entry.getKey(), DateUtils.convert(dates[0]));
                wrapper.le(entry.getKey(), DateUtils.convert(dates[1]));
            } else {
                wrapper.like(entry.getKey(), val);
            }
        }
    public R page(@RequestParam(defaultValue = "1") Integer curr,
                  @RequestParam(defaultValue = "10") Integer limit,
                  @RequestParam(required = false) String condition,
                  @RequestParam(required = false, value = "dept_id") Long deptId,
                  @RequestParam(required = false, value = "user_id") Long userId) {
        return R.ok(planService.getPage(new Page<>(curr, limit)
                , getHostId()
                , deptId == null ? null : String.valueOf(deptId)
                , userId == null ? getUserId() : userId
                , condition)
        );
    }
    @RequestMapping(value = "/plan/add/auth")
@@ -86,17 +71,6 @@
            planService.deleteById(id);
        }
        return R.ok();
    }
    @RequestMapping(value = "/plan/export/auth")
    @ManagerAuth
    public R export(@RequestBody JSONObject param){
        EntityWrapper<Plan> wrapper = new EntityWrapper<>();
        List<String> fields = JSONObject.parseArray(param.getJSONArray("fields").toJSONString(), String.class);
        Map<String, Object> map = excludeTrash(param.getJSONObject("plan"));
        convert(map, wrapper);
        List<Plan> list = planService.selectList(wrapper);
        return R.ok(exportSupport(list, fields));
    }
    @RequestMapping(value = "/planQuery/auth")