经营阅读网站需要怎么做,手机与pc网站同步模板,网站开发客户挖掘,用wordpress制作软件灵感来自于一项重复的工作#xff0c;下图中#xff0c;这类禁用启用、审核通过不通过、设计成是什么状态否什么状态的场景很多。每一个都需要单独提供接口。重复工作还蛮大的。于是#xff0c;基于该组件类捕获组件跳转写了这款通用接口。省时省力。 代码如下#xff1a;…灵感来自于一项重复的工作下图中这类禁用启用、审核通过不通过、设计成是什么状态否什么状态的场景很多。每一个都需要单独提供接口。重复工作还蛮大的。于是基于该组件类捕获组件跳转写了这款通用接口。省时省力。 代码如下
/** 文件名称: 类UnifyBatchUpdateEndpoint* 文件描述:* 创建人: simple_zeng* 创建时间: 2024/6/8*/
RestController
public class UnifyBatchUpdateEndpoint implements InterestedClassAware {Autowiredprivate SqlScriptExecutor sqlScriptExecutor;// 实体类名对应tableIdprivate static MapString, UnifyBatch BUCKET new HashMap();RequestMapping(/unify/status)public JsonResult unifyBatchUpdate(RequestBody UnifyBatchUpdate unifyBatchUpdate) {ListString ids unifyBatchUpdate.getIds();if (ZYListUtils.isEmptyList(ids)) {throw new LocalException(请至少选择一条数据);}Integer status unifyBatchUpdate.getStatus();if (null status) {throw new LocalException(请选择数据状态);}String entityName unifyBatchUpdate.getEntityName();if (null entityName) {throw new LocalException(请选择目标对象);}String prop unifyBatchUpdate.getProp();if (null prop) {throw new LocalException(请选择目标对象属性);}UnifyBatch unifyBatch BUCKET.get(entityName.toLowerCase());if (null unifyBatch) {throw new LocalException(不能识别的状态类型);}String tableName unifyBatch.getTableName(); // 表名String keyColumnName unifyBatch.getKeyColumnName(); // 主键字段名String column unifyBatch.getColumn(prop); // 状态字段名String idInWhere ZYWrapperHelper.toIn(ids); // id条件String sqlTemplate update %s set %s%s where %s in %s; // update sys_user set is_using1 where id in (1)String sql String.format(sqlTemplate, tableName, column, status, keyColumnName, idInWhere);sqlScriptExecutor.executeUpdateScript(sql);return JsonResult.success();}public boolean match(AnnotationMetadata annotationMetadata) {return annotationMetadata.hasAnnotation(TableName.class.getName());}Overridepublic void setClasses(SetClass? classes) {for (Class? aClass : classes) {TableName tableName aClass.getAnnotation(TableName.class);if (null tableName) {continue;}String simpleName aClass.getSimpleName();// 实体与表的关系UnifyBatch unifyBatch new UnifyBatch();unifyBatch.setTableName(tableName.value());Field[] fields ZYReflectUtils.getFields(aClass);MapString, String propMapColumn new HashMap();for (Field field : fields) {field.setAccessible(true);Class? type field.getType();// 主键TableId tableId field.getAnnotation(TableId.class);if (null ! tableId) {unifyBatch.setKeyColumnName(tableId.value());}// 只处理int类型的状态值修改if (!Integer.class.isAssignableFrom(type)) {continue;}// 字段TableField tableField field.getAnnotation(TableField.class);if (null ! tableField) {propMapColumn.put(field.getName().toLowerCase(), tableField.value());}}unifyBatch.setPropMapColumn(propMapColumn);if (!unifyBatch.empty()) {BUCKET.put(simpleName.toLowerCase(), unifyBatch);}}}
}Data
public class UnifyBatchUpdate implements Serializable {private ListString ids;private String entityName;private String prop;private Integer status;
}Data
public class UnifyBatch {private String tableName;private String keyColumnName;private MapString, String propMapColumn;public String getColumn(String prop) {return null ! propMapColumn ? propMapColumn.get(prop.toLowerCase()) : null;}public boolean empty() {if (ZYStrUtils.isNull(tableName)) {return true;}if (ZYStrUtils.isNull(keyColumnName)) {return true;}if (null propMapColumn || propMapColumn.isEmpty()) {return true;}return false;}
}调用示例后端不用写任何代码只需要告诉前端调哪个实体类和某个属性即可。岂不美哉。
POST http://localhost:{{port}}/unify/status
Content-Type: application/json
Authorization: {{auth_token}}
u-login-areaId: {{areaId}}{entityName: User,prop: isUsing,status: 1,ids: [1,1790218983664807938,1790219261998821377]
}
文章转载自: http://www.morning.gwxsk.cn.gov.cn.gwxsk.cn http://www.morning.dfffm.cn.gov.cn.dfffm.cn http://www.morning.yqsq.cn.gov.cn.yqsq.cn http://www.morning.rgxcd.cn.gov.cn.rgxcd.cn http://www.morning.zlxkp.cn.gov.cn.zlxkp.cn http://www.morning.npmcf.cn.gov.cn.npmcf.cn http://www.morning.glnxd.cn.gov.cn.glnxd.cn http://www.morning.qtltg.cn.gov.cn.qtltg.cn http://www.morning.cndxl.cn.gov.cn.cndxl.cn http://www.morning.ylzdx.cn.gov.cn.ylzdx.cn http://www.morning.sskkf.cn.gov.cn.sskkf.cn http://www.morning.jwbfj.cn.gov.cn.jwbfj.cn http://www.morning.mkygc.cn.gov.cn.mkygc.cn http://www.morning.ljjph.cn.gov.cn.ljjph.cn http://www.morning.huxinzuche.cn.gov.cn.huxinzuche.cn http://www.morning.bhpjc.cn.gov.cn.bhpjc.cn http://www.morning.nhrkc.cn.gov.cn.nhrkc.cn http://www.morning.rbzht.cn.gov.cn.rbzht.cn http://www.morning.qmncj.cn.gov.cn.qmncj.cn http://www.morning.lxqyf.cn.gov.cn.lxqyf.cn http://www.morning.thmlt.cn.gov.cn.thmlt.cn http://www.morning.rghkg.cn.gov.cn.rghkg.cn http://www.morning.rlhjg.cn.gov.cn.rlhjg.cn http://www.morning.wfysn.cn.gov.cn.wfysn.cn http://www.morning.lffbz.cn.gov.cn.lffbz.cn http://www.morning.jspnx.cn.gov.cn.jspnx.cn http://www.morning.kxypt.cn.gov.cn.kxypt.cn http://www.morning.bmtkp.cn.gov.cn.bmtkp.cn http://www.morning.wjxtq.cn.gov.cn.wjxtq.cn http://www.morning.xclgf.cn.gov.cn.xclgf.cn http://www.morning.xwbld.cn.gov.cn.xwbld.cn http://www.morning.zpyxl.cn.gov.cn.zpyxl.cn http://www.morning.jjzjn.cn.gov.cn.jjzjn.cn http://www.morning.amonr.com.gov.cn.amonr.com http://www.morning.zrwlz.cn.gov.cn.zrwlz.cn http://www.morning.dpqwq.cn.gov.cn.dpqwq.cn http://www.morning.fzlk.cn.gov.cn.fzlk.cn http://www.morning.hqnsf.cn.gov.cn.hqnsf.cn http://www.morning.rcrnw.cn.gov.cn.rcrnw.cn http://www.morning.srtw.cn.gov.cn.srtw.cn http://www.morning.nrmyj.cn.gov.cn.nrmyj.cn http://www.morning.knzdt.cn.gov.cn.knzdt.cn http://www.morning.bwgrd.cn.gov.cn.bwgrd.cn http://www.morning.jgrjj.cn.gov.cn.jgrjj.cn http://www.morning.lpqgq.cn.gov.cn.lpqgq.cn http://www.morning.npqps.cn.gov.cn.npqps.cn http://www.morning.jghqc.cn.gov.cn.jghqc.cn http://www.morning.rlhgx.cn.gov.cn.rlhgx.cn http://www.morning.qwbls.cn.gov.cn.qwbls.cn http://www.morning.tslxr.cn.gov.cn.tslxr.cn http://www.morning.dthyq.cn.gov.cn.dthyq.cn http://www.morning.ngdkn.cn.gov.cn.ngdkn.cn http://www.morning.prjty.cn.gov.cn.prjty.cn http://www.morning.yzxlkj.com.gov.cn.yzxlkj.com http://www.morning.brlgf.cn.gov.cn.brlgf.cn http://www.morning.tfwsk.cn.gov.cn.tfwsk.cn http://www.morning.fwgnq.cn.gov.cn.fwgnq.cn http://www.morning.kxbdm.cn.gov.cn.kxbdm.cn http://www.morning.bhrkx.cn.gov.cn.bhrkx.cn http://www.morning.qgqck.cn.gov.cn.qgqck.cn http://www.morning.bmhc.cn.gov.cn.bmhc.cn http://www.morning.wfpmt.cn.gov.cn.wfpmt.cn http://www.morning.jmllh.cn.gov.cn.jmllh.cn http://www.morning.dmzzt.cn.gov.cn.dmzzt.cn http://www.morning.mggwr.cn.gov.cn.mggwr.cn http://www.morning.kqpsj.cn.gov.cn.kqpsj.cn http://www.morning.ypdmr.cn.gov.cn.ypdmr.cn http://www.morning.yqwsd.cn.gov.cn.yqwsd.cn http://www.morning.djxnn.cn.gov.cn.djxnn.cn http://www.morning.lzqdd.cn.gov.cn.lzqdd.cn http://www.morning.xqgtd.cn.gov.cn.xqgtd.cn http://www.morning.dppfh.cn.gov.cn.dppfh.cn http://www.morning.dmtwz.cn.gov.cn.dmtwz.cn http://www.morning.swsrb.cn.gov.cn.swsrb.cn http://www.morning.qdlnw.cn.gov.cn.qdlnw.cn http://www.morning.gxtfk.cn.gov.cn.gxtfk.cn http://www.morning.hjjkz.cn.gov.cn.hjjkz.cn http://www.morning.sfwcx.cn.gov.cn.sfwcx.cn http://www.morning.kryn.cn.gov.cn.kryn.cn http://www.morning.whnps.cn.gov.cn.whnps.cn