200 lines
5.0 KiB
Markdown
200 lines
5.0 KiB
Markdown
---
|
|
title: 本地开发-不常用
|
|
tags: [develop]
|
|
---
|
|
|
|
{/* truncate */}
|
|
|
|
### hibernate/jdbc
|
|
|
|
```java
|
|
//hibernate查询
|
|
findById(Long);
|
|
Dao.getHibernateTemplate().find(sql);
|
|
findByHql(StringBuffer, new ArrayList<Object>());
|
|
.findByHql(hql);
|
|
|
|
//hibernate分页
|
|
Dao.findByHql(page, hql, params);
|
|
|
|
//hibernate保存
|
|
Dao.saveOrUpdate(对象);
|
|
|
|
//jdbc查询
|
|
queryForObject
|
|
_jdbcQueryForListNotAll
|
|
jdbcSqlQueryForListBean
|
|
|
|
//jdbc分页
|
|
_jdbcQueryForPage
|
|
jdbcQueryForPage
|
|
|
|
//jdbc保存
|
|
getJdbcTemplate().update
|
|
|
|
//刷新hibernate事务
|
|
Dao.getHibernateTemplate().getSessionFactory().getCurrentSession().flush();
|
|
|
|
//持久化对象变成托管状态
|
|
appendixLackInfoDao.getHibernateTemplate().getSessionFactory().getCurrentSession().evict(appendix);
|
|
```
|
|
|
|
|
|
|
|
### 角色/管辖通用方法
|
|
|
|
```java
|
|
//登录人信息
|
|
TawSystemSessionForm sessionform = (TawSystemSessionForm) HttpTool.getSession().getAttribute("sessionform");
|
|
|
|
//缓存查人查字典
|
|
ID2NameService id2NameService = (ID2NameService) ApplicationContextHolder.getInstance().getBean("id2nameService");
|
|
id2NameService.id2Name(peopleId, "org.hpin.basicsdate.dao.TawSystemUserDao");
|
|
id2NameService.id2Name(dictTypeCode, "tawSystemDictTypeCache");
|
|
|
|
//获取角色
|
|
roleIdLong roleId = MainRoleConstants.getInstance().getRoleId(MainRoleConstants.ROLEID_QJL);
|
|
|
|
//登录人是否某角色
|
|
MainRoleConstants.getInstance().isHjzxZyN(StaticMethod.nullObject2Long(sessionform.getRoleid()));
|
|
isSpecialUserRole(MainRoleConstants.ROLEID_GXGJ, true);
|
|
|
|
//登录人是否有菜单权限
|
|
PrivMgrLocator.getPrivMgr().hasPriv(sessionForm.getUserid(),"work_sf_termination");
|
|
|
|
//用户id查询用户信息
|
|
tawSystemUserService.findByUserId(housePeopleGJId);
|
|
TawSystemSessionBo.getSessionForm(housePeopleGJId);
|
|
|
|
//角色id查询角色
|
|
nameITawSystemRoleManager mgr = (ITawSystemRoleManager)SpringTool.getBean("ItawSystemRoleManager");
|
|
|
|
//角色id查询角色(审核人的角色名)
|
|
String roleName = mgr.getRoleNameById(Long.parseLong(actApprovalInsInfo.getCurrentTaskRole()));
|
|
String roleName = iTawSystemRoleManager.getRoleNameById(Long.parseLong(sessionform.getRoleid()));
|
|
|
|
//登录人和角色 查用户(上海)
|
|
tawSystemUserDao.getUserByUserIdAndRoleId(housePeopleGJId,MainRoleConstants.getInstance().getRoleId(MainRoleConstants.ROLEID_SFGJ)+"");
|
|
|
|
//管辖范围和角色id 查所有用户
|
|
tawSystemUserService.getUpUserByRegionsAndRoleId(ownRegionList, roleId);
|
|
(TawSystemUserRefRole)mgr.getUserRefRoleByuserid(actApprovalInsInfo.getLastModifiorName()).get(0).getRoleid();
|
|
|
|
//管辖范围
|
|
sqlList<String> conditionList = new ArrayList<String>();
|
|
conditionList.add("contractMainInfo.STORE_CODE");
|
|
String regionCondition = DataQueryConditionUtil.getStoreQueryCondition(sessionForm, conditionList,DataQueryConditionUtil.TYPE12, null, null, false);
|
|
|
|
//查询用户上级
|
|
getUpUserByRegionAndRoleIds
|
|
|
|
//刷新redis 条件是 不是windows就可以刷
|
|
TawSystemDictTypeCache.afterPropertiesSet
|
|
```
|
|
|
|
### utils
|
|
|
|
```java
|
|
//创建数据编号
|
|
StaticCode.getGenerationCode(StaticCode.WTTP, changeContractBatch.getId().toString())
|
|
|
|
//字典list
|
|
.getDictSonsByDictid
|
|
|
|
//日期util
|
|
DateUtils .convertDate
|
|
|
|
//改文字编码
|
|
URLDecoder.decode
|
|
|
|
//拷贝对象
|
|
PropertyUtils.copyProperties(new,old)
|
|
```
|
|
|
|
### 定时
|
|
|
|
| 标题 | 内容 | 备注 |
|
|
| ------------ | ------------------------------------------------------------ | ---- |
|
|
| 控制定时时间 | 5秒一次 0/5 * * * * ?<br/>5分一次 0 0/5 * * * ?<br/>9点到6点 5分一次 0 0/5 9-16 * * ?<br/>每天两点 0 0 2 * * ? | |
|
|
| | | |
|
|
|
|
|
|
|
|
### 杂
|
|
|
|
#### 网段被限制
|
|
|
|
```
|
|
网段被限制 PermitIpInfoDao.java
|
|
或 checkCurrentIpIsPermited 把false删掉
|
|
登录被限制 WIWJ_PERMIT_EQUIPMENT_TABLE
|
|
```
|
|
|
|
|
|
|
|
#### 正则
|
|
|
|
```js
|
|
var regex= /^\d{11}$/;
|
|
if (!regex.test(agentPhoneNo)) {
|
|
alert("请输入11位的手机号码。");
|
|
return true;
|
|
}
|
|
```
|
|
|
|
|
|
|
|
### sessionfrom存值
|
|
|
|
```
|
|
id=8080806660b71ff10160b9c6b40a0583
|
|
userid=8162544
|
|
username=符永跃
|
|
deptid=10201JH030102
|
|
deptpriid=1126846
|
|
deptname=万年花城一区租赁A店收房组
|
|
privid=<null>
|
|
isHavePriv=false
|
|
privname=<null>
|
|
roleid=562
|
|
rolename=<null>
|
|
isadmin=false
|
|
romteaddr=10.1.74.43
|
|
password=1191c13a9e1661ba2b38d766b642eb54
|
|
rolelist=[org.hpin.commons.system.role.model.TawSystemSubRole@c20995ee]
|
|
contactMobile=13000000000
|
|
memSubCompayid=0
|
|
memSubCompscname=
|
|
memSubCompscode=<null>
|
|
projectInfoId=<null>
|
|
projectInfoName=<null>
|
|
diptidTop=102
|
|
circleCode=null
|
|
deviceID=<null>
|
|
isOpen=<null>
|
|
isFirstLogin=false
|
|
dqRegionId=101JH
|
|
ztRegionId=101JH03
|
|
mdRegionId=101JH0301
|
|
storeId=101JH030102
|
|
storePkId=155637
|
|
isMedia=false
|
|
storeCode=01.0839.003.004
|
|
roleCircleMap={0=null}
|
|
isByCircleSearch=false
|
|
storeName=万年花城一区租赁A店收房组
|
|
userdegree=0
|
|
ownRegionIds=101JH030102
|
|
sharedRegionIds=<null>
|
|
isCWUser=false
|
|
isSFUser=false
|
|
isAllRegion=false
|
|
machineCode=<null>
|
|
userUnit=562','8162544','10201JH030102
|
|
roles=<null>
|
|
roleNames=<null>
|
|
validatorResults=<null>
|
|
page=0
|
|
```
|
|
|