
刚刚 clone 公司的项目代码,看到一堆的 Wrapper 真的绷不住了。好好的在 xml 里面写 SQL 不好吗?非要在 Service 写那么多和业务无关的东西,代码看得我头大。
@Override public int deleteByColorId(Long colorId,String userCode) { LambdaUpdateWrapper<ColorLibraryFile> updateWrapper = new LambdaUpdteWrapper<>(); updateWrapper.set(ColorLibraryFile::getDeletedFlag,DeletedFlagEnum.DELETE.getCode()); updateWrapper.set(ColorLibraryFile::getDeletedBy,userCode); updateWrapper.set(ColorLibraryFile::getDeletedTime, new Date()); updateWrapper.eq(ColorLibraryFile::getColorId,colorId); updateWrapper.eq(ColorLibraryFile::getDeletedFlag,DeletedFlagEnum.NORMAL.getCode()); return colorLibraryFileDao.update(null,updateWrapper); } 1 itechify PRO 有人喜欢,有人讨厌,不做评论 |
2 itechify PRO 更感觉是代码规范问题,数据库持久层写在 Repository/DAO 里面吧 |
3 codingerj 15 小时 0 分钟前 我遇到过挺多这样写代码的人,给我的感觉就是会这么写的这辈子都写不出优雅易读的代码,干这行纯是混口饭吃 |
5 fj19 14 小时 27 分钟前 你写在 dao 层怎么了,要啥 xml |
6 bjfane PRO 不懂就问,mybatis-plus 这么写能不能平滑切换 mysql 和 postgre ? 如果是 sql 的话 有的是不是不行? |
7 v2306 13 小时 18 分钟前 |
8 Ketteiron 13 小时 9 分钟前 这段代码确实很垃圾,明明一行链式就搞定。 mybatis-plus 我觉得没什么问题,在复杂动态条件拼接与类型安全上远胜 xml 。 但受困于 java 的表达能力,写起来确实有点折磨。 |
9 slert 12 小时 17 分钟前 java 就没有好点的 orm 了吗? |