当前位置: 首页> 健康> 母婴 > 固安网站建设_小程序公司十大排名_打开网址资料网站_海门网站建设

固安网站建设_小程序公司十大排名_打开网址资料网站_海门网站建设

时间:2025/7/19 23:49:40来源:https://blog.csdn.net/weixin_44893650/article/details/142567396 浏览次数:0次
固安网站建设_小程序公司十大排名_打开网址资料网站_海门网站建设
loadMap
// 调用
@loadMap($src, $field, $strTableName, $key, $target, $other, $systemId)/*** loadMap* 加载map。** @param $src:list:列表。* @param $field:string:参数域。* @param $strTableName:string:数据表名。* @param $key:string:键。* @param $target:string:落地属性。* @param $other:map:其它条件。* @param $systemId:string:系统id。** @return list:加载数据后的列表。**/
#function loadMap($src, $field, $strTableName, $key, $target, $other, $systemId)// 参数处理#set($where = $vs.util.newMap())#if ($vs.util.isMap($other))$where.putAll($other)#end// 数据收集#set($fields = @collectSet($src, $field))// 查询条件$where.put($key, $fields)// 列表数据#set($list = $vs.util.newList())#if ($vs.util.isString($systemId))#set($list = @remoteList($systemId, $strTableName, '*', $where))#else#set($list = $vs.dbTools.select($strTableName, $where))#end// 列表分组#set($map = @list2map($list, $key, null))// 数据组装@listPut($src, $map, $field, $target)// 初始化默认值#foreach ($row in $src)#if (!$vs.util.isMap($row.get($target)))$row.put($target, $vs.util.newMap())#end#end// 返回return $src
#end/*** collectSet* 集合数据收集list实现:判空、去重。** @param $list:list:列表。* @param $field:string:字段。** @return list**/
#function collectSet($list, $field)#if ($vs.util.isList($list))#set($result = $vs.util.newList())#set($set = $vs.util.newList())#foreach($row in $list)#set($value = $row)#if ($vs.util.isNotNull($field))#set($value = $row.get($field))#end#if ($vs.util.isNotNull($value) and !$set.contains($value))$result.add($value)$set.add($value)#end#endreturn $result#endreturn null
#end/*** remoteList* 远程列表。** @param $systemId:string:系统id。* @param $strTableName:string:表。* @param $strColumns:string:字段。* @param $where:map:条件。** @return list:列表。**/
#function remoteList($systemId, $strTableName, $strColumns, $where)#if ($vs.util.isBlankOne($strTableName, $systemId))return null#end#if ($vs.util.isNull($strColumns))#set($strColumns = ' * ')#end#set($strSql = `select${$strColumns}from${strTableName}where 1 = 1`)#set($strSql = $strSql + @andWhere($where))return $vs.dbTools.remoteList($systemId, $strSql ,$where)
#end/*** andWhere* 条件。* * @param $where:map:条件** @return string:sql。**/
#function andWhere($where)#set($sql = '')#if ($vs.util.isMap($where))#foreach ($key in $vs.util.getMapKeys($where))#set($value = $where.get($key))#if ($vs.util.isList($value))#set($sql = $sql + " and " + $vs.sqlHelper.listIn($value, $key))#else#set($sql = $sql + $vs.sqlHelper.and($where, $key))#end#end#endreturn $sql
#end/*** list2map* list转map:支持全量映射、单字段映射。* * @param $list:list:列表。* @param $key:string:键字段域。* @param $field:string:值字段域。** @return map**/ 
#function list2map($list, $key, $field)#if ($vs.util.isList($list))#set($map = $vs.util.newMap())#foreach($row in $list)#set($value = $row)#if (!$vs.util.isNull($field))#set($value = $row.get($field))#end$map.put($row.get($key), $value)#endreturn $map#endreturn null
#end/*** listPut* 数据组装。** @param $list:list:列表。* @param $map:map:映射。* @param $key:string:键。* @param $field:string:域。** @return null**/ 
#function listPut($list, $map, $key, $field)#if ($vs.util.isList($list) and $vs.util.isMap($map) and $vs.util.isString($key))#if ($vs.util.isNull($field))#set($field = 'data')#end#foreach($item in $list)#set($itemKey = $item.get($key))#set($data = $map.get($itemKey))$item.put($field, $data)#end#endreturn null
#end
关键字:固安网站建设_小程序公司十大排名_打开网址资料网站_海门网站建设

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

责任编辑: