当前位置: 首页 > wzjs >正文

小学学校网站建设计划网络游戏陪玩

小学学校网站建设计划,网络游戏陪玩,wordpress下载官网,wordpress Nirvana公共字段自动填充 技术点 枚举 自定义注解 AOP切面 反射 /*** 自定义注解 用于标识某个方法需要进行功能字段自动填充处理*/ Target(ElementType.METHOD) Retention(RetentionPolicy.RUNTIME) public interface ChengoAutoFill {//数据库操作类型 UPDATE INSERTOperationType v…

公共字段自动填充 技术点 枚举 自定义注解 AOP切面 反射

/*** 自定义注解 用于标识某个方法需要进行功能字段自动填充处理*/
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
public @interface ChengoAutoFill {//数据库操作类型 UPDATE INSERTOperationType value();
}/*** 自定义切面 实现公共字段自动填充处理逻辑*/
@Aspect
@Component
@Slf4j
public class ChengoAutoFillAspect {/*** 切入点 拦截insert和update操作*/@Pointcut("execution(* com.sky.mapper.*.*(..)) && @annotation(com.sky.annotation.ChengoAutoFill)")public void autoFillPointCut(){}/*** 前置通知 在通知中尽显公共字段的赋值* @param joinPoint*/@Before("autoFillPointCut()")public void autoFill(JoinPoint joinPoint){log.info("开始进行公共字段自动填充....");//获取当前被拦截的方法上的数据库操作类型 反射操作MethodSignature signature = (MethodSignature) joinPoint.getSignature();//方法签名对象ChengoAutoFill autoFill = signature.getMethod().getAnnotation(ChengoAutoFill.class);//获得方法上的注解对象OperationType operationType = autoFill.value();//获得数据库操作类型//获取当前被拦截方法的参数 -- 实体对象Object[] args = joinPoint.getArgs();if(args == null || args.length == 0){return;}Object entity = args[0];//准备赋值的数据LocalDateTime now = LocalDateTime.now();Long currentId = BaseContext.getCurrentId();//根据当前不同的操作类型 为对应的属性通过反射来赋值if(operationType == OperationType.INSERT){//四个公共字段赋值try {Method setCreateTime = entity.getClass().getDeclaredMethod(SET_CREATE_TIME, LocalDateTime.class);Method setCreateUser = entity.getClass().getDeclaredMethod(SET_CREATE_USER, Long.class);Method setUpdateTime = entity.getClass().getDeclaredMethod(SET_UPDATE_TIME, LocalDateTime.class);Method setUpdateUser = entity.getClass().getDeclaredMethod(SET_UPDATE_USER, Long.class);//通过反射为对象属性赋值setCreateUser.invoke(entity,currentId);setUpdateUser.invoke(entity,currentId);setCreateTime.invoke(entity,now);setUpdateTime.invoke(entity,now);} catch (Exception e) {throw new RuntimeException(e);}} else if (operationType == OperationType.UPDATE) {//两个公共字段赋值 修改时间和修改人try {Method setUpdateTime = entity.getClass().getDeclaredMethod(SET_UPDATE_TIME, LocalDateTime.class);Method setUpdateUser = entity.getClass().getDeclaredMethod(SET_UPDATE_USER, Long.class);//通过反射为对象属性赋值setUpdateUser.invoke(entity,currentId);setUpdateTime.invoke(entity,now);} catch (Exception e) {throw new RuntimeException(e);}}}Mapper里上自定义注解@ChengoAutoFill(value = OperationType.UPDATE)void update(Employee employee);@ChengoAutoFill(value = OperationType.INSERT)void insert(Employee employee);

增菜品

上传文件需要阿里云oss 配置好自己的信息 写好yml和上传内容即可

/*** 配置类 用于创建AliOssUtil对象*/
@Configuration
@Slf4j
public class OssConfiguration {@Bean@ConditionalOnMissingBean//只创建一个bean 确保程序启动过程中只有一个beanpublic AliOssUtil aliOssUtil(AliOssProperties aliOssProperties){return new AliOssUtil(aliOssProperties.getEndpoint(),aliOssProperties.getAccessKeyId(),aliOssProperties.getAccessKeySecret(),aliOssProperties.getBucketName());}
}
控制层
@RestController
@RequestMapping("/admin/common")
@Api(tags = "通用接口")
@Slf4j
public class CommonController {@Autowiredprivate AliOssUtil aliOssUtil;/*** 文件上传* @param file* @return*/@PostMapping("/upload")@ApiOperation("文件上传")public Result<String> upload(@RequestBody MultipartFile file){log.info("文件上传:{}",file);try {//取出原始文件名String originalFilename = file.getOriginalFilename();//截取原始文件名的后缀 。。。。.png .jpgString substring = originalFilename.substring(originalFilename.lastIndexOf("."));//构建新文件名称String objectName = UUID.randomUUID().toString() + substring;//文件请求连接String filePath = aliOssUtil.upload(file.getBytes(), objectName);return Result.success(filePath);} catch (IOException e) {log.error("文件上传失败:{}",e);}return Result.error(MessageConstant.UPLOAD_FAILED);}
}

上面是怎么上传文件 下面的新增菜品让我烦了好长一段时间 总结经验 不能边看边敲 需要看明白再回来思考 并自己先敲

这个问题折腾了我一个小时 第二次犯了 sql语句写的封装类对象里不能用下划线 并且必须驼峰命名

查询

这里有个VO设计

在这个模块上花了三个小时左右,, 就是因为我服务器太久没动宕机了 很崩溃 不想做了

还是继续做吧‘、、、、、、、、、、

删除菜品

     控制层/*** 菜品批量删除* @param ids* @return*/@DeleteMapping@ApiOperation("菜品批量删除")public Result delete(@RequestParam List<Long> ids){log.info("菜品批量删除:{}",ids);dishService.deleteBatch(ids);return Result.success();}@Mapper  持久层
public interface SetmealDishMapper {/*** 根据菜品id查找套餐id* @param dishIds* @return*/List<Long> getSetmealIdsByDishIds(List<Long> dishIds);}业务实现层/*** 菜品批量删除* @param ids*/@Overridepublic void deleteBatch(List<Long> ids) {//当前菜品是否能够删除 是否起售for (Long id : ids) {Dish dish = dishMapper.getById(id);if(dish.getStatus() == StatusConstant.ENABLE){//起售中 不能删除throw new DeletionNotAllowedException(MessageConstant.DISH_ON_SALE);}}//判断当餐票是否能被删除 --是否被套餐关联List<Long> setmealIdsByDishIds = setmealDishMapper.getSetmealIdsByDishIds(ids);if(setmealIdsByDishIds != null && setmealIdsByDishIds.size() > 0){//当前菜品被套餐关联 不能删除throw new DeletionNotAllowedException(MessageConstant.DISH_BE_RELATED_BY_SETMEAL);}//删除菜品表中的菜品数据for (Long id : ids) {dishMapper.deleteById(id);//删除口味表里的口味数据dishFlavorMapper.deleteById(id);}要删除菜品与其连带的口味数据/*** 根据id主键删菜品* @param id*/@Delete("delete from dish where id = #{id};")void deleteById(Long id);/*** 根据菜品id来删口味数据* @param dishIds*/@Delete("delete from dish_flavor where dish_id = #{dishIds}")void deleteById(Long dishIds);

改菜品

根据id查询菜品 需要分两次查询 第一次查询dish菜品 第二次查询菜品关联的口味

    业务层/*** 根据id查询菜品和对应的口味数据* @param id* @return*/@Overridepublic DishVO getByIdWithFlavor(Long id) {//根据id查询菜品数据Dish dish = dishMapper.getById(id);//根据菜品id查询口味数据List<DishFlavor> dishFlavors = dishFlavorMapper.getByDishId(id);//把查询到的数据封装到VODishVO dishVO = new DishVO();BeanUtils.copyProperties(dish,dishVO);dishVO.setFlavors(dishFlavors);return dishVO;}*************************************************接口层/*** 根据id查询菜品和对应的口味数据* @param id* @return*/DishVO getByIdWithFlavor(Long id);*************************************************控制层@GetMapping("/{id}")@ApiOperation("根据id查询菜品·")public Result<DishVO> getById(@PathVariable Long id){log.info("根据id查询菜品:{}",id);DishVO dishVO = dishService.getByIdWithFlavor(id);return Result.success(dishVO);}*************************************************Mapper层/*** 根据菜品id查询口味数据* @param dishId* @return*/@Select("select * from dish_flavor where dish_id = #{dishId}")List<DishFlavor> getByDishId(Long dishId);/*** 查询菜品* @param id* @return*/@Select("select * from dish where id = #{id}")Dish getById(Long id);

 在这写修改的时候 把控制层的内容写到实体类里了,, 还好发现了

继续加油


文章转载自:

http://9Ad7LasK.bpLqh.cn
http://JowruOgX.bpLqh.cn
http://Kvx79tA1.bpLqh.cn
http://xihrtfuv.bpLqh.cn
http://CoMIvuTa.bpLqh.cn
http://xI5NwT3p.bpLqh.cn
http://kg7vUoYD.bpLqh.cn
http://I6w8EKEs.bpLqh.cn
http://KIKUjM3J.bpLqh.cn
http://IevknvNa.bpLqh.cn
http://Nyp6yjY5.bpLqh.cn
http://6FlxoSlY.bpLqh.cn
http://GJdcYoOi.bpLqh.cn
http://wU1bE8K4.bpLqh.cn
http://ALFC49RS.bpLqh.cn
http://gxh2PL9I.bpLqh.cn
http://Gk9V6LKx.bpLqh.cn
http://YHg4g0ry.bpLqh.cn
http://MosKmg7U.bpLqh.cn
http://apteo5fP.bpLqh.cn
http://23znn881.bpLqh.cn
http://FZ4DZLCR.bpLqh.cn
http://o6xrINAc.bpLqh.cn
http://654t4Bdr.bpLqh.cn
http://9fIENfF1.bpLqh.cn
http://NZfbCc2n.bpLqh.cn
http://XFcHkJob.bpLqh.cn
http://3D6RBCLh.bpLqh.cn
http://rLJvHg0E.bpLqh.cn
http://Okqp3dJU.bpLqh.cn
http://www.dtcms.com/wzjs/625457.html

相关文章:

  • 公司网站建设的签订合同网站在哪里
  • 网站建设后需要维护吗三室一厅装修效果图
  • 东莞建设培训中心网站比较厉害的网站制作公司
  • 架设仿冒网站挂马饰品电子商务网站的建设
  • 长沙网上商城网站建设方案提供秦皇岛网站建设
  • 自己做的网站响应速度慢帝国做网站的步骤
  • 建设网站需要什么内容金华开发区人才网
  • 做喷绘可以在那个网站找外贸新手怎样用谷歌找客户
  • 网站的设计方法有哪些内容网站定制合同
  • 网站做影集安全吗网站建设公司利润
  • asp.net网站开发试题网站之间如何交换友情链接
  • 华大 网站建设郑东新区建设局网站
  • 万网发布网站做小程序商城
  • 还能用的wap网站后台查看网站容量
  • 昆山专业的网站建设哪些网站是做货源的
  • 网站建设与营销有没有做的很炫的科技型网站
  • 企业开展网站建设网站定制设计制作公司
  • 江西省城乡建设培训网官方网站百度网站名称
  • 购物网站怎么做项目简介wordpress为什么被
  • 网站刷流量会怎么样开发网站的基本流程五个阶段
  • 公司门户网站模板网站建立多少钱
  • 深圳网站建设哪家最好小程序登录网址
  • 大一学生做的网站哪个网站可以做代练
  • 一个网站大概多少页面网站建设的竞争对手的分析
  • 网站建设宣传方案建站优化公司
  • 站内优化网站怎么做兰州市网站建设公司
  • 装饰网站建设套餐报价营销型网站应用
  • 网站优化检测珠海网站定制
  • 搜狗网站推广网站弹出公告代码
  • 网站首页被k还有救吗上海外贸营销网站建设地址