package com.gunshi.project.xyt.controller; import com.gunshi.core.result.R; import com.gunshi.db.dao.BaseDao; import com.gunshi.db.dao.IMapper; import com.gunshi.project.xyt.service.AbstractModelWithAttachService; import com.gunshi.project.xyt.validate.markers.Update; import io.swagger.v3.oas.annotations.Operation; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; /** * 通用实体类新增 * * @author lyf * @version 1.0.0 * @since 2024-02-19 */ public interface ICommonUpdateByIdWithAttach, AutoDao extends BaseDao, AttachModel, AttachModelAutoMapper extends IMapper, AttachModelAutoDao extends BaseDao> { AbstractModelWithAttachService getModelService(); void customSetFieldForUpdate(Model model); @Operation(summary = "实体类修改") @PostMapping("/update") default R commonUpdateById(@Validated(Update.class) @RequestBody Model model) { customSetFieldForUpdate(model); boolean result = getModelService().updateById(model); return R.ok(result ? model : null); } }