|
@@ -6,21 +6,25 @@ import com.yonge.cooleshow.biz.dal.dto.excel.UserWithdrawalExport;
|
|
import com.yonge.cooleshow.biz.dal.support.PageUtil;
|
|
import com.yonge.cooleshow.biz.dal.support.PageUtil;
|
|
import com.yonge.cooleshow.common.controller.BaseController;
|
|
import com.yonge.cooleshow.common.controller.BaseController;
|
|
import com.yonge.cooleshow.common.entity.HttpResponseResult;
|
|
import com.yonge.cooleshow.common.entity.HttpResponseResult;
|
|
|
|
+import com.yonge.cooleshow.common.exception.BizException;
|
|
import com.yonge.cooleshow.common.page.PageInfo;
|
|
import com.yonge.cooleshow.common.page.PageInfo;
|
|
-import com.yonge.toolset.utils.easyexcel.ExcelUtils;
|
|
|
|
|
|
+import com.yonge.toolset.utils.easyexcel.*;
|
|
|
|
+import com.yonge.toolset.utils.string.StringUtil;
|
|
import io.swagger.annotations.*;
|
|
import io.swagger.annotations.*;
|
|
import org.apache.commons.beanutils.BeanUtils;
|
|
import org.apache.commons.beanutils.BeanUtils;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+import org.springframework.http.HttpStatus;
|
|
|
|
+import org.springframework.util.CollectionUtils;
|
|
import org.springframework.util.DigestUtils;
|
|
import org.springframework.util.DigestUtils;
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import com.yonge.cooleshow.biz.dal.vo.UserWithdrawalVo;
|
|
import com.yonge.cooleshow.biz.dal.vo.UserWithdrawalVo;
|
|
import com.yonge.cooleshow.biz.dal.dto.search.TeacherWithdrawalSearch;
|
|
import com.yonge.cooleshow.biz.dal.dto.search.TeacherWithdrawalSearch;
|
|
import com.yonge.cooleshow.biz.dal.service.UserWithdrawalService;
|
|
import com.yonge.cooleshow.biz.dal.service.UserWithdrawalService;
|
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import java.lang.reflect.InvocationTargetException;
|
|
import java.lang.reflect.InvocationTargetException;
|
|
-import java.util.ArrayList;
|
|
|
|
-import java.util.List;
|
|
|
|
|
|
+import java.util.*;
|
|
|
|
|
|
@RestController
|
|
@RestController
|
|
@RequestMapping("/userWithdrawal")
|
|
@RequestMapping("/userWithdrawal")
|
|
@@ -30,24 +34,24 @@ public class UserWithdrawalController extends BaseController {
|
|
@Autowired
|
|
@Autowired
|
|
private UserWithdrawalService userWithdrawalService;
|
|
private UserWithdrawalService userWithdrawalService;
|
|
|
|
|
|
- /**
|
|
|
|
|
|
+ /**
|
|
* 查询单条
|
|
* 查询单条
|
|
*/
|
|
*/
|
|
@GetMapping("/detail/{id}")
|
|
@GetMapping("/detail/{id}")
|
|
@ApiOperation(value = "详情", notes = "传入id")
|
|
@ApiOperation(value = "详情", notes = "传入id")
|
|
public HttpResponseResult<UserWithdrawalVo> detail(@PathVariable("id") Long id) {
|
|
public HttpResponseResult<UserWithdrawalVo> detail(@PathVariable("id") Long id) {
|
|
- return succeed(userWithdrawalService.detail(id));
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
|
|
+ return succeed(userWithdrawalService.detail(id));
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 查询分页
|
|
* 查询分页
|
|
*/
|
|
*/
|
|
@PostMapping("/page")
|
|
@PostMapping("/page")
|
|
@ApiOperation(value = "查询分页", notes = "传入teacherWithdrawalSearch")
|
|
@ApiOperation(value = "查询分页", notes = "传入teacherWithdrawalSearch")
|
|
public HttpResponseResult<PageInfo<UserWithdrawalVo>> page(@RequestBody TeacherWithdrawalSearch query) {
|
|
public HttpResponseResult<PageInfo<UserWithdrawalVo>> page(@RequestBody TeacherWithdrawalSearch query) {
|
|
- IPage<UserWithdrawalVo> pages = userWithdrawalService.selectPage(PageUtil.getPage(query), query);
|
|
|
|
|
|
+ IPage<UserWithdrawalVo> pages = userWithdrawalService.selectPage(PageUtil.getPage(query), query);
|
|
return succeed(PageUtil.pageInfo(pages));
|
|
return succeed(PageUtil.pageInfo(pages));
|
|
- }
|
|
|
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
/**
|
|
* 查询导出
|
|
* 查询导出
|
|
@@ -57,11 +61,12 @@ public class UserWithdrawalController extends BaseController {
|
|
public void exportExcel(@RequestBody TeacherWithdrawalSearch query) {
|
|
public void exportExcel(@RequestBody TeacherWithdrawalSearch query) {
|
|
List<UserWithdrawalVo> withdrawalVoList = userWithdrawalService.selectList(query);
|
|
List<UserWithdrawalVo> withdrawalVoList = userWithdrawalService.selectList(query);
|
|
List<UserWithdrawalExport> list = new ArrayList<>();
|
|
List<UserWithdrawalExport> list = new ArrayList<>();
|
|
- withdrawalVoList.forEach(o-> {
|
|
|
|
|
|
+ withdrawalVoList.forEach(o -> {
|
|
UserWithdrawalExport export = new UserWithdrawalExport();
|
|
UserWithdrawalExport export = new UserWithdrawalExport();
|
|
try {
|
|
try {
|
|
- BeanUtils.copyProperties(export,o);
|
|
|
|
|
|
+ BeanUtils.copyProperties(export, o);
|
|
StringBuffer buffer = new StringBuffer(export.getId().toString());
|
|
StringBuffer buffer = new StringBuffer(export.getId().toString());
|
|
|
|
+ buffer.append(export.getUserId());
|
|
buffer.append(export.getAmount());
|
|
buffer.append(export.getAmount());
|
|
buffer.append(export.getActualAmount());
|
|
buffer.append(export.getActualAmount());
|
|
String s = DigestUtils.md5DigestAsHex(buffer.toString().getBytes());
|
|
String s = DigestUtils.md5DigestAsHex(buffer.toString().getBytes());
|
|
@@ -77,35 +82,23 @@ public class UserWithdrawalController extends BaseController {
|
|
"列表数据");
|
|
"列表数据");
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
/**
|
|
/**
|
|
- * 查询导出
|
|
|
|
|
|
+ * 导入
|
|
*/
|
|
*/
|
|
@PostMapping("/importExcel")
|
|
@PostMapping("/importExcel")
|
|
- @ApiOperation(value = "查询导出", notes = "传入TeacherWithdrawalSearch")
|
|
|
|
- public void importExcel(@RequestBody TeacherWithdrawalSearch query) {
|
|
|
|
- List<UserWithdrawalVo> withdrawalVoList = userWithdrawalService.selectList(query);
|
|
|
|
- List<UserWithdrawalExport> list = new ArrayList<>();
|
|
|
|
- withdrawalVoList.forEach(o-> {
|
|
|
|
- UserWithdrawalExport export = new UserWithdrawalExport();
|
|
|
|
- try {
|
|
|
|
- BeanUtils.copyProperties(export,o);
|
|
|
|
- StringBuffer buffer = new StringBuffer(export.getId().toString());
|
|
|
|
- buffer.append(export.getAmount());
|
|
|
|
- buffer.append(export.getActualAmount());
|
|
|
|
- String s = DigestUtils.md5DigestAsHex(buffer.toString().getBytes());
|
|
|
|
- export.setSign(s);
|
|
|
|
- list.add(export);
|
|
|
|
- } catch (IllegalAccessException e) {
|
|
|
|
- e.printStackTrace();
|
|
|
|
- } catch (InvocationTargetException e) {
|
|
|
|
- e.printStackTrace();
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
- ExcelUtils.exportExcel(list, "提现列表数据" + System.currentTimeMillis(),
|
|
|
|
- "列表数据");
|
|
|
|
|
|
+ @ApiOperation(value = "导入", notes = "传入file")
|
|
|
|
+ public HttpResponseResult<List<ErrMsg>> importExcel(@RequestParam("file") MultipartFile file) {
|
|
|
|
+ if (null == file) {
|
|
|
|
+ return HttpResponseResult.failed("请上传文件");
|
|
|
|
+ }
|
|
|
|
+ ExcelDataReader<UserWithdrawalExport> reader = ExcelUtils.getReader(UserWithdrawalExport.class, file);
|
|
|
|
+ try {
|
|
|
|
+ userWithdrawalService.importExcel(reader.getDataList());
|
|
|
|
+ return HttpResponseResult.succeed();
|
|
|
|
+ }catch (ExcelException e){
|
|
|
|
+ return HttpResponseResult.failed(HttpStatus.INTERNAL_SERVER_ERROR,e.getErrMsgList(),"导入文件异常");
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
|
|
|
|
}
|
|
}
|