小编Dev*_*wal的帖子

计算MySQL中两个日期时间之间的差异

我将最后登录时间存储在MySQL中的datetime-type字段中.当用户登录时,我想获得上次登录时间和当前时间(我使用的NOW())之间的差异.

我怎么计算呢?

mysql

144
推荐指数
3
解决办法
19万
查看次数

如何在c ++字符串中删除所有出现的char

我使用以下:

replace (str1.begin(), str1.end(), 'a' , '')
Run Code Online (Sandbox Code Playgroud)

但这会导致编译错误.

c++ stl

88
推荐指数
5
解决办法
17万
查看次数

如何进行多个请求并等待数据来自retrofit 2.0中的所有请求 - android

当前代码:

Retrofit retrofit = new Retrofit.Builder()
                  .baseUrl(Constant.BASEURL)
                  .addConverterFactory(GsonConverterFactory.create())
                  .build();

APIService service = retrofit.create(APIService.class);

Call<ResponseWrap> call = service.getNewsData();

call.enqueue(new Callback<ResponseWrap>() {

  @Override
  public void onResponse(Call<ResponseWrap> call1, Response<ResponseWrap> response) {
    if (response.isSuccess()) {

        ResponseWrap finalRes = response.body();
        for(int i=0; i<finalRes.getResponse().getResults().size(); ++i){
            String title = finalRes.getResponse().getResults().get(i).getWebTitle();
            News n = new News(titleCategory, title, null);
            newsList.add(n);
        }

        AdapterRecommendation adapter = new AdapterRecommendation(getApplicationContext(), newsList);
        listView.setAdapter(adapter);

    }
    else{
        Toast.makeText(getApplicationContext(), "onResponse  - something wrong" + response.message(), Toast.LENGTH_LONG).show();
    }
  }

  @Override
  public void onFailure(Call<ResponseWrap> call1, Throwable t) {
      Toast.makeText(getApplicationContext(), …
Run Code Online (Sandbox Code Playgroud)

android retrofit2

45
推荐指数
1
解决办法
3万
查看次数

如何使用AngularJS上传文件?

我正在尝试使用AngularJS上传文件.这是我的代码:

HTML

<input type="file" file-model="myFile"/>
<button ng-click="uploadFile()">upload me</button>
Run Code Online (Sandbox Code Playgroud)

JavaScript的

$scope.uploadFile = function(){
    var file = $scope.myFile;
    var uploadUrl = "http://admin.localhost/images/patanjali/";
    VariantService.uploadFileToUrl(file, uploadUrl);
};

VariantService.uploadFileToUrl = function(file, uploadUrl){
    var fd = new FormData();
    fd.append('file', file);
    $http.post(uploadUrl, fd, {
        transformRequest: angular.identity,
        headers: {'Content-Type': undefined}
    })
    .success(function(){
        alert ('success');
    })
    .error(function(){
    });
}
Run Code Online (Sandbox Code Playgroud)

虽然我可以在我的服务中看到("成功")警报,但该文件未保存在控制器中提供的位置.

有人能帮我吗?缺什么?

javascript file-upload angularjs

20
推荐指数
2
解决办法
4637
查看次数

我们可以在Angular.js中同时进行href和ng-click

我有一个文本框.

<input type="text" ng-model="SearchText" >
Run Code Online (Sandbox Code Playgroud)

和链接

<a href="#signout" ng-click="SearchText=''">Sign out</a>
Run Code Online (Sandbox Code Playgroud)

我想在上面的超链接中进行论述.ng-click清空文本框,#signout并将ng-route注销HTML和控制器.

但我可以ng-click在Angular.js中看到href覆盖

如何执行?

angularjs angularjs-ng-click

16
推荐指数
2
解决办法
3万
查看次数

如何在Android片段和服务中请求注入?

我正在按照本教程将Dagger 2添加到我的Android项目中.

在设置并创建模块和组件之后,我可以在Activity中添加依赖项,如下所示:

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_account);
    ButterKnife.bind(this);
    ((AppController) getApplication()).getNetComponent().inject(this);
}
Run Code Online (Sandbox Code Playgroud)

我正在努力如何在Fragment和IntentService中注入依赖项?

public class FragmentBrandList extends ListFragment {
}
Run Code Online (Sandbox Code Playgroud)

在这个类中,@Override我应该请求注入哪个方法以及这个代码是什么?

java android android-fragments dagger-2

13
推荐指数
3
解决办法
2万
查看次数

如何在TabLayout android中的活动中获取tab click事件

这是我的活动中onCreate函数的实现.我需要动态创建标签.为简单起见,我制作了两个标签.

public class ActivityProductList extends AppCompatActivity {

    private android.support.v7.widget.SearchView searchView = null;
    private RecyclerView recyclerView;
    MyAdapter adapter;
    List<ParentListItem> parentListItems = new ArrayList<>();
    List<ParentListItem> originalProductList = new ArrayList<>();
    String query = null;
    int categoryId = 0;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_products_final);

        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);
        getSupportActionBar().setTitle("PRODUCTS");
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);

        //ViewPager viewPager = (ViewPager) findViewById(R.id.pager);

        TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs);
        tabLayout.addTab(tabLayout.newTab().setText("Tab 1"));
        tabLayout.addTab(tabLayout.newTab().setText("Tab 2"));
        //setupViewPager(viewPager);
        //tabLayout.setupWithViewPager(viewPager);
        //viewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabLayout));

        searchView = (android.support.v7.widget.SearchView) findViewById(R.id.searchView);
        searchView.setIconified(false);
        searchView.onActionViewExpanded();
        searchView.clearFocus();
        searchView.setOnQueryTextListener(new android.support.v7.widget.SearchView.OnQueryTextListener() {
            @Override …
Run Code Online (Sandbox Code Playgroud)

android

12
推荐指数
2
解决办法
3万
查看次数

如何在angularjs材料设计中创建固定页脚

这是我的页面布局.

<div  layout="column" layout-fill ng-controller="MainCtrl as mc">
      <header>

        <md-toolbar md-scroll-shrink>
           <div layout="row" layout-align="center center" flex>
            HEADER INFO
          </div>
        </md-toolbar>

      </header>

      <main>
        <div ui-view>
        </div>
      </main>

      <footer>
        <md-toolbar class="md-scroll-shrink">
          <div layout="row" layout-align="center center" flex>
            FOOTER INFO
          </div>
        </md-toolbar>
      </footer>

  </div>
Run Code Online (Sandbox Code Playgroud)

目前页脚正在主要内容之后显示.取决于显示屏幕中间某处或页面高度以下的主要页脚大小.

我希望页脚始终固定在屏幕的底部.并且根据main的大小,主要内容中应该有一个滚动.

谁可以帮我这个事?

html css angularjs material-design angular-material

10
推荐指数
1
解决办法
2万
查看次数

AngularJS过滤器不适用于来自2个不同键的多个单词

这是一些示例JSON数据.

$scope.Products = [
{
    "Variants": [],
    "SubCategoryID": "66",
    "ProductImagePath": "/images/britannia/887.png",
    "SubCategoryName": "Butter",
    "BrandName": "Britannia",
    "ProductID": "887",
    "BrandID": "76",
    "ProductName": "Butter"
},
{
    "Variants": [],
    "SubCategoryID": "71",
    "ProductImagePath": "/images/amul/886.png",
    "SubCategoryName": "Cheese",
    "BrandName": "Amul",
    "ProductID": "886",
    "BrandID": "47",
    "ProductName": "cheese"
},
{
    "Variants": [],
    "SubCategoryID": "106",
    "ProductImagePath": "/images/amul/885.png",
    "SubCategoryName": "Curd",
    "BrandName": "Amul",
    "ProductID": "885",
    "BrandID": "47",
    "ProductName": "curd"
}
]
Run Code Online (Sandbox Code Playgroud)

这就是我如何渲染到网页.

<div ng-if="SearchText" class='box' ng-repeat="product in Products | filter:FilterExpr | orderBy:'ProductName'">
    <ng-include src="'commonTemplate.html'"></ng-include>
</div>
Run Code Online (Sandbox Code Playgroud)

页面中有一个搜索文本框.当用户开始在serach文本框中输入时,我会像这样为FilterExpr分配值.

$scope.$on('SearchTextChanged', function(event, SearchText) {

    if (SearchText.length …
Run Code Online (Sandbox Code Playgroud)

javascript angularjs

8
推荐指数
1
解决办法
1209
查看次数

在mysql中无法正确获取订单总和和订单值

我有4张桌子.

table_orders

order_id
customer_id
order_datetime
order_payment_type
order_delivery_date
delivery_time_slot  
Run Code Online (Sandbox Code Playgroud)

table_order_details

order_id
product_id
varient_id
quantity
product_mrp
product_sell_price
product_name
Run Code Online (Sandbox Code Playgroud)

table_order_status

order_id
status_id
status_datetime
Run Code Online (Sandbox Code Playgroud)

table_order_status_values

value_id
value_desc  
Run Code Online (Sandbox Code Playgroud)

我想获得订单ID,订单金额,订单日期,订单数量,订单时间,value_desc.

我正在运行此查询.

SELECT oo.order_id, oo.amount, oo.date, oo.quantity, oo.time, value_desc
FROM 
(
     SELECT s.order_id,  SUM(OD.product_sell_price * OD.quantity) as amount, 
       DATE_FORMAT(o.order_datetime, '%d/%m/%Y') as date, SUM(OD.quantity) 
       as quantity, TIME(o.order_datetime) as time, MAX( status_id ) as laststatus
     FROM table_orders o
     INNER JOIN table_order_details AS OD ON o.order_id = OD.order_id
     INNER JOIN table_order_status s ON s.order_id = o.order_id
     GROUP BY o.order_id
)oo …
Run Code Online (Sandbox Code Playgroud)

mysql

7
推荐指数
1
解决办法
170
查看次数