yanyang #36

Merged
yanyang merged 2 commits from yanyang into master 2023-12-28 15:34:13 +08:00
12 changed files with 200 additions and 27 deletions

View File

@ -1,5 +1,6 @@
package com.cnbm.packing.controller; package com.cnbm.packing.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.cnbm.admin.annotation.LogOperation; import com.cnbm.admin.annotation.LogOperation;
import com.cnbm.common.constant.Constant; import com.cnbm.common.constant.Constant;
import com.cnbm.common.page.PageData; import com.cnbm.common.page.PageData;
@ -10,8 +11,11 @@ import com.cnbm.common.validator.ValidatorUtils;
import com.cnbm.common.validator.group.AddGroup; import com.cnbm.common.validator.group.AddGroup;
import com.cnbm.common.validator.group.DefaultGroup; import com.cnbm.common.validator.group.DefaultGroup;
import com.cnbm.common.validator.group.UpdateGroup; import com.cnbm.common.validator.group.UpdateGroup;
import com.cnbm.packing.dto.IdVo;
import com.cnbm.packing.dto.ProductLevelDTO; import com.cnbm.packing.dto.ProductLevelDTO;
import com.cnbm.packing.entity.ProductLevel;
import com.cnbm.packing.excel.ProductLevelExcel; import com.cnbm.packing.excel.ProductLevelExcel;
import com.cnbm.packing.mapper.ProductLevelMapper;
import com.cnbm.packing.service.ProductLevelServiceBiz; import com.cnbm.packing.service.ProductLevelServiceBiz;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParam;
@ -39,6 +43,8 @@ import java.util.Map;
public class ProductLevelController { public class ProductLevelController {
@Autowired @Autowired
private ProductLevelServiceBiz productLevelService; private ProductLevelServiceBiz productLevelService;
@Autowired
private ProductLevelMapper productLevelMapper;
@GetMapping("page") @GetMapping("page")
@ApiOperation("分页") @ApiOperation("分页")
@ -69,26 +75,51 @@ public class ProductLevelController {
@ApiOperation("保存") @ApiOperation("保存")
@LogOperation("保存") @LogOperation("保存")
// @PreAuthorize("@ex.hasAuthority('basic:productLevel:save')") // @PreAuthorize("@ex.hasAuthority('basic:productLevel:save')")
public Result<Long> save(@RequestBody ProductLevelDTO dto){ public Result<IdVo> save(@RequestBody ProductLevelDTO dto){
//效验数据 //效验数据
ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class);
productLevelService.save(dto); //验证编码是否重名
QueryWrapper<ProductLevel> wrapper1 = new QueryWrapper<>();
return new Result<Long>().ok(dto.getId()); wrapper1.eq(ProductLevel.CODE, dto.getCode());
if(productLevelMapper.selectCount(wrapper1)!= 0){
return new Result().error(1,"编码重复");
}
//验证名称是否重名
QueryWrapper<ProductLevel> wrapper2 = new QueryWrapper<>();
wrapper2.eq(ProductLevel.PRODUCT_LEVEL, dto.getProductLevel());
if(productLevelMapper.selectCount(wrapper2)!= 0){
return new Result().error(1,"名称重复");
}
else {
return new Result<IdVo>().ok(productLevelService.add(dto));
}
} }
@PutMapping @PutMapping
@ApiOperation("修改") @ApiOperation("修改")
@LogOperation("修改") @LogOperation("修改")
// @PreAuthorize("@ex.hasAuthority('basic:productLevel:update')") // @PreAuthorize("@ex.hasAuthority('basic:productLevel:update')")
public Result<Long> update(@RequestBody ProductLevelDTO dto){ public Result<IdVo> update(@RequestBody ProductLevelDTO dto){
//效验数据 //效验数据
ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class);
productLevelService.update(dto); //验证编码是否重名
ProductLevelDTO entity = productLevelService.get(dto.getId());
return new Result<Long>().ok(dto.getId()); QueryWrapper<ProductLevel> wrapper1 = new QueryWrapper<>();
wrapper1.eq(ProductLevel.CODE, dto.getCode());
if(entity.getCode()!=dto.getCode() && productLevelMapper.selectCount(wrapper1)!= 0){
return new Result().error(1,"编码重复");
}
//验证名称是否重名
QueryWrapper<ProductLevel> wrapper2 = new QueryWrapper<>();
wrapper2.eq(ProductLevel.PRODUCT_LEVEL, dto.getProductLevel());
if(entity.getProductLevel()!=dto.getProductLevel() && productLevelMapper.selectCount(wrapper2)!= 0){
return new Result().error(1,"名称重复");
}
else {
return new Result<IdVo>().ok(productLevelService.edit(dto));
}
} }
@DeleteMapping @DeleteMapping

View File

@ -1,5 +1,6 @@
package com.cnbm.packing.controller; package com.cnbm.packing.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.cnbm.admin.annotation.LogOperation; import com.cnbm.admin.annotation.LogOperation;
import com.cnbm.common.constant.Constant; import com.cnbm.common.constant.Constant;
import com.cnbm.common.page.PageData; import com.cnbm.common.page.PageData;
@ -10,8 +11,11 @@ import com.cnbm.common.validator.ValidatorUtils;
import com.cnbm.common.validator.group.AddGroup; import com.cnbm.common.validator.group.AddGroup;
import com.cnbm.common.validator.group.DefaultGroup; import com.cnbm.common.validator.group.DefaultGroup;
import com.cnbm.common.validator.group.UpdateGroup; import com.cnbm.common.validator.group.UpdateGroup;
import com.cnbm.packing.dto.IdVo;
import com.cnbm.packing.dto.ScenesDTO; import com.cnbm.packing.dto.ScenesDTO;
import com.cnbm.packing.entity.Scenes;
import com.cnbm.packing.excel.ScenesExcel; import com.cnbm.packing.excel.ScenesExcel;
import com.cnbm.packing.mapper.ScenesMapper;
import com.cnbm.packing.service.ScenesServiceBiz; import com.cnbm.packing.service.ScenesServiceBiz;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParam;
@ -39,6 +43,8 @@ import java.util.Map;
public class ScenesController { public class ScenesController {
@Autowired @Autowired
private ScenesServiceBiz scenesService; private ScenesServiceBiz scenesService;
@Autowired
private ScenesMapper scenesMapper;
@GetMapping("page") @GetMapping("page")
@ApiOperation("分页") @ApiOperation("分页")
@ -69,26 +75,53 @@ public class ScenesController {
@ApiOperation("保存") @ApiOperation("保存")
@LogOperation("保存") @LogOperation("保存")
// @PreAuthorize("@ex.hasAuthority('basic:scenes:save')") // @PreAuthorize("@ex.hasAuthority('basic:scenes:save')")
public Result<Long> save(@RequestBody ScenesDTO dto){ public Result<IdVo> save(@RequestBody ScenesDTO dto){
//效验数据 //效验数据
ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class);
scenesService.save(dto); //验证编码是否重名
QueryWrapper<Scenes> wrapper1 = new QueryWrapper<>();
return new Result<Long>().ok(dto.getId()); wrapper1.eq(Scenes.CODE, dto.getCode());
if(scenesMapper.selectCount(wrapper1)!= 0){
return new Result().error(1,"编码重复");
}
//验证名称是否重名
QueryWrapper<Scenes> wrapper2 = new QueryWrapper<>();
wrapper2.eq(Scenes.SCENES_NAME, dto.getScenesName());
System.out.println(scenesMapper.selectCount(wrapper2));
if(scenesMapper.selectCount(wrapper2)!= 0){
return new Result().error(1,"名称重复");
}
else {
return new Result<IdVo>().ok(scenesService.add(dto));
}
} }
@PutMapping @PutMapping
@ApiOperation("修改") @ApiOperation("修改")
@LogOperation("修改") @LogOperation("修改")
// @PreAuthorize("@ex.hasAuthority('basic:scenes:update')") // @PreAuthorize("@ex.hasAuthority('basic:scenes:update')")
public Result<Long> update(@RequestBody ScenesDTO dto){ public Result<IdVo> update(@RequestBody ScenesDTO dto){
//效验数据 //效验数据
ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class);
scenesService.update(dto); //验证编码是否重名
ScenesDTO entity = scenesService.get(dto.getId());
return new Result<Long>().ok(dto.getId()); QueryWrapper<Scenes> wrapper1 = new QueryWrapper<>();
wrapper1.eq(Scenes.CODE, dto.getCode());
if(entity.getCode()!=dto.getCode() && scenesMapper.selectCount(wrapper1)!= 0){
return new Result().error(1,"编码重复");
}
//验证名称是否重名
QueryWrapper<Scenes> wrapper2 = new QueryWrapper<>();
wrapper2.eq(Scenes.SCENES_NAME, dto.getScenesName());
System.out.println(scenesMapper.selectCount(wrapper2));
if(entity.getScenesName()!=dto.getScenesName() && scenesMapper.selectCount(wrapper2)!= 0){
return new Result().error(1,"名称重复");
}
else {
return new Result<IdVo>().ok(scenesService.edit(dto));
}
} }
@DeleteMapping @DeleteMapping

View File

@ -1,5 +1,6 @@
package com.cnbm.packing.controller; package com.cnbm.packing.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.cnbm.admin.annotation.LogOperation; import com.cnbm.admin.annotation.LogOperation;
import com.cnbm.common.constant.Constant; import com.cnbm.common.constant.Constant;
import com.cnbm.common.page.PageData; import com.cnbm.common.page.PageData;
@ -10,8 +11,11 @@ import com.cnbm.common.validator.ValidatorUtils;
import com.cnbm.common.validator.group.AddGroup; import com.cnbm.common.validator.group.AddGroup;
import com.cnbm.common.validator.group.DefaultGroup; import com.cnbm.common.validator.group.DefaultGroup;
import com.cnbm.common.validator.group.UpdateGroup; import com.cnbm.common.validator.group.UpdateGroup;
import com.cnbm.packing.dto.IdVo;
import com.cnbm.packing.dto.WorkingTimeDTO; import com.cnbm.packing.dto.WorkingTimeDTO;
import com.cnbm.packing.entity.WorkingTime;
import com.cnbm.packing.excel.WorkingTimeExcel; import com.cnbm.packing.excel.WorkingTimeExcel;
import com.cnbm.packing.mapper.WorkingTimeMapper;
import com.cnbm.packing.service.WorkingTimeServiceBiz; import com.cnbm.packing.service.WorkingTimeServiceBiz;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParam;
@ -41,6 +45,8 @@ import java.util.Map;
public class WorkingTimeController { public class WorkingTimeController {
@Autowired @Autowired
private WorkingTimeServiceBiz workingTimeService; private WorkingTimeServiceBiz workingTimeService;
@Autowired
private WorkingTimeMapper workingTimeMapper;
@GetMapping("page") @GetMapping("page")
@ApiOperation("分页") @ApiOperation("分页")
@ -68,25 +74,50 @@ public class WorkingTimeController {
@PostMapping @PostMapping
@ApiOperation("保存") @ApiOperation("保存")
@LogOperation("保存") @LogOperation("保存")
public Result<Long> save(@RequestBody WorkingTimeDTO dto){ public Result<IdVo> save(@RequestBody WorkingTimeDTO dto){
//效验数据 //效验数据
ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class);
workingTimeService.save(dto); //验证编码是否重名
QueryWrapper<WorkingTime> wrapper1 = new QueryWrapper<>();
return new Result<Long>().ok(dto.getId()); wrapper1.eq(WorkingTime.CODE, dto.getCode());
if(workingTimeMapper.selectCount(wrapper1)!= 0){
return new Result().error(1,"编码重复");
}
//验证名称是否重名
QueryWrapper<WorkingTime> wrapper2 = new QueryWrapper<>();
wrapper2.eq(WorkingTime.ORDER_NAME, dto.getOrderName());
if(workingTimeMapper.selectCount(wrapper2)!= 0){
return new Result().error(1,"名称重复");
}
else {
return new Result<IdVo>().ok(workingTimeService.add(dto));
}
} }
@PutMapping @PutMapping
@ApiOperation("修改") @ApiOperation("修改")
@LogOperation("修改") @LogOperation("修改")
public Result<Long> update(@RequestBody WorkingTimeDTO dto){ public Result<IdVo> update(@RequestBody WorkingTimeDTO dto){
//效验数据 //效验数据
ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class);
workingTimeService.update(dto); //验证编码是否重名
WorkingTimeDTO entity = workingTimeService.get(dto.getId());
return new Result<Long>().ok(dto.getId()); QueryWrapper<WorkingTime> wrapper1 = new QueryWrapper<>();
wrapper1.eq(WorkingTime.CODE, dto.getCode());
if(entity.getCode()!=dto.getCode() && workingTimeMapper.selectCount(wrapper1)!= 0){
return new Result().error(1,"编码重复");
}
//验证名称是否重名
QueryWrapper<WorkingTime> wrapper2 = new QueryWrapper<>();
wrapper2.eq( WorkingTime.ORDER_NAME, dto.getOrderName());
if(entity.getOrderName()!=dto.getOrderName() && workingTimeMapper.selectCount(wrapper2)!= 0){
return new Result().error(1,"名称重复");
}
else {
return new Result<IdVo>().ok(workingTimeService.edit(dto));
}
} }
@DeleteMapping @DeleteMapping

View File

@ -2,6 +2,7 @@ package com.cnbm.packing.service;
import com.cnbm.common.page.PageData; import com.cnbm.common.page.PageData;
import com.cnbm.common.service.CrudService; import com.cnbm.common.service.CrudService;
import com.cnbm.packing.dto.IdVo;
import com.cnbm.packing.dto.ProductLevelDTO; import com.cnbm.packing.dto.ProductLevelDTO;
import com.cnbm.packing.entity.ProductLevel; import com.cnbm.packing.entity.ProductLevel;
@ -28,4 +29,7 @@ public interface ProductLevelServiceBiz extends CrudService<ProductLevel, Produc
List<ProductLevelDTO> list(); List<ProductLevelDTO> list();
IdVo add(ProductLevelDTO dto);
IdVo edit(ProductLevelDTO dto);
} }

View File

@ -2,6 +2,7 @@ package com.cnbm.packing.service;
import com.cnbm.common.page.PageData; import com.cnbm.common.page.PageData;
import com.cnbm.common.service.CrudService; import com.cnbm.common.service.CrudService;
import com.cnbm.packing.dto.IdVo;
import com.cnbm.packing.dto.ScenesDTO; import com.cnbm.packing.dto.ScenesDTO;
import com.cnbm.packing.entity.Scenes; import com.cnbm.packing.entity.Scenes;
@ -22,8 +23,12 @@ public interface ScenesServiceBiz extends CrudService<Scenes, ScenesDTO> {
void save(ScenesDTO dto); void save(ScenesDTO dto);
IdVo add(ScenesDTO dto);
void update(ScenesDTO dto); void update(ScenesDTO dto);
IdVo edit(ScenesDTO dto);
void delete(Long[] ids); void delete(Long[] ids);
List<ScenesDTO> list(); List<ScenesDTO> list();

View File

@ -2,6 +2,7 @@ package com.cnbm.packing.service;
import com.cnbm.common.page.PageData; import com.cnbm.common.page.PageData;
import com.cnbm.common.service.CrudService; import com.cnbm.common.service.CrudService;
import com.cnbm.packing.dto.IdVo;
import com.cnbm.packing.dto.WorkingTimeDTO; import com.cnbm.packing.dto.WorkingTimeDTO;
import com.cnbm.packing.dto.WorkingTimeDTO; import com.cnbm.packing.dto.WorkingTimeDTO;
import com.cnbm.packing.entity.WorkingTime; import com.cnbm.packing.entity.WorkingTime;
@ -31,4 +32,8 @@ public interface WorkingTimeServiceBiz extends CrudService<WorkingTime, WorkingT
List<WorkingTimeDTO> list(); List<WorkingTimeDTO> list();
String getOrderName(LocalDateTime time); String getOrderName(LocalDateTime time);
IdVo add(WorkingTimeDTO dto);
IdVo edit(WorkingTimeDTO dto);
} }

View File

@ -6,6 +6,7 @@ import com.cnbm.admin.utils.BaseSupportUtils;
import com.cnbm.common.page.PageData; import com.cnbm.common.page.PageData;
import com.cnbm.common.service.impl.CrudServiceImpl; import com.cnbm.common.service.impl.CrudServiceImpl;
import com.cnbm.common.utils.ConvertUtils; import com.cnbm.common.utils.ConvertUtils;
import com.cnbm.packing.dto.IdVo;
import com.cnbm.packing.dto.ProductLevelDTO; import com.cnbm.packing.dto.ProductLevelDTO;
import com.cnbm.packing.entity.ProductLevel; import com.cnbm.packing.entity.ProductLevel;
import com.cnbm.packing.mapper.ProductLevelMapper; import com.cnbm.packing.mapper.ProductLevelMapper;
@ -64,6 +65,16 @@ public class ProductLevelServiceBizImpl extends CrudServiceImpl<ProductLevelMapp
insert(entity); insert(entity);
} }
@Override
@Transactional(rollbackFor = Exception.class)
public IdVo add(ProductLevelDTO dto) {
ProductLevel entity = ConvertUtils.sourceToTarget(dto, ProductLevel.class);
BaseSupportUtils.setCommonField(entity);
insert(entity);
return IdVo.builder().id(entity.getId()).build();
}
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void update(ProductLevelDTO dto) { public void update(ProductLevelDTO dto) {
@ -72,6 +83,15 @@ public class ProductLevelServiceBizImpl extends CrudServiceImpl<ProductLevelMapp
updateById(entity); updateById(entity);
} }
@Override
@Transactional(rollbackFor = Exception.class)
public IdVo edit(ProductLevelDTO dto) {
ProductLevel entity = ConvertUtils.sourceToTarget(dto, ProductLevel.class);
BaseSupportUtils.setUpdateCommonField(entity);
updateById(entity);
return IdVo.builder().id(entity.getId()).build();
}
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void delete(Long[] ids) { public void delete(Long[] ids) {

View File

@ -6,6 +6,7 @@ import com.cnbm.admin.utils.BaseSupportUtils;
import com.cnbm.common.page.PageData; import com.cnbm.common.page.PageData;
import com.cnbm.common.service.impl.CrudServiceImpl; import com.cnbm.common.service.impl.CrudServiceImpl;
import com.cnbm.common.utils.ConvertUtils; import com.cnbm.common.utils.ConvertUtils;
import com.cnbm.packing.dto.IdVo;
import com.cnbm.packing.dto.ScenesDTO; import com.cnbm.packing.dto.ScenesDTO;
import com.cnbm.packing.entity.Scenes; import com.cnbm.packing.entity.Scenes;
import com.cnbm.packing.mapper.ScenesMapper; import com.cnbm.packing.mapper.ScenesMapper;
@ -86,5 +87,22 @@ public class ScenesServiceBizImpl extends CrudServiceImpl<ScenesMapper, Scenes,
return list; return list;
} }
@Override
@Transactional(rollbackFor = Exception.class)
public IdVo add(ScenesDTO dto) {
Scenes entity = ConvertUtils.sourceToTarget(dto, Scenes.class);
BaseSupportUtils.setCommonField(entity);
insert(entity);
return IdVo.builder().id(entity.getId()).build();
}
@Override
@Transactional(rollbackFor = Exception.class)
public IdVo edit(ScenesDTO dto) {
Scenes entity = ConvertUtils.sourceToTarget(dto, Scenes.class);
BaseSupportUtils.setUpdateCommonField(entity);
updateById(entity);
return IdVo.builder().id(entity.getId()).build();
}
} }

View File

@ -8,6 +8,7 @@ import com.cnbm.common.page.PageData;
import com.cnbm.common.service.impl.CrudServiceImpl; import com.cnbm.common.service.impl.CrudServiceImpl;
import com.cnbm.common.utils.ConvertUtils; import com.cnbm.common.utils.ConvertUtils;
import com.cnbm.packing.dto.IdVo;
import com.cnbm.packing.dto.WorkingTimeDTO; import com.cnbm.packing.dto.WorkingTimeDTO;
import com.cnbm.packing.entity.WorkingTime; import com.cnbm.packing.entity.WorkingTime;
import com.cnbm.packing.mapper.WorkingTimeMapper; import com.cnbm.packing.mapper.WorkingTimeMapper;
@ -72,6 +73,17 @@ public class WorkingTimeServiceBizImpl extends CrudServiceImpl<WorkingTimeMapper
insert(entity); insert(entity);
} }
@Override
@Transactional(rollbackFor = Exception.class)
public IdVo add(WorkingTimeDTO dto) {
//验证时间段不重合
timeOverlap(dto);
WorkingTime entity = ConvertUtils.sourceToTarget(dto, WorkingTime.class);
BaseSupportUtils.setCommonField(entity);
insert(entity);
return IdVo.builder().id(entity.getId()).build();
}
public void timeOverlap(WorkingTimeDTO newTime){ public void timeOverlap(WorkingTimeDTO newTime){
List<WorkingTimeDTO> dtoList = list(); List<WorkingTimeDTO> dtoList = list();
LocalTime newBeginTime = newTime.getBeginTime().toLocalTime(); LocalTime newBeginTime = newTime.getBeginTime().toLocalTime();
@ -115,6 +127,18 @@ public class WorkingTimeServiceBizImpl extends CrudServiceImpl<WorkingTimeMapper
updateById(entity); updateById(entity);
} }
@Override
@Transactional(rollbackFor = Exception.class)
public IdVo edit(WorkingTimeDTO dto) {
//验证时间段不重合
timeOverlap(dto);
WorkingTime entity = ConvertUtils.sourceToTarget(dto, WorkingTime.class);
BaseSupportUtils.setUpdateCommonField(entity);
updateById(entity);
return IdVo.builder().id(entity.getId()).build();
}
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void delete(Long[] ids) { public void delete(Long[] ids) {
@ -154,5 +178,4 @@ public class WorkingTimeServiceBizImpl extends CrudServiceImpl<WorkingTimeMapper
} }
} }

View File

@ -18,6 +18,7 @@
<select id="list" resultType="com.cnbm.packing.dto.ProductLevelDTO"> <select id="list" resultType="com.cnbm.packing.dto.ProductLevelDTO">
select * from t_product_level select * from t_product_level
where valid = 1
order by id asc order by id asc
</select> </select>

View File

@ -17,6 +17,7 @@
<select id="list" resultType="com.cnbm.packing.dto.ScenesDTO"> <select id="list" resultType="com.cnbm.packing.dto.ScenesDTO">
select * from t_scenes select * from t_scenes
where valid = 1
order by id asc order by id asc
</select> </select>

View File

@ -19,6 +19,7 @@
<select id="list" resultType="com.cnbm.packing.dto.WorkingTimeDTO"> <select id="list" resultType="com.cnbm.packing.dto.WorkingTimeDTO">
select * from t_working_time select * from t_working_time
where valid = 1
order by id asc order by id asc
</select> </select>