收藏模块+统计维度

This commit is contained in:
guojunjie 2025-01-22 19:21:50 +08:00
parent 0c5ac83574
commit fab091e614
19 changed files with 330 additions and 190 deletions

View File

@ -94,6 +94,7 @@ public class CpLabelController extends BaseController {
@ApiOperation(value = "查询单个标签") @ApiOperation(value = "查询单个标签")
@RequestMapping(value = "{id}", method = {RequestMethod.GET}) @RequestMapping(value = "{id}", method = {RequestMethod.GET})
@ApiImplicitParam(name = "id", value = "标签ID", required = true, paramType = "path") @ApiImplicitParam(name = "id", value = "标签ID", required = true, paramType = "path")
@Unsecured
public Result one(@PathVariable final Integer id) { public Result one(@PathVariable final Integer id) {
try { try {
CpLabel entity = entityService.getLabelById(id); CpLabel entity = entityService.getLabelById(id);

View File

@ -59,7 +59,7 @@ public class AcLogController extends BaseController {
private PaConsumptionService paConsumptionService; private PaConsumptionService paConsumptionService;
@SysLog(action = "statistics:basicInformation", value = "") @SysLog(action = "statistics:basicInformation", value = "")
@ApiOperation(value = "统计基础信息:用户数,今天新增用户数,首页总浏览数,今日浏览数") @ApiOperation(value = "统计基础信息:用户数,今天新增用户数,首页总浏览数,今日浏览数,今日充值数,总充值数")
@GetMapping("basicInformation") @GetMapping("basicInformation")
public Result basicInformation() { public Result basicInformation() {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd", Locale.getDefault()); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd", Locale.getDefault());
@ -74,13 +74,36 @@ public class AcLogController extends BaseController {
Integer userTotalCount=acUserService.count(); Integer userTotalCount=acUserService.count();
Integer userTodayCount=acUserService.lambdaQuery() Integer userTodayCount=acUserService.lambdaQuery()
.between(AcUser::getCreatetime, Timestamp.valueOf(today),Timestamp.valueOf(tomorrow)).count(); .between(AcUser::getCreatetime, Timestamp.valueOf(today),Timestamp.valueOf(tomorrow)).count();
Integer HomeviewTotalCount=entityService.lambdaQuery() Integer HomeviewTotalCount=entityService.lambdaQuery()
.eq(AcLog::getAction,"homeViews").count(); .eq(AcLog::getAction,"homeViews").count();
Integer HomeviewCount=entityService.lambdaQuery() Integer HomeviewCount=entityService.lambdaQuery()
.eq(AcLog::getAction,"homeViews") .eq(AcLog::getAction,"homeViews")
.between(AcLog::getCreatetime, Timestamp.valueOf(today),Timestamp.valueOf(tomorrow)).count(); .between(AcLog::getCreatetime, Timestamp.valueOf(today),Timestamp.valueOf(tomorrow)).count();
BasicInformationVo basicInformationVo=new BasicInformationVo(userTotalCount,userTodayCount,HomeviewTotalCount,HomeviewCount);
List<PaConsumption> 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); return new Result(true, basicInformationVo);
} }

View File

@ -15,4 +15,12 @@ public class BasicInformationVo {
private Integer HomeviewCount; private Integer HomeviewCount;
@ApiModelProperty("今日浏览数") @ApiModelProperty("今日浏览数")
private Integer HomeviewTodayCount; private Integer HomeviewTodayCount;
@ApiModelProperty("今日充值数")
private Integer rechargeTodayAmount;
@ApiModelProperty("总充值数")
private Integer rechargeAmount;
@ApiModelProperty("今日消费数")
private Integer consumptionTodayAmount;
@ApiModelProperty("总消费数")
private Integer consumptionAmount;
} }

View File

@ -1,5 +1,8 @@
package com.pixelai.api.pa.controller; 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 org.springframework.web.bind.annotation.RequestMapping;
import com.base.annotation.SysLog; import com.base.annotation.SysLog;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
@ -19,6 +22,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import javax.validation.Valid; import javax.validation.Valid;
import java.util.Collections; import java.util.Collections;
import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -30,106 +34,116 @@ import java.util.Map;
* @author gjj * @author gjj
* @since 2024-12-05 * @since 2024-12-05
*/ */
@Api(tags = "PaCollection") @Api(tags = "用户收藏")
@RestController @RestController
@RequestMapping("/paCollection") @RequestMapping("/paCollection")
public class PaCollectionController extends BaseController { public class PaCollectionController extends BaseController {
private static final Logger LOG = LoggerFactory.getLogger(PaCollectionController.class); private static final Logger LOG = LoggerFactory.getLogger(PaCollectionController.class);
@Autowired @Autowired
private PaCollectionService entityService; private PaCollectionService entityService;
@Autowired
private AcUserService acUserService;
@SysLog(action = "findByPage", value = "分页查询订单") @SysLog(action = "findByPage", value = "分页查询收藏")
@ApiOperation(value = "分页查询订单", notes = "分页查询订单") @ApiOperation(value = "分页查询收藏", notes = "分页查询收藏")
@RequestMapping(method = RequestMethod.GET) @RequestMapping(method = RequestMethod.GET)
@ApiImplicitParams({@ApiImplicitParam(name = "size", value = "分页大小", paramType = "query"), @ApiImplicitParams({@ApiImplicitParam(name = "size", value = "分页大小", paramType = "query"),
@ApiImplicitParam(name = "current", value = "当前页面从1开始", paramType = "query")}) @ApiImplicitParam(name = "current", value = "当前页面从1开始", paramType = "query")})
public Result<IPage<PaCollection>> findByPage(final PaCollection example, final Page page) { public Result<IPage<PaCollectionVo>> findByPage(final PaCollection example, final Page page) {
IPage<PaCollection> records = entityService.page(example,page); IPage<PaCollectionVo> records = entityService.findByPage(example,page);
return new Result(true, records); 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 = "删除订单") // @SysLog(action = "one", value = "查询单个收藏")
@ApiOperation(value = "删除订单") // @ApiOperation(value = "查询单个收藏")
@RequestMapping(value = "{id}", method = {RequestMethod.DELETE}) // @RequestMapping(value = "{id}", method = {RequestMethod.GET})
@ApiImplicitParam(name = "id", value = "订单ID", required = true, paramType = "path") // @ApiImplicitParam(name = "id", value = "收藏ID", required = true, paramType = "path")
public Result delete(@PathVariable final Integer id) { // public Result one(@PathVariable final Integer id) {
try { // try {
entityService.removeById(id); // PaCollection entity = entityService.getById(id);
return new Result(true, "成功删除订单", null); // return new Result(true, entity);
} catch (DataIntegrityViolationException e) { // } catch (Exception e) {
LOG.error("删除订单失败", e); // LOG.error("查询单个收藏失败", e);
return new Result(false, "删除订单失败", "该订单不能删除,存在其他关联数据"); // return new Result(false, new PaCollection());
} catch (Exception e) { // }
LOG.error("删除订单失败", e); // }
return new Result(false, "删除订单失败", e.getMessage());
}
}
@SysLog(action = "one", value = "查询单个订单") @SysLog(action = "add", value = "收藏作品")
@ApiOperation(value = "查询单个订单") @ApiOperation(value = "收藏作品")
@RequestMapping(value = "{id}", method = {RequestMethod.GET}) @RequestMapping(method = {RequestMethod.POST})
@ApiImplicitParam(name = "id", value = "订单ID", required = true, paramType = "path") public Result add(@Valid @RequestBody final PaCollection entity, final BindingResult result) {
public Result one(@PathVariable final Integer id) { try {
try { if (result.hasErrors()) {
PaCollection entity = entityService.getById(id); Map<String, String> map = this.getErrors(result);
return new Result(true, entity); String errorMsg = map.entrySet().iterator().next().getValue();
} catch (Exception e) { return new Result(false, "保存收藏失败", errorMsg, map);
LOG.error("查询单个订单失败", e); } else {
return new Result(false, new PaCollection()); Integer userid=acUserService.getUserId();
} if (userid==null){
} return new Result(false, "用户不存在");
@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<String, String> 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) { entity.setState("t");
LOG.error("添加订单失败", e); entity.setUserId(userid);
return new Result(false, "保存订单失败", e.getMessage()); 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 = "修改订单") // @SysLog(action = "update", value = "修改收藏")
@ApiOperation(value = "修改订单") // @ApiOperation(value = "修改收藏")
@RequestMapping(method = {RequestMethod.PUT}) // @RequestMapping(method = {RequestMethod.PUT})
public Result update(@Valid @RequestBody final PaCollection entity, final BindingResult result) { // public Result update(@Valid @RequestBody final PaCollection entity, final BindingResult result) {
try { // try {
if (result.hasErrors()) { // if (result.hasErrors()) {
Map<String, String> map = this.getErrors(result); // Map<String, String> map = this.getErrors(result);
String errorMsg = map.entrySet().iterator().next().getValue(); // String errorMsg = map.entrySet().iterator().next().getValue();
return new Result(false, "修改订单失败", errorMsg, map); // return new Result(false, "修改收藏失败", errorMsg, map);
} else { // } else {
if (null == entity.getId()) { // if (null == entity.getId()) {
throw new RuntimeException("id不能为空"); // throw new RuntimeException("id不能为空");
} // }
entityService.updateById(entity); // entityService.updateById(entity);
return new Result(true, "成功修改订单", null); // return new Result(true, "成功修改收藏", null);
} // }
} catch (Exception e) { // } catch (Exception e) {
LOG.error("修改订单失败", e); // LOG.error("修改收藏失败", e);
return new Result(false, "修改订单失败", e.getMessage()); // return new Result(false, "修改收藏失败", e.getMessage());
} // }
} // }
//
@ApiOperation(value = "全部订单") // @ApiOperation(value = "全部收藏")
@RequestMapping(value = "all", method = RequestMethod.GET) // @RequestMapping(value = "all", method = RequestMethod.GET)
public Result<List<PaCollection>> all(PaCollection example) { // public Result<List<PaCollection>> all(PaCollection example) {
List<PaCollection> entitys = entityService.list(example); // List<PaCollection> entitys = entityService.list(example);
if (null != entitys) { // if (null != entitys) {
return new Result<>(true, entitys); // return new Result<>(true, entitys);
} // }
return new Result<>(true, Collections.emptyList()); // return new Result<>(true, Collections.emptyList());
} // }
} }

View File

@ -35,101 +35,100 @@ import java.util.Map;
@RequestMapping("/paConsumption") @RequestMapping("/paConsumption")
public class PaConsumptionController extends BaseController { public class PaConsumptionController extends BaseController {
private static final Logger LOG = LoggerFactory.getLogger(PaConsumptionController.class); private static final Logger LOG = LoggerFactory.getLogger(PaConsumptionController.class);
@Autowired @Autowired
private PaConsumptionService entityService; private PaConsumptionService entityService;
@SysLog(action = "findByPage", value = "分页查询订单") @SysLog(action = "findByPage", value = "分页查询生成记录")
@ApiOperation(value = "分页查询订单", notes = "分页查询订单") @ApiOperation(value = "分页查询生成记录", notes = "分页查询生成记录")
@RequestMapping(method = RequestMethod.GET) @RequestMapping(method = RequestMethod.GET)
@ApiImplicitParams({@ApiImplicitParam(name = "size", value = "分页大小", paramType = "query"), @ApiImplicitParams({@ApiImplicitParam(name = "size", value = "分页大小", paramType = "query"),
@ApiImplicitParam(name = "current", value = "当前页面从1开始", paramType = "query")}) @ApiImplicitParam(name = "current", value = "当前页面从1开始", paramType = "query")})
public Result<IPage<PaConsumption>> findByPage(final PaConsumption example, final Page page) { public Result<IPage<PaConsumption>> findByPage(final PaConsumption example, final Page page) {
IPage<PaConsumption> records = entityService.page(example,page); IPage<PaConsumption> records = entityService.page(example,page);
return new Result(true, records); 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 = "删除订单") @SysLog(action = "one", value = "查询单个生成记录")
@ApiOperation(value = "删除订单") @ApiOperation(value = "查询单个生成记录")
@RequestMapping(value = "{id}", method = {RequestMethod.DELETE}) @RequestMapping(value = "{id}", method = {RequestMethod.GET})
@ApiImplicitParam(name = "id", value = "订单ID", required = true, paramType = "path") @ApiImplicitParam(name = "id", value = "生成记录ID", required = true, paramType = "path")
public Result delete(@PathVariable final Integer id) { public Result one(@PathVariable final Integer id) {
try { try {
entityService.removeById(id); PaConsumption entity = entityService.getById(id);
return new Result(true, "成功删除订单", null); return new Result(true, entity);
} catch (DataIntegrityViolationException e) { } catch (Exception e) {
LOG.error("删除订单失败", e); LOG.error("查询单个生成记录失败", e);
return new Result(false, "删除订单失败", "该订单不能删除,存在其他关联数据"); return new Result(false, new PaConsumption());
} catch (Exception e) { }
LOG.error("删除订单失败", e); }
return new Result(false, "删除订单失败", e.getMessage());
@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<String, String> 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 = "查询单个订单") @SysLog(action = "update", value = "修改生成记录")
@ApiOperation(value = "查询单个订单") @ApiOperation(value = "修改生成记录")
@RequestMapping(value = "{id}", method = {RequestMethod.GET}) @RequestMapping(method = {RequestMethod.PUT})
@ApiImplicitParam(name = "id", value = "订单ID", required = true, paramType = "path") public Result update(@Valid @RequestBody final PaConsumption entity, final BindingResult result) {
public Result one(@PathVariable final Integer id) { try {
try { if (result.hasErrors()) {
PaConsumption entity = entityService.getById(id); Map<String, String> map = this.getErrors(result);
return new Result(true, entity); String errorMsg = map.entrySet().iterator().next().getValue();
} catch (Exception e) { return new Result(false, "修改生成记录失败", errorMsg, map);
LOG.error("查询单个订单失败", e); } else {
return new Result(false, new PaConsumption()); if (null == entity.getId()) {
} throw new RuntimeException("id不能为空");
}
@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<String, String> 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) { entityService.updateById(entity);
LOG.error("添加订单失败", e); return new Result(true, "成功修改生成记录", null);
return new Result(false, "保存订单失败", e.getMessage());
} }
} catch (Exception e) {
LOG.error("修改生成记录失败", e);
return new Result(false, "修改生成记录失败", e.getMessage());
} }
}
@SysLog(action = "update", value = "修改订单") @ApiOperation(value = "全部生成记录")
@ApiOperation(value = "修改订单") @RequestMapping(value = "all", method = RequestMethod.GET)
@RequestMapping(method = {RequestMethod.PUT}) public Result<List<PaConsumption>> all(PaConsumption example) {
public Result update(@Valid @RequestBody final PaConsumption entity, final BindingResult result) { List<PaConsumption> entitys = entityService.list(example);
try { if (null != entitys) {
if (result.hasErrors()) { return new Result<>(true, entitys);
Map<String, String> 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<List<PaConsumption>> all(PaConsumption example) {
List<PaConsumption> entitys = entityService.list(example);
if (null != entitys) {
return new Result<>(true, entitys);
}
return new Result<>(true, Collections.emptyList());
} }
return new Result<>(true, Collections.emptyList());
}
} }

View File

@ -1,7 +1,14 @@
package com.pixelai.api.pa.dao; 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.pixelai.api.pa.entity.PaCollection;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.pixelai.api.pa.vo.PaCollectionVo;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/** /**
* <p> * <p>
@ -13,4 +20,5 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
*/ */
public interface PaCollectionMapper extends BaseMapper<PaCollection> { public interface PaCollectionMapper extends BaseMapper<PaCollection> {
List<PaCollectionVo> findByExample(@Param(Constants.WRAPPER)QueryWrapper<PaCollectionVo> paCollectionVoQueryWrapper, Page page);
} }

View File

@ -4,6 +4,8 @@ import com.baomidou.mybatisplus.annotation.IdType;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableId;
import java.io.Serializable; import java.io.Serializable;
import java.util.Date;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
@ -33,9 +35,11 @@ public class PaCollection implements Serializable {
private Integer userId; private Integer userId;
private LocalDateTime createtime; private Date createtime;
private String state; private String state;
} }

View File

@ -1,8 +1,10 @@
package com.pixelai.api.pa.service; package com.pixelai.api.pa.service;
import com.baomidou.mybatisplus.core.metadata.IPage; 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.entity.PaCollection;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.pixelai.api.pa.vo.PaCollectionVo;
import java.util.List; import java.util.List;
@ -31,4 +33,5 @@ public interface PaCollectionService extends IService<PaCollection> {
*/ */
IPage<PaCollection> page(PaCollection example,IPage page); IPage<PaCollection> page(PaCollection example,IPage page);
IPage<PaCollectionVo> findByPage(PaCollection example, Page page);
} }

View File

@ -2,10 +2,15 @@ package com.pixelai.api.pa.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; 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.entity.PaCollection;
import com.pixelai.api.pa.dao.PaCollectionMapper; import com.pixelai.api.pa.dao.PaCollectionMapper;
import com.pixelai.api.pa.service.PaCollectionService; import com.pixelai.api.pa.service.PaCollectionService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; 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 org.springframework.stereotype.Service;
import java.util.List; import java.util.List;
@ -20,7 +25,8 @@ import java.util.List;
*/ */
@Service @Service
public class PaCollectionServiceImpl extends ServiceImpl<PaCollectionMapper, PaCollection> implements PaCollectionService { public class PaCollectionServiceImpl extends ServiceImpl<PaCollectionMapper, PaCollection> implements PaCollectionService {
@Autowired
private AcUserService acUserService;
@Override @Override
public List<PaCollection> list(PaCollection example) { public List<PaCollection> list(PaCollection example) {
return this.list(buildWrapper(example)); return this.list(buildWrapper(example));
@ -31,6 +37,23 @@ public class PaCollectionServiceImpl extends ServiceImpl<PaCollectionMapper, PaC
return this.page(page,buildWrapper(example)); return this.page(page,buildWrapper(example));
} }
@Override
public IPage<PaCollectionVo> findByPage(PaCollection example, Page page) {
page.setOptimizeCountSql(false);
return page.setRecords(this.baseMapper.findByExample(buildPaCollectionVoWrapper(example), page));
}
private QueryWrapper<PaCollectionVo> buildPaCollectionVoWrapper(PaCollection example) {
Integer userId=acUserService.getUserId();
QueryWrapper<PaCollectionVo> wrapper = new QueryWrapper<>();
wrapper.eq("user_id", userId)
.eq("collection_state", "t")
.eq("photo_state", "t")
.eq("creation_state", "t")
.orderByDesc("createtime");
return wrapper;
}
/** /**
* 构建查询 * 构建查询
* *

View File

@ -6,6 +6,9 @@ import com.pixelai.api.pa.entity.PaConsumption;
import com.pixelai.api.pa.dao.PaConsumptionMapper; import com.pixelai.api.pa.dao.PaConsumptionMapper;
import com.pixelai.api.pa.service.PaConsumptionService; import com.pixelai.api.pa.service.PaConsumptionService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; 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 org.springframework.stereotype.Service;
import java.util.List; import java.util.List;
@ -20,7 +23,8 @@ import java.util.List;
*/ */
@Service @Service
public class PaConsumptionServiceImpl extends ServiceImpl<PaConsumptionMapper, PaConsumption> implements PaConsumptionService { public class PaConsumptionServiceImpl extends ServiceImpl<PaConsumptionMapper, PaConsumption> implements PaConsumptionService {
@Autowired
private AcUserService acUserService;
@Override @Override
public List<PaConsumption> list(PaConsumption example) { public List<PaConsumption> list(PaConsumption example) {
return this.list(buildWrapper(example)); return this.list(buildWrapper(example));
@ -39,6 +43,12 @@ public class PaConsumptionServiceImpl extends ServiceImpl<PaConsumptionMapper, P
*/ */
private QueryWrapper<PaConsumption> buildWrapper(PaConsumption example) { private QueryWrapper<PaConsumption> buildWrapper(PaConsumption example) {
QueryWrapper<PaConsumption> wrapper = new QueryWrapper<>(); QueryWrapper<PaConsumption> 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; return wrapper;
} }

View File

@ -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;
}

View File

@ -64,7 +64,7 @@ public class ScheduledTasks {
//每隔30秒拉取一次阿里云火山生成结果 //每隔30秒拉取一次阿里云火山生成结果
@Scheduled(fixedRate = 30*1000) // @Scheduled(fixedRate = 30*1000)
public void getCreationUrl() throws Exception { public void getCreationUrl() throws Exception {
//2阿里云3火山 //2阿里云3火山
List<PaCreation> paCreations= paCreationService.lambdaQuery() List<PaCreation> paCreations= paCreationService.lambdaQuery()

View File

@ -107,6 +107,9 @@ public class VolcengineUtil {
case 50429: case 50429:
errorMessage="当前使用人数过多,请重试"; errorMessage="当前使用人数过多,请重试";
break; break;
case 50501:
errorMessage="服务器内部RPC错误,正在重试";
break;
} }
return errorMessage; return errorMessage;
} }

View File

@ -178,7 +178,7 @@ public class AcUserController extends BaseController {
if (!toLogin) { if (!toLogin) {
return new Result(false, "登录失败", "登录失败次数超过5次请半个小时后再进行尝试"); return new Result(false, "登录失败", "登录失败次数超过5次请半个小时后再进行尝试");
} }
AcUser user = entityService.findByUsername(login.getUsername()); AcUser user = entityService.findByUsername(login.getUsername(),1);
if (null == user) { if (null == user) {
acLoginlogService.addLog(null, login.getUsername(), "f", "该账号不存在"); acLoginlogService.addLog(null, login.getUsername(), "f", "该账号不存在");
return new Result(false, "该账号不存在", "该账号不存在"); return new Result(false, "该账号不存在", "该账号不存在");

View File

@ -40,7 +40,7 @@ public interface AcUserMapper extends BaseMapper<AcUser> {
* @param username * @param username
* @return * @return
*/ */
AcUser findByUsername(@Param("username") String username); AcUser findByUsername(@Param("username") String username,@Param("usertype") Integer usertype);
/** /**
* 条件查询 * 条件查询

View File

@ -72,7 +72,7 @@ public interface AcUserService extends IService<AcUser> {
* @param username * @param username
* @return * @return
*/ */
AcUser findByUsername(String username); AcUser findByUsername(String username,Integer usertype);
/** /**
* 设置订单状态 * 设置订单状态

View File

@ -68,7 +68,7 @@ public class AcUserServiceImpl extends ServiceImpl<AcUserMapper, AcUser> impleme
} }
@Override @Override
public Result<LoginSuccessVo> phoneLogin(String username, String password) { public Result<LoginSuccessVo> phoneLogin(String username, String password) {
AcUser user = this.findByUsername(username); AcUser user = this.findByUsername(username,2);
if(user==null){ if(user==null){
return new Result<>(false,"用户不存在",""); return new Result<>(false,"用户不存在","");
} }
@ -130,7 +130,7 @@ public class AcUserServiceImpl extends ServiceImpl<AcUserMapper, AcUser> impleme
if(!password.equals(confirmPassword)){ if(!password.equals(confirmPassword)){
return new Result<>(false,"两次输入的密码不一致"); return new Result<>(false,"两次输入的密码不一致");
} }
AcUser acUser=acUserMapper.findByUsername(username); AcUser acUser=acUserMapper.findByUsername(username,2);
if(acUser!=null){ if(acUser!=null){
return new Result<>(false,"用户已存在,无法注册"); return new Result<>(false,"用户已存在,无法注册");
} }
@ -281,8 +281,8 @@ public class AcUserServiceImpl extends ServiceImpl<AcUserMapper, AcUser> impleme
} }
@Override @Override
public AcUser findByUsername(String username) { public AcUser findByUsername(String username,Integer usertype) {
return this.baseMapper.findByUsername(username); return this.baseMapper.findByUsername(username,usertype);
} }
@Override @Override
@ -312,7 +312,7 @@ public class AcUserServiceImpl extends ServiceImpl<AcUserMapper, AcUser> impleme
acUser.setPwdupdatetime(new Date()); acUser.setPwdupdatetime(new Date());
acUser.setState("1"); acUser.setState("1");
if (this.save(acUser)) { if (this.save(acUser)) {
return this.findByUsername(examinee.getUsername()); return this.findByUsername(examinee.getUsername(),2);
} else { } else {
return null; return null;
} }
@ -331,7 +331,7 @@ public class AcUserServiceImpl extends ServiceImpl<AcUserMapper, AcUser> impleme
acUser.setPwdupdatetime(new Date()); acUser.setPwdupdatetime(new Date());
acUser.setState("1"); acUser.setState("1");
if (this.save(acUser)) { if (this.save(acUser)) {
return this.findByUsername(student.getUsername()); return this.findByUsername(student.getUsername(),2);
} else { } else {
return null; return null;
} }

View File

@ -79,7 +79,7 @@
<select id="findByUsername" resultMap="BaseResultMap" parameterType="java.lang.String"> <select id="findByUsername" resultMap="BaseResultMap" parameterType="java.lang.String">
select select
<include refid="Base_Column_List"/> <include refid="Base_Column_List"/>
FROM ac_user where username = #{username} and state = 't' FROM ac_user where username = #{username} and usertype = #{usertype} and state = 't'
</select> </select>
<select id="findByExample" resultType="com.pixelai.api.user.vo.AcUserVo" <select id="findByExample" resultType="com.pixelai.api.user.vo.AcUserVo"

View File

@ -16,4 +16,36 @@
id, creation_id, user_id, createtime, state id, creation_id, user_id, createtime, state
</sql> </sql>
<select id="findByExample" resultType="com.pixelai.api.pa.vo.PaCollectionVo"
parameterType="com.pixelai.api.pa.vo.PaCollectionVo">
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}
</select>
</mapper> </mapper>