Merge remote-tracking branch 'origin/master'
| | |
| | | package com.panzhihua.applets_backstage.api; |
| | | |
| | | import com.alibaba.excel.EasyExcel; |
| | | import com.alibaba.excel.ExcelWriter; |
| | | import com.alibaba.excel.write.metadata.WriteSheet; |
| | | import com.alibaba.excel.write.style.column.LongestMatchColumnWidthStyleStrategy; |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.panzhihua.common.controller.BaseController; |
| | | import com.panzhihua.common.model.dtos.shop.PageComShopGoodsDTO; |
| | | import com.panzhihua.common.model.dtos.shop.PageComShopStoreDTO; |
| | | import com.panzhihua.common.excel.CustomSheetWriteHandler; |
| | | import com.panzhihua.common.interfaces.ShopOperLog; |
| | | import com.panzhihua.common.model.dtos.shop.*; |
| | | import com.panzhihua.common.model.vos.LoginUserInfoVO; |
| | | import com.panzhihua.common.model.vos.R; |
| | | import com.panzhihua.common.model.vos.shop.AddShopGoodsVO; |
| | | import com.panzhihua.common.model.vos.shop.PageShopStoreVO; |
| | | import com.panzhihua.common.model.vos.shop.ShopStoreVO; |
| | | import com.panzhihua.common.model.vos.shop.*; |
| | | import com.panzhihua.common.model.vos.user.AdministratorsUserVO; |
| | | import com.panzhihua.common.model.vos.user.ChangePasswordVO; |
| | | import com.panzhihua.common.model.vos.user.SysUserVO; |
| | | import com.panzhihua.common.service.community.CommunityService; |
| | | import com.panzhihua.common.service.user.UserService; |
| | | import com.panzhihua.common.utlis.ClazzUtils; |
| | | import com.panzhihua.common.utlis.SFTPUtil; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.validation.Valid; |
| | | import java.io.File; |
| | | import java.io.FileInputStream; |
| | | import java.io.InputStream; |
| | | import java.net.URLEncoder; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.UUID; |
| | | |
| | | /** |
| | | * @auther llming |
| | |
| | | @Api(tags = {"商城管理模块"}) |
| | | @RestController("/shop") |
| | | public class ShopApi extends BaseController { |
| | | @Value("${excel.userurl}") |
| | | private String excelUrl; |
| | | // FTP 登录用户名 |
| | | @Value("${ftp.username}") |
| | | private String userName; |
| | | // FTP 登录密码 |
| | | @Value("${ftp.password}") |
| | | private String password; |
| | | // FTP 服务器地址IP地址 |
| | | @Value("${ftp.host}") |
| | | private String host; |
| | | // FTP 端口 |
| | | @Value("${ftp.port}") |
| | | private int port; |
| | | @Resource |
| | | private CommunityService communityService; |
| | | @Resource |
| | |
| | | } |
| | | |
| | | |
| | | @ApiOperation(value = "分页查询商品", response = PageShopStoreVO.class) |
| | | @ApiOperation(value = "分页查询商品", response = PageShopGoodsVO.class) |
| | | @PostMapping("/goods/page") |
| | | public R pageGoodsList(@RequestBody PageComShopGoodsDTO pageComShopGoodsDTO) { |
| | | return communityService.pageGoodsList(pageComShopGoodsDTO); |
| | |
| | | } |
| | | |
| | | @ApiOperation(value = "商品上下架") |
| | | @ApiImplicitParams({@ApiImplicitParam(value = "id",name = "商品Id"), |
| | | @ApiImplicitParam(value = "status",name = "1.上架 2.下架 ")}) |
| | | @ApiImplicitParams({@ApiImplicitParam(name = "id",value = "商品Id"), |
| | | @ApiImplicitParam(name = "status",value = "1.上架 2.下架 ")}) |
| | | @GetMapping("/goods/changeStatus") |
| | | R changeStatus(@RequestParam("id") Long id,@RequestParam("status")Integer status) { |
| | | return communityService.changeStatus(id,status); |
| | | } |
| | | |
| | | @ApiOperation(value = "订单_分页列表",response = ComShopOrderSearchVO.class) |
| | | @PostMapping("/order/page") |
| | | public R page(@RequestBody @Validated PageComShopOrderSearchDTO pageComShopOrderSearchDTO){ |
| | | pageComShopOrderSearchDTO.setUserId(this.getUserId()); |
| | | ClazzUtils.setIfStringIsEmpty(pageComShopOrderSearchDTO); |
| | | return communityService.pageShopOrder(pageComShopOrderSearchDTO); |
| | | } |
| | | |
| | | |
| | | @ApiOperation(value = "订单_详细",response = ComShopOrderPageVO.class) |
| | | @GetMapping("/order/detail") |
| | | @ShopOperLog(operType = 11) |
| | | public R detail(@RequestParam("orderId") Long orderId){ |
| | | return communityService.orderDetail(orderId); |
| | | } |
| | | |
| | | @ApiOperation(value = "订单_导出表格") |
| | | @PostMapping("/order/export") |
| | | @ShopOperLog(operType = 12) |
| | | public R export(@RequestBody ComShopOrderExportDTO comShopOrderExportDTO){ |
| | | ClazzUtils.setIfStringIsEmpty(comShopOrderExportDTO); |
| | | String url=excelUrl; |
| | | String uuid= UUID.randomUUID().toString().replace("-",""); |
| | | //String name=uuid+".xlsx"; |
| | | String ftpUrl="/mnt/data/web/excel/"; |
| | | |
| | | R<ShopStoreVO> storeR = communityService.getUserStoreInfo(getUserId()); |
| | | |
| | | if(!R.isOk(storeR)){ |
| | | return R.fail("用户不是商家"); |
| | | } |
| | | |
| | | ShopStoreVO shopStoreVO = JSONObject.parseObject(JSONObject.toJSONString(storeR.getData()),ShopStoreVO.class); |
| | | Long userId = this.getUserId(); |
| | | comShopOrderExportDTO.setUserId(userId); |
| | | R r=communityService.shopOrderExportData(comShopOrderExportDTO); |
| | | if (R.isOk(r)) { |
| | | List<ExcelShopOrderDTO> excelShopOrderDTO = JSONArray.parseArray(JSONArray.toJSONString(r.getData()),ExcelShopOrderDTO.class); |
| | | if(excelShopOrderDTO==null||excelShopOrderDTO.size()==0){ |
| | | return R.ok("未找到数据"); |
| | | } |
| | | try { |
| | | SFTPUtil sftp = new SFTPUtil(userName,password,host,port); |
| | | sftp.login(); |
| | | String name = shopStoreVO.getName() +"商城订单-" + new SimpleDateFormat("yyyyMMddhhmmss").format(new Date()) + ".xlsx"; |
| | | boolean existDir = sftp.isExistDir(ftpUrl+name); |
| | | if (!existDir) { |
| | | String property = System.getProperty("user.dir"); |
| | | String fileName = property + File.separator+name; |
| | | // 这里 需要指定写用哪个class去写 |
| | | ExcelWriter excelWriter = null; |
| | | InputStream inputStream=null; |
| | | try { |
| | | excelWriter = EasyExcel.write(fileName, ExcelShopOrderDTO.class).registerWriteHandler(new LongestMatchColumnWidthStyleStrategy()).registerWriteHandler(new CustomSheetWriteHandler()).build(); |
| | | WriteSheet writeSheet = EasyExcel.writerSheet(shopStoreVO.getName()+"订单").build(); |
| | | excelWriter.write(excelShopOrderDTO, writeSheet); |
| | | excelWriter.finish(); |
| | | File file=new File(fileName); |
| | | inputStream=new FileInputStream(file); |
| | | sftp.uploadMore(ftpUrl, name, inputStream); |
| | | sftp.logout(); |
| | | inputStream.close(); |
| | | String absolutePath = file.getAbsolutePath(); |
| | | boolean delete = file.delete(); |
| | | log.info("删除excel【{}】结果【{}】",absolutePath,delete); |
| | | } finally { |
| | | // 千万别忘记finish 会帮忙关闭流 |
| | | if (inputStream != null) { |
| | | inputStream.close(); |
| | | } |
| | | if (excelWriter != null) { |
| | | excelWriter.finish(); |
| | | } |
| | | } |
| | | } |
| | | return R.ok(url+ URLEncoder.encode(name,"UTF-8")); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | log.error("文件传输失败【{}】", e.getMessage()); |
| | | return R.fail(); |
| | | } |
| | | } |
| | | return R.fail("导出数据失败"); |
| | | } |
| | | |
| | | @ApiOperation(value = "资金_统计信息") |
| | | @GetMapping("/capital/stat") |
| | | public R stat(){ |
| | | return communityService.getFundsStat(getUserId()); |
| | | } |
| | | |
| | | @ApiOperation(value = "资金_分页列表") |
| | | @PostMapping("/capital/page") |
| | | public R page(@RequestBody PageComShopFundsSearchDTO pageComShopFundsSearchDTO){ |
| | | pageComShopFundsSearchDTO.setUserId(getUserId()); |
| | | ClazzUtils.setIfStringIsEmpty(pageComShopFundsSearchDTO); |
| | | return communityService.pageShopFunds(pageComShopFundsSearchDTO); |
| | | } |
| | | |
| | | @ApiOperation(value = "资金_详情",response = CapitalDetailVO.class) |
| | | @ApiImplicitParam(name = "orderId",value = "订单Id") |
| | | @GetMapping("/capital/capitalDetailByStore") |
| | | R capitalDetailByStore(@RequestParam("orderId") Long orderId){ |
| | | return communityService.capitalDetailByStore(orderId); |
| | | } |
| | | |
| | | |
| | | @ApiOperation(value = "资金_导出表格") |
| | | @PostMapping("/capital/export") |
| | | @ShopOperLog(operType = 12) |
| | | public R export(@RequestBody ComShopFundsExportDTO comShopFundsExportDTO){ |
| | | ClazzUtils.setIfStringIsEmpty(comShopFundsExportDTO); |
| | | String url=excelUrl; |
| | | String uuid= UUID.randomUUID().toString().replace("-",""); |
| | | //String name=uuid+".xlsx"; |
| | | String ftpUrl="/mnt/data/web/excel/"; |
| | | |
| | | R<ShopStoreVO> storeR = communityService.getUserStoreInfo(getUserId()); |
| | | |
| | | if(!R.isOk(storeR)){ |
| | | return R.fail("用户不是商家"); |
| | | } |
| | | |
| | | ShopStoreVO shopStoreVO = JSONObject.parseObject(JSONObject.toJSONString(storeR.getData()),ShopStoreVO.class); |
| | | Long userId = this.getUserId(); |
| | | comShopFundsExportDTO.setUserId(userId); |
| | | R r=communityService.shopOrderFundsExportData(comShopFundsExportDTO); |
| | | if (R.isOk(r)) { |
| | | List<ExcelShopFundsDTO> excelShopFundsDTO = JSONArray.parseArray(JSONArray.toJSONString(r.getData()),ExcelShopFundsDTO.class); |
| | | if(excelShopFundsDTO==null||excelShopFundsDTO.size()==0){ |
| | | return R.ok("未找到数据"); |
| | | } |
| | | try { |
| | | SFTPUtil sftp = new SFTPUtil(userName,password,host,port); |
| | | sftp.login(); |
| | | String name = shopStoreVO.getName() +"-商家资金流水-" + new SimpleDateFormat("yyyyMMddhhmmss").format(new Date()) + ".xlsx"; |
| | | boolean existDir = sftp.isExistDir(ftpUrl+name); |
| | | if (!existDir) { |
| | | String property = System.getProperty("user.dir"); |
| | | String fileName = property + File.separator+name; |
| | | // 这里 需要指定写用哪个class去写 |
| | | ExcelWriter excelWriter = null; |
| | | InputStream inputStream=null; |
| | | try { |
| | | excelWriter = EasyExcel.write(fileName, ExcelShopFundsDTO.class).registerWriteHandler(new LongestMatchColumnWidthStyleStrategy()).registerWriteHandler(new CustomSheetWriteHandler()).build(); |
| | | WriteSheet writeSheet = EasyExcel.writerSheet(shopStoreVO.getName()+"订单").build(); |
| | | excelWriter.write(excelShopFundsDTO, writeSheet); |
| | | excelWriter.finish(); |
| | | File file=new File(fileName); |
| | | inputStream=new FileInputStream(file); |
| | | sftp.uploadMore(ftpUrl, name, inputStream); |
| | | sftp.logout(); |
| | | inputStream.close(); |
| | | String absolutePath = file.getAbsolutePath(); |
| | | boolean delete = file.delete(); |
| | | log.info("删除excel【{}】结果【{}】",absolutePath,delete); |
| | | } finally { |
| | | // 千万别忘记finish 会帮忙关闭流 |
| | | if (inputStream != null) { |
| | | inputStream.close(); |
| | | } |
| | | if (excelWriter != null) { |
| | | excelWriter.finish(); |
| | | } |
| | | } |
| | | } |
| | | return R.ok(url+ URLEncoder.encode(name,"UTF-8")); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | log.error("文件传输失败【{}】", e.getMessage()); |
| | | return R.fail(); |
| | | } |
| | | } |
| | | return R.fail("导出数据失败"); |
| | | } |
| | | } |
New file |
| | |
| | | package com.panzhihua.common.excel; |
| | | |
| | | import com.alibaba.excel.write.handler.SheetWriteHandler; |
| | | import com.alibaba.excel.write.metadata.holder.WriteSheetHolder; |
| | | import com.alibaba.excel.write.metadata.holder.WriteWorkbookHolder; |
| | | import org.apache.poi.ss.usermodel.DataValidation; |
| | | import org.apache.poi.ss.usermodel.DataValidationConstraint; |
| | | import org.apache.poi.ss.usermodel.DataValidationHelper; |
| | | import org.apache.poi.ss.util.CellRangeAddressList; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | |
| | | /** |
| | | * 自定义拦截器.对第一列第一行和第二行的数据新增下拉框,显示 测试1 测试2 |
| | | * |
| | | * @author Jiaju Zhuang |
| | | */ |
| | | public class CustomSheetWriteHandler implements SheetWriteHandler { |
| | | |
| | | private static final Logger LOGGER = LoggerFactory.getLogger(CustomSheetWriteHandler.class); |
| | | |
| | | @Override |
| | | public void beforeSheetCreate(WriteWorkbookHolder writeWorkbookHolder, WriteSheetHolder writeSheetHolder) { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void afterSheetCreate(WriteWorkbookHolder writeWorkbookHolder, WriteSheetHolder writeSheetHolder) { |
| | | LOGGER.info("第{}个Sheet写入成功。", writeSheetHolder.getSheetNo()); |
| | | |
| | | // 区间设置 第一列第一行和第二行的数据。由于第一行是头,所以第一、二行的数据实际上是第二三行 |
| | | CellRangeAddressList cellRangeAddressList = new CellRangeAddressList(1, 2000, 1, 1); |
| | | CellRangeAddressList cellRangeAddressList1 = new CellRangeAddressList(1, 2000, 3 ,3); |
| | | CellRangeAddressList cellRangeAddressList2 = new CellRangeAddressList(1, 2000, 10 ,10); |
| | | DataValidationHelper helper = writeSheetHolder.getSheet().getDataValidationHelper(); |
| | | DataValidationConstraint constraint = helper.createExplicitListConstraint(new String[] {"是", "否"}); |
| | | DataValidationConstraint constraint1 = helper.createExplicitListConstraint(new String[] {"中共党员","中共预备党员","共青团员","民革党员","民盟盟员","民建会员","农工党党员","致公党党员","九三学社社员","台盟盟员","无党派人士","群众"}); |
| | | DataValidationConstraint constraint2 = helper.createExplicitListConstraint(new String[] {"男", "女","未知"}); |
| | | DataValidation dataValidation = helper.createValidation(constraint2, cellRangeAddressList); |
| | | DataValidation dataValidation1 = helper.createValidation(constraint, cellRangeAddressList1); |
| | | DataValidation dataValidation2= helper.createValidation(constraint1, cellRangeAddressList2); |
| | | |
| | | writeSheetHolder.getSheet().addValidationData(dataValidation); |
| | | writeSheetHolder.getSheet().addValidationData(dataValidation1); |
| | | writeSheetHolder.getSheet().addValidationData(dataValidation2); |
| | | } |
| | | } |
| | |
| | | private String receiverPhone; |
| | | @ApiModelProperty(value = "商品",example = "鞋") |
| | | private String goodsName; |
| | | @ApiModelProperty(value = "店铺名称",example = "小二的店") |
| | | private String storeName; |
| | | @ApiModelProperty(value = "订单状态(1.待付款 2.代发货 3.待收货 4.待评价 5.已完成 6.已取消)",example = "1") |
| | | private Integer status; |
| | | @ApiModelProperty(value = "下单时间-开始",example = "1") |
New file |
| | |
| | | package com.panzhihua.common.model.vos.shop; |
| | | |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * @auther llming |
| | | * @describe 商家订单资金详情 |
| | | */ |
| | | @Data |
| | | public class CapitalDetailVO { |
| | | @ApiModelProperty(value = "商家账号") |
| | | private String storeAccount; |
| | | @ApiModelProperty(value = "商家姓名") |
| | | private String contacts; |
| | | @ApiModelProperty(value = "店铺名称") |
| | | private String storeName; |
| | | @ApiModelProperty(value = "金额(元)") |
| | | private BigDecimal totalAmount; |
| | | @ApiModelProperty("支付方式(1.微信支付)") |
| | | private Integer payType; |
| | | @ApiModelProperty("类型") |
| | | private String type; |
| | | @ApiModelProperty("支付时间") |
| | | private Date payTime; |
| | | @ApiModelProperty("下单时间") |
| | | private Date createAt; |
| | | @ApiModelProperty("订单号") |
| | | private String orderNo; |
| | | } |
New file |
| | |
| | | package com.panzhihua.common.model.vos.shop; |
| | | |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * @auther llming |
| | | * @describe 商家订单资金列表 |
| | | */ |
| | | @Data |
| | | public class CapitalPageVO { |
| | | @ApiModelProperty(value = "商家账号") |
| | | private String storeAccount; |
| | | @ApiModelProperty(value = "商家姓名") |
| | | private String contacts; |
| | | @ApiModelProperty(value = "店铺名称") |
| | | private String storeName; |
| | | @ApiModelProperty(value = "金额(元)") |
| | | private BigDecimal payAmount; |
| | | @ApiModelProperty(value = "订单Id") |
| | | private Long orderId; |
| | | @ApiModelProperty("支付方式(1.微信支付)") |
| | | private Integer payType; |
| | | @ApiModelProperty("类型") |
| | | private String type="订单收入"; |
| | | @ApiModelProperty("支付时间") |
| | | private Date payTime; |
| | | } |
| | |
| | | @ApiModel("商城店铺") |
| | | public class PageShopStoreVO { |
| | | |
| | | @ApiModelProperty("负责人") |
| | | @ApiModelProperty("商家、联系人") |
| | | private String contacts; |
| | | |
| | | @ApiModelProperty("店铺登陆账号") |
| | |
| | | import org.springframework.cloud.openfeign.FeignClient; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @PostMapping("/shop/changeShopGoodsStatus") |
| | | @GetMapping("/shop/changeShopGoodsStatus") |
| | | R changeStatus(@RequestParam("id") Long id,@RequestParam("status")Integer status); |
| | | /** |
| | | * 结果 |
| | |
| | | R pageShopOperLog(@RequestBody PageDTO pageDTO); |
| | | |
| | | /** |
| | | * 分页查询 商家后台操作日志 |
| | | * 订单分页查询 |
| | | * @param pageComShopOrderSearchDTO 分页数据 |
| | | * @return 分页日志 |
| | | * @return 订单分页查询 |
| | | */ |
| | | @PostMapping("/shop/order/page") |
| | | R pageShopOrder(@RequestBody PageComShopOrderSearchDTO pageComShopOrderSearchDTO); |
| | |
| | | @PostMapping("/shop/orderStatistics") |
| | | R orderStatistics(@RequestParam("userId") Long userId); |
| | | |
| | | /** |
| | | * 商家资金的订单详情 |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @GetMapping("/shop/capitalDetailByStore") |
| | | R capitalDetailByStore(@RequestParam("id") Long id); |
| | | |
| | | |
| | | /** |
| | | * 订单发货 |
New file |
| | |
| | | package com.panzhihua.common.utlis; |
| | | |
| | | import com.panzhihua.common.model.dtos.shop.PageComShopOrderSearchDTO; |
| | | |
| | | import java.lang.reflect.Field; |
| | | import java.text.DecimalFormat; |
| | | import java.util.Arrays; |
| | | |
| | | /** |
| | | * 工具类 |
| | | */ |
| | | public class ClazzUtils { |
| | | |
| | | /** |
| | | * 如果string属性为“”, 则将其设置为NULL |
| | | * @param o |
| | | */ |
| | | public static void setIfStringIsEmpty(Object o){ |
| | | if(o==null){ |
| | | return; |
| | | } |
| | | Class clazz = o.getClass(); |
| | | Field[] fields = clazz.getDeclaredFields(); |
| | | Arrays.stream(fields).forEach(field -> { |
| | | if(String.class == field.getType()){ |
| | | try { |
| | | field.setAccessible(true); |
| | | if(field.get(o)!=null) { |
| | | String oVal = (String) field.get(o); |
| | | if ("".equals(oVal)) { |
| | | field.set(o, null); |
| | | } |
| | | } |
| | | } catch (IllegalAccessException e) { |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | |
| | | public static void main(String[] args){ |
| | | PageComShopOrderSearchDTO dto = new PageComShopOrderSearchDTO(); |
| | | dto.setGoodsName(""); |
| | | dto.setOrderNo("123"); |
| | | setIfStringIsEmpty(dto); |
| | | System.out.println(dto); |
| | | |
| | | double d = 1234.200; |
| | | DecimalFormat df = new DecimalFormat("0.00"); |
| | | System.out.println(df.format(d)); |
| | | } |
| | | |
| | | } |
| | |
| | | <version>${feign-httpclient.version}</version> |
| | | </dependency> |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | </dependencies> |
| | | </dependencyManagement> |
| | | |
| | |
| | | <module>community_backstage</module> |
| | | <module>service_community</module> |
| | | <module>service_user</module> |
| | | <module>shop_backstage</module> |
| | | </modules> |
| | | <packaging>pom</packaging> |
| | | |
| | |
| | | import com.panzhihua.common.model.dtos.shop.PageComShopStoreDTO; |
| | | import com.panzhihua.common.model.vos.R; |
| | | import com.panzhihua.common.model.vos.shop.AddShopGoodsVO; |
| | | import com.panzhihua.service_community.model.dos.ComShopOrderDO; |
| | | import com.panzhihua.service_community.service.*; |
| | | import com.panzhihua.common.model.vos.shop.ShopOperLogVO; |
| | | import com.panzhihua.common.model.vos.shop.ShopStoreVO; |
| | |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import javax.validation.constraints.NotNull; |
| | | |
| | |
| | | } |
| | | |
| | | /** |
| | | * 删除商品 |
| | | * 修改商品状态 |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @GetMapping("changeShopGoodsStatus") |
| | | public R changeStatus(@RequestParam("id") Long id,@RequestParam("status")Integer status) { |
| | | return comShopGoodsService.changeStatus(id,status); |
| | | } |
| | | |
| | | /** |
| | | * 商家资金的订单详情 |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @GetMapping("capitalDetailByStore") |
| | | public R capitalDetailByStore(@RequestParam("id") Long id) { |
| | | return comShopOrderService.capitalDetailByStore(id); |
| | | } |
| | | |
| | | /** |
| | |
| | | } |
| | | |
| | | /** |
| | | * 订单发货 |
| | | * 订单配送 |
| | | * @param deliverDTO 订单ID |
| | | * @return 发货结果 |
| | | * @return 配送结果 |
| | | */ |
| | | @PostMapping("/deliverOrder") |
| | | R deliverOrder(@RequestBody ComShopOrderDeliverDTO deliverDTO){ |
| | |
| | | return comShopOrderService.deliverOrder(orderId); |
| | | } |
| | | /** |
| | | * 订单发货 |
| | | * 订单配送 |
| | | * @param deliverDTO 订单ID |
| | | * @return 发货结果 |
| | | * @return 配送完成 |
| | | */ |
| | | @PostMapping("/finishDeliverOrder") |
| | | R finishDeliverOrder(@RequestBody ComShopOrderDeliverDTO deliverDTO){ |
| | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.panzhihua.common.model.dtos.shop.PageComOrderListDTO; |
| | | import com.panzhihua.common.model.vos.shop.*; |
| | | import com.panzhihua.common.model.dtos.shop.*; |
| | | import com.panzhihua.common.model.vos.shop.*; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | |
| | | import com.panzhihua.service_community.model.dos.ComShopOrderDO; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | import org.apache.ibatis.annotations.Param; |
| | | import org.apache.ibatis.annotations.Select; |
| | | import org.apache.ibatis.annotations.Select; |
| | | |
| | | /** |
| | |
| | | " LEFT JOIN com_shop_user_address uad ON sr.receiver_id = uad.id \n" + |
| | | " LEFT JOIN com_shop_store ss ON sr.store_id = ss.id \n" + |
| | | " WHERE sr.delete_status = 1" + |
| | | "<if test='pageComShopOrderSearchDTO.userId != null'>" + |
| | | " AND sr.user_id = #{pageComShopOrderSearchDTO.userId} " + |
| | | " </if> " + |
| | | "<if test='pageComShopOrderSearchDTO.createAtStart != null'>" + |
| | | " AND #{pageComShopOrderSearchDTO.createAtStart} <![CDATA[<=]]> sr.create_at " + |
| | | " </if> " + |
| | |
| | | " </if> " + |
| | | "<if test='pageComShopOrderSearchDTO.status != null '>" + |
| | | " AND sr.status = #{pageComShopOrderSearchDTO.status} " + |
| | | " </if> " + |
| | | "<if test='pageComShopOrderSearchDTO.storeName != null '>" + |
| | | " AND ss.name like concat('%', #{pageComShopOrderSearchDTO.storeName}, '%') " + |
| | | " </if> " + |
| | | " ORDER BY sr.create_at "+ |
| | | "</script>") |
| | |
| | | " LEFT JOIN com_shop_store ss ON sr.store_id = ss.id \n" + |
| | | " WHERE sr.delete_status = 1" + |
| | | "<if test='comShopOrderExportDTO.userId != null'>" + |
| | | " AND com_shop_store.user_id = #{comShopOrderExportDTO.userId} " + |
| | | " AND ss.user_id = #{comShopOrderExportDTO.userId} " + |
| | | " </if> " + |
| | | "<if test='comShopOrderExportDTO.orderIds != null and comShopOrderExportDTO.orderIds.length>0 '>" + |
| | | " AND sr.id in " + |
| | |
| | | |
| | | @Select("<script> " + |
| | | " SELECT sys_user_id,\n" + |
| | | " sum(case when abt.days = DATE_FORMAT(NOW(),'%Y%m%d') then abt.t END) AS todayTotal,\n" + |
| | | " sum(case when abt.days = DATE_FORMAT(NOW(),'%Y%u') then abt.t END) AS weekTotal,\n" + |
| | | " sum(case when abt.days = DATE_FORMAT(NOW(),'%Y%m') then abt.t END) AS monthTotal\n" + |
| | | " COALESCE(SUM(CASE WHEN abt.days = DATE_FORMAT(NOW(),'%Y%m%d') THEN abt.t END), 0) AS todayTotal,\n" + |
| | | " COALESCE(SUM(CASE WHEN abt.days = DATE_FORMAT(NOW(),'%Y%u') THEN abt.t END), 0) AS weekTotal,\n" + |
| | | " COALESCE(SUM(CASE WHEN abt.days = DATE_FORMAT(NOW(),'%Y%m') THEN abt.t END), 0) AS monthTotal\n" + |
| | | "FROM (\n" + |
| | | "SELECT ss.sys_user_id, (sr.pay_amount) AS t , DATE_FORMAT(sr.pay_time,'%Y%m%d') days\n" + |
| | | "SELECT ss.sys_user_id, sum(sr.pay_amount) AS t , DATE_FORMAT(sr.pay_time,'%Y%m%d') days\n" + |
| | | "FROM com_shop_order sr LEFT JOIN com_shop_store ss ON sr.store_id = ss.id\n" + |
| | | "WHERE sr.pay_status = 2 AND DATE_FORMAT(sr.pay_time,'%Y%m%d') = DATE_FORMAT(NOW(),'%Y%m%d')\n" + |
| | | "<if test='userId!=null'>" + |
| | | " and ss.sys_user_id = #{userId}\n" + |
| | | "</if>" + |
| | | "GROUP BY days\n" + |
| | | "UNION \n" + |
| | | "SELECT ss.sys_user_id, sum(sr.pay_amount) AS t, DATE_FORMAT(sr.pay_time,'%Y%u') weeks\n" + |
| | | "FROM com_shop_order sr LEFT JOIN com_shop_store ss ON sr.store_id = ss.id\n" + |
| | | "WHERE sr.pay_status = 2 AND DATE_FORMAT(sr.pay_time,'%Y%u') = DATE_FORMAT(NOW(),'%Y%u')\n" + |
| | | "<if test='userId!=null'>" + |
| | | " and ss.sys_user_id = #{userId}\n" + |
| | | "</if>" + |
| | | "GROUP BY weeks\n" + |
| | | "UNION \n" + |
| | | "SELECT ss.sys_user_id, sum(sr.pay_amount) AS t, DATE_FORMAT(sr.pay_time,'%Y%m') months\n" + |
| | | "FROM com_shop_order sr LEFT JOIN com_shop_store ss ON sr.store_id = ss.id\n" + |
| | | "WHERE sr.pay_status = 2 AND DATE_FORMAT(sr.pay_time,'%Y%m') = DATE_FORMAT(NOW(),'%Y%m')\n" + |
| | | "<if test='userId!=null'>" + |
| | | " and ss.sys_user_id = #{userId}\n" + |
| | | "</if>" + |
| | | "GROUP BY months\n" + |
| | | ") abt\n" + |
| | | "GROUP BY abt.sys_user_id "+ |
| | | "</script>") |
| | | ComShopFundsVO queryStatis(Long userId); |
| | | ComShopFundsVO queryStatis(@Param("userId") Long userId); |
| | | |
| | | @Select("<script> " + |
| | | "SELECT sr.id, sr.total_amount, sr.pay_time, sr.order_no, \n" + |
| | |
| | | " GROUP BY sr.id ORDER BY sr.create_at "+ |
| | | "</script>") |
| | | IPage<ComShopFundsOrderVO> pageShopFunds(Page page, @Param("pageComShopFundsSearchDTO") PageComShopFundsSearchDTO pageComShopFundsSearchDTO); |
| | | |
| | | @Select("<script> " + |
| | | "SELECT\n" + |
| | | "css.store_account,\n" + |
| | | "css.`contacts`,\n" + |
| | | "css.`name` as storeName,\n" + |
| | | "cso.total_amount,\n" + |
| | | "cso.pay_type,\n" + |
| | | "cso.pay_time, \n" + |
| | | "cso.create_at, \n" + |
| | | "cso.order_no\n" + |
| | | "FROM\n" + |
| | | "com_shop_order cso\n" + |
| | | "left JOIN com_shop_store css on cso.store_id=css.id \n" + |
| | | "where cso.id =#{id} "+ |
| | | "</script>") |
| | | CapitalDetailVO capitalDetailByStore(@Param("id")Long id); |
| | | } |
| | |
| | | public interface ComShopStoreDAO extends BaseMapper<ComShopStoreDO> { |
| | | |
| | | @Select("<script>" + |
| | | "select id,`name`,store_account,classify_id,logo,phone,delivery_type,remark,`status`,sale,sale_volume,store_detail,create_at from com_shop_store c" + |
| | | "select id,`name`,contacts,store_account,classify_id,logo,phone,delivery_type,remark,`status`,sale,sale_volume,store_detail,create_at from com_shop_store c" + |
| | | " <where>" + |
| | | "<if test='pageComShopStoreDTO.contacts != null and pageComShopStoreDTO.contacts.trim() != ""'>" + |
| | | "and c.contacts like concat('%',#{pageComShopStoreDTO.contacts},'%') \n" + |
| | |
| | | package com.panzhihua.service_community.model.dos; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import lombok.Data; |
| | | |
| | |
| | | /** |
| | | * 日志主键 |
| | | */ |
| | | @TableId(type = IdType.AUTO) |
| | | private Long operId; |
| | | |
| | | /** |
| | |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.panzhihua.common.model.dtos.shop.*; |
| | | import com.panzhihua.common.model.dtos.shop.*; |
| | | import com.panzhihua.common.model.vos.R; |
| | | import com.panzhihua.common.model.vos.R; |
| | | import com.panzhihua.service_community.model.dos.ComShopOrderDO; |
| | |
| | | R orderStatistics(Long userId); |
| | | |
| | | /** |
| | | * 商家资金的订单详情 |
| | | * @param id 订单id |
| | | * @return |
| | | */ |
| | | R capitalDetailByStore(Long id); |
| | | |
| | | /** |
| | | * 订单发货 |
| | | * @param orderShipDTO 订单发货信息 |
| | | * @return 发货结果 |
| | |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.panzhihua.common.model.dtos.PageDTO; |
| | | import com.panzhihua.common.model.dtos.shop.*; |
| | |
| | | |
| | | /** |
| | | * 订单预览 |
| | | * @param orderPreviewDTO 请求参数 |
| | | * @return 订单预览数据 |
| | | * |
| | | * @param orderPreviewDTO 请求参数 |
| | | * @return 订单预览数据 |
| | | */ |
| | | @Override |
| | | public R orderPreview(ComShopOrderPreviewDTO orderPreviewDTO){ |
| | |
| | | IPage<ComShopOrderSearchVO> ipage = this.baseMapper.pageOrderBy(page, pageComShopOrderSearchDTO); |
| | | return R.ok(ipage); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | @Override |
| | | public R capitalDetailByStore(Long id) { |
| | | if(id==null){ |
| | | R.fail("订单号不能为空!"); |
| | | } |
| | | CapitalDetailVO vo = this.baseMapper.capitalDetailByStore(id); |
| | | return R.ok(vo); |
| | | } |
| | | } |
| | |
| | | |
| | | @Override |
| | | public R deleteStore(Long[] id) { |
| | | ComShopStoreDO storeDO = new ComShopStoreDO(); |
| | | storeDO.setDeleteStatus(2); |
| | | LambdaQueryWrapper<ComShopStoreDO> query = new LambdaQueryWrapper<ComShopStoreDO>().eq(ComShopStoreDO::getId, id); |
| | | int update = this.baseMapper.update(storeDO, query); |
| | | LambdaQueryWrapper<ComShopStoreDO> query = new LambdaQueryWrapper<ComShopStoreDO>().in(ComShopStoreDO::getId, id); |
| | | ComShopStoreDO comShopStoreDO = this.baseMapper.selectOne(query); |
| | | comShopStoreDO.setDeleteStatus(2); |
| | | int update = this.baseMapper.updateById(comShopStoreDO); |
| | | return update > 0 ? R.ok() : R.fail(); |
| | | } |
| | | |
New file |
| | |
| | | HELP.md |
| | | target/ |
| | | !.mvn/wrapper/maven-wrapper.jar |
| | | !**/src/main/**/target/ |
| | | !**/src/test/**/target/ |
| | | |
| | | ### STS ### |
| | | .apt_generated |
| | | .classpath |
| | | .factorypath |
| | | .project |
| | | .settings |
| | | .springBeans |
| | | .sts4-cache |
| | | |
| | | ### IntelliJ IDEA ### |
| | | .idea |
| | | *.iws |
| | | *.iml |
| | | *.ipr |
| | | |
| | | ### NetBeans ### |
| | | /nbproject/private/ |
| | | /nbbuild/ |
| | | /dist/ |
| | | /nbdist/ |
| | | /.nb-gradle/ |
| | | build/ |
| | | !**/src/main/**/build/ |
| | | !**/src/test/**/build/ |
| | | |
| | | ### VS Code ### |
| | | .vscode/ |
New file |
| | |
| | | @REM ---------------------------------------------------------------------------- |
| | | @REM Licensed to the Apache Software Foundation (ASF) under one |
| | | @REM or more contributor license agreements. See the NOTICE file |
| | | @REM distributed with this work for additional information |
| | | @REM regarding copyright ownership. The ASF licenses this file |
| | | @REM to you under the Apache License, Version 2.0 (the |
| | | @REM "License"); you may not use this file except in compliance |
| | | @REM with the License. You may obtain a copy of the License at |
| | | @REM |
| | | @REM https://www.apache.org/licenses/LICENSE-2.0 |
| | | @REM |
| | | @REM Unless required by applicable law or agreed to in writing, |
| | | @REM software distributed under the License is distributed on an |
| | | @REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| | | @REM KIND, either express or implied. See the License for the |
| | | @REM specific language governing permissions and limitations |
| | | @REM under the License. |
| | | @REM ---------------------------------------------------------------------------- |
| | | |
| | | @REM ---------------------------------------------------------------------------- |
| | | @REM Maven Start Up Batch script |
| | | @REM |
| | | @REM Required ENV vars: |
| | | @REM JAVA_HOME - location of a JDK home dir |
| | | @REM |
| | | @REM Optional ENV vars |
| | | @REM M2_HOME - location of maven2's installed home dir |
| | | @REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands |
| | | @REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending |
| | | @REM MAVEN_OPTS - parameters passed to the Java VM when running Maven |
| | | @REM e.g. to debug Maven itself, use |
| | | @REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 |
| | | @REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files |
| | | @REM ---------------------------------------------------------------------------- |
| | | |
| | | @REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' |
| | | @echo off |
| | | @REM set title of command window |
| | | title %0 |
| | | @REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' |
| | | @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% |
| | | |
| | | @REM set %HOME% to equivalent of $HOME |
| | | if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") |
| | | |
| | | @REM Execute a user defined script before this one |
| | | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre |
| | | @REM check for pre script, once with legacy .bat ending and once with .cmd ending |
| | | if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" |
| | | if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" |
| | | :skipRcPre |
| | | |
| | | @setlocal |
| | | |
| | | set ERROR_CODE=0 |
| | | |
| | | @REM To isolate internal variables from possible post scripts, we use another setlocal |
| | | @setlocal |
| | | |
| | | @REM ==== START VALIDATION ==== |
| | | if not "%JAVA_HOME%" == "" goto OkJHome |
| | | |
| | | echo. |
| | | echo Error: JAVA_HOME not found in your environment. >&2 |
| | | echo Please set the JAVA_HOME variable in your environment to match the >&2 |
| | | echo location of your Java installation. >&2 |
| | | echo. |
| | | goto error |
| | | |
| | | :OkJHome |
| | | if exist "%JAVA_HOME%\bin\java.exe" goto init |
| | | |
| | | echo. |
| | | echo Error: JAVA_HOME is set to an invalid directory. >&2 |
| | | echo JAVA_HOME = "%JAVA_HOME%" >&2 |
| | | echo Please set the JAVA_HOME variable in your environment to match the >&2 |
| | | echo location of your Java installation. >&2 |
| | | echo. |
| | | goto error |
| | | |
| | | @REM ==== END VALIDATION ==== |
| | | |
| | | :init |
| | | |
| | | @REM Find the project base dir, i.e. the directory that contains the folder ".mvn". |
| | | @REM Fallback to current working directory if not found. |
| | | |
| | | set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% |
| | | IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir |
| | | |
| | | set EXEC_DIR=%CD% |
| | | set WDIR=%EXEC_DIR% |
| | | :findBaseDir |
| | | IF EXIST "%WDIR%"\.mvn goto baseDirFound |
| | | cd .. |
| | | IF "%WDIR%"=="%CD%" goto baseDirNotFound |
| | | set WDIR=%CD% |
| | | goto findBaseDir |
| | | |
| | | :baseDirFound |
| | | set MAVEN_PROJECTBASEDIR=%WDIR% |
| | | cd "%EXEC_DIR%" |
| | | goto endDetectBaseDir |
| | | |
| | | :baseDirNotFound |
| | | set MAVEN_PROJECTBASEDIR=%EXEC_DIR% |
| | | cd "%EXEC_DIR%" |
| | | |
| | | :endDetectBaseDir |
| | | |
| | | IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig |
| | | |
| | | @setlocal EnableExtensions EnableDelayedExpansion |
| | | for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a |
| | | @endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% |
| | | |
| | | :endReadAdditionalConfig |
| | | |
| | | SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" |
| | | set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" |
| | | set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain |
| | | |
| | | set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" |
| | | |
| | | FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( |
| | | IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B |
| | | ) |
| | | |
| | | @REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central |
| | | @REM This allows using the maven wrapper in projects that prohibit checking in binary data. |
| | | if exist %WRAPPER_JAR% ( |
| | | if "%MVNW_VERBOSE%" == "true" ( |
| | | echo Found %WRAPPER_JAR% |
| | | ) |
| | | ) else ( |
| | | if not "%MVNW_REPOURL%" == "" ( |
| | | SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" |
| | | ) |
| | | if "%MVNW_VERBOSE%" == "true" ( |
| | | echo Couldn't find %WRAPPER_JAR%, downloading it ... |
| | | echo Downloading from: %DOWNLOAD_URL% |
| | | ) |
| | | |
| | | powershell -Command "&{"^ |
| | | "$webclient = new-object System.Net.WebClient;"^ |
| | | "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ |
| | | "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ |
| | | "}"^ |
| | | "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^ |
| | | "}" |
| | | if "%MVNW_VERBOSE%" == "true" ( |
| | | echo Finished downloading %WRAPPER_JAR% |
| | | ) |
| | | ) |
| | | @REM End of extension |
| | | |
| | | @REM Provide a "standardized" way to retrieve the CLI args that will |
| | | @REM work with both Windows and non-Windows executions. |
| | | set MAVEN_CMD_LINE_ARGS=%* |
| | | |
| | | %MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* |
| | | if ERRORLEVEL 1 goto error |
| | | goto end |
| | | |
| | | :error |
| | | set ERROR_CODE=1 |
| | | |
| | | :end |
| | | @endlocal & set ERROR_CODE=%ERROR_CODE% |
| | | |
| | | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost |
| | | @REM check for post script, once with legacy .bat ending and once with .cmd ending |
| | | if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" |
| | | if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" |
| | | :skipRcPost |
| | | |
| | | @REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' |
| | | if "%MAVEN_BATCH_PAUSE%" == "on" pause |
| | | |
| | | if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% |
| | | |
| | | exit /B %ERROR_CODE% |
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
| | | xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> |
| | | <modelVersion>4.0.0</modelVersion> |
| | | <parent> |
| | | <groupId>com.panzhihua</groupId> |
| | | <artifactId>zhihuishequ</artifactId> |
| | | <version>1.0-SNAPSHOT</version> |
| | | </parent> |
| | | <groupId>com.panzhihua</groupId> |
| | | <artifactId>shop_backstage</artifactId> |
| | | <version>0.0.1-SNAPSHOT</version> |
| | | <name>shop_backstage</name> |
| | | <description>商家后台</description> |
| | | |
| | | <dependencies> |
| | | <dependency> |
| | | <groupId>org.springframework.boot</groupId> |
| | | <artifactId>spring-boot-starter-web</artifactId> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>org.springframework.cloud</groupId> |
| | | <artifactId>spring-cloud-starter-config</artifactId> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>org.springframework.cloud</groupId> |
| | | <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>org.springframework.cloud</groupId> |
| | | <artifactId>spring-cloud-starter-openfeign</artifactId> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>org.projectlombok</groupId> |
| | | <artifactId>lombok</artifactId> |
| | | <optional>true</optional> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>com.panzhihua</groupId> |
| | | <artifactId>common</artifactId> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>com.netflix.hystrix</groupId> |
| | | <artifactId>hystrix-javanica</artifactId> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>com.github.xiaoymin</groupId> |
| | | <artifactId>swagger-bootstrap-ui</artifactId> |
| | | </dependency> |
| | | </dependencies> |
| | | |
| | | <build> |
| | | <plugins> |
| | | <plugin> |
| | | <groupId>org.springframework.boot</groupId> |
| | | <artifactId>spring-boot-maven-plugin</artifactId> |
| | | <configuration> |
| | | <mainClass>com.panzhihua.shop_backstage.ShopBackstageApplication</mainClass> |
| | | </configuration> |
| | | <executions> |
| | | <execution> |
| | | <goals> |
| | | <goal>repackage</goal> |
| | | </goals> |
| | | </execution> |
| | | </executions> |
| | | </plugin> |
| | | |
| | | <plugin> |
| | | <groupId>com.spotify</groupId> |
| | | <artifactId>docker-maven-plugin</artifactId> |
| | | <version>1.2.0</version> |
| | | <configuration> |
| | | <imageName>registry.cn-chengdu.aliyuncs.com/panzhihua/shop_backstage:v1</imageName> |
| | | <serverId></serverId> |
| | | <baseImage>java</baseImage> |
| | | <entryPoint>["java", "-jar", "/${project.build.finalName}.jar"]</entryPoint> |
| | | <resources> |
| | | <resource> |
| | | <targetPath>/</targetPath> |
| | | <directory>${project.build.directory}</directory> |
| | | <include>${project.build.finalName}.jar</include> |
| | | </resource> |
| | | </resources> |
| | | </configuration> |
| | | </plugin> |
| | | </plugins> |
| | | </build> |
| | | |
| | | <repositories> |
| | | <repository> |
| | | <id>spring-snapshots</id> |
| | | <name>Spring Snapshots</name> |
| | | <url>https://repo.spring.io/snapshot</url> |
| | | <snapshots> |
| | | <enabled>true</enabled> |
| | | </snapshots> |
| | | </repository> |
| | | <repository> |
| | | <id>spring-milestones</id> |
| | | <name>Spring Milestones</name> |
| | | <url>https://repo.spring.io/milestone</url> |
| | | </repository> |
| | | </repositories> |
| | | |
| | | </project> |
New file |
| | |
| | | package com.panzhihua.shop_backstage; |
| | | |
| | | import org.springframework.boot.SpringApplication; |
| | | import org.springframework.cloud.client.SpringCloudApplication; |
| | | import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker; |
| | | import org.springframework.cloud.netflix.eureka.EnableEurekaClient; |
| | | import org.springframework.cloud.openfeign.EnableFeignClients; |
| | | import org.springframework.context.annotation.ComponentScan; |
| | | import springfox.documentation.swagger2.annotations.EnableSwagger2; |
| | | |
| | | @EnableSwagger2 |
| | | @SpringCloudApplication |
| | | @EnableCircuitBreaker |
| | | @EnableEurekaClient |
| | | @EnableFeignClients(basePackages = {"com.panzhihua.common.service"}) |
| | | @ComponentScan({"com.panzhihua.shop_backstage","com.panzhihua.common"}) |
| | | public class ShopBackstageApplication { |
| | | |
| | | public static void main(String[] args) { |
| | | SpringApplication.run(ShopBackstageApplication.class, args); |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.panzhihua.shop_backstage.aop; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.panzhihua.common.constants.Constants; |
| | | import com.panzhihua.common.constants.TokenConstant; |
| | | import com.panzhihua.common.interfaces.ShopOperLog; |
| | | import com.panzhihua.common.model.vos.LoginUserInfoVO; |
| | | import com.panzhihua.common.model.vos.R; |
| | | import com.panzhihua.common.model.vos.shop.ShopOperLogVO; |
| | | import com.panzhihua.common.service.community.CommunityService; |
| | | import com.panzhihua.common.service.user.UserService; |
| | | import com.panzhihua.common.utlis.AES; |
| | | import com.panzhihua.common.utlis.IPUtil; |
| | | import com.panzhihua.shop_backstage.model.vos.LoginBody; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.aspectj.lang.JoinPoint; |
| | | import org.aspectj.lang.annotation.AfterReturning; |
| | | import org.aspectj.lang.annotation.Aspect; |
| | | import org.aspectj.lang.annotation.Pointcut; |
| | | import org.aspectj.lang.reflect.MethodSignature; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.util.ObjectUtils; |
| | | import org.springframework.web.context.request.RequestAttributes; |
| | | import org.springframework.web.context.request.RequestContextHolder; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.BufferedReader; |
| | | import java.io.IOException; |
| | | import java.lang.reflect.Method; |
| | | import java.util.Date; |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * @ClasssName 商家后台日志 |
| | | * @Description |
| | | * @Author cedoo |
| | | * @Date 2021/4/16 |
| | | * @Version 1.0 |
| | | **/ |
| | | @Slf4j |
| | | @Aspect |
| | | @Component |
| | | public class OperLogAspect { |
| | | |
| | | @Resource |
| | | private CommunityService communityService; |
| | | @Resource |
| | | private UserService userService; |
| | | |
| | | /** |
| | | * 设置操作日志切入点 记录操作日志 在注解的位置切入代码 |
| | | */ |
| | | @Pointcut("@annotation(com.panzhihua.common.interfaces.ShopOperLog)") |
| | | public void operLogPoinCut() { |
| | | } |
| | | |
| | | |
| | | |
| | | // /** |
| | | // * 设置操作异常切入点记录异常日志 扫描所有controller包下操作 |
| | | // */ |
| | | // @Pointcut("execution(* com.hyd.zcar.cms.controller..*.*(..))") |
| | | // public void operExceptionLogPoinCut() { |
| | | // } |
| | | |
| | | /** |
| | | * 正常返回通知,拦截用户操作日志,连接点正常执行完成后执行, 如果连接点抛出异常,则不会执行 |
| | | * |
| | | * @param joinPoint 切入点 |
| | | * @param keys 返回结果 |
| | | */ |
| | | @AfterReturning(value = "operLogPoinCut()", returning = "keys") |
| | | public void saveOperLog(JoinPoint joinPoint, Object keys) { |
| | | log.info("进入切面"); |
| | | // 获取RequestAttributes |
| | | RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes(); |
| | | // 从获取RequestAttributes中获取HttpServletRequest的信息 |
| | | HttpServletRequest request = (HttpServletRequest) requestAttributes |
| | | .resolveReference(RequestAttributes.REFERENCE_REQUEST); |
| | | // 登录对象信息 |
| | | String userInfo = request.getHeader(TokenConstant.TOKEN_USERINFO); |
| | | boolean empty = ObjectUtils.isEmpty(userInfo); |
| | | if (empty) { |
| | | log.error("操作日志获取登录用户信息失败【{}】",joinPoint); |
| | | return; |
| | | } |
| | | byte[] bytes = AES.parseHexStr2Byte(userInfo); |
| | | byte[] decrypt = AES.decrypt(bytes, Constants.AES_KEY); |
| | | userInfo=new String(decrypt); |
| | | LoginUserInfoVO loginUserInfoVO= JSONObject.parseObject(userInfo,LoginUserInfoVO.class); |
| | | |
| | | ShopOperLogVO shopOperlog = new ShopOperLogVO(); |
| | | try { |
| | | |
| | | // 从切面织入点处通过反射机制获取织入点处的方法 |
| | | MethodSignature signature = (MethodSignature) joinPoint.getSignature(); |
| | | // 获取切入点所在的方法 |
| | | Method method = signature.getMethod(); |
| | | // 获取操作 |
| | | ShopOperLog opLog = method.getAnnotation(ShopOperLog.class); |
| | | if (opLog != null) { |
| | | String operModul = opLog.operModul(); |
| | | int operType = opLog.operType(); |
| | | shopOperlog.setTitle(operModul); // 操作模块 |
| | | shopOperlog.setBusinessType(operType); // 操作类型 |
| | | } |
| | | // 获取请求的类名 |
| | | String className = joinPoint.getTarget().getClass().getName(); |
| | | // 获取请求的方法名 |
| | | String methodName = method.getName(); |
| | | methodName = className + "." + methodName; |
| | | |
| | | shopOperlog.setMethod(methodName); // 请求方法 |
| | | |
| | | if (joinPoint.getArgs().length > 0) { |
| | | for (Object o : joinPoint.getArgs()) { |
| | | if (o instanceof HttpServletRequest || o instanceof HttpServletResponse) { |
| | | continue; |
| | | } |
| | | shopOperlog.setOperParam(JSONObject.toJSONString(o)); // 请求参数 |
| | | } |
| | | } |
| | | |
| | | shopOperlog.setJsonResult(JSONObject.toJSONString(keys)); // 返回结果 |
| | | shopOperlog.setAccount(loginUserInfoVO.getAccount()); |
| | | shopOperlog.setOperName(loginUserInfoVO.getName()); // 请求用户名称 |
| | | shopOperlog.setOperIp(IPUtil.getIpAddress(request)); // 请求IP |
| | | shopOperlog.setOperUrl(request.getRequestURI()); // 请求URI |
| | | shopOperlog.setRequestMethod(request.getMethod()); |
| | | shopOperlog.setOperLocation(IPUtil.getIpBelongAddress(request)); |
| | | shopOperlog.setOperTime(new Date()); // 创建时间 |
| | | shopOperlog.setAccount(loginUserInfoVO.getAccount()); |
| | | Long communityId = loginUserInfoVO.getCommunityId(); |
| | | shopOperlog.setCommunityId(null==communityId?0:communityId); |
| | | shopOperlog.setUserId(loginUserInfoVO.getUserId()); |
| | | communityService.addShopOperLog(shopOperlog); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | // /** |
| | | // * 异常返回通知,用于拦截异常日志信息 连接点抛出异常后执行 |
| | | // * |
| | | // * @param joinPoint 切入点 |
| | | // * @param e 异常信息 |
| | | // */ |
| | | // @AfterThrowing(pointcut = "operExceptionLogPoinCut()", throwing = "e") |
| | | // public void saveExceptionLog(JoinPoint joinPoint, Throwable e) { |
| | | // // 获取RequestAttributes |
| | | // RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes(); |
| | | // // 从获取RequestAttributes中获取HttpServletRequest的信息 |
| | | // HttpServletRequest request = (HttpServletRequest) requestAttributes |
| | | // .resolveReference(RequestAttributes.REFERENCE_REQUEST); |
| | | // |
| | | // ExceptionLog excepLog = new ExceptionLog(); |
| | | // try { |
| | | // // 从切面织入点处通过反射机制获取织入点处的方法 |
| | | // MethodSignature signature = (MethodSignature) joinPoint.getSignature(); |
| | | // // 获取切入点所在的方法 |
| | | // Method method = signature.getMethod(); |
| | | // excepLog.setExcId(UuidUtil.get32UUID()); |
| | | // // 获取请求的类名 |
| | | // String className = joinPoint.getTarget().getClass().getName(); |
| | | // // 获取请求的方法名 |
| | | // String methodName = method.getName(); |
| | | // methodName = className + "." + methodName; |
| | | // // 请求的参数 |
| | | // Map<String, String> rtnMap = converMap(request.getParameterMap()); |
| | | // // 将参数所在的数组转换成json |
| | | // String params = JSON.toJSONString(rtnMap); |
| | | // excepLog.setExcRequParam(params); // 请求参数 |
| | | // excepLog.setOperMethod(methodName); // 请求方法名 |
| | | // excepLog.setExcName(e.getClass().getName()); // 异常名称 |
| | | // excepLog.setExcMessage(stackTraceToString(e.getClass().getName(), e.getMessage(), e.getStackTrace())); // 异常信息 |
| | | // excepLog.setOperUserId(UserShiroUtil.getCurrentUserLoginName()); // 操作员ID |
| | | // excepLog.setOperUserName(UserShiroUtil.getCurrentUserName()); // 操作员名称 |
| | | // excepLog.setOperUri(request.getRequestURI()); // 操作URI |
| | | // excepLog.setOperIp(IPUtil.getRemortIP(request)); // 操作员IP |
| | | // excepLog.setOperVer(operVer); // 操作版本号 |
| | | // excepLog.setOperCreateTime(new Date()); // 发生异常时间 |
| | | // |
| | | // exceptionLogService.insert(excepLog); |
| | | // |
| | | // } catch (Exception e2) { |
| | | // e2.printStackTrace(); |
| | | // } |
| | | // |
| | | // } |
| | | |
| | | /** |
| | | * 转换request 请求参数 |
| | | * |
| | | * @param paramMap request获取的参数数组 |
| | | */ |
| | | public Map<String, String> converMap(Map<String, String[]> paramMap) { |
| | | Map<String, String> rtnMap = new HashMap<String, String>(); |
| | | for (String key : paramMap.keySet()) { |
| | | rtnMap.put(key, paramMap.get(key)[0]); |
| | | } |
| | | return rtnMap; |
| | | } |
| | | |
| | | private String getPostData(HttpServletRequest request) { |
| | | StringBuffer data = new StringBuffer(); |
| | | String line = null; |
| | | BufferedReader reader = null; |
| | | try { |
| | | reader = request.getReader(); |
| | | while (null != (line = reader.readLine())) |
| | | data.append(line); |
| | | } catch (IOException e) { |
| | | } finally { |
| | | } |
| | | return data.toString(); |
| | | } |
| | | |
| | | /** |
| | | * 转换异常信息为字符串 |
| | | * |
| | | * @param exceptionName 异常名称 |
| | | * @param exceptionMessage 异常信息 |
| | | * @param elements 堆栈信息 |
| | | */ |
| | | public String stackTraceToString(String exceptionName, String exceptionMessage, StackTraceElement[] elements) { |
| | | StringBuffer strbuff = new StringBuffer(); |
| | | for (StackTraceElement stet : elements) { |
| | | strbuff.append(stet + "\n"); |
| | | } |
| | | String message = exceptionName + ":" + exceptionMessage + "\n\t" + strbuff.toString(); |
| | | return message; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 登录日志切入点 |
| | | */ |
| | | @Pointcut("execution(public * com.panzhihua.shop_backstage.api.LoginApi.login(..) )") |
| | | public void operLogLoginPoinCut() { |
| | | } |
| | | |
| | | /** |
| | | * 正常返回通知,拦截用户操作日志,连接点正常执行完成后执行, 如果连接点抛出异常,则不会执行 |
| | | * |
| | | * @param joinPoint 切入点 |
| | | * @param keys 返回结果 |
| | | */ |
| | | @AfterReturning(value = "operLogLoginPoinCut()", returning = "keys") |
| | | public void saveLoginOperLog(JoinPoint joinPoint, Object keys) { |
| | | log.info("进入商家后台登录日志切面"); |
| | | // 获取RequestAttributes |
| | | RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes(); |
| | | // 从获取RequestAttributes中获取HttpServletRequest的信息 |
| | | HttpServletRequest request = (HttpServletRequest) requestAttributes |
| | | .resolveReference(RequestAttributes.REFERENCE_REQUEST); |
| | | if(keys instanceof R ){ |
| | | R r = (R)keys; |
| | | if(r.getCode()==200 && "success".equals(r.getMsg())) { |
| | | |
| | | Object obj = joinPoint.getArgs(); |
| | | Object[] obja = (Object[])obj; |
| | | LoginBody loginBody = (LoginBody)obja[0]; |
| | | String userName = loginBody.getAccount(); |
| | | R<LoginUserInfoVO> userR = userService.getUserInfo(userName+"_5"); |
| | | LoginUserInfoVO loginUserInfoVO = userR.getData(); |
| | | |
| | | ShopOperLogVO shopOperlog = new ShopOperLogVO(); |
| | | try { |
| | | |
| | | // 从切面织入点处通过反射机制获取织入点处的方法 |
| | | MethodSignature signature = (MethodSignature) joinPoint.getSignature(); |
| | | // 获取切入点所在的方法 |
| | | Method method = signature.getMethod(); |
| | | // 获取操作 |
| | | ShopOperLog opLog = method.getAnnotation(ShopOperLog.class); |
| | | if (opLog != null) { |
| | | String operModul = opLog.operModul(); |
| | | int operType = opLog.operType(); |
| | | shopOperlog.setTitle(operModul); // 操作模块 |
| | | shopOperlog.setBusinessType(operType); // 操作类型 |
| | | } |
| | | // 获取请求的类名 |
| | | String className = joinPoint.getTarget().getClass().getName(); |
| | | // 获取请求的方法名 |
| | | String methodName = method.getName(); |
| | | methodName = className + "." + methodName; |
| | | |
| | | shopOperlog.setMethod(methodName); // 请求方法 |
| | | |
| | | |
| | | if (joinPoint.getArgs().length > 0) { |
| | | for (Object o : joinPoint.getArgs()) { |
| | | if (o instanceof HttpServletRequest || o instanceof HttpServletResponse) { |
| | | continue; |
| | | } |
| | | shopOperlog.setOperParam(JSONObject.toJSONString(o)); // 请求参数 |
| | | } |
| | | } |
| | | |
| | | shopOperlog.setJsonResult(JSONObject.toJSONString(keys)); // 返回结果 |
| | | shopOperlog.setAccount(loginUserInfoVO.getAccount()); |
| | | shopOperlog.setOperName(loginUserInfoVO.getName()); // 请求用户名称 |
| | | shopOperlog.setOperIp(IPUtil.getIpAddress(request)); // 请求IP |
| | | shopOperlog.setOperUrl(request.getRequestURI()); // 请求URI |
| | | shopOperlog.setRequestMethod(request.getMethod()); |
| | | shopOperlog.setOperLocation(IPUtil.getIpBelongAddress(request)); |
| | | shopOperlog.setOperTime(new Date()); // 创建时间 |
| | | shopOperlog.setAccount(loginUserInfoVO.getAccount()); |
| | | Long communityId = loginUserInfoVO.getCommunityId(); |
| | | shopOperlog.setCommunityId(null==communityId?0:communityId); |
| | | shopOperlog.setUserId(loginUserInfoVO.getUserId()); |
| | | communityService.addShopOperLog(shopOperlog); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.panzhihua.shop_backstage.api; |
| | | |
| | | import com.alibaba.excel.EasyExcel; |
| | | import com.alibaba.excel.ExcelWriter; |
| | | import com.alibaba.excel.write.metadata.WriteSheet; |
| | | import com.alibaba.excel.write.style.column.LongestMatchColumnWidthStyleStrategy; |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.panzhihua.common.controller.BaseController; |
| | | import com.panzhihua.common.interfaces.ShopOperLog; |
| | | import com.panzhihua.common.model.dtos.shop.*; |
| | | import com.panzhihua.common.model.vos.R; |
| | | import com.panzhihua.common.model.vos.shop.ShopStoreVO; |
| | | import com.panzhihua.common.service.community.CommunityService; |
| | | import com.panzhihua.common.utlis.SFTPUtil; |
| | | import com.panzhihua.common.excel.CustomSheetWriteHandler; |
| | | import com.panzhihua.common.utlis.ClazzUtils; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.io.File; |
| | | import java.io.FileInputStream; |
| | | import java.io.InputStream; |
| | | import java.net.URLEncoder; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.UUID; |
| | | |
| | | /** |
| | | * @ClasssName GoodsApi 商品API |
| | | * @Description |
| | | * @Author cedoo |
| | | * @Date 2021/4/16 |
| | | * @Version 1.0 |
| | | **/ |
| | | |
| | | @Slf4j |
| | | @RestController |
| | | @RequestMapping("/funs") |
| | | @Api(tags = {"资金管理"}) |
| | | public class FundsApi extends BaseController { |
| | | |
| | | @Resource |
| | | private CommunityService communityService; |
| | | |
| | | @Value("${excel.userurl}") |
| | | private String excelUrl; |
| | | // FTP 登录用户名 |
| | | @Value("${ftp.username}") |
| | | private String userName; |
| | | // FTP 登录密码 |
| | | @Value("${ftp.password}") |
| | | private String password; |
| | | // FTP 服务器地址IP地址 |
| | | @Value("${ftp.host}") |
| | | private String host; |
| | | // FTP 端口 |
| | | @Value("${ftp.port}") |
| | | private int port; |
| | | |
| | | @ApiOperation(value = "订单分页") |
| | | @PostMapping("/page") |
| | | public R page(@RequestBody PageComShopFundsSearchDTO pageComShopFundsSearchDTO){ |
| | | pageComShopFundsSearchDTO.setUserId(getUserId()); |
| | | ClazzUtils.setIfStringIsEmpty(pageComShopFundsSearchDTO); |
| | | return communityService.pageShopFunds(pageComShopFundsSearchDTO); |
| | | } |
| | | |
| | | @ApiOperation(value = "资金统计信息") |
| | | @GetMapping("/stat") |
| | | public R stat(){ |
| | | return communityService.getFundsStat(getUserId()); |
| | | } |
| | | |
| | | @ApiOperation(value = "导出表格") |
| | | @PostMapping("/export") |
| | | @ShopOperLog(operType = 12) |
| | | public R export(@RequestBody ComShopFundsExportDTO comShopFundsExportDTO){ |
| | | ClazzUtils.setIfStringIsEmpty(comShopFundsExportDTO); |
| | | String url=excelUrl; |
| | | String uuid= UUID.randomUUID().toString().replace("-",""); |
| | | //String name=uuid+".xlsx"; |
| | | String ftpUrl="/mnt/data/web/excel/"; |
| | | |
| | | R<ShopStoreVO> storeR = communityService.getUserStoreInfo(getUserId()); |
| | | |
| | | if(!R.isOk(storeR)){ |
| | | return R.fail("用户不是商家"); |
| | | } |
| | | |
| | | ShopStoreVO shopStoreVO = JSONObject.parseObject(JSONObject.toJSONString(storeR.getData()),ShopStoreVO.class); |
| | | Long userId = this.getUserId(); |
| | | comShopFundsExportDTO.setUserId(userId); |
| | | R r=communityService.shopOrderFundsExportData(comShopFundsExportDTO); |
| | | if (R.isOk(r)) { |
| | | List<ExcelShopFundsDTO> excelShopFundsDTO = JSONArray.parseArray(JSONArray.toJSONString(r.getData()),ExcelShopFundsDTO.class); |
| | | if(excelShopFundsDTO==null||excelShopFundsDTO.size()==0){ |
| | | return R.ok("未找到数据"); |
| | | } |
| | | try { |
| | | SFTPUtil sftp = new SFTPUtil(userName,password,host,port); |
| | | sftp.login(); |
| | | String name = shopStoreVO.getName() +"-商家资金流水-" + new SimpleDateFormat("yyyyMMddhhmmss").format(new Date()) + ".xlsx"; |
| | | boolean existDir = sftp.isExistDir(ftpUrl+name); |
| | | if (!existDir) { |
| | | String property = System.getProperty("user.dir"); |
| | | String fileName = property + File.separator+name; |
| | | // 这里 需要指定写用哪个class去写 |
| | | ExcelWriter excelWriter = null; |
| | | InputStream inputStream=null; |
| | | try { |
| | | excelWriter = EasyExcel.write(fileName, ExcelShopFundsDTO.class).registerWriteHandler(new LongestMatchColumnWidthStyleStrategy()).registerWriteHandler(new CustomSheetWriteHandler()).build(); |
| | | WriteSheet writeSheet = EasyExcel.writerSheet(shopStoreVO.getName()+"订单").build(); |
| | | excelWriter.write(excelShopFundsDTO, writeSheet); |
| | | excelWriter.finish(); |
| | | File file=new File(fileName); |
| | | inputStream=new FileInputStream(file); |
| | | sftp.uploadMore(ftpUrl, name, inputStream); |
| | | sftp.logout(); |
| | | inputStream.close(); |
| | | String absolutePath = file.getAbsolutePath(); |
| | | boolean delete = file.delete(); |
| | | log.info("删除excel【{}】结果【{}】",absolutePath,delete); |
| | | } finally { |
| | | // 千万别忘记finish 会帮忙关闭流 |
| | | if (inputStream != null) { |
| | | inputStream.close(); |
| | | } |
| | | if (excelWriter != null) { |
| | | excelWriter.finish(); |
| | | } |
| | | } |
| | | } |
| | | return R.ok(url+ URLEncoder.encode(name,"UTF-8")); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | log.error("文件传输失败【{}】", e.getMessage()); |
| | | return R.fail(); |
| | | } |
| | | } |
| | | return R.fail("导出数据失败"); |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.panzhihua.shop_backstage.api; |
| | | |
| | | import com.panzhihua.common.controller.BaseController; |
| | | import com.panzhihua.common.model.dtos.shop.ComShopGoodsDTO; |
| | | import com.panzhihua.common.model.vos.R; |
| | | import com.panzhihua.common.model.vos.shop.AddShopGoodsVO; |
| | | import com.panzhihua.common.service.community.CommunityService; |
| | | import com.panzhihua.common.validated.PageGroup; |
| | | import com.panzhihua.common.interfaces.ShopOperLog; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | /** |
| | | * @ClasssName GoodsApi 商品API |
| | | * @Description |
| | | * @Author cedoo |
| | | * @Date 2021/4/16 |
| | | * @Version 1.0 |
| | | **/ |
| | | |
| | | @Slf4j |
| | | @RestController |
| | | @RequestMapping("/goods") |
| | | @Api(tags = {"商品管理"}) |
| | | public class GoodsApi extends BaseController { |
| | | |
| | | @Resource |
| | | private CommunityService communityService; |
| | | |
| | | @ApiOperation(value = "商品分页搜索") |
| | | @PostMapping("/page") |
| | | public R search(@RequestBody @Validated(PageGroup.class) ComShopGoodsDTO comShopGoodsDTO){ |
| | | return communityService.pageShopGoods(comShopGoodsDTO); |
| | | } |
| | | |
| | | @ApiOperation(value = "添加商品") |
| | | @ShopOperLog(operType = 3) |
| | | @PostMapping("/add") |
| | | public R search(@RequestBody AddShopGoodsVO addShopGoodsVO){ |
| | | return communityService.saveShopGoods(addShopGoodsVO); |
| | | } |
| | | |
| | | @ApiOperation(value = "编辑商品") |
| | | @ShopOperLog(operType = 4) |
| | | @PutMapping("/edit/{id}") |
| | | R editShopGoods(@PathVariable("id") Long id,@RequestBody AddShopGoodsVO addShopGoodsVO) { |
| | | return communityService.editShopGoods(id,addShopGoodsVO); |
| | | } |
| | | |
| | | @ApiOperation(value = "下架商品") |
| | | @ShopOperLog(operType = 5) |
| | | @PutMapping("/toggleDown/{id}") |
| | | public R toggleDown(@PathVariable("id") Long id){ |
| | | return communityService.changeStatus(id,2); |
| | | } |
| | | |
| | | @ApiOperation(value = "上架商品") |
| | | @ShopOperLog(operType = 6) |
| | | @PutMapping("/toggleUp/{id}") |
| | | public R toggleUp(@PathVariable("id") Long id){ |
| | | return communityService.changeStatus(id,1); |
| | | } |
| | | |
| | | @ApiOperation(value = "删除商品") |
| | | @ShopOperLog(operType = 7) |
| | | @DeleteMapping("/delete") |
| | | R deleteShopGoods(@RequestBody Long[] id) { |
| | | return communityService.deleteShopGoods(id); |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.panzhihua.shop_backstage.api; |
| | | |
| | | import com.panzhihua.common.controller.BaseController; |
| | | import com.panzhihua.common.model.dtos.PageDTO; |
| | | import com.panzhihua.common.model.vos.LoginUserInfoVO; |
| | | import com.panzhihua.common.model.vos.R; |
| | | import com.panzhihua.common.service.community.CommunityService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | /** |
| | | * @ClasssName GoodsApi 商品API |
| | | * @Description |
| | | * @Author cedoo |
| | | * @Date 2021/4/16 |
| | | * @Version 1.0 |
| | | **/ |
| | | |
| | | @Slf4j |
| | | @RestController |
| | | @RequestMapping("/log") |
| | | @Api(tags = {"操作日志"}) |
| | | public class LogApi extends BaseController { |
| | | |
| | | @Resource |
| | | private CommunityService communityService; |
| | | |
| | | @ApiOperation(value = "登陆用户操作日志") |
| | | @GetMapping("/page") |
| | | public R page(@RequestParam("pageNum") Long pageNum, @RequestParam("pageSize") Long pageSize){ |
| | | PageDTO pageDTO = new PageDTO(); |
| | | pageDTO.setPageNum(pageNum); |
| | | pageDTO.setPageSize(pageSize); |
| | | if(pageNum==null||new Long(0).equals(pageNum.longValue())){ |
| | | pageDTO.setPageNum(1l); |
| | | } |
| | | if(pageSize==null||new Long(0).equals(pageSize.longValue())){ |
| | | pageDTO.setPageSize(10l); |
| | | } |
| | | |
| | | LoginUserInfoVO loginUserInfoVO = this.getLoginUserInfo(); |
| | | if(loginUserInfoVO==null){ |
| | | return R.fail("未登陆"); |
| | | } |
| | | pageDTO.setUserId(loginUserInfoVO.getUserId()); |
| | | return communityService.pageShopOperLog(pageDTO); |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.panzhihua.shop_backstage.api; |
| | | |
| | | import com.panzhihua.common.controller.BaseController; |
| | | import com.panzhihua.common.model.vos.LoginUserInfoVO; |
| | | import com.panzhihua.common.model.vos.R; |
| | | import com.panzhihua.common.model.vos.user.ChangePasswordVO; |
| | | import com.panzhihua.common.service.auth.TokenService; |
| | | import com.panzhihua.common.service.user.UserService; |
| | | import com.panzhihua.common.interfaces.ShopOperLog; |
| | | import com.panzhihua.shop_backstage.model.vos.LoginBody; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.util.ObjectUtils; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | @Slf4j |
| | | @RestController |
| | | @RequestMapping("/") |
| | | @Api(tags = {"登录"}) |
| | | public class LoginApi extends BaseController { |
| | | @Resource |
| | | private TokenService tokenService; |
| | | @Resource |
| | | private UserService userService; |
| | | |
| | | @ApiOperation(value = "商家后台登录") |
| | | @ShopOperLog(operType = 1) |
| | | @PostMapping("login") |
| | | public R login(@RequestBody LoginBody loginBody){ |
| | | String account = loginBody.getAccount(); |
| | | String password = loginBody.getPassword(); |
| | | boolean empty = ObjectUtils.isEmpty(account); |
| | | boolean empty1 = ObjectUtils.isEmpty(password); |
| | | if (empty||empty1) { |
| | | return R.fail("账户密码不能为空"); |
| | | } |
| | | log.info("登录用户信息【{}】",loginBody); |
| | | R r = tokenService.loginShopBackStage(account,password); |
| | | return r; |
| | | } |
| | | |
| | | @ApiOperation(value = "修改密码") |
| | | @PutMapping("changepassword") |
| | | @ShopOperLog(operType = 2) |
| | | public R changePassword(@Validated @RequestBody ChangePasswordVO changePasswordVO){ |
| | | Long userId = this.getUserId(); |
| | | String newPassword = changePasswordVO.getNewPassword(); |
| | | String oldPassword=changePasswordVO.getOldPassword(); |
| | | if (newPassword.equals(oldPassword)) { |
| | | return R.fail("修改失败,新密码和原密码一致"); |
| | | } |
| | | changePasswordVO.setUserId(userId); |
| | | return userService.changePassword(changePasswordVO); |
| | | } |
| | | |
| | | @ApiOperation(value = "当前登录用户信息",response = LoginUserInfoVO.class) |
| | | @GetMapping("user") |
| | | public R detailUser(){ |
| | | Long userId = this.getUserId(); |
| | | return userService.detailUser(userId); |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.panzhihua.shop_backstage.api; |
| | | |
| | | import com.alibaba.excel.EasyExcel; |
| | | import com.alibaba.excel.ExcelWriter; |
| | | import com.alibaba.excel.write.metadata.WriteSheet; |
| | | import com.alibaba.excel.write.style.column.LongestMatchColumnWidthStyleStrategy; |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.panzhihua.common.controller.BaseController; |
| | | import com.panzhihua.common.model.dtos.shop.*; |
| | | import com.panzhihua.common.model.vos.R; |
| | | import com.panzhihua.common.interfaces.ShopOperLog; |
| | | import com.panzhihua.common.model.vos.shop.ComShopOrderPageVO; |
| | | import com.panzhihua.common.model.vos.shop.ShopStoreVO; |
| | | import com.panzhihua.common.service.community.CommunityService; |
| | | import com.panzhihua.common.utlis.SFTPUtil; |
| | | import com.panzhihua.common.excel.CustomSheetWriteHandler; |
| | | import com.panzhihua.common.utlis.ClazzUtils; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.io.File; |
| | | import java.io.FileInputStream; |
| | | import java.io.InputStream; |
| | | import java.net.URLEncoder; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.UUID; |
| | | |
| | | /** |
| | | * @ClasssName GoodsApi 商品API |
| | | * @Description |
| | | * @Author cedoo |
| | | * @Date 2021/4/16 |
| | | * @Version 1.0 |
| | | **/ |
| | | |
| | | @Slf4j |
| | | @RestController |
| | | @RequestMapping("/order") |
| | | @Api(tags = {"订单管理"}) |
| | | public class OrderApi extends BaseController { |
| | | |
| | | @Resource |
| | | private CommunityService communityService; |
| | | |
| | | @Value("${excel.userurl}") |
| | | private String excelUrl; |
| | | // FTP 登录用户名 |
| | | @Value("${ftp.username}") |
| | | private String userName; |
| | | // FTP 登录密码 |
| | | @Value("${ftp.password}") |
| | | private String password; |
| | | // FTP 服务器地址IP地址 |
| | | @Value("${ftp.host}") |
| | | private String host; |
| | | // FTP 端口 |
| | | @Value("${ftp.port}") |
| | | private int port; |
| | | |
| | | @ApiOperation(value = "订单分页") |
| | | @PostMapping("") |
| | | public R page(@RequestBody @Validated PageComShopOrderSearchDTO pageComShopOrderSearchDTO){ |
| | | pageComShopOrderSearchDTO.setUserId(this.getUserId()); |
| | | ClazzUtils.setIfStringIsEmpty(pageComShopOrderSearchDTO); |
| | | return communityService.pageShopOrder(pageComShopOrderSearchDTO); |
| | | } |
| | | |
| | | @ApiOperation(value = "取消订单") |
| | | @PutMapping("/cancel") |
| | | @ShopOperLog(operType = 8) |
| | | public R cancel(@RequestBody ComShopOrderQueryDTO comShopOrderQueryDTO){ |
| | | return communityService.orderCancel(comShopOrderQueryDTO); |
| | | } |
| | | |
| | | @ApiOperation(value = "发货") |
| | | @PutMapping("/ship") |
| | | @ShopOperLog(operType = 9) |
| | | public R ship(@RequestBody ComShopOrderShipDTO orderShipDTO){ |
| | | return communityService.shipOrder(orderShipDTO); |
| | | } |
| | | |
| | | @ApiOperation(value = "配送") |
| | | @PutMapping("/startDeliver") |
| | | @ShopOperLog(operType = 10) |
| | | public R deliver(@RequestBody ComShopOrderDeliverDTO deliverDTO){ |
| | | return communityService.deliverOrder(deliverDTO); |
| | | } |
| | | |
| | | @ApiOperation(value = "配送完成") |
| | | @PutMapping("/finishDeliver") |
| | | public R finishDeliver(@RequestBody ComShopOrderDeliverDTO deliverDTO){ |
| | | return communityService.finishDeliverOrder(deliverDTO); |
| | | } |
| | | |
| | | @ApiOperation(value = "订单详细",response = ComShopOrderPageVO.class) |
| | | @GetMapping("/detail") |
| | | @ShopOperLog(operType = 11) |
| | | public R detail(@RequestParam("orderId") Long orderId){ |
| | | return communityService.orderDetail(orderId); |
| | | } |
| | | |
| | | @ApiOperation(value = "导出表格") |
| | | @PostMapping("/export") |
| | | @ShopOperLog(operType = 12) |
| | | public R export(@RequestBody ComShopOrderExportDTO comShopOrderExportDTO){ |
| | | ClazzUtils.setIfStringIsEmpty(comShopOrderExportDTO); |
| | | String url=excelUrl; |
| | | String uuid= UUID.randomUUID().toString().replace("-",""); |
| | | //String name=uuid+".xlsx"; |
| | | String ftpUrl="/mnt/data/web/excel/"; |
| | | |
| | | R<ShopStoreVO> storeR = communityService.getUserStoreInfo(getUserId()); |
| | | |
| | | if(!R.isOk(storeR)){ |
| | | return R.fail("用户不是商家"); |
| | | } |
| | | |
| | | ShopStoreVO shopStoreVO = JSONObject.parseObject(JSONObject.toJSONString(storeR.getData()),ShopStoreVO.class); |
| | | Long userId = this.getUserId(); |
| | | comShopOrderExportDTO.setUserId(userId); |
| | | R r=communityService.shopOrderExportData(comShopOrderExportDTO); |
| | | if (R.isOk(r)) { |
| | | List<ExcelShopOrderDTO> excelShopOrderDTO = JSONArray.parseArray(JSONArray.toJSONString(r.getData()),ExcelShopOrderDTO.class); |
| | | if(excelShopOrderDTO==null||excelShopOrderDTO.size()==0){ |
| | | return R.ok("未找到数据"); |
| | | } |
| | | try { |
| | | SFTPUtil sftp = new SFTPUtil(userName,password,host,port); |
| | | sftp.login(); |
| | | String name = shopStoreVO.getName() +"商城订单-" + new SimpleDateFormat("yyyyMMddhhmmss").format(new Date()) + ".xlsx"; |
| | | boolean existDir = sftp.isExistDir(ftpUrl+name); |
| | | if (!existDir) { |
| | | String property = System.getProperty("user.dir"); |
| | | String fileName = property + File.separator+name; |
| | | // 这里 需要指定写用哪个class去写 |
| | | ExcelWriter excelWriter = null; |
| | | InputStream inputStream=null; |
| | | try { |
| | | excelWriter = EasyExcel.write(fileName, ExcelShopOrderDTO.class).registerWriteHandler(new LongestMatchColumnWidthStyleStrategy()).registerWriteHandler(new CustomSheetWriteHandler()).build(); |
| | | WriteSheet writeSheet = EasyExcel.writerSheet(shopStoreVO.getName()+"订单").build(); |
| | | excelWriter.write(excelShopOrderDTO, writeSheet); |
| | | excelWriter.finish(); |
| | | File file=new File(fileName); |
| | | inputStream=new FileInputStream(file); |
| | | sftp.uploadMore(ftpUrl, name, inputStream); |
| | | sftp.logout(); |
| | | inputStream.close(); |
| | | String absolutePath = file.getAbsolutePath(); |
| | | boolean delete = file.delete(); |
| | | log.info("删除excel【{}】结果【{}】",absolutePath,delete); |
| | | } finally { |
| | | // 千万别忘记finish 会帮忙关闭流 |
| | | if (inputStream != null) { |
| | | inputStream.close(); |
| | | } |
| | | if (excelWriter != null) { |
| | | excelWriter.finish(); |
| | | } |
| | | } |
| | | } |
| | | return R.ok(url+ URLEncoder.encode(name,"UTF-8")); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | log.error("文件传输失败【{}】", e.getMessage()); |
| | | return R.fail(); |
| | | } |
| | | } |
| | | return R.fail("导出数据失败"); |
| | | } |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.panzhihua.shop_backstage.config; |
| | | |
| | | import lombok.Data; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.context.annotation.Configuration; |
| | | |
| | | /** |
| | | * @Author: llming |
| | | * @Description: |
| | | */ |
| | | @Configuration |
| | | @Data |
| | | public class SFTPConfig { |
| | | // FTP 登录用户名 |
| | | @Value("${ftp.username}") |
| | | private String userName; |
| | | // FTP 登录密码 |
| | | @Value("${ftp.password}") |
| | | private String password; |
| | | // FTP 服务器地址IP地址 |
| | | @Value("${ftp.host}") |
| | | private String host; |
| | | // FTP 端口 |
| | | @Value("${ftp.port}") |
| | | private int port; |
| | | @Value("${ftp.url}") |
| | | private String url; |
| | | @Value("${excel.userurl}") |
| | | private String excelUrl; |
| | | } |
New file |
| | |
| | | package com.panzhihua.shop_backstage.config; |
| | | |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.context.annotation.Bean; |
| | | import org.springframework.context.annotation.Configuration; |
| | | import springfox.documentation.builders.ApiInfoBuilder; |
| | | import springfox.documentation.builders.PathSelectors; |
| | | import springfox.documentation.builders.RequestHandlerSelectors; |
| | | import springfox.documentation.service.ApiInfo; |
| | | import springfox.documentation.service.Contact; |
| | | import springfox.documentation.spi.DocumentationType; |
| | | import springfox.documentation.spring.web.plugins.Docket; |
| | | |
| | | /** |
| | | * @program: springcloud_k8s_panzhihuazhihuishequ |
| | | * @description: swagger3 |
| | | * @author: huang.hongfa weixin hhf9596 qq 959656820 |
| | | * @create: 2020-11-19 16:08 |
| | | **/ |
| | | @Configuration |
| | | public class SwaggerConfig { |
| | | @Bean |
| | | public Docket createRestApi() { |
| | | return new Docket(DocumentationType.SWAGGER_2) |
| | | .apiInfo(apiInfo()) |
| | | .select() |
| | | .apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class)) |
| | | .paths(PathSelectors.any()) |
| | | .build(); |
| | | } |
| | | |
| | | private ApiInfo apiInfo() { |
| | | return new ApiInfoBuilder() |
| | | .title("商家后台管理接口") |
| | | .description("。") |
| | | .contact(new Contact("Ray。", "http://www.ruiyeclub.cn", "ruiyeclub@foxmail.com")) |
| | | .version("1.0") |
| | | .build(); |
| | | } |
| | | } |
New file |
| | |
| | | package com.panzhihua.shop_backstage.model.vos; |
| | | |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.Data; |
| | | import lombok.NoArgsConstructor; |
| | | |
| | | /** |
| | | * @program: springcloud_k8s_panzhihuazhihuishequ |
| | | * @description: 登录 |
| | | * @author: huang.hongfa weixin hhf9596 qq 959656820 |
| | | * @create: 2020-11-24 10:54 |
| | | **/ |
| | | @Data |
| | | @ApiModel(value = "小程序后台登录") |
| | | @AllArgsConstructor |
| | | @NoArgsConstructor |
| | | public class LoginBody { |
| | | |
| | | @ApiModelProperty(value = "登录账户") |
| | | private String account; |
| | | @ApiModelProperty(value = "登录密码") |
| | | private String password; |
| | | |
| | | } |
New file |
| | |
| | | spring: |
| | | application: |
| | | name: shopbackstage |
| | | cloud: |
| | | config: |
| | | discovery: |
| | | enabled: true |
| | | service-id: config # 注册中心的服务名 |
| | | profile: ${ENV:dev} # 指定配置文件的环境 |
| | | uri: http://${CONFIG_URL:localhost}:8193/ |
| | | profiles: |
| | | active: ${ENV:dev} |
| | | servlet: |
| | | multipart: |
| | | max-file-size: 10MB |
| | | max-request-size: 10MB |
| | | |
| | | eureka: |
| | | client: |
| | | service-url: |
| | | defaultZone: http://${EUREKA_URL:localhost}:8192/eureka |
| | | |
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <configuration debug="false"> |
| | | <!--定义日志文件的存储地址 勿在 LogBack 的配置中使用相对路径--> |
| | | <springProfile name="dev"> |
| | | <property name="LOG_HOME" value="F:/log" /> |
| | | </springProfile> |
| | | <springProfile name="test"> |
| | | <property name="LOG_HOME" value="/mnt/data/gocd/log" /> |
| | | </springProfile> |
| | | <property name="LOG_HOME" value="/mnt/data/gocd/log" /> |
| | | <!-- 控制台输出 --> |
| | | <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> |
| | | <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder"> |
| | | <!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度%msg:日志消息,%n是换行符--> |
| | | <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern> |
| | | </encoder> |
| | | </appender> |
| | | <!-- 按照每天生成日志文件 --> |
| | | <appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> |
| | | <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> |
| | | <!--日志文件输出的文件名--> |
| | | <FileNamePattern>${LOG_HOME}/shop_backstage.log.%d{yyyy-MM-dd}.log</FileNamePattern> |
| | | <!--日志文件保留天数--> |
| | | <MaxHistory>30</MaxHistory> |
| | | </rollingPolicy> |
| | | <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder"> |
| | | <!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度%msg:日志消息,%n是换行符--> |
| | | <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern> |
| | | </encoder> |
| | | <!--日志文件最大的大小--> |
| | | <triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy"> |
| | | <MaxFileSize>10MB</MaxFileSize> |
| | | </triggeringPolicy> |
| | | </appender> |
| | | |
| | | <!--myibatis log configure--> |
| | | <logger name="com.apache.ibatis" level="TRACE"/> |
| | | <logger name="java.sql.Connection" level="DEBUG"/> |
| | | <logger name="java.sql.Statement" level="DEBUG"/> |
| | | <logger name="java.sql.PreparedStatement" level="DEBUG"/> |
| | | <logger name="com.panzhihua.shop_backstage" level="DEBUG"/> |
| | | |
| | | <!-- 日志输出级别 --> |
| | | <root level="DEBUG"> |
| | | <appender-ref ref="STDOUT" /> |
| | | </root> |
| | | <root level="INFO"> |
| | | <appender-ref ref="STDOUT" /> |
| | | <appender-ref ref="FILE" /> |
| | | </root> |
| | | </configuration> |
| | |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.cloud.netflix.zuul.filters.Route; |
| | | import org.springframework.cloud.netflix.zuul.filters.RouteLocator; |
| | | import org.springframework.context.MessageSource; |
| | | import org.springframework.context.annotation.Bean; |
| | | import org.springframework.context.annotation.Configuration; |
| | | import org.springframework.context.annotation.Primary; |
| | |
| | | import springfox.documentation.swagger.web.SwaggerResourcesProvider; |
| | | import springfox.documentation.swagger2.annotations.EnableSwagger2; |
| | | |
| | | import java.text.MessageFormat; |
| | | import java.util.*; |
| | | |
| | | import static java.util.stream.Collectors.collectingAndThen; |
| | |
| | | //RouteLocator可以根据zuul配置的路由列表获取服务 |
| | | private final RouteLocator routeLocator; |
| | | |
| | | private String[]ids=new String[]{"appletsbackstage","applets","communitybackstage"}; |
| | | private String[]ids=new String[]{"appletsbackstage","applets","communitybackstage", "shopbackstage"}; |
| | | |
| | | public SwaggerConfig(RouteLocator routeLocator) { |
| | | this.routeLocator = routeLocator; |
| | |
| | | @Override |
| | | public List<SwaggerResource> get() { |
| | | List resources = new ArrayList(); |
| | | List<Route> routes = routeLocator.getRoutes(); |
| | | routes = routes.stream().collect( |
| | | collectingAndThen( |
| | | toCollection(() -> new TreeSet<>(Comparator.comparing(Route::getId))), ArrayList::new) |
| | | ); |
| | | //通过RouteLocator获取路由配置,遍历获取所配置服务的接口文档,这样不需要手动添加,实现动态获取 |
| | | List<String>stringList= Arrays.asList(ids); |
| | | for (Route route: routes) { |
| | | String id = route.getId(); |
| | | boolean contains = stringList.contains(id); |
| | | String fullPath = route.getFullPath(); |
| | | String s = fullPath.replaceFirst("/api", ""); |
| | | String s1 = s.replaceFirst("/" + id, ""); |
| | | if (contains) { |
| | | resources.add(swaggerResource(id,s1.replace("**", "v2/api-docs"),"1.0")); |
| | | } |
| | | } |
| | | Arrays.asList(ids).forEach(id->{ |
| | | resources.add(swaggerResource(id, MessageFormat.format("/api/{0}/v2/api-docs", id), "1.0")); |
| | | }); |
| | | return resources; |
| | | } |
| | | |