public Result fieldSwitch(Integer id, String fieldName, Object fieldValue) {
Shop shop = new Shop();
shop.setId(id);
try {
Field field = Shop.class.getDeclaredField(fieldName);
if (!field.isAccessible()) {
field.setAccessible(true);
}
Object convert = ConvertUtils.convert(fieldValue, field.getType());
field.set(shop, convert);
} catch (NoSuchFieldException | IllegalAccessException e) {
e.printStackTrace();
}
return Result.ok(shopMapper.updateById(shop));
}
统一接口
最新推荐文章于 2024-07-30 20:50:32 发布