Compare commits
2 Commits
41c1eea1c3
...
203ec708fe
Author | SHA1 | Date |
---|---|---|
GatsbyH | 203ec708fe | |
GatsbyH | 4db10c4fe2 |
|
@ -4,8 +4,9 @@
|
|||
<component name="GradleSettings">
|
||||
<option name="linkedExternalProjectsSettings">
|
||||
<GradleProjectSettings>
|
||||
<option name="testRunner" value="GRADLE" />
|
||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||
<option name="gradleJvm" value="17" />
|
||||
<option name="gradleJvm" value="Embedded JDK" />
|
||||
<option name="modules">
|
||||
<set>
|
||||
<option value="$PROJECT_DIR$" />
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ASMIdeaPluginConfiguration">
|
||||
<asm skipDebug="false" skipFrames="false" skipCode="false" expandFrames="false" />
|
||||
|
@ -50,7 +49,7 @@
|
|||
<component name="FrameworkDetectionExcludesConfiguration">
|
||||
<file type="web" url="file://$PROJECT_DIR$" />
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" project-jdk-name="11" project-jdk-type="JavaSDK">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" project-jdk-name="jbr-17" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||
</component>
|
||||
<component name="ProjectType">
|
||||
|
|
|
@ -8,7 +8,7 @@ spring:
|
|||
master:
|
||||
url: jdbc:mysql://localhost:3306/jizhang?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
|
||||
username: root
|
||||
password: 336699
|
||||
password: jieyi123
|
||||
# 从库数据源
|
||||
slave:
|
||||
# 从数据源开关/默认关闭
|
||||
|
|
|
@ -22,7 +22,7 @@ import com.ruoyi.framework.security.handle.LogoutSuccessHandlerImpl;
|
|||
|
||||
/**
|
||||
* spring security配置
|
||||
*
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@EnableGlobalMethodSecurity(prePostEnabled = true, securedEnabled = true)
|
||||
|
@ -33,7 +33,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter
|
|||
*/
|
||||
@Autowired
|
||||
private UserDetailsService userDetailsService;
|
||||
|
||||
|
||||
/**
|
||||
* 认证失败处理类
|
||||
*/
|
||||
|
@ -51,7 +51,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter
|
|||
*/
|
||||
@Autowired
|
||||
private JwtAuthenticationTokenFilter authenticationTokenFilter;
|
||||
|
||||
|
||||
/**
|
||||
* 跨域过滤器
|
||||
*/
|
||||
|
@ -114,7 +114,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter
|
|||
.antMatchers("/login", "/register", "/captchaImage").permitAll()
|
||||
// 静态资源,可匿名访问
|
||||
.antMatchers(HttpMethod.GET, "/", "/*.html", "/**/*.html", "/**/*.css", "/**/*.js", "/profile/**").permitAll()
|
||||
.antMatchers("/swagger-ui.html", "/swagger-resources/**", "/webjars/**", "/*/api-docs", "/druid/**").permitAll()
|
||||
.antMatchers("/swagger-ui.html", "/swagger-resources/**", "/webjars/**", "/*/api-docs", "/druid/**","/app/**").permitAll()
|
||||
// 除上面外的所有请求全部需要鉴权认证
|
||||
.anyRequest().authenticated()
|
||||
.and()
|
||||
|
|
|
@ -1,10 +1,20 @@
|
|||
package com.ruoyi.app.controller;
|
||||
|
||||
|
||||
import com.ruoyi.app.system.domain.Accounttb;
|
||||
import com.ruoyi.app.system.service.IAccounttbService;
|
||||
import com.ruoyi.app.system.service.ICategoryService;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.common.utils.SecurityUtils;
|
||||
import com.ruoyi.system.domain.Category;
|
||||
import java.util.List;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
@ -17,6 +27,9 @@ import org.springframework.web.bind.annotation.RestController;
|
|||
public class AppCategoryController {
|
||||
@Autowired
|
||||
private ICategoryService categoryService;
|
||||
|
||||
@Autowired
|
||||
private IAccounttbService accounttbService;
|
||||
@PutMapping
|
||||
private AjaxResult addCategory(@RequestBody com.ruoyi.system.domain.Category category){
|
||||
Long userId = SecurityUtils.getLoginUser().getUser().getUserId();
|
||||
|
@ -24,4 +37,28 @@ public class AppCategoryController {
|
|||
|
||||
return AjaxResult.success( categoryService.insertCategory(category));
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody Accounttb accounttb)
|
||||
{
|
||||
return AjaxResult.success(accounttbService.insertAccounttb(accounttb));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@GetMapping("/list")
|
||||
public AjaxResult list(Accounttb accounttb)
|
||||
{
|
||||
List<Accounttb> list = accounttbService.selectAccounttbList(accounttb);
|
||||
return AjaxResult.success(list);
|
||||
}
|
||||
|
||||
@GetMapping("/getSumMoneyOneDay")
|
||||
public AjaxResult getSumMoneyOneDay(Accounttb accounttb)
|
||||
{
|
||||
Float sumMoneyOneDay = accounttbService.getSumMoneyOneDay(accounttb);
|
||||
return AjaxResult.success(sumMoneyOneDay);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ public class AppUserController {
|
|||
AjaxResult ajax = new AjaxResult();
|
||||
String token = loginService.loginNoCode(loginBody.getUsername(),loginBody.getPassword());
|
||||
ajax.put(Constants.TOKEN,token);
|
||||
return success(ajax);
|
||||
return AjaxResult.success("登陆成功",token);
|
||||
}
|
||||
|
||||
|
||||
|
@ -63,6 +63,7 @@ public class AppUserController {
|
|||
SysUser currentUser = SecurityUtils.getLoginUser().getUser();
|
||||
currentUser.setNickName(user.getNickName());
|
||||
currentUser.setEmail(user.getEmail());
|
||||
currentUser.setPassword(user.getPassword());
|
||||
currentUser.setPhonenumber(user.getPhonenumber());
|
||||
currentUser.setSex(user.getSex());
|
||||
user.setUserId(userId);
|
||||
|
|
|
@ -37,6 +37,7 @@ public class Accounttb extends BaseEntity
|
|||
private Long money;
|
||||
|
||||
/** $column.columnComment */
|
||||
@JsonFormat(pattern = "yyyy年MM月dd日 HH:mm")
|
||||
@Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
|
||||
private Date time;
|
||||
|
||||
|
|
|
@ -60,4 +60,6 @@ public interface AccounttbMapper
|
|||
* @return 结果
|
||||
*/
|
||||
public int deleteAccounttbByIds(Long[] ids);
|
||||
|
||||
Float getSumMoneyOneDay(Accounttb accounttb);
|
||||
}
|
||||
|
|
|
@ -60,4 +60,6 @@ public interface IAccounttbService
|
|||
* @return 结果
|
||||
*/
|
||||
public int deleteAccounttbById(Long id);
|
||||
|
||||
Float getSumMoneyOneDay(Accounttb accounttb);
|
||||
}
|
||||
|
|
|
@ -93,4 +93,9 @@ public class AccounttbServiceImpl implements IAccounttbService
|
|||
{
|
||||
return accounttbMapper.deleteAccounttbById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Float getSumMoneyOneDay(Accounttb accounttb) {
|
||||
return accounttbMapper.getSumMoneyOneDay(accounttb);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,8 +40,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<include refid="selectAccounttbVo"/>
|
||||
where id = #{id}
|
||||
</select>
|
||||
<select id="getSumMoneyOneDay" resultType="float">
|
||||
SELECT SUM(money) AS total
|
||||
FROM accounttb
|
||||
WHERE
|
||||
<trim prefix="(" suffix=")" suffixOverrides="AND">
|
||||
<if test="year != null">year = #{year} AND</if>
|
||||
<if test="month != null">month = #{month} AND</if>
|
||||
<if test="day != null">day = #{day} AND</if>
|
||||
<if test="kind != null">kind = #{kind} AND</if>
|
||||
</trim>
|
||||
</select>
|
||||
|
||||
<insert id="insertAccounttb" parameterType="Accounttb" useGeneratedKeys="true" keyProperty="id">
|
||||
<insert id="insertAccounttb" parameterType="Accounttb" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into accounttb
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="typename != null">typename,</if>
|
||||
|
|
|
@ -39,6 +39,11 @@ dependencies {
|
|||
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
|
||||
implementation 'androidx.navigation:navigation-fragment:2.4.1'
|
||||
implementation 'androidx.navigation:navigation-ui:2.4.1'
|
||||
implementation 'com.github.xuexiangjys:XHttp2:1.0.4'
|
||||
implementation 'com.google.code.gson:gson:2.10.1'
|
||||
implementation 'com.squareup.okhttp3:okhttp:5.0.0-alpha.12'
|
||||
implementation 'io.reactivex.rxjava2:rxjava:2.2.21'
|
||||
implementation 'io.reactivex.rxjava2:rxandroid:2.1.1'
|
||||
// implementation 'com.github.PhilJay:MPAndroidChart:v3.0.3'
|
||||
testImplementation 'junit:junit:4.13.2'
|
||||
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
|
||||
|
@ -46,5 +51,12 @@ dependencies {
|
|||
implementation 'me.majiajie:pager-bottom-tab-strip:2.4.0'
|
||||
implementation 'com.blankj:utilcodex:1.31.1'
|
||||
|
||||
implementation 'com.github.xuexiangjys:XHttp2:2.0.4'
|
||||
|
||||
implementation 'com.google.code.gson:gson:2.8.5'
|
||||
implementation 'com.squareup.okhttp3:okhttp:3.10.0'
|
||||
implementation 'io.reactivex.rxjava2:rxjava:2.2.0'
|
||||
implementation 'io.reactivex.rxjava2:rxandroid:2.1.0'
|
||||
|
||||
|
||||
}
|
|
@ -1,8 +1,11 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.example.tally" >
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||
<application
|
||||
|
||||
android:usesCleartextTraffic="true"
|
||||
android:name=".UniteApp"
|
||||
android:allowBackup="true"
|
||||
android:icon="@drawable/logo"
|
||||
|
@ -10,6 +13,7 @@
|
|||
android:roundIcon="@mipmap/ic_launcher_round"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/Theme.Tally" >
|
||||
|
||||
<activity
|
||||
android:name=".XinxiActivity"
|
||||
android:exported="false" />
|
||||
|
|
|
@ -11,6 +11,7 @@ public class AboutActivity extends AppCompatActivity {
|
|||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_about);
|
||||
|
||||
}
|
||||
public void onClick(View view) {
|
||||
finish();
|
||||
|
|
|
@ -3,8 +3,11 @@ package com.example.tally;
|
|||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ListView;
|
||||
|
@ -14,6 +17,10 @@ import com.example.tally.adapter.AccountAdapter;
|
|||
import com.example.tally.db.AccountBean;
|
||||
import com.example.tally.db.DBManager;
|
||||
import com.example.tally.utils.CalendarDialog;
|
||||
import com.xuexiang.xhttp2.XHttp;
|
||||
import com.xuexiang.xhttp2.XHttpSDK;
|
||||
import com.xuexiang.xhttp2.callback.SimpleCallBack;
|
||||
import com.xuexiang.xhttp2.exception.ApiException;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
|
@ -74,10 +81,34 @@ public class HistoryActivity extends AppCompatActivity {
|
|||
|
||||
/* 获取指定年份月份收支情况的列表*/
|
||||
private void loadData(int year,int month) {
|
||||
List<AccountBean> list = DBManager.getAccountListOneMonthFromAccounttb(year, month);//两个参数是指定的年份月份
|
||||
mDatas.clear();
|
||||
mDatas.addAll(list);
|
||||
adapter.notifyDataSetChanged();
|
||||
|
||||
XHttpSDK.setSuccessCode(200);
|
||||
SharedPreferences sharedPreferences = getSharedPreferences("myPrefs", Context.MODE_PRIVATE);
|
||||
String token = sharedPreferences.getString("token", "");
|
||||
XHttp.get("/app/Category/list")
|
||||
.headers("Authorization", "Bearer " + token)
|
||||
.params("year",year)
|
||||
.params("month",month)
|
||||
.syncRequest(false) //异步请求
|
||||
.onMainThread(true) //回到主线程
|
||||
.execute(new SimpleCallBack<List<AccountBean>>() {
|
||||
@Override
|
||||
public void onSuccess(List<AccountBean> response) throws Throwable {
|
||||
if (response != null && response.size() > 0) {
|
||||
mDatas.clear();
|
||||
mDatas.addAll(response);
|
||||
adapter.notifyDataSetChanged();
|
||||
Log.e("YourClass", "getHistoryInfo success, response: " + response.toString());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(ApiException e) {
|
||||
e.printStackTrace();
|
||||
Log.e("YourClass", "getHistoryInfo error: " + e.getMessage());
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void initTime() {
|
||||
|
|
|
@ -3,11 +3,13 @@ package com.example.tally;
|
|||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.database.Cursor;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
|
@ -16,6 +18,17 @@ import android.widget.RadioGroup;
|
|||
import android.widget.Toast;
|
||||
|
||||
import com.example.tally.db.DBOpenHelper;
|
||||
import com.xuexiang.xhttp2.XHttp;
|
||||
import com.xuexiang.xhttp2.XHttpSDK;
|
||||
import com.xuexiang.xhttp2.callback.SimpleCallBack;
|
||||
import com.xuexiang.xhttp2.exception.ApiException;
|
||||
import com.xuexiang.xhttp2.model.HttpHeaders;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import okhttp3.FormBody;
|
||||
import okhttp3.RequestBody;
|
||||
|
||||
public class LoginActivity extends AppCompatActivity implements View.OnClickListener {
|
||||
EditText ed_name;
|
||||
|
@ -70,6 +83,42 @@ public class LoginActivity extends AppCompatActivity implements View.OnClickList
|
|||
Toast.makeText(LoginActivity.this, "请输入密码", Toast.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
|
||||
JSONObject requestBody = new JSONObject();
|
||||
try {
|
||||
requestBody.put("username", name);
|
||||
requestBody.put("password", password);
|
||||
} catch (JSONException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
String requestBodyString = requestBody.toString();
|
||||
XHttpSDK.setSuccessCode(200);
|
||||
XHttp.post("/app/user/login")
|
||||
// .params("username", name)
|
||||
// .params("password", password)
|
||||
.upJson(requestBodyString)
|
||||
.execute(new SimpleCallBack<String>() {
|
||||
@Override
|
||||
public void onSuccess(String result){
|
||||
SharedPreferences sp = getSharedPreferences("myPrefs",MODE_PRIVATE);
|
||||
SharedPreferences.Editor editor = sp.edit();
|
||||
editor.putString("token",result);
|
||||
editor.apply();
|
||||
Log.e("TAG", "成功:" + result );
|
||||
Toast.makeText(LoginActivity.this, "登陆成功", Toast.LENGTH_LONG).show();
|
||||
Intent intent = new Intent(LoginActivity.this,MainActivity.class);
|
||||
startActivity(intent);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(ApiException e) {
|
||||
Log.e("TAG", "登录失败:" + e.getMessage() + ", Code: " + e.getCode() );
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
// SharedPreferences sp = getSharedPreferences("regInfo",MODE_PRIVATE);
|
||||
// String name1 = sp.getString("account","");
|
||||
// String pass1 = sp.getString("password","");
|
||||
|
@ -80,32 +129,32 @@ public class LoginActivity extends AppCompatActivity implements View.OnClickList
|
|||
// startActivity(intent);
|
||||
// }
|
||||
// 从数据库中国获取信息
|
||||
db = helper.getReadableDatabase();
|
||||
//select * from where name="mark"
|
||||
Cursor cursor = db.query("user", null, "account=?", new String[]{name}, null, null, null);
|
||||
// db.query("user",null,"name=?",new String[]{ed_name.getText().toString()},null,null,null);
|
||||
if (cursor.getCount() > 0) {
|
||||
cursor.moveToNext();//结果集中的指针指向下一个位置
|
||||
userName = cursor.getString(cursor.getColumnIndex("account"));
|
||||
Password = cursor.getString(cursor.getColumnIndex("password"));
|
||||
}
|
||||
db.close();
|
||||
if (name.equals(userName) && password.equals(Password)) {
|
||||
Toast.makeText(LoginActivity.this, "登陆成功", Toast.LENGTH_LONG).show();
|
||||
Intent intent = new Intent(LoginActivity.this,MainActivity.class);
|
||||
startActivity(intent);
|
||||
SharedPreferences sp = getSharedPreferences("loginInfo", MODE_PRIVATE);
|
||||
SharedPreferences.Editor editor = sp.edit();
|
||||
editor.putString("account", name);
|
||||
editor.putString("password", password);
|
||||
editor.commit();
|
||||
// Intent intent = getIntent();
|
||||
// String name = intent.getStringExtra("name");
|
||||
// Intent intent1 = new Intent(UserActivity.this,EditInfoActivity.class);
|
||||
// intent1.putExtra("name",name);
|
||||
} else {
|
||||
Toast.makeText(LoginActivity.this, "账号或密码错误", Toast.LENGTH_LONG).show();
|
||||
}
|
||||
// db = helper.getReadableDatabase();
|
||||
// //select * from where name="mark"
|
||||
// Cursor cursor = db.query("user", null, "account=?", new String[]{name}, null, null, null);
|
||||
//// db.query("user",null,"name=?",new String[]{ed_name.getText().toString()},null,null,null);
|
||||
// if (cursor.getCount() > 0) {
|
||||
// cursor.moveToNext();//结果集中的指针指向下一个位置
|
||||
// userName = cursor.getString(cursor.getColumnIndex("account"));
|
||||
// Password = cursor.getString(cursor.getColumnIndex("password"));
|
||||
// }
|
||||
// db.close();
|
||||
// if (name.equals(userName) && password.equals(Password)) {
|
||||
// Toast.makeText(LoginActivity.this, "登陆成功", Toast.LENGTH_LONG).show();
|
||||
// Intent intent = new Intent(LoginActivity.this,MainActivity.class);
|
||||
// startActivity(intent);
|
||||
// SharedPreferences sp = getSharedPreferences("loginInfo", MODE_PRIVATE);
|
||||
// SharedPreferences.Editor editor = sp.edit();
|
||||
// editor.putString("account", name);
|
||||
// editor.putString("password", password);
|
||||
// editor.commit();
|
||||
//// Intent intent = getIntent();
|
||||
//// String name = intent.getStringExtra("name");
|
||||
//// Intent intent1 = new Intent(UserActivity.this,EditInfoActivity.class);
|
||||
//// intent1.putExtra("name",name);
|
||||
// } else {
|
||||
// Toast.makeText(LoginActivity.this, "账号或密码错误", Toast.LENGTH_LONG).show();
|
||||
// }
|
||||
break;
|
||||
case R.id.btn_reg:
|
||||
Intent intent = new Intent(LoginActivity.this, RegistActivity.class);
|
||||
|
|
|
@ -54,6 +54,7 @@ public class MainActivity extends AppCompatActivity{
|
|||
}
|
||||
/** 初始化自带的View的方法*/
|
||||
private void initView() {
|
||||
|
||||
mFragmentList = new ArrayList<>();
|
||||
mainBottomNavigationAdapter = new MainBottomNavigationAdapter(getSupportFragmentManager());
|
||||
viewPager = findViewById(R.id.viewpager);
|
||||
|
|
|
@ -4,8 +4,11 @@ import androidx.appcompat.app.AppCompatActivity;
|
|||
import androidx.fragment.app.Fragment;
|
||||
import androidx.viewpager.widget.ViewPager;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.graphics.Color;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.TextView;
|
||||
|
@ -15,6 +18,10 @@ import com.example.tally.db.DBManager;
|
|||
import com.example.tally.frag_chart.IncomeChartFragment;
|
||||
import com.example.tally.frag_chart.OutcomeChartFragment;
|
||||
import com.example.tally.utils.CalendarDialog;
|
||||
import com.xuexiang.xhttp2.XHttp;
|
||||
import com.xuexiang.xhttp2.XHttpSDK;
|
||||
import com.xuexiang.xhttp2.callback.SimpleCallBack;
|
||||
import com.xuexiang.xhttp2.exception.ApiException;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
|
@ -31,7 +38,8 @@ public class MonthChartActivity extends AppCompatActivity {
|
|||
private IncomeChartFragment incomChartFragment;
|
||||
private OutcomeChartFragment outcomChartFragment;
|
||||
private ChartVPAdapter chartVPAdapter;
|
||||
|
||||
float inMoneyOneMonth=0;
|
||||
float outMoneyOneMonth=0;
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
@ -73,16 +81,74 @@ public class MonthChartActivity extends AppCompatActivity {
|
|||
|
||||
/* 统计某年某月的收支情况数据*/
|
||||
private void initStatistics(int year, int month) {
|
||||
float inMoneyOneMonth = DBManager.getSumMoneyOneMonth(year, month, 1); //收入总钱数
|
||||
float outMoneyOneMonth = DBManager.getSumMoneyOneMonth(year, month, 0); //支出总钱数
|
||||
SharedPreferences sharedPreferences = getSharedPreferences("myPrefs", Context.MODE_PRIVATE);
|
||||
String token = sharedPreferences.getString("token", "");
|
||||
XHttpSDK.setSuccessCode(200);
|
||||
XHttp.get("/app/Category/getSumMoneyOneDay")
|
||||
.headers("Authorization", "Bearer " + token)
|
||||
.params("year",year)
|
||||
.params("month",month)
|
||||
.params("kind",1)
|
||||
.syncRequest(false) //异步请求
|
||||
.onMainThread(true) //回到主线程
|
||||
.execute(new SimpleCallBack<Float>() {
|
||||
@Override
|
||||
public void onSuccess(Float response) throws Throwable {
|
||||
inMoneyOneMonth=response;
|
||||
updateStatistics();
|
||||
Log.e("YourClass", "getSumMoneyOneMonth incountItemOneMonth success, response: " + response.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(ApiException e) {
|
||||
e.printStackTrace();
|
||||
Log.e("YourClass", "getSumMoneyOneMonth error: " + e.getMessage());
|
||||
}
|
||||
});
|
||||
XHttpSDK.setSuccessCode(200);
|
||||
XHttp.get("/app/Category/getSumMoneyOneDay")
|
||||
.headers("Authorization", "Bearer " + token)
|
||||
.params("year",year)
|
||||
.params("month",month)
|
||||
.params("kind",0)
|
||||
.syncRequest(false) //异步请求
|
||||
.onMainThread(true) //回到主线程
|
||||
.execute(new SimpleCallBack<Float>() {
|
||||
@Override
|
||||
public void onSuccess(Float response) throws Throwable {
|
||||
outMoneyOneMonth=response;
|
||||
updateStatistics();
|
||||
Log.e("YourClass", "getSumMoneyOneMonth outcountItemOneMonth success, response: " + response.toString());
|
||||
}
|
||||
@Override
|
||||
public void onError(ApiException e) {
|
||||
e.printStackTrace();
|
||||
Log.e("YourClass", "getSumMoneyOneMonth error: " + e.getMessage());
|
||||
}
|
||||
});
|
||||
// float inMoneyOneMonth = DBManager.getSumMoneyOneMonth(year, month, 1); //收入总钱数
|
||||
// float outMoneyOneMonth = DBManager.getSumMoneyOneMonth(year, month, 0); //支出总钱数
|
||||
int incountItemOneMonth = DBManager.getCountItemOneMonth(year, month, 1); //收入多少笔
|
||||
int outcountItemOneMonth = DBManager.getCountItemOneMonth(year, month, 0); //支出多少笔
|
||||
dateTv.setText(year+"年"+month+"月账单");
|
||||
inTv.setText("共"+incountItemOneMonth+"笔收入, ¥ "+inMoneyOneMonth);
|
||||
outTv.setText("共"+outcountItemOneMonth+"笔支出, ¥ "+outMoneyOneMonth);
|
||||
|
||||
}
|
||||
|
||||
private void updateStatistics() {
|
||||
int incountItemOneMonth = DBManager.getCountItemOneMonth(year, month, 1);
|
||||
int outcountItemOneMonth = DBManager.getCountItemOneMonth(year, month, 0);
|
||||
|
||||
// 更新UI
|
||||
runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
dateTv.setText(year + "年" + month + "月账单");
|
||||
inTv.setText("共" + incountItemOneMonth + "笔收入, ¥ " + inMoneyOneMonth);
|
||||
outTv.setText("共" + outcountItemOneMonth + "笔支出, ¥ " + outMoneyOneMonth);
|
||||
}
|
||||
});
|
||||
}
|
||||
/** 初始化时间的方法*/
|
||||
private void initTime() {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
|
|
|
@ -13,6 +13,13 @@ import android.widget.EditText;
|
|||
import android.widget.Toast;
|
||||
|
||||
import com.example.tally.db.DBOpenHelper;
|
||||
import com.xuexiang.xhttp2.XHttp;
|
||||
import com.xuexiang.xhttp2.XHttpSDK;
|
||||
import com.xuexiang.xhttp2.callback.SimpleCallBack;
|
||||
import com.xuexiang.xhttp2.exception.ApiException;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
public class RegistActivity extends AppCompatActivity implements View.OnClickListener {
|
||||
EditText ed_username,ed_userpwd,ed_userpwdr,ed_email,ed_phone;
|
||||
|
@ -52,23 +59,51 @@ public class RegistActivity extends AppCompatActivity implements View.OnClickLis
|
|||
if(!userPsd.equals(confirPsd)){
|
||||
Toast.makeText(RegistActivity.this,"两次输入的密码不一致,注册失败",Toast.LENGTH_LONG).show();
|
||||
}else {
|
||||
SharedPreferences sp = getSharedPreferences("regInfo",MODE_PRIVATE);
|
||||
SharedPreferences.Editor editor = sp.edit();
|
||||
editor.putString("account",userName);
|
||||
editor.putString("password",userPsd);
|
||||
editor.putString("email",userEmail);
|
||||
editor.putString("phone",userPhone);
|
||||
editor.commit();//获取创建的数据库对象
|
||||
db = helper.getWritableDatabase();//获取创建的数据库对象
|
||||
ContentValues values = new ContentValues();
|
||||
values.put("account",userName);
|
||||
values.put("password",userPsd);
|
||||
values.put("email",userEmail);
|
||||
values.put("phone",userPhone);
|
||||
db.insert("user",null,values);
|
||||
db.close();
|
||||
Log.i("animee","insertItemToUserb:ok!!!");
|
||||
Toast.makeText(RegistActivity.this,"注册成功",Toast.LENGTH_LONG).show();//获取创建的数据库对象
|
||||
JSONObject requestBody = new JSONObject();
|
||||
try {
|
||||
requestBody.put("username", userName);
|
||||
requestBody.put("password", userPsd);
|
||||
} catch (JSONException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
String requestBodyString = requestBody.toString();
|
||||
XHttpSDK.setSuccessCode(200);
|
||||
XHttp.post("/app/user/register")
|
||||
// .params("username", name)
|
||||
// .params("password", password)
|
||||
.upJson(requestBodyString)
|
||||
.execute(new SimpleCallBack<String>() {
|
||||
@Override
|
||||
public void onSuccess(String result){
|
||||
|
||||
Toast.makeText(RegistActivity.this,"注册成功",Toast.LENGTH_LONG).show();//获取创建的数据库对象
|
||||
Log.e("TAG", "成功:" + result );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(ApiException e) {
|
||||
Log.e("TAG", "注册失败:" + e.getMessage() + ", Code: " + e.getCode() );
|
||||
|
||||
}
|
||||
});
|
||||
// SharedPreferences sp = getSharedPreferences("regInfo",MODE_PRIVATE);
|
||||
// SharedPreferences.Editor editor = sp.edit();
|
||||
// editor.putString("account",userName);
|
||||
// editor.putString("password",userPsd);
|
||||
// editor.putString("email",userEmail);
|
||||
// editor.putString("phone",userPhone);
|
||||
// editor.commit();//获取创建的数据库对象
|
||||
// db = helper.getWritableDatabase();//获取创建的数据库对象
|
||||
// ContentValues values = new ContentValues();
|
||||
// values.put("account",userName);
|
||||
// values.put("password",userPsd);
|
||||
// values.put("email",userEmail);
|
||||
// values.put("phone",userPhone);
|
||||
// db.insert("user",null,values);
|
||||
// db.close();
|
||||
// Log.i("animee","insertItemToUserb:ok!!!");
|
||||
// Toast.makeText(RegistActivity.this,"注册成功",Toast.LENGTH_LONG).show();//获取创建的数据库对象
|
||||
}
|
||||
break;
|
||||
case R.id.BackLoginButton:
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.example.tally;
|
|||
import android.app.Application;
|
||||
|
||||
import com.example.tally.db.DBManager;
|
||||
import com.xuexiang.xhttp2.XHttpSDK;
|
||||
|
||||
/* 表示全局应用的类*/
|
||||
public class UniteApp extends Application {
|
||||
|
@ -11,6 +12,10 @@ public class UniteApp extends Application {
|
|||
super.onCreate();
|
||||
// 初始化数据库
|
||||
DBManager.initDB(getApplicationContext());
|
||||
XHttpSDK.init(this);
|
||||
|
||||
//设置网络请求的全局基础地址
|
||||
XHttpSDK.setBaseUrl("http://192.168.0.8:8831/");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -3,17 +3,27 @@ package com.example.tally;
|
|||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import android.content.ContentValues;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.database.Cursor;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.example.tally.db.DBOpenHelper;
|
||||
import com.example.tally.entity.SysUser;
|
||||
import com.xuexiang.xhttp2.XHttp;
|
||||
import com.xuexiang.xhttp2.XHttpSDK;
|
||||
import com.xuexiang.xhttp2.callback.SimpleCallBack;
|
||||
import com.xuexiang.xhttp2.exception.ApiException;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
public class XinxiActivity extends AppCompatActivity implements View.OnClickListener{
|
||||
EditText ed_username,ed_userpwd,ed_email,ed_phone;
|
||||
|
@ -50,27 +60,71 @@ public class XinxiActivity extends AppCompatActivity implements View.OnClickList
|
|||
// ed_email.setText(sp.getString("email",""));
|
||||
// ed_phone.setText(sp.getString("phone",""));
|
||||
//
|
||||
String name = sp.getString("account","");
|
||||
db = helper.getReadableDatabase();
|
||||
Cursor cursor = db.query("user",null,"account=?",new String[]{name},null,null,null);
|
||||
if(cursor.getCount()>0){
|
||||
cursor.moveToNext();
|
||||
ed_username.setText(cursor.getString(cursor.getColumnIndex("account")));
|
||||
ed_userpwd.setText(cursor.getString(cursor.getColumnIndex("password")));
|
||||
XHttpSDK.setSuccessCode(200);
|
||||
SharedPreferences sharedPreferences = getSharedPreferences("myPrefs", Context.MODE_PRIVATE);
|
||||
String token = sharedPreferences.getString("token", "");
|
||||
Log.e("缓存",token);
|
||||
XHttp.get("app/user")
|
||||
.headers("Authorization", "Bearer " + token)
|
||||
.syncRequest(false) //异步请求
|
||||
.onMainThread(true) //回到主线程
|
||||
.execute(new SimpleCallBack<SysUser>() {
|
||||
@Override
|
||||
public void onSuccess(SysUser result) {
|
||||
Log.e("TAG", "查询结果:" + result );
|
||||
ed_username.setText(result.getUserName());
|
||||
// ed_userpwd.setText(result.getPassword());
|
||||
// ed_PasswordR.setText(cursor.getString(cursor.getColumnIndex("password")));
|
||||
ed_email.setText(cursor.getString(cursor.getColumnIndex("email")));
|
||||
ed_phone.setText(cursor.getString(cursor.getColumnIndex("phone")));
|
||||
}
|
||||
db.close();
|
||||
}
|
||||
ed_email.setText(result.getEmail());
|
||||
ed_phone.setText(result.getPhonenumber());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(ApiException e) {
|
||||
|
||||
Log.e("TAG", "查询失败:" + e.getMessage() + ", Code: " + e.getCode() ); }
|
||||
});
|
||||
|
||||
}
|
||||
JSONObject requestBody = new JSONObject();
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
String pp = ed_userpwd.getText().toString();
|
||||
if (pp.isEmpty()) {
|
||||
Toast.makeText(XinxiActivity.this, "密码不能为空,请输入", Toast.LENGTH_LONG).show();
|
||||
}else
|
||||
db = helper.getWritableDatabase();
|
||||
|
||||
try {
|
||||
requestBody.put("nickName", ed_username.getText().toString());
|
||||
requestBody.put("password", ed_userpwd.getText().toString());
|
||||
requestBody.put("email", ed_email.getText().toString());
|
||||
requestBody.put("phonenumber", ed_phone.getText().toString());
|
||||
} catch (JSONException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
SharedPreferences sharedPreferences = getSharedPreferences("myPrefs", Context.MODE_PRIVATE);
|
||||
String token = sharedPreferences.getString("token", "");
|
||||
String requestBodyString = requestBody.toString();
|
||||
XHttpSDK.setSuccessCode(200);
|
||||
XHttp.post("/app/user")
|
||||
.headers("Authorization", "Bearer " + token)
|
||||
.upJson(requestBodyString)
|
||||
.execute(new SimpleCallBack<Integer>() {
|
||||
@Override
|
||||
public void onSuccess(Integer result){
|
||||
if (result > 0) {
|
||||
Toast.makeText(XinxiActivity.this, "修改成功", Toast.LENGTH_LONG).show();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(ApiException e) {
|
||||
Log.e("TAG", "登录失败:" + e.getMessage() + ", Code: " + e.getCode() );
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
db = helper.getWritableDatabase();
|
||||
values = new ContentValues();
|
||||
values.put("password", ed_userpwd.getText().toString());
|
||||
values.put("email", ed_email.getText().toString());
|
||||
|
|
|
@ -1,13 +1,27 @@
|
|||
package com.example.tally.db;
|
||||
|
||||
import static android.content.Context.MODE_PRIVATE;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.ContentValues;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.database.Cursor;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.util.Log;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.example.tally.LoginActivity;
|
||||
import com.example.tally.MainActivity;
|
||||
import com.example.tally.utils.FloatUtils;
|
||||
import com.xuexiang.xhttp2.XHttp;
|
||||
import com.xuexiang.xhttp2.XHttpSDK;
|
||||
import com.xuexiang.xhttp2.callback.SimpleCallBack;
|
||||
import com.xuexiang.xhttp2.exception.ApiException;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
@ -60,6 +74,8 @@ public class DBManager {
|
|||
values.put("month",bean.getMonth());
|
||||
values.put("day",bean.getDay());
|
||||
values.put("kind",bean.getKind());
|
||||
|
||||
|
||||
db.insert("accounttb",null,values);
|
||||
Log.i("animee","insertItemToAccounttb:ok!!!");
|
||||
}
|
||||
|
|
|
@ -0,0 +1,201 @@
|
|||
package com.example.tally.entity;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 用户对象 sys_user
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
public class SysUser
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 用户ID */
|
||||
|
||||
private Long userId;
|
||||
|
||||
/** 部门ID */
|
||||
|
||||
private Long deptId;
|
||||
|
||||
/** 用户账号 */
|
||||
|
||||
private String userName;
|
||||
|
||||
/** 用户昵称 */
|
||||
|
||||
private String nickName;
|
||||
|
||||
/** 用户邮箱 */
|
||||
|
||||
private String email;
|
||||
|
||||
/** 手机号码 */
|
||||
|
||||
private String phonenumber;
|
||||
|
||||
/** 用户性别 */
|
||||
|
||||
private String sex;
|
||||
|
||||
/** 用户头像 */
|
||||
private String avatar;
|
||||
|
||||
/** 密码 */
|
||||
private String password;
|
||||
|
||||
/** 帐号状态(0正常 1停用) */
|
||||
|
||||
private String status;
|
||||
|
||||
/** 删除标志(0代表存在 2代表删除) */
|
||||
private String delFlag;
|
||||
|
||||
/** 最后登录IP */
|
||||
|
||||
private String loginIp;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public String getNickName()
|
||||
{
|
||||
return nickName;
|
||||
}
|
||||
|
||||
public void setNickName(String nickName)
|
||||
{
|
||||
this.nickName = nickName;
|
||||
}
|
||||
|
||||
|
||||
public String getUserName()
|
||||
{
|
||||
return userName;
|
||||
}
|
||||
|
||||
public void setUserName(String userName)
|
||||
{
|
||||
this.userName = userName;
|
||||
}
|
||||
|
||||
|
||||
public String getEmail()
|
||||
{
|
||||
return email;
|
||||
}
|
||||
|
||||
public void setEmail(String email)
|
||||
{
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
|
||||
public String getPhonenumber()
|
||||
{
|
||||
return phonenumber;
|
||||
}
|
||||
|
||||
public void setPhonenumber(String phonenumber)
|
||||
{
|
||||
this.phonenumber = phonenumber;
|
||||
}
|
||||
|
||||
public String getSex()
|
||||
{
|
||||
return sex;
|
||||
}
|
||||
|
||||
public void setSex(String sex)
|
||||
{
|
||||
this.sex = sex;
|
||||
}
|
||||
|
||||
public String getAvatar()
|
||||
{
|
||||
return avatar;
|
||||
}
|
||||
|
||||
public void setAvatar(String avatar)
|
||||
{
|
||||
this.avatar = avatar;
|
||||
}
|
||||
|
||||
public String getPassword()
|
||||
{
|
||||
return password;
|
||||
}
|
||||
|
||||
public void setPassword(String password)
|
||||
{
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public String getStatus()
|
||||
{
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(String status)
|
||||
{
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public String getDelFlag()
|
||||
{
|
||||
return delFlag;
|
||||
}
|
||||
|
||||
public void setDelFlag(String delFlag)
|
||||
{
|
||||
this.delFlag = delFlag;
|
||||
}
|
||||
|
||||
public String getLoginIp()
|
||||
{
|
||||
return loginIp;
|
||||
}
|
||||
|
||||
public void setLoginIp(String loginIp)
|
||||
{
|
||||
this.loginIp = loginIp;
|
||||
}
|
||||
|
||||
|
||||
public Long getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setUserId(Long userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "SysUser{" +
|
||||
"userId=" + userId +
|
||||
", deptId=" + deptId +
|
||||
", userName='" + userName + '\'' +
|
||||
", nickName='" + nickName + '\'' +
|
||||
", email='" + email + '\'' +
|
||||
", phonenumber='" + phonenumber + '\'' +
|
||||
", sex='" + sex + '\'' +
|
||||
", avatar='" + avatar + '\'' +
|
||||
", password='" + password + '\'' +
|
||||
", status='" + status + '\'' +
|
||||
", delFlag='" + delFlag + '\'' +
|
||||
", loginIp='" + loginIp + '\'' +
|
||||
'}';
|
||||
}
|
||||
|
||||
public Long getDeptId() {
|
||||
return deptId;
|
||||
}
|
||||
|
||||
public void setDeptId(Long deptId) {
|
||||
this.deptId = deptId;
|
||||
}
|
||||
}
|
|
@ -8,6 +8,7 @@ import android.content.SharedPreferences;
|
|||
import android.os.Bundle;
|
||||
import android.text.method.HideReturnsTransformationMethod;
|
||||
import android.text.method.PasswordTransformationMethod;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
@ -33,6 +34,10 @@ import com.example.tally.db.AccountBean;
|
|||
import com.example.tally.db.DBManager;
|
||||
import com.example.tally.utils.BudgetDialog;
|
||||
import com.example.tally.utils.MoreDialog;
|
||||
import com.xuexiang.xhttp2.XHttp;
|
||||
import com.xuexiang.xhttp2.XHttpSDK;
|
||||
import com.xuexiang.xhttp2.callback.SimpleCallBack;
|
||||
import com.xuexiang.xhttp2.exception.ApiException;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
|
@ -54,6 +59,12 @@ public class MainFragment extends Fragment implements View.OnClickListener {
|
|||
SharedPreferences preferences;//设置预算
|
||||
private Context mContext;
|
||||
|
||||
float incomeOneDay=0;
|
||||
|
||||
float outcomeOneDay=0;
|
||||
|
||||
float incomeOneMonth=0;
|
||||
float outcomeOneMonth=0;
|
||||
@Override
|
||||
public void onAttach(@NonNull Context context) {
|
||||
super.onAttach(context);
|
||||
|
@ -187,32 +198,169 @@ public class MainFragment extends Fragment implements View.OnClickListener {
|
|||
/* 设置头布局当中文本内容的显示*/
|
||||
private void setTopTvShow() {
|
||||
//获取今日支出和收入总金额,显示在view当中
|
||||
float incomeOneDay = DBManager.getSumMoneyOneDay(year, month, day, 1);
|
||||
float outcomeOneDay = DBManager.getSumMoneyOneDay(year, month, day, 0);
|
||||
String infoOneDay = "今日支出 ¥"+outcomeOneDay+" 收入 ¥"+incomeOneDay;
|
||||
topConTv.setText(infoOneDay);
|
||||
// 获取本月收入和支出总金额
|
||||
float incomeOneMonth = DBManager.getSumMoneyOneMonth(year, month, 1);
|
||||
float outcomeOneMonth = DBManager.getSumMoneyOneMonth(year, month, 0);
|
||||
topInTv.setText("¥"+incomeOneMonth);
|
||||
topOutTv.setText("¥"+outcomeOneMonth);
|
||||
XHttpSDK.setSuccessCode(200);
|
||||
Context context = getContext();
|
||||
SharedPreferences sharedPreferences = context.getSharedPreferences("myPrefs", Context.MODE_PRIVATE);
|
||||
String token = sharedPreferences.getString("token", "");
|
||||
XHttp.get("/app/Category/getSumMoneyOneDay")
|
||||
.headers("Authorization", "Bearer " + token)
|
||||
.params("year",year)
|
||||
.params("month",month)
|
||||
.params("day",day)
|
||||
.params("kind",1)
|
||||
.syncRequest(false) //异步请求
|
||||
.onMainThread(true) //回到主线程
|
||||
.execute(new SimpleCallBack<Float>() {
|
||||
@Override
|
||||
public void onSuccess(Float response) throws Throwable {
|
||||
incomeOneDay=response;
|
||||
updateTopTvShow();
|
||||
Log.e("YourClass", "getDemoNewInfos success, response: " + response.toString());
|
||||
}
|
||||
|
||||
// 设置显示运算剩余
|
||||
float bmoney = preferences.getFloat("bmoney", 0);//预算
|
||||
if (bmoney == 0) {
|
||||
topbudgetTv.setText("¥ 0");
|
||||
}else{
|
||||
float syMoney = bmoney-outcomeOneMonth;
|
||||
topbudgetTv.setText("¥"+syMoney);
|
||||
}
|
||||
@Override
|
||||
public void onError(ApiException e) {
|
||||
e.printStackTrace();
|
||||
Log.e("YourClass", "getDemoNewInfos error: " + e.getMessage());
|
||||
}
|
||||
});
|
||||
//获取今日支出和收入总金额,显示在view当中
|
||||
XHttpSDK.setSuccessCode(200);
|
||||
XHttp.get("/app/Category/getSumMoneyOneDay")
|
||||
.headers("Authorization", "Bearer " + token)
|
||||
.params("year",year)
|
||||
.params("month",month)
|
||||
.params("day",day)
|
||||
.params("kind",0)
|
||||
.syncRequest(false) //异步请求
|
||||
.onMainThread(true) //回到主线程
|
||||
.execute(new SimpleCallBack<Float>() {
|
||||
@Override
|
||||
public void onSuccess(Float response) throws Throwable {
|
||||
outcomeOneDay=response;
|
||||
updateTopTvShow();
|
||||
Log.e("YourClass", "getSumMoneyOneDay outcomeOneDay success, response: " + response.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(ApiException e) {
|
||||
e.printStackTrace();
|
||||
Log.e("YourClass", "getDemoNewInfos error: " + e.getMessage());
|
||||
}
|
||||
});
|
||||
// float incomeOneDay = DBManager.getSumMoneyOneDay(year, month, day, 1);
|
||||
// float outcomeOneDay = DBManager.getSumMoneyOneDay(year, month, day, 0);
|
||||
// String infoOneDay = "今日支出 ¥"+outcomeOneDay+" 收入 ¥"+incomeOneDay;
|
||||
// topConTv.setText(infoOneDay);
|
||||
// 获取本月收入和支出总金额
|
||||
// float incomeOneMonth = DBManager.getSumMoneyOneMonth(year, month, 1);
|
||||
// float outcomeOneMonth = DBManager.getSumMoneyOneMonth(year, month, 0);
|
||||
XHttpSDK.setSuccessCode(200);
|
||||
XHttp.get("/app/Category/getSumMoneyOneDay")
|
||||
.headers("Authorization", "Bearer " + token)
|
||||
.params("year",year)
|
||||
.params("month",month)
|
||||
.params("kind",1)
|
||||
.syncRequest(false) //异步请求
|
||||
.onMainThread(true) //回到主线程
|
||||
.execute(new SimpleCallBack<Float>() {
|
||||
@Override
|
||||
public void onSuccess(Float response) throws Throwable {
|
||||
incomeOneMonth=response;
|
||||
updateTopTvShow();
|
||||
Log.e("YourClass", "getSumMoneyOneMonth outcomeOneMonth success, response: " + response.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(ApiException e) {
|
||||
e.printStackTrace();
|
||||
Log.e("YourClass", "getSumMoneyOneMonth error: " + e.getMessage());
|
||||
}
|
||||
});
|
||||
XHttpSDK.setSuccessCode(200);
|
||||
XHttp.get("/app/Category/getSumMoneyOneDay")
|
||||
.headers("Authorization", "Bearer " + token)
|
||||
.params("year",year)
|
||||
.params("month",month)
|
||||
.params("kind",0)
|
||||
.syncRequest(false) //异步请求
|
||||
.onMainThread(true) //回到主线程
|
||||
.execute(new SimpleCallBack<Float>() {
|
||||
@Override
|
||||
public void onSuccess(Float response) throws Throwable {
|
||||
outcomeOneMonth=response;
|
||||
updateTopTvShow();
|
||||
Log.e("YourClass", "getSumMoneyOneMonth outcomeOneMonth success, response: " + response.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(ApiException e) {
|
||||
e.printStackTrace();
|
||||
Log.e("YourClass", "getSumMoneyOneMonth error: " + e.getMessage());
|
||||
}
|
||||
});
|
||||
// topInTv.setText("¥"+incomeOneMonth);
|
||||
// topOutTv.setText("¥"+outcomeOneMonth);
|
||||
// accountAdapter.notifyDataSetChanged();
|
||||
//// 设置显示运算剩余
|
||||
// float bmoney = preferences.getFloat("bmoney", 0);//预算
|
||||
// if (bmoney == 0) {
|
||||
// topbudgetTv.setText("¥ 0");
|
||||
// }else{
|
||||
// float syMoney = bmoney-outcomeOneMonth;
|
||||
// topbudgetTv.setText("¥"+syMoney);
|
||||
// }
|
||||
}
|
||||
|
||||
private void updateTopTvShow() {
|
||||
// 更新UI
|
||||
String infoOneDay = "今日支出 ¥" + outcomeOneDay + " 收入 ¥" + incomeOneDay;
|
||||
topConTv.setText(infoOneDay);
|
||||
topInTv.setText("¥" + incomeOneMonth);
|
||||
topOutTv.setText("¥" + outcomeOneMonth);
|
||||
accountAdapter.notifyDataSetChanged();
|
||||
|
||||
// 设置显示运算剩余
|
||||
float bmoney = preferences.getFloat("bmoney", 0); // 预算
|
||||
if (bmoney == 0) {
|
||||
topbudgetTv.setText("¥ 0");
|
||||
} else {
|
||||
float syMoney = bmoney - outcomeOneMonth;
|
||||
topbudgetTv.setText("¥" + syMoney);
|
||||
}
|
||||
}
|
||||
// 加载数据库数据
|
||||
private void LoadDBData() {
|
||||
List<AccountBean> list = DBManager.getAccountListOneDayFromAccounttb(year, month, day);
|
||||
mDatas.clear();
|
||||
mDatas.addAll(list);
|
||||
accountAdapter.notifyDataSetChanged();
|
||||
XHttpSDK.setSuccessCode(200);
|
||||
Context context = getContext();
|
||||
SharedPreferences sharedPreferences = context.getSharedPreferences("myPrefs", Context.MODE_PRIVATE);
|
||||
String token = sharedPreferences.getString("token", "");
|
||||
XHttp.get("/app/Category/list")
|
||||
.headers("Authorization", "Bearer " + token)
|
||||
.params("year",year)
|
||||
.params("month",month)
|
||||
.params("day",day)
|
||||
.syncRequest(false) //异步请求
|
||||
.onMainThread(true) //回到主线程
|
||||
.execute(new SimpleCallBack<List<AccountBean>>() {
|
||||
@Override
|
||||
public void onSuccess(List<AccountBean> response) throws Throwable {
|
||||
if (response != null && response.size() > 0) {
|
||||
mDatas.clear();
|
||||
mDatas.addAll(response);
|
||||
accountAdapter.notifyDataSetChanged();
|
||||
Log.e("YourClass", "getDemoNewInfos success, response: " + response.toString());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(ApiException e) {
|
||||
e.printStackTrace();
|
||||
Log.e("YourClass", "getDemoNewInfos error: " + e.getMessage());
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
//头布局的点击事件
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package com.example.tally.frag_record;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.inputmethodservice.KeyboardView;
|
||||
import android.os.Bundle;
|
||||
|
||||
|
@ -7,6 +9,7 @@ import androidx.annotation.Nullable;
|
|||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
@ -15,14 +18,23 @@ import android.widget.EditText;
|
|||
import android.widget.GridView;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.example.tally.R;
|
||||
import com.example.tally.XinxiActivity;
|
||||
import com.example.tally.db.AccountBean;
|
||||
import com.example.tally.db.DBManager;
|
||||
import com.example.tally.db.TypeBean;
|
||||
import com.example.tally.utils.BeiZhuDialog;
|
||||
import com.example.tally.utils.KeyBoardUtils;
|
||||
import com.example.tally.utils.SelectTimeDialog;
|
||||
import com.xuexiang.xhttp2.XHttp;
|
||||
import com.xuexiang.xhttp2.XHttpSDK;
|
||||
import com.xuexiang.xhttp2.callback.SimpleCallBack;
|
||||
import com.xuexiang.xhttp2.exception.ApiException;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
|
@ -126,6 +138,7 @@ public abstract class BaseRecordFragment extends Fragment implements View.OnClic
|
|||
}
|
||||
float money = Float.parseFloat(moneyStr);
|
||||
accountBean.setMoney(money);
|
||||
|
||||
//获取记录的信息,保存在数据库当中
|
||||
saveAccountToDB();
|
||||
// 返回上一级页面
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
package com.example.tally.frag_record;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
@ -11,6 +14,13 @@ import android.view.ViewGroup;
|
|||
import com.example.tally.R;
|
||||
import com.example.tally.db.DBManager;
|
||||
import com.example.tally.db.TypeBean;
|
||||
import com.xuexiang.xhttp2.XHttp;
|
||||
import com.xuexiang.xhttp2.XHttpSDK;
|
||||
import com.xuexiang.xhttp2.callback.SimpleCallBack;
|
||||
import com.xuexiang.xhttp2.exception.ApiException;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -32,6 +42,42 @@ public class IncomeFragment extends BaseRecordFragment {
|
|||
@Override
|
||||
public void saveAccountToDB() {
|
||||
accountBean.setKind(1);
|
||||
DBManager.insertItemToAccounttb(accountBean);
|
||||
JSONObject requestBody = new JSONObject();
|
||||
try {
|
||||
requestBody.put("typename", accountBean.getTypename());
|
||||
requestBody.put("money", accountBean.getMoney());
|
||||
requestBody.put("kind", accountBean.getKind());
|
||||
requestBody.put("beizhu", accountBean.getBeizhu());
|
||||
requestBody.put("time", accountBean.getTime());
|
||||
requestBody.put("year", accountBean.getYear());
|
||||
requestBody.put("month", accountBean.getMonth());
|
||||
requestBody.put("day", accountBean.getDay());
|
||||
requestBody.put("sImageId", accountBean.getsImageId());
|
||||
} catch (JSONException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
Context context = getContext();
|
||||
SharedPreferences sharedPreferences = context.getSharedPreferences("myPrefs", Context.MODE_PRIVATE);
|
||||
String token = sharedPreferences.getString("token", "");
|
||||
String requestBodyString = requestBody.toString();
|
||||
XHttpSDK.setSuccessCode(200);
|
||||
XHttp.post("/app/Category")
|
||||
.headers("Authorization", "Bearer " + token)
|
||||
.upJson(requestBodyString)
|
||||
.execute(new SimpleCallBack<Integer>() {
|
||||
@Override
|
||||
public void onSuccess(Integer result){
|
||||
if (result > 0) {
|
||||
Log.e("TAG", "添加成功:"+result );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(ApiException e) {
|
||||
Log.e("TAG", "添加失败:" + e.getMessage() + ", Code: " + e.getCode() );
|
||||
|
||||
}
|
||||
});
|
||||
// DBManager.insertItemToAccounttb(accountBean);
|
||||
}
|
||||
}
|
|
@ -1,9 +1,12 @@
|
|||
package com.example.tally.frag_record;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
@ -11,6 +14,13 @@ import android.view.ViewGroup;
|
|||
import com.example.tally.R;
|
||||
import com.example.tally.db.DBManager;
|
||||
import com.example.tally.db.TypeBean;
|
||||
import com.xuexiang.xhttp2.XHttp;
|
||||
import com.xuexiang.xhttp2.XHttpSDK;
|
||||
import com.xuexiang.xhttp2.callback.SimpleCallBack;
|
||||
import com.xuexiang.xhttp2.exception.ApiException;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -33,7 +43,43 @@ public class OutcomeFragment extends BaseRecordFragment{
|
|||
@Override
|
||||
public void saveAccountToDB() {
|
||||
accountBean.setKind(0);
|
||||
DBManager.insertItemToAccounttb(accountBean);
|
||||
JSONObject requestBody = new JSONObject();
|
||||
try {
|
||||
requestBody.put("typename", accountBean.getTypename());
|
||||
requestBody.put("money", accountBean.getMoney());
|
||||
requestBody.put("kind", accountBean.getKind());
|
||||
requestBody.put("beizhu", accountBean.getBeizhu());
|
||||
requestBody.put("time", accountBean.getTime());
|
||||
requestBody.put("year", accountBean.getYear());
|
||||
requestBody.put("month", accountBean.getMonth());
|
||||
requestBody.put("day", accountBean.getDay());
|
||||
requestBody.put("sImageId", accountBean.getsImageId());
|
||||
} catch (JSONException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
Context context = getContext();
|
||||
SharedPreferences sharedPreferences = context.getSharedPreferences("myPrefs", Context.MODE_PRIVATE);
|
||||
String token = sharedPreferences.getString("token", "");
|
||||
String requestBodyString = requestBody.toString();
|
||||
XHttpSDK.setSuccessCode(200);
|
||||
XHttp.post("/app/Category")
|
||||
.headers("Authorization", "Bearer " + token)
|
||||
.upJson(requestBodyString)
|
||||
.execute(new SimpleCallBack<Integer>() {
|
||||
@Override
|
||||
public void onSuccess(Integer result){
|
||||
if (result > 0) {
|
||||
Log.e("TAG", "添加成功:"+result );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(ApiException e) {
|
||||
Log.e("TAG", "添加失败:" + e.getMessage() + ", Code: " + e.getCode() );
|
||||
|
||||
}
|
||||
});
|
||||
// DBManager.insertItemToAccounttb(accountBean);
|
||||
}
|
||||
|
||||
}
|
|
@ -14,6 +14,10 @@ dependencyResolutionManagement {
|
|||
google()
|
||||
mavenCentral()
|
||||
}
|
||||
repositories {
|
||||
// JitPack 远程仓库:https://jitpack.io
|
||||
maven { url 'https://jitpack.io' }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue