Merge remote-tracking branch 'origin/weiran'
commit
4bdd939bb4
|
@ -0,0 +1,44 @@
|
|||
package com.muyu.cloud.market.domin;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
/**
|
||||
* @Author:weiran
|
||||
* @Package:com.muyu.cloud.market.domin
|
||||
* @Project:cloud-market
|
||||
* @name:UserProductCount
|
||||
* @Date:2024/9/3 10:12
|
||||
*/
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@SuperBuilder
|
||||
@TableName(value = "user_product_count",autoResultMap = true)
|
||||
public class UserProductCount {
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@TableId(value = "test_id",type = IdType.AUTO)
|
||||
private Integer testId;
|
||||
/**
|
||||
* 用户Id
|
||||
*/
|
||||
private long userId;
|
||||
/**
|
||||
* 产品Id
|
||||
*/
|
||||
private Integer productId;
|
||||
/**
|
||||
* 测试次数
|
||||
*/
|
||||
private Integer testCount;
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,61 @@
|
|||
package com.muyu.cloud.market.controller;
|
||||
|
||||
import com.muyu.cloud.market.domin.Product;
|
||||
import com.muyu.cloud.market.domin.UserProductCount;
|
||||
import com.muyu.cloud.market.service.ProducttestService;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author:weiran
|
||||
* @Package:com.muyu.cloud.market.controller
|
||||
* @Project:cloud-market
|
||||
* @name:ProducttestController
|
||||
* @Date:2024/9/3 10:16
|
||||
*/
|
||||
@Log4j2
|
||||
@RestController
|
||||
@RequestMapping("/producttest")
|
||||
@Tag(name = "产品测试",description = "产品测试相关操作")
|
||||
public class ProducttestController {
|
||||
@Autowired
|
||||
private ProducttestService producttestService;
|
||||
|
||||
|
||||
/**
|
||||
* 不同用户/方式的测试次数
|
||||
* @param userProductCount
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/findcount")
|
||||
@Operation(summary = "不同用户/方式的测试次数",description = "不同用户/方式的测试次数")
|
||||
public Result findcount(@Validated @RequestBody UserProductCount userProductCount, HttpServletRequest request){
|
||||
UserProductCount findcount = producttestService.findcount(userProductCount, request);
|
||||
return Result.success(findcount);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 测试次数-1
|
||||
* @param userProductCount
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/reducetestcount")
|
||||
@Operation(summary = "测试次数-1",description = "测试次数-1")
|
||||
public void reducetestcount(@Validated @RequestBody UserProductCount userProductCount){
|
||||
Integer reducetestcount = producttestService.reducetestcount(userProductCount);
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
package com.muyu.cloud.market.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.muyu.cloud.market.domin.Product;
|
||||
import com.muyu.cloud.market.domin.UserProductCount;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author:weiran
|
||||
* @Package:com.muyu.cloud.market.mapper
|
||||
* @Project:cloud-market
|
||||
* @name:ProducttestMapper
|
||||
* @Date:2024/9/3 10:20
|
||||
*/
|
||||
@Mapper
|
||||
public interface ProducttestMapper extends BaseMapper<UserProductCount> {
|
||||
|
||||
/**
|
||||
* 不同用户/方式的测试次数
|
||||
* @param userProductCount
|
||||
* @return
|
||||
*/
|
||||
UserProductCount findcount(UserProductCount userProductCount);
|
||||
|
||||
/**
|
||||
* 测试次数-1
|
||||
* @param userProductCount
|
||||
* @return
|
||||
*/
|
||||
Integer reducetestcount(UserProductCount userProductCount);
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
package com.muyu.cloud.market.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.muyu.cloud.market.domin.Product;
|
||||
import com.muyu.cloud.market.domin.UserProductCount;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author:weiran
|
||||
* @Package:com.muyu.cloud.market.service
|
||||
* @Project:cloud-market
|
||||
* @name:ProducttestService
|
||||
* @Date:2024/9/3 10:19
|
||||
*/
|
||||
public interface ProducttestService extends IService<UserProductCount> {
|
||||
|
||||
/**
|
||||
* 不同用户/方式的测试次数
|
||||
* @param userProductCount
|
||||
* @return
|
||||
*/
|
||||
UserProductCount findcount(UserProductCount userProductCount, HttpServletRequest request);
|
||||
|
||||
/**
|
||||
* 测试次数-1
|
||||
* @param userProductCount
|
||||
* @return
|
||||
*/
|
||||
Integer reducetestcount(UserProductCount userProductCount);
|
||||
}
|
|
@ -0,0 +1,59 @@
|
|||
package com.muyu.cloud.market.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.muyu.cloud.market.domin.Product;
|
||||
import com.muyu.cloud.market.domin.UserProductCount;
|
||||
import com.muyu.cloud.market.mapper.ProducttestMapper;
|
||||
import com.muyu.cloud.market.service.ProducttestService;
|
||||
import com.muyu.common.security.service.TokenService;
|
||||
import com.muyu.common.security.utils.SecurityUtils;
|
||||
import com.muyu.common.system.domain.LoginUser;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author:weiran
|
||||
* @Package:com.muyu.cloud.market.service.impl
|
||||
* @Project:cloud-market
|
||||
* @name:ProducttestServiceImpl
|
||||
* @Date:2024/9/3 10:19
|
||||
*/
|
||||
@Service
|
||||
public class ProducttestServiceImpl extends ServiceImpl<ProducttestMapper, UserProductCount> implements ProducttestService {
|
||||
@Autowired
|
||||
private ProducttestMapper producttestMapper;
|
||||
@Autowired
|
||||
private TokenService tokenService;
|
||||
|
||||
|
||||
/**
|
||||
* 不同用户/方式的测试次数
|
||||
* @param userProductCount
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public UserProductCount findcount(UserProductCount userProductCount, HttpServletRequest request) {
|
||||
String token = SecurityUtils.getToken();// 获取当前Token
|
||||
LoginUser loginUser = tokenService.getLoginUser(token); // 获取当前登录用户
|
||||
Long userid = loginUser.getUserid();
|
||||
userProductCount.setUserId(userid);
|
||||
return producttestMapper.findcount(userProductCount);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 测试次数-1
|
||||
* @param userProductCount
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Integer reducetestcount(UserProductCount userProductCount) {
|
||||
|
||||
Integer iftest = producttestMapper.reducetestcount(userProductCount);
|
||||
return iftest;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
|
||||
<mapper namespace="com.muyu.cloud.market.mapper.ProducttestMapper">
|
||||
|
||||
<select id="findcount" resultType="com.muyu.cloud.market.domin.UserProductCount">
|
||||
SELECT
|
||||
sys_user.user_id,
|
||||
product.product_id,
|
||||
user_product_count.test_count
|
||||
FROM
|
||||
sys_user
|
||||
LEFT JOIN user_product_count on sys_user.user_id = user_product_count.user_id
|
||||
left join product on user_product_count.product_id=product.product_id
|
||||
<where>
|
||||
and user_product_count.user_id=#{userId}
|
||||
<if test="product_id!=null and product_id!=''">
|
||||
and user_product_count.product_id=#{productId}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<update id="reducetestcount">
|
||||
UPDATE `h6_cloud_server`.`user_product_count`
|
||||
SET `test_count` = `test_count`-1 WHERE `user_id` = #{userId} and `product_id` = #{productId};
|
||||
</update>
|
||||
</mapper>
|
Loading…
Reference in New Issue