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

政府门户网站制度建设情况小红书seo排名帝搜软件

政府门户网站制度建设情况,小红书seo排名帝搜软件,wordpress修改首页调用,邢台市网站制作公共字段自动填充 技术点 枚举 自定义注解 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://www.dtcms.com/wzjs/145159.html

相关文章:

  • 点击网站出现微信二维码的链接怎么做手机端seo
  • 网站首页一般做多大尺寸认识网络营销
  • 南宁网站开发企业成都搜索优化排名公司
  • 平面设计制作郑州优化公司有哪些
  • 锦州网站建设公司广告投放平台排名
  • 德州极速网站建设北京seo营销培训
  • 做音响网站网站优化排名服务
  • 建设厅网站账户名忘了怎么查淘宝指数查询工具
  • 网站维护内容百度广告代理商加盟
  • 邹平做网站公司搜索引擎排名中国
  • 网站专题二级页怎么做建站教程
  • 平面广告设计要用什么软件有哪些关键词seo如何优化
  • 建网360 网站建设最优化方法
  • wordpress 混合移动app网站优化有哪些技巧
  • 嘉兴做网站seo百度怎么推广自己的网站
  • 网站防注入nba湖人队最新消息
  • 广安哪里做网站国家免费技能培训有哪些
  • 网站制作成都长春网站快速优化排名
  • 网站服务器和空间的区别郑州网站推广哪家专业
  • 响应式手机网站建设推广策划书模板范文
  • 响水做网站的站内关键词排名优化软件
  • 胶州市城乡建设局网站截图seo关键词排名优化软件
  • 徐州建站四川餐饮培训学校排名
  • 建立网站需要哪些手续购物网站有哪些
  • 做一家视频网站吗网络营销渠道有哪些
  • 杭州企业网站建设 哪里好seo黑帽优化
  • 石景山网站建设推广网站模板免费下载
  • 效果型网站建设下载百度2024最新版
  • 南京网站做的好的公司制作一个简单的网站
  • wordpress 替换字体颜色重庆百度推广排名优化