业务逻辑模块
public interface IUserService {
UserInfoResponseVmo getUserInfo(Integer userId, List<Integer> userIds, BigDecimal amout, Stringmobile)throws Exception;
UserInfoResponseVmo getUserInfo(UserInfoRequestVmo request)throws Exception;
}
@Service
public class UserServiceImpl implements IUserService {
@Autowired
UserDao userDao;
@Autowired
UserClint userClint;
@Autowired
UserMapper userMapper;
@Value("${get.user.info.cache.minutes:10}")
private int getUserinfoCacheMinutes;
@Override
public UserInfoResponseVmo getUserInfo(Integer userId, List<Integer> userIds, BigDecimal amout, Stringmobile)throws Exception {
UserInfoResponseVmo result = new UserInfoResponseVmo();
userDao.getUserInfo(userId);
userClint.getUserInfo(userId);
try {
userMapper.selectUserInfoById(userId);
} catch (Exception e) {
LogUtil.logApplicationError(code,message,e);
}finally{
}
return result;
}
}
接口规范
规范
* 1 依赖注入使用注解:@Autowired,注入时 T t 建议一致,反例:EndUserMapper userMapper;
* 2 禁止在service层进行数据交互和数据输出
* 3 禁止一个方法内,一个大try...catch
建议
* 1 配置中心配置建议给一个默认值
* 2 建议相同逻辑抽取公共方法,提高代码复用率
* 3 复杂的逻辑模块按照功能抽取单独方法,保证每个方法逻辑不超过80行代码
* 4 建议数据层model和输出层model在service进行转换,保证数据安全性
* 5 建议分支语句代码不超过三层,反向判断,快速返回
* 6 代码业务异常处理都在该层