diff --git a/src/main/java/com/pixelai/api/component/controller/CpLabelController.java b/src/main/java/com/pixelai/api/component/controller/CpLabelController.java index 01256f0..49ea6ca 100644 --- a/src/main/java/com/pixelai/api/component/controller/CpLabelController.java +++ b/src/main/java/com/pixelai/api/component/controller/CpLabelController.java @@ -94,6 +94,7 @@ public class CpLabelController extends BaseController { @ApiOperation(value = "查询单个标签") @RequestMapping(value = "{id}", method = {RequestMethod.GET}) @ApiImplicitParam(name = "id", value = "标签ID", required = true, paramType = "path") + @Unsecured public Result one(@PathVariable final Integer id) { try { CpLabel entity = entityService.getLabelById(id); diff --git a/src/main/java/com/pixelai/api/log/controller/AcLogController.java b/src/main/java/com/pixelai/api/log/controller/AcLogController.java index 4c894d8..59934fe 100644 --- a/src/main/java/com/pixelai/api/log/controller/AcLogController.java +++ b/src/main/java/com/pixelai/api/log/controller/AcLogController.java @@ -59,7 +59,7 @@ public class AcLogController extends BaseController { private PaConsumptionService paConsumptionService; @SysLog(action = "statistics:basicInformation", value = "") - @ApiOperation(value = "统计基础信息:用户数,今天新增用户数,首页总浏览数,今日浏览数") + @ApiOperation(value = "统计基础信息:用户数,今天新增用户数,首页总浏览数,今日浏览数,今日充值数,总充值数") @GetMapping("basicInformation") public Result basicInformation() { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd", Locale.getDefault()); @@ -74,13 +74,36 @@ public class AcLogController extends BaseController { Integer userTotalCount=acUserService.count(); Integer userTodayCount=acUserService.lambdaQuery() .between(AcUser::getCreatetime, Timestamp.valueOf(today),Timestamp.valueOf(tomorrow)).count(); + Integer HomeviewTotalCount=entityService.lambdaQuery() .eq(AcLog::getAction,"homeViews").count(); Integer HomeviewCount=entityService.lambdaQuery() .eq(AcLog::getAction,"homeViews") .between(AcLog::getCreatetime, Timestamp.valueOf(today),Timestamp.valueOf(tomorrow)).count(); - BasicInformationVo basicInformationVo=new BasicInformationVo(userTotalCount,userTodayCount,HomeviewTotalCount,HomeviewCount); + List paConsumptions=paConsumptionService.lambdaQuery() + .between(PaConsumption::getCreatetime, Timestamp.valueOf(today),Timestamp.valueOf(tomorrow)).list(); + Integer rechargeTodayAmount=0; + Integer consumptionTodayAmount=0; + for (PaConsumption paConsumption:paConsumptions){ + if(paConsumption.getAddOrSub().equals("add")){ + rechargeTodayAmount=rechargeTodayAmount+paConsumption.getValue(); + }else{ + consumptionTodayAmount=consumptionTodayAmount+paConsumption.getValue(); + } + } + + paConsumptions=paConsumptionService.lambdaQuery().list(); + Integer rechargeAmount=0; + Integer consumptionAmount=0; + for (PaConsumption paConsumption:paConsumptions){ + if(paConsumption.getAddOrSub().equals("add")){ + rechargeAmount=rechargeAmount+paConsumption.getValue(); + }else{ + consumptionAmount=consumptionAmount+paConsumption.getValue(); + } + } + BasicInformationVo basicInformationVo=new BasicInformationVo(userTotalCount,userTodayCount,HomeviewTotalCount,HomeviewCount,rechargeTodayAmount,rechargeAmount,consumptionTodayAmount,consumptionAmount); return new Result(true, basicInformationVo); } diff --git a/src/main/java/com/pixelai/api/log/vo/BasicInformationVo.java b/src/main/java/com/pixelai/api/log/vo/BasicInformationVo.java index 318c4b7..6845add 100644 --- a/src/main/java/com/pixelai/api/log/vo/BasicInformationVo.java +++ b/src/main/java/com/pixelai/api/log/vo/BasicInformationVo.java @@ -15,4 +15,12 @@ public class BasicInformationVo { private Integer HomeviewCount; @ApiModelProperty("今日浏览数") private Integer HomeviewTodayCount; + @ApiModelProperty("今日充值数") + private Integer rechargeTodayAmount; + @ApiModelProperty("总充值数") + private Integer rechargeAmount; + @ApiModelProperty("今日消费数") + private Integer consumptionTodayAmount; + @ApiModelProperty("总消费数") + private Integer consumptionAmount; } diff --git a/src/main/java/com/pixelai/api/pa/controller/PaCollectionController.java b/src/main/java/com/pixelai/api/pa/controller/PaCollectionController.java index b0cd7c4..f3e5e3e 100644 --- a/src/main/java/com/pixelai/api/pa/controller/PaCollectionController.java +++ b/src/main/java/com/pixelai/api/pa/controller/PaCollectionController.java @@ -1,5 +1,8 @@ package com.pixelai.api.pa.controller; +import com.pixelai.api.pa.entity.PaCreation; +import com.pixelai.api.pa.vo.PaCollectionVo; +import com.pixelai.api.user.service.AcUserService; import org.springframework.web.bind.annotation.RequestMapping; import com.base.annotation.SysLog; import org.springframework.web.bind.annotation.RestController; @@ -19,6 +22,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import javax.validation.Valid; import java.util.Collections; +import java.util.Date; import java.util.List; import java.util.Map; @@ -30,106 +34,116 @@ import java.util.Map; * @author gjj * @since 2024-12-05 */ -@Api(tags = "PaCollection") +@Api(tags = "用户收藏") @RestController @RequestMapping("/paCollection") public class PaCollectionController extends BaseController { - private static final Logger LOG = LoggerFactory.getLogger(PaCollectionController.class); - @Autowired - private PaCollectionService entityService; + private static final Logger LOG = LoggerFactory.getLogger(PaCollectionController.class); + @Autowired + private PaCollectionService entityService; + @Autowired + private AcUserService acUserService; - @SysLog(action = "findByPage", value = "分页查询订单") - @ApiOperation(value = "分页查询订单", notes = "分页查询订单") - @RequestMapping(method = RequestMethod.GET) - @ApiImplicitParams({@ApiImplicitParam(name = "size", value = "分页大小", paramType = "query"), - @ApiImplicitParam(name = "current", value = "当前页面:从1开始", paramType = "query")}) - public Result> findByPage(final PaCollection example, final Page page) { - IPage records = entityService.page(example,page); - return new Result(true, records); + @SysLog(action = "findByPage", value = "分页查询收藏") + @ApiOperation(value = "分页查询收藏", notes = "分页查询收藏") + @RequestMapping(method = RequestMethod.GET) + @ApiImplicitParams({@ApiImplicitParam(name = "size", value = "分页大小", paramType = "query"), + @ApiImplicitParam(name = "current", value = "当前页面:从1开始", paramType = "query")}) + public Result> findByPage(final PaCollection example, final Page page) { + IPage records = entityService.findByPage(example,page); + return new Result(true, records); + } + + @SysLog(action = "delete", value = "删除收藏") + @ApiOperation(value = "删除收藏") + @RequestMapping(value = "{id}", method = {RequestMethod.DELETE}) + @ApiImplicitParam(name = "id", value = "收藏ID", required = true, paramType = "path") + public Result delete(@PathVariable final Integer id) { + try { + PaCollection paCollection = entityService.getById(id); + paCollection.setState("f"); + entityService.updateById(paCollection); + return new Result(true, "成功删除收藏", null); + } catch (DataIntegrityViolationException e) { + LOG.error("删除收藏失败", e); + return new Result(false, "删除收藏失败", "该收藏不能删除,存在其他关联数据"); + } catch (Exception e) { + LOG.error("删除收藏失败", e); + return new Result(false, "删除收藏失败", e.getMessage()); } + } - @SysLog(action = "delete", value = "删除订单") - @ApiOperation(value = "删除订单") - @RequestMapping(value = "{id}", method = {RequestMethod.DELETE}) - @ApiImplicitParam(name = "id", value = "订单ID", required = true, paramType = "path") - public Result delete(@PathVariable final Integer id) { - try { - entityService.removeById(id); - return new Result(true, "成功删除订单", null); - } catch (DataIntegrityViolationException e) { - LOG.error("删除订单失败", e); - return new Result(false, "删除订单失败", "该订单不能删除,存在其他关联数据"); - } catch (Exception e) { - LOG.error("删除订单失败", e); - return new Result(false, "删除订单失败", e.getMessage()); - } - } +// @SysLog(action = "one", value = "查询单个收藏") +// @ApiOperation(value = "查询单个收藏") +// @RequestMapping(value = "{id}", method = {RequestMethod.GET}) +// @ApiImplicitParam(name = "id", value = "收藏ID", required = true, paramType = "path") +// public Result one(@PathVariable final Integer id) { +// try { +// PaCollection entity = entityService.getById(id); +// return new Result(true, entity); +// } catch (Exception e) { +// LOG.error("查询单个收藏失败", e); +// return new Result(false, new PaCollection()); +// } +// } - @SysLog(action = "one", value = "查询单个订单") - @ApiOperation(value = "查询单个订单") - @RequestMapping(value = "{id}", method = {RequestMethod.GET}) - @ApiImplicitParam(name = "id", value = "订单ID", required = true, paramType = "path") - public Result one(@PathVariable final Integer id) { - try { - PaCollection entity = entityService.getById(id); - return new Result(true, entity); - } catch (Exception e) { - LOG.error("查询单个订单失败", e); - return new Result(false, new PaCollection()); - } - } - - @SysLog(action = "add", value = "添加订单") - @ApiOperation(value = "添加订单") - @RequestMapping(method = {RequestMethod.POST}) - public Result add(@Valid @RequestBody final PaCollection entity, final BindingResult result) { - try { - if (result.hasErrors()) { - Map map = this.getErrors(result); - String errorMsg = map.entrySet().iterator().next().getValue(); - return new Result(false, "保存订单失败", errorMsg, map); - } else { - entityService.save(entity); - return new Result(true, "成功保存订单", null); + @SysLog(action = "add", value = "收藏作品") + @ApiOperation(value = "收藏作品") + @RequestMapping(method = {RequestMethod.POST}) + public Result add(@Valid @RequestBody final PaCollection entity, final BindingResult result) { + try { + if (result.hasErrors()) { + Map map = this.getErrors(result); + String errorMsg = map.entrySet().iterator().next().getValue(); + return new Result(false, "保存收藏失败", errorMsg, map); + } else { + Integer userid=acUserService.getUserId(); + if (userid==null){ + return new Result(false, "用户不存在"); } - } catch (Exception e) { - LOG.error("添加订单失败", e); - return new Result(false, "保存订单失败", e.getMessage()); + entity.setState("t"); + entity.setUserId(userid); + entity.setCreatetime(new Date()); + entityService.save(entity); + return new Result(true, "成功保存收藏", null); } + } catch (Exception e) { + LOG.error("添加收藏失败", e); + return new Result(false, "保存收藏失败", e.getMessage()); } + } - @SysLog(action = "update", value = "修改订单") - @ApiOperation(value = "修改订单") - @RequestMapping(method = {RequestMethod.PUT}) - public Result update(@Valid @RequestBody final PaCollection entity, final BindingResult result) { - try { - if (result.hasErrors()) { - Map map = this.getErrors(result); - String errorMsg = map.entrySet().iterator().next().getValue(); - return new Result(false, "修改订单失败", errorMsg, map); - } else { - if (null == entity.getId()) { - throw new RuntimeException("id不能为空"); - } - entityService.updateById(entity); - return new Result(true, "成功修改订单", null); - } - } catch (Exception e) { - LOG.error("修改订单失败", e); - return new Result(false, "修改订单失败", e.getMessage()); - } - } - - @ApiOperation(value = "全部订单") - @RequestMapping(value = "all", method = RequestMethod.GET) - public Result> all(PaCollection example) { - List entitys = entityService.list(example); - if (null != entitys) { - return new Result<>(true, entitys); - } - return new Result<>(true, Collections.emptyList()); - } +// @SysLog(action = "update", value = "修改收藏") +// @ApiOperation(value = "修改收藏") +// @RequestMapping(method = {RequestMethod.PUT}) +// public Result update(@Valid @RequestBody final PaCollection entity, final BindingResult result) { +// try { +// if (result.hasErrors()) { +// Map map = this.getErrors(result); +// String errorMsg = map.entrySet().iterator().next().getValue(); +// return new Result(false, "修改收藏失败", errorMsg, map); +// } else { +// if (null == entity.getId()) { +// throw new RuntimeException("id不能为空"); +// } +// entityService.updateById(entity); +// return new Result(true, "成功修改收藏", null); +// } +// } catch (Exception e) { +// LOG.error("修改收藏失败", e); +// return new Result(false, "修改收藏失败", e.getMessage()); +// } +// } +// +// @ApiOperation(value = "全部收藏") +// @RequestMapping(value = "all", method = RequestMethod.GET) +// public Result> all(PaCollection example) { +// List entitys = entityService.list(example); +// if (null != entitys) { +// return new Result<>(true, entitys); +// } +// return new Result<>(true, Collections.emptyList()); +// } } - diff --git a/src/main/java/com/pixelai/api/pa/controller/PaConsumptionController.java b/src/main/java/com/pixelai/api/pa/controller/PaConsumptionController.java index 823e669..41b1b78 100644 --- a/src/main/java/com/pixelai/api/pa/controller/PaConsumptionController.java +++ b/src/main/java/com/pixelai/api/pa/controller/PaConsumptionController.java @@ -35,101 +35,100 @@ import java.util.Map; @RequestMapping("/paConsumption") public class PaConsumptionController extends BaseController { - private static final Logger LOG = LoggerFactory.getLogger(PaConsumptionController.class); - @Autowired - private PaConsumptionService entityService; + private static final Logger LOG = LoggerFactory.getLogger(PaConsumptionController.class); + @Autowired + private PaConsumptionService entityService; - @SysLog(action = "findByPage", value = "分页查询订单") - @ApiOperation(value = "分页查询订单", notes = "分页查询订单") - @RequestMapping(method = RequestMethod.GET) - @ApiImplicitParams({@ApiImplicitParam(name = "size", value = "分页大小", paramType = "query"), - @ApiImplicitParam(name = "current", value = "当前页面:从1开始", paramType = "query")}) - public Result> findByPage(final PaConsumption example, final Page page) { - IPage records = entityService.page(example,page); - return new Result(true, records); + @SysLog(action = "findByPage", value = "分页查询生成记录") + @ApiOperation(value = "分页查询生成记录", notes = "分页查询生成记录") + @RequestMapping(method = RequestMethod.GET) + @ApiImplicitParams({@ApiImplicitParam(name = "size", value = "分页大小", paramType = "query"), + @ApiImplicitParam(name = "current", value = "当前页面:从1开始", paramType = "query")}) + public Result> findByPage(final PaConsumption example, final Page page) { + IPage records = entityService.page(example,page); + return new Result(true, records); + } + + @SysLog(action = "delete", value = "删除生成记录") + @ApiOperation(value = "删除生成记录") + @RequestMapping(value = "{id}", method = {RequestMethod.DELETE}) + @ApiImplicitParam(name = "id", value = "生成记录ID", required = true, paramType = "path") + public Result delete(@PathVariable final Integer id) { + try { + entityService.removeById(id); + return new Result(true, "成功删除生成记录", null); + } catch (DataIntegrityViolationException e) { + LOG.error("删除生成记录失败", e); + return new Result(false, "删除生成记录失败", "该生成记录不能删除,存在其他关联数据"); + } catch (Exception e) { + LOG.error("删除生成记录失败", e); + return new Result(false, "删除生成记录失败", e.getMessage()); } + } - @SysLog(action = "delete", value = "删除订单") - @ApiOperation(value = "删除订单") - @RequestMapping(value = "{id}", method = {RequestMethod.DELETE}) - @ApiImplicitParam(name = "id", value = "订单ID", required = true, paramType = "path") - public Result delete(@PathVariable final Integer id) { - try { - entityService.removeById(id); - return new Result(true, "成功删除订单", null); - } catch (DataIntegrityViolationException e) { - LOG.error("删除订单失败", e); - return new Result(false, "删除订单失败", "该订单不能删除,存在其他关联数据"); - } catch (Exception e) { - LOG.error("删除订单失败", e); - return new Result(false, "删除订单失败", e.getMessage()); + @SysLog(action = "one", value = "查询单个生成记录") + @ApiOperation(value = "查询单个生成记录") + @RequestMapping(value = "{id}", method = {RequestMethod.GET}) + @ApiImplicitParam(name = "id", value = "生成记录ID", required = true, paramType = "path") + public Result one(@PathVariable final Integer id) { + try { + PaConsumption entity = entityService.getById(id); + return new Result(true, entity); + } catch (Exception e) { + LOG.error("查询单个生成记录失败", e); + return new Result(false, new PaConsumption()); + } + } + + @SysLog(action = "add", value = "添加生成记录") + @ApiOperation(value = "添加生成记录") + @RequestMapping(method = {RequestMethod.POST}) + public Result add(@Valid @RequestBody final PaConsumption entity, final BindingResult result) { + try { + if (result.hasErrors()) { + Map map = this.getErrors(result); + String errorMsg = map.entrySet().iterator().next().getValue(); + return new Result(false, "保存生成记录失败", errorMsg, map); + } else { + entityService.save(entity); + return new Result(true, "成功保存生成记录", null); } + } catch (Exception e) { + LOG.error("添加生成记录失败", e); + return new Result(false, "保存生成记录失败", e.getMessage()); } + } - @SysLog(action = "one", value = "查询单个订单") - @ApiOperation(value = "查询单个订单") - @RequestMapping(value = "{id}", method = {RequestMethod.GET}) - @ApiImplicitParam(name = "id", value = "订单ID", required = true, paramType = "path") - public Result one(@PathVariable final Integer id) { - try { - PaConsumption entity = entityService.getById(id); - return new Result(true, entity); - } catch (Exception e) { - LOG.error("查询单个订单失败", e); - return new Result(false, new PaConsumption()); - } - } - - @SysLog(action = "add", value = "添加订单") - @ApiOperation(value = "添加订单") - @RequestMapping(method = {RequestMethod.POST}) - public Result add(@Valid @RequestBody final PaConsumption entity, final BindingResult result) { - try { - if (result.hasErrors()) { - Map map = this.getErrors(result); - String errorMsg = map.entrySet().iterator().next().getValue(); - return new Result(false, "保存订单失败", errorMsg, map); - } else { - entityService.save(entity); - return new Result(true, "成功保存订单", null); + @SysLog(action = "update", value = "修改生成记录") + @ApiOperation(value = "修改生成记录") + @RequestMapping(method = {RequestMethod.PUT}) + public Result update(@Valid @RequestBody final PaConsumption entity, final BindingResult result) { + try { + if (result.hasErrors()) { + Map map = this.getErrors(result); + String errorMsg = map.entrySet().iterator().next().getValue(); + return new Result(false, "修改生成记录失败", errorMsg, map); + } else { + if (null == entity.getId()) { + throw new RuntimeException("id不能为空"); } - } catch (Exception e) { - LOG.error("添加订单失败", e); - return new Result(false, "保存订单失败", e.getMessage()); + entityService.updateById(entity); + return new Result(true, "成功修改生成记录", null); } + } catch (Exception e) { + LOG.error("修改生成记录失败", e); + return new Result(false, "修改生成记录失败", e.getMessage()); } + } - @SysLog(action = "update", value = "修改订单") - @ApiOperation(value = "修改订单") - @RequestMapping(method = {RequestMethod.PUT}) - public Result update(@Valid @RequestBody final PaConsumption entity, final BindingResult result) { - try { - if (result.hasErrors()) { - Map map = this.getErrors(result); - String errorMsg = map.entrySet().iterator().next().getValue(); - return new Result(false, "修改订单失败", errorMsg, map); - } else { - if (null == entity.getId()) { - throw new RuntimeException("id不能为空"); - } - entityService.updateById(entity); - return new Result(true, "成功修改订单", null); - } - } catch (Exception e) { - LOG.error("修改订单失败", e); - return new Result(false, "修改订单失败", e.getMessage()); - } - } - - @ApiOperation(value = "全部订单") - @RequestMapping(value = "all", method = RequestMethod.GET) - public Result> all(PaConsumption example) { - List entitys = entityService.list(example); - if (null != entitys) { - return new Result<>(true, entitys); - } - return new Result<>(true, Collections.emptyList()); + @ApiOperation(value = "全部生成记录") + @RequestMapping(value = "all", method = RequestMethod.GET) + public Result> all(PaConsumption example) { + List entitys = entityService.list(example); + if (null != entitys) { + return new Result<>(true, entitys); } + return new Result<>(true, Collections.emptyList()); + } } - diff --git a/src/main/java/com/pixelai/api/pa/dao/PaCollectionMapper.java b/src/main/java/com/pixelai/api/pa/dao/PaCollectionMapper.java index 757ba46..f000181 100644 --- a/src/main/java/com/pixelai/api/pa/dao/PaCollectionMapper.java +++ b/src/main/java/com/pixelai/api/pa/dao/PaCollectionMapper.java @@ -1,7 +1,14 @@ package com.pixelai.api.pa.dao; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Constants; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.pixelai.api.pa.entity.PaCollection; import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.pixelai.api.pa.vo.PaCollectionVo; +import org.apache.ibatis.annotations.Param; + +import java.util.List; /** *

@@ -13,4 +20,5 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; */ public interface PaCollectionMapper extends BaseMapper { + List findByExample(@Param(Constants.WRAPPER)QueryWrapper paCollectionVoQueryWrapper, Page page); } diff --git a/src/main/java/com/pixelai/api/pa/entity/PaCollection.java b/src/main/java/com/pixelai/api/pa/entity/PaCollection.java index 2336476..d308104 100644 --- a/src/main/java/com/pixelai/api/pa/entity/PaCollection.java +++ b/src/main/java/com/pixelai/api/pa/entity/PaCollection.java @@ -4,6 +4,8 @@ import com.baomidou.mybatisplus.annotation.IdType; import java.time.LocalDateTime; import com.baomidou.mybatisplus.annotation.TableId; import java.io.Serializable; +import java.util.Date; + import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @@ -33,9 +35,11 @@ public class PaCollection implements Serializable { private Integer userId; - private LocalDateTime createtime; + private Date createtime; private String state; + + } diff --git a/src/main/java/com/pixelai/api/pa/service/PaCollectionService.java b/src/main/java/com/pixelai/api/pa/service/PaCollectionService.java index 55da1c9..909e717 100644 --- a/src/main/java/com/pixelai/api/pa/service/PaCollectionService.java +++ b/src/main/java/com/pixelai/api/pa/service/PaCollectionService.java @@ -1,8 +1,10 @@ package com.pixelai.api.pa.service; import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.pixelai.api.pa.entity.PaCollection; import com.baomidou.mybatisplus.extension.service.IService; +import com.pixelai.api.pa.vo.PaCollectionVo; import java.util.List; @@ -31,4 +33,5 @@ public interface PaCollectionService extends IService { */ IPage page(PaCollection example,IPage page); + IPage findByPage(PaCollection example, Page page); } diff --git a/src/main/java/com/pixelai/api/pa/service/impl/PaCollectionServiceImpl.java b/src/main/java/com/pixelai/api/pa/service/impl/PaCollectionServiceImpl.java index 98ab57f..cc3c714 100644 --- a/src/main/java/com/pixelai/api/pa/service/impl/PaCollectionServiceImpl.java +++ b/src/main/java/com/pixelai/api/pa/service/impl/PaCollectionServiceImpl.java @@ -2,10 +2,15 @@ package com.pixelai.api.pa.service.impl; 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.pixelai.api.pa.entity.PaCollection; import com.pixelai.api.pa.dao.PaCollectionMapper; import com.pixelai.api.pa.service.PaCollectionService; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.pixelai.api.pa.vo.PaCollectionVo; +import com.pixelai.api.pa.vo.PaCreationVo; +import com.pixelai.api.user.service.AcUserService; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.List; @@ -20,7 +25,8 @@ import java.util.List; */ @Service public class PaCollectionServiceImpl extends ServiceImpl implements PaCollectionService { - + @Autowired + private AcUserService acUserService; @Override public List list(PaCollection example) { return this.list(buildWrapper(example)); @@ -31,6 +37,23 @@ public class PaCollectionServiceImpl extends ServiceImpl findByPage(PaCollection example, Page page) { + page.setOptimizeCountSql(false); + return page.setRecords(this.baseMapper.findByExample(buildPaCollectionVoWrapper(example), page)); + } + + private QueryWrapper buildPaCollectionVoWrapper(PaCollection example) { + Integer userId=acUserService.getUserId(); + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq("user_id", userId) + .eq("collection_state", "t") + .eq("photo_state", "t") + .eq("creation_state", "t") + .orderByDesc("createtime"); + return wrapper; + } + /** * 构建查询 * diff --git a/src/main/java/com/pixelai/api/pa/service/impl/PaConsumptionServiceImpl.java b/src/main/java/com/pixelai/api/pa/service/impl/PaConsumptionServiceImpl.java index 071db41..7a902f6 100644 --- a/src/main/java/com/pixelai/api/pa/service/impl/PaConsumptionServiceImpl.java +++ b/src/main/java/com/pixelai/api/pa/service/impl/PaConsumptionServiceImpl.java @@ -6,6 +6,9 @@ import com.pixelai.api.pa.entity.PaConsumption; import com.pixelai.api.pa.dao.PaConsumptionMapper; import com.pixelai.api.pa.service.PaConsumptionService; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.pixelai.api.user.entity.AcUser; +import com.pixelai.api.user.service.AcUserService; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.List; @@ -20,7 +23,8 @@ import java.util.List; */ @Service public class PaConsumptionServiceImpl extends ServiceImpl implements PaConsumptionService { - + @Autowired + private AcUserService acUserService; @Override public List list(PaConsumption example) { return this.list(buildWrapper(example)); @@ -39,6 +43,12 @@ public class PaConsumptionServiceImpl extends ServiceImpl buildWrapper(PaConsumption example) { QueryWrapper wrapper = new QueryWrapper<>(); + Integer userId=acUserService.getUserId(); + AcUser acuser=acUserService.getById(userId); + if (acuser.getAcgroup()!=1){ + wrapper.lambda().eq(PaConsumption::getUserid,userId); + } + wrapper.orderByDesc("createtime"); return wrapper; } diff --git a/src/main/java/com/pixelai/api/pa/vo/PaCollectionVo.java b/src/main/java/com/pixelai/api/pa/vo/PaCollectionVo.java new file mode 100644 index 0000000..fd505df --- /dev/null +++ b/src/main/java/com/pixelai/api/pa/vo/PaCollectionVo.java @@ -0,0 +1,12 @@ +package com.pixelai.api.pa.vo; + +import com.pixelai.api.pa.entity.PaCollection; +import com.pixelai.api.pa.entity.PaCreation; +import lombok.Data; + +@Data +public class PaCollectionVo extends PaCollection { + String path; + String type; + Integer reviewStatus; +} diff --git a/src/main/java/com/pixelai/api/picture/schedule/ScheduledTasks.java b/src/main/java/com/pixelai/api/picture/schedule/ScheduledTasks.java index 19bb5b0..f31c1a7 100644 --- a/src/main/java/com/pixelai/api/picture/schedule/ScheduledTasks.java +++ b/src/main/java/com/pixelai/api/picture/schedule/ScheduledTasks.java @@ -64,7 +64,7 @@ public class ScheduledTasks { //每隔30秒拉取一次阿里云、火山生成结果 - @Scheduled(fixedRate = 30*1000) +// @Scheduled(fixedRate = 30*1000) public void getCreationUrl() throws Exception { //2阿里云,3火山 List paCreations= paCreationService.lambdaQuery() diff --git a/src/main/java/com/pixelai/api/picture/util/VolcengineUtil.java b/src/main/java/com/pixelai/api/picture/util/VolcengineUtil.java index 379c9ab..4484847 100644 --- a/src/main/java/com/pixelai/api/picture/util/VolcengineUtil.java +++ b/src/main/java/com/pixelai/api/picture/util/VolcengineUtil.java @@ -107,6 +107,9 @@ public class VolcengineUtil { case 50429: errorMessage="当前使用人数过多,请重试"; break; + case 50501: + errorMessage="服务器内部RPC错误,正在重试"; + break; } return errorMessage; } diff --git a/src/main/java/com/pixelai/api/user/controller/AcUserController.java b/src/main/java/com/pixelai/api/user/controller/AcUserController.java index 6f5c745..1ffd525 100644 --- a/src/main/java/com/pixelai/api/user/controller/AcUserController.java +++ b/src/main/java/com/pixelai/api/user/controller/AcUserController.java @@ -178,7 +178,7 @@ public class AcUserController extends BaseController { if (!toLogin) { return new Result(false, "登录失败", "登录失败次数超过5次,请半个小时后再进行尝试"); } - AcUser user = entityService.findByUsername(login.getUsername()); + AcUser user = entityService.findByUsername(login.getUsername(),1); if (null == user) { acLoginlogService.addLog(null, login.getUsername(), "f", "该账号不存在"); return new Result(false, "该账号不存在", "该账号不存在"); diff --git a/src/main/java/com/pixelai/api/user/dao/AcUserMapper.java b/src/main/java/com/pixelai/api/user/dao/AcUserMapper.java index 96c2c06..ac3f924 100644 --- a/src/main/java/com/pixelai/api/user/dao/AcUserMapper.java +++ b/src/main/java/com/pixelai/api/user/dao/AcUserMapper.java @@ -40,7 +40,7 @@ public interface AcUserMapper extends BaseMapper { * @param username * @return */ - AcUser findByUsername(@Param("username") String username); + AcUser findByUsername(@Param("username") String username,@Param("usertype") Integer usertype); /** * 条件查询 diff --git a/src/main/java/com/pixelai/api/user/service/AcUserService.java b/src/main/java/com/pixelai/api/user/service/AcUserService.java index dff1a1c..bced0b5 100644 --- a/src/main/java/com/pixelai/api/user/service/AcUserService.java +++ b/src/main/java/com/pixelai/api/user/service/AcUserService.java @@ -72,7 +72,7 @@ public interface AcUserService extends IService { * @param username * @return */ - AcUser findByUsername(String username); + AcUser findByUsername(String username,Integer usertype); /** * 设置订单状态 diff --git a/src/main/java/com/pixelai/api/user/service/impl/AcUserServiceImpl.java b/src/main/java/com/pixelai/api/user/service/impl/AcUserServiceImpl.java index 658c7b0..ce6e5b8 100644 --- a/src/main/java/com/pixelai/api/user/service/impl/AcUserServiceImpl.java +++ b/src/main/java/com/pixelai/api/user/service/impl/AcUserServiceImpl.java @@ -68,7 +68,7 @@ public class AcUserServiceImpl extends ServiceImpl impleme } @Override public Result phoneLogin(String username, String password) { - AcUser user = this.findByUsername(username); + AcUser user = this.findByUsername(username,2); if(user==null){ return new Result<>(false,"用户不存在",""); } @@ -130,7 +130,7 @@ public class AcUserServiceImpl extends ServiceImpl impleme if(!password.equals(confirmPassword)){ return new Result<>(false,"两次输入的密码不一致"); } - AcUser acUser=acUserMapper.findByUsername(username); + AcUser acUser=acUserMapper.findByUsername(username,2); if(acUser!=null){ return new Result<>(false,"用户已存在,无法注册"); } @@ -281,8 +281,8 @@ public class AcUserServiceImpl extends ServiceImpl impleme } @Override - public AcUser findByUsername(String username) { - return this.baseMapper.findByUsername(username); + public AcUser findByUsername(String username,Integer usertype) { + return this.baseMapper.findByUsername(username,usertype); } @Override @@ -312,7 +312,7 @@ public class AcUserServiceImpl extends ServiceImpl impleme acUser.setPwdupdatetime(new Date()); acUser.setState("1"); if (this.save(acUser)) { - return this.findByUsername(examinee.getUsername()); + return this.findByUsername(examinee.getUsername(),2); } else { return null; } @@ -331,7 +331,7 @@ public class AcUserServiceImpl extends ServiceImpl impleme acUser.setPwdupdatetime(new Date()); acUser.setState("1"); if (this.save(acUser)) { - return this.findByUsername(student.getUsername()); + return this.findByUsername(student.getUsername(),2); } else { return null; } diff --git a/src/main/resources/mapper/AcUserMapper.xml b/src/main/resources/mapper/AcUserMapper.xml index ec4ebcd..d0b2064 100644 --- a/src/main/resources/mapper/AcUserMapper.xml +++ b/src/main/resources/mapper/AcUserMapper.xml @@ -79,7 +79,7 @@ + select + id, + name, + photo_id, + user_id, + createtime, + path, + type, + review_status + from (select + pa_creation."id", + pa_creation."name", + pa_creation.photo_id, + pa_creation.user_id, + pa_creation.createtime, + pa_collection."state" as collection_state, + pa_creation."state" as creation_state, + cp_attachment."path", + cp_attachment."state" as photo_state, + pa_services."name" as type, + pa_creation_release.review_status + from pa_collection + left join pa_creation on pa_creation.id=pa_collection.creation_id + left join pa_services on pa_services.id=pa_creation.service_id + left join pa_creation_release on pa_creation_release.creation_id=pa_creation.id + left join cp_attachment on cp_attachment.id=pa_creation.photo_id) t + ${ew.customSqlSegment} + + +