#
Junjie
2024-01-11 901b2ab3e0e7c592602848cfa256f34c5b0c7bb8
zy-asrs-framework/src/main/resources/templates/Controller.txt
@@ -10,6 +10,7 @@
import com.zy.asrs.framework.common.Cools;
import com.zy.asrs.framework.common.R;
import com.zy.asrs.framework.domain.KeyValueVo;
import com.zy.asrs.framework.common.DateUtils;
import com.zy.asrs.common.web.BaseController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@@ -30,13 +31,20 @@
    @RequestMapping(value = "/@{SIMPLEENTITYNAME}/page/auth")
    @ManagerAuth
    public R page(@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){
    public R page(@RequestParam(defaultValue = "1") Integer curr,
                  @RequestParam(defaultValue = "10") Integer limit,
                  @RequestParam(required = false) String condition,
                  @RequestParam(required = false) String timeRange,
                  @RequestParam Map<String, Object> param) {
        LambdaQueryWrapper<@{ENTITYNAME}> wrapper = new LambdaQueryWrapper<>();
        if (!Cools.isEmpty(condition)) {
            wrapper.like(@{ENTITYNAME}::get@{MAJORCOLUMN0}, condition);
        }
        if (!Cools.isEmpty(timeRange)) {
            String[] range = timeRange.split(RANGE_TIME_LINK);
            wrapper.ge(@{ENTITYNAME}::getCreateTime, DateUtils.convert(range[0]));
            wrapper.le(@{ENTITYNAME}::getCreateTime, DateUtils.convert(range[1]));
        }
        return R.ok(@{SIMPLEENTITYNAME}Service.page(new Page<>(curr, limit), wrapper));
    }
@@ -88,7 +96,9 @@
    public R getDataKV(@RequestParam(required = false) String condition) {
        List<KeyValueVo> vos = new ArrayList<>();
        LambdaQueryWrapper<@{ENTITYNAME}> wrapper = new LambdaQueryWrapper<>();
        wrapper.like(@{ENTITYNAME}::get@{MAJORCOLUMN0}, condition);
        if (!Cools.isEmpty(condition)) {
            wrapper.like(@{ENTITYNAME}::get@{MAJORCOLUMN0}, condition);
        }
        @{SIMPLEENTITYNAME}Service.page(new Page<>(1, 30), wrapper).getRecords().forEach(item -> vos.add(new KeyValueVo(String.valueOf(item.get@{MAJORCOLUMN0}()), item.get@{PRIMARYKEYCOLUMN}())));
        return R.ok().add(vos);
    }