| | |
| | | package @{COMPANYNAME}.controller; |
| | | |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import @{COMPANYNAME}.entity.@{ENTITYNAME}; |
| | | import @{COMPANYNAME}.service.@{ENTITYNAME}Service; |
| | | import com.zy.asrs.framework.annotations.ManagerAuth; |
| | | 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.*; |
| | | |
| | | import java.util.*; |
| | | |
| | | @RestController |
| | | public class @{ENTITYNAME}Controller extends BaseController { |
| | | |
| | | @Autowired |
| | | private @{ENTITYNAME}Service @{SIMPLEENTITYNAME}Service; |
| | | |
| | | @RequestMapping(value = "/@{SIMPLEENTITYNAME}/{id}/auth") |
| | | @ManagerAuth |
| | | public R get(@PathVariable("id") String id) { |
| | | return R.ok(@{SIMPLEENTITYNAME}Service.getById(String.valueOf(id))); |
| | | } |
| | | |
| | | @RequestMapping(value = "/@{SIMPLEENTITYNAME}/page/auth") |
| | | @ManagerAuth |
| | | 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)); |
| | | } |
| | | |
| | | |
| | | @RequestMapping(value = "/@{SIMPLEENTITYNAME}/add/auth") |
| | | @ManagerAuth |
| | | public R add(@{ENTITYNAME} @{SIMPLEENTITYNAME}) { |
| | | @{SIMPLEENTITYNAME}Service.save(@{SIMPLEENTITYNAME}); |
| | | return R.ok(); |
| | | } |
| | | |
| | | @RequestMapping(value = "/@{SIMPLEENTITYNAME}/update/auth") |
| | | @ManagerAuth |
| | | public R update(@{ENTITYNAME} @{SIMPLEENTITYNAME}){ |
| | | if (Cools.isEmpty(@{SIMPLEENTITYNAME}) || null==@{SIMPLEENTITYNAME}.get@{PRIMARYKEYCOLUMN}()){ |
| | | return R.error(); |
| | | } |
| | | @{SIMPLEENTITYNAME}Service.updateById(@{SIMPLEENTITYNAME}); |
| | | return R.ok(); |
| | | } |
| | | |
| | | @RequestMapping(value = "/@{SIMPLEENTITYNAME}/delete/auth") |
| | | @ManagerAuth |
| | | public R delete(@RequestParam(value="ids[]") Long[] ids){ |
| | | for (Long id : ids){ |
| | | @{SIMPLEENTITYNAME}Service.removeById(id); |
| | | } |
| | | return R.ok(); |
| | | } |
| | | |
| | | @RequestMapping(value = "/@{SIMPLEENTITYNAME}Query/auth") |
| | | @ManagerAuth |
| | | public R query(String condition) { |
| | | LambdaQueryWrapper<@{ENTITYNAME}> wrapper = new LambdaQueryWrapper<>(); |
| | | wrapper.like(@{ENTITYNAME}::get@{MAJORCOLUMN0}, condition); |
| | | Page<@{ENTITYNAME}> page = @{SIMPLEENTITYNAME}Service.page(new Page<>(0, 10), wrapper); |
| | | List<Map<String, Object>> result = new ArrayList<>(); |
| | | for (@{ENTITYNAME} @{SIMPLEENTITYNAME} : page.getRecords()){ |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("id", @{SIMPLEENTITYNAME}.get@{PRIMARYKEYCOLUMN}()); |
| | | map.put("value", @{SIMPLEENTITYNAME}.get@{MAJORCOLUMN_UP}()); |
| | | result.add(map); |
| | | } |
| | | return R.ok(result); |
| | | } |
| | | |
| | | @RequestMapping("/@{SIMPLEENTITYNAME}/all/get/kv") |
| | | @ManagerAuth |
| | | public R getDataKV(@RequestParam(required = false) String condition) { |
| | | List<KeyValueVo> vos = new ArrayList<>(); |
| | | LambdaQueryWrapper<@{ENTITYNAME}> wrapper = new LambdaQueryWrapper<>(); |
| | | 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); |
| | | } |
| | | |
| | | } |
| | | package @{COMPANYNAME}.controller;
|
| | |
|
| | | import com.alibaba.fastjson.JSONArray;
|
| | | import com.alibaba.fastjson.JSONObject;
|
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
| | | import @{COMPANYNAME}.entity.@{ENTITYNAME};
|
| | | import @{COMPANYNAME}.service.@{ENTITYNAME}Service;
|
| | | import com.zy.asrs.framework.annotations.ManagerAuth;
|
| | | 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.*;
|
| | |
|
| | | import java.util.*;
|
| | |
|
| | | @RestController
|
| | | public class @{ENTITYNAME}Controller extends BaseController {
|
| | |
|
| | | @Autowired
|
| | | private @{ENTITYNAME}Service @{SIMPLEENTITYNAME}Service;
|
| | |
|
| | | @RequestMapping(value = "/@{SIMPLEENTITYNAME}/{id}/auth")
|
| | | @ManagerAuth
|
| | | public R get(@PathVariable("id") String id) {
|
| | | return R.ok(@{SIMPLEENTITYNAME}Service.getById(String.valueOf(id)));
|
| | | }
|
| | |
|
| | | @RequestMapping(value = "/@{SIMPLEENTITYNAME}/page/auth")
|
| | | @ManagerAuth
|
| | | 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));
|
| | | }
|
| | |
|
| | |
|
| | | @RequestMapping(value = "/@{SIMPLEENTITYNAME}/add/auth")
|
| | | @ManagerAuth
|
| | | public R add(@{ENTITYNAME} @{SIMPLEENTITYNAME}) {
|
| | | @{SIMPLEENTITYNAME}Service.save(@{SIMPLEENTITYNAME});
|
| | | return R.ok();
|
| | | }
|
| | |
|
| | | @RequestMapping(value = "/@{SIMPLEENTITYNAME}/update/auth")
|
| | | @ManagerAuth
|
| | | public R update(@{ENTITYNAME} @{SIMPLEENTITYNAME}){
|
| | | if (Cools.isEmpty(@{SIMPLEENTITYNAME}) || null==@{SIMPLEENTITYNAME}.get@{PRIMARYKEYCOLUMN}()){
|
| | | return R.error();
|
| | | }
|
| | | @{SIMPLEENTITYNAME}Service.updateById(@{SIMPLEENTITYNAME});
|
| | | return R.ok();
|
| | | }
|
| | |
|
| | | @RequestMapping(value = "/@{SIMPLEENTITYNAME}/delete/auth")
|
| | | @ManagerAuth
|
| | | public R delete(@RequestParam(value="ids[]") Long[] ids){
|
| | | for (Long id : ids){
|
| | | @{SIMPLEENTITYNAME}Service.removeById(id);
|
| | | }
|
| | | return R.ok();
|
| | | }
|
| | |
|
| | | @RequestMapping(value = "/@{SIMPLEENTITYNAME}Query/auth")
|
| | | @ManagerAuth
|
| | | public R query(String condition) {
|
| | | LambdaQueryWrapper<@{ENTITYNAME}> wrapper = new LambdaQueryWrapper<>();
|
| | | wrapper.like(@{ENTITYNAME}::get@{MAJORCOLUMN0}, condition);
|
| | | Page<@{ENTITYNAME}> page = @{SIMPLEENTITYNAME}Service.page(new Page<>(0, 10), wrapper);
|
| | | List<Map<String, Object>> result = new ArrayList<>();
|
| | | for (@{ENTITYNAME} @{SIMPLEENTITYNAME} : page.getRecords()){
|
| | | Map<String, Object> map = new HashMap<>();
|
| | | map.put("id", @{SIMPLEENTITYNAME}.get@{PRIMARYKEYCOLUMN}());
|
| | | map.put("value", @{SIMPLEENTITYNAME}.get@{MAJORCOLUMN_UP}());
|
| | | result.add(map);
|
| | | }
|
| | | return R.ok(result);
|
| | | }
|
| | |
|
| | | @RequestMapping("/@{SIMPLEENTITYNAME}/all/get/kv")
|
| | | @ManagerAuth
|
| | | public R getDataKV(@RequestParam(required = false) String condition) {
|
| | | List<KeyValueVo> vos = new ArrayList<>();
|
| | | LambdaQueryWrapper<@{ENTITYNAME}> wrapper = new LambdaQueryWrapper<>();
|
| | | 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);
|
| | | }
|
| | |
|
| | | }
|