|
@@ -0,0 +1,91 @@
|
|
|
+package com.yonge.cooleshow.teacher.controller;
|
|
|
+
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import com.yonge.cooleshow.auth.api.client.SysUserFeignService;
|
|
|
+import com.yonge.cooleshow.auth.api.entity.SysUser;
|
|
|
+import com.yonge.cooleshow.biz.dal.dto.req.TotalReq;
|
|
|
+import com.yonge.cooleshow.biz.dal.dto.search.UserAccountRecordSearch;
|
|
|
+import com.yonge.cooleshow.biz.dal.enums.InOrOutEnum;
|
|
|
+import com.yonge.cooleshow.biz.dal.service.UserAccountRecordService;
|
|
|
+import com.yonge.cooleshow.biz.dal.service.UserAccountService;
|
|
|
+import com.yonge.cooleshow.biz.dal.support.PageUtil;
|
|
|
+import com.yonge.cooleshow.biz.dal.vo.UserAccountRecordVo;
|
|
|
+import com.yonge.cooleshow.biz.dal.vo.UserAccountVo;
|
|
|
+import com.yonge.cooleshow.biz.dal.vo.res.AccountTotal;
|
|
|
+import com.yonge.cooleshow.biz.dal.vo.res.HomeTotalTeacher;
|
|
|
+import com.yonge.cooleshow.common.controller.BaseController;
|
|
|
+import com.yonge.cooleshow.common.entity.HttpResponseResult;
|
|
|
+import com.yonge.cooleshow.common.exception.BizException;
|
|
|
+import com.yonge.cooleshow.common.page.PageInfo;
|
|
|
+import com.yonge.toolset.utils.date.DateUtil;
|
|
|
+import com.yonge.toolset.utils.string.StringUtil;
|
|
|
+import io.swagger.annotations.Api;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.http.HttpStatus;
|
|
|
+import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+
|
|
|
+import javax.validation.Valid;
|
|
|
+import java.util.Calendar;
|
|
|
+import java.util.Date;
|
|
|
+
|
|
|
+@RestController
|
|
|
+@RequestMapping("/userAccount")
|
|
|
+@Api(value = "用户账户表", tags = "用户账户表")
|
|
|
+public class UserAccountController extends BaseController {
|
|
|
+ @Autowired
|
|
|
+ private UserAccountService userAccountService;
|
|
|
+ @Autowired
|
|
|
+ private UserAccountRecordService userAccountRecordService;
|
|
|
+ @Autowired
|
|
|
+ private SysUserFeignService sysUserFeignService;
|
|
|
+ /**
|
|
|
+ * 查询单条
|
|
|
+ */
|
|
|
+ @GetMapping("/detail/{id}")
|
|
|
+ @ApiOperation(value = "详情", notes = "传入id")
|
|
|
+ public HttpResponseResult<UserAccountVo> detail() {
|
|
|
+ SysUser user = sysUserFeignService.queryUserInfo();
|
|
|
+ if (user == null || null == user.getId()) {
|
|
|
+ return failed(HttpStatus.FORBIDDEN, "请登录");
|
|
|
+ }
|
|
|
+ return succeed(userAccountService.detail(user.getId()));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询分页
|
|
|
+ */
|
|
|
+ @PostMapping("/page")
|
|
|
+ @ApiOperation(value = "查询分页", notes = "传入userAccountRecordSearch")
|
|
|
+ public HttpResponseResult<PageInfo<UserAccountRecordVo>> page(@RequestBody UserAccountRecordSearch query) {
|
|
|
+ SysUser user = sysUserFeignService.queryUserInfo();
|
|
|
+ if (user == null || null == user.getId()) {
|
|
|
+ return failed(HttpStatus.FORBIDDEN, "请登录");
|
|
|
+ }
|
|
|
+ query.setUserId(user.getId());
|
|
|
+ query.setInOrOut(InOrOutEnum.IN);
|
|
|
+ if (StringUtil.isEmpty(query.getSearchDate())) {
|
|
|
+ query.setSearchDate(DateUtil.format(new Date(), "yyyy-MM"));
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ Calendar calendar = Calendar.getInstance();
|
|
|
+ String[] classDateSp = query.getSearchDate().split("-");
|
|
|
+ calendar.set(Integer.parseInt(classDateSp[0]), Integer.parseInt(classDateSp[1]), 1, 0, 0, 0);
|
|
|
+ query.setStartTime(calendar.getTime());
|
|
|
+ query.setEndTime(DateUtil.dayEnd(DateUtil.getLastDayOfMonth(calendar.getTime())));
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new BizException("查询时间格式不正确 [" + query.getSearchDate() + "]");
|
|
|
+ }
|
|
|
+ IPage<UserAccountRecordVo> pages = userAccountRecordService.selectPage(PageUtil.getPage(query), query);
|
|
|
+ return succeed(PageUtil.pageInfo(pages));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @ApiOperation(value = "收入数据统计")
|
|
|
+ @PostMapping("/accountTotal")
|
|
|
+ public HttpResponseResult<AccountTotal> accountTotal(@Valid @RequestBody TotalReq totalReq) {
|
|
|
+ return userAccountService.accountTotal(totalReq);
|
|
|
+ }
|
|
|
+
|
|
|
+}
|