工作总结之添加数据库
1.首先在idb中新建任务--表结构变更,在里面设计好后,同步到线下数据库。
2.在main/resources里添加sqlmap_dingtalk.xml文件,然后在sqlmap-config中注册该文件
<sqlMap resource="com/taobao/cun/biz/dingtalk/sqlmaps/sqlmap_dingtalk.xml"/>
3.在cuntaocenter-core核心库里的resources的文件beans-persistence里注册config文件
<value>classpath:/com/taobao/cun/biz/dingtalk/sqlmaps/sqlmap-config.xml</value>
4.根据相应的数据表建立对应的DO文件
5.写DAO文件,例
import java.util.List; import com.taobao.cun.biz.dingtalk.dataobject.DingtalkUserDO; import com.taobao.cun.core.dao.DAOException; public interface DingtalkDao { public List<DingtalkUserDO> getDingtalkList(DingtalkUserDO dingtalkUserDO) throws DAOException; public DingtalkUserDO getByUserId(Long userId) throws DAOException; public List<DingtalkUserDO> getByUserIds(List<Long> userIds) throws DAOException; }
6.实现DAO文件,例DingtalkDaoImpl
7.建立文件beans-dao.xml在里面配置相应的资源
<bean id="dingtalkDao" class="com.taobao.cun.biz.dingtalk.dao.impl.DingtalkDaoImpl" />
8.建立DingtalkUserDto文件
9.提供相应的服务
public interface DingtalkQueryService { public ResultModel<DingtalkUserDto> getDingtalkByTaobaoUserId(Long userId); public ResultModel<List<DingtalkUserDto>> getDingtalksByTaobaoUserIds(List<Long> userIds); }
10.其中ResultModel类如下
public class ResultModel<T> implements Serializable{ private static final long serialVersionUID = 6267272693804765947L; protected boolean success; protected ServiceException exception; protected T result; public T getResult() { return result; } public void setResult(T result) { this.result = result; } public boolean isSuccess() { return success; } public void setSuccess(boolean success) { this.success = success; } public ServiceException getException() { return exception; } public void setException(ServiceException exception) { this.exception = exception; } }
11.提供服务实现类DingtalkQueryServiceImpl,这里需要注入
@Resource
private DingtalkDao dingtalkDao;
12.新建beans-server文件,在HSF中注册服务例如
<bean id="DingtalkQueryService" class="com.taobao.cun.dingtalk.service.impl.DingtalkQueryServiceImpl"/> <bean class="com.taobao.hsf.app.spring.util.HSFSpringProviderBean" init-method="init">
13.在auto-config.xml中加入
<generate template="com/taobao/cun/biz/dingtalk/spring/beans-server.xml"/>
<generate template="com/taobao/cun/biz/dingtalk/spring/beans-dao.xml"/>
14.在cuntaocenter-web中的spring-all中加入
<import resource="classpath:/com/taobao/cun/biz/dingtalk/spring/beans-dao.xml"/>
<import resource="classpath:/com/taobao/cun/biz/dingtalk/spring/beans-server.xml"/>
15.发布二方库
以更改cuntaocenter-client为例
将cuntaocenter的根目录下的pom.xml
cuntao.center.client.version改为例如1.6.0
然后在Aone中的概况里提交应用二方库发布
发布后在Nexus中查找自己的二方库是否已发布成功
16.使用新的二方库
然后在用到cuntaocenter-client的项目里更新
例如在cuntaobops里的pom.xml中更新cuntao.center.client.version
17.使用新的HSF服务
<bean id="dingtalkQueryService" class="com.taobao.hsf.app.spring.util.HSFSpringConsumerBean" init-method="syncInit">
<property name="interfaceName" value="com.taobao.cun.service.dingtalk.DingtalkQueryService" />
<property name="maxWaitAddressTimeMS" value="100000" />
<property name="version" value="${cuntao.dingtalkQueryService.version}" />
</bean>
需要在Aone中配置使用到的版本
使用
@Resource(name="dingtalkQueryService")
DingtalkQueryService dingtalkQueryService;