企业列表出来了

master
法外狂徒张三 2024-09-06 20:21:03 +08:00
parent f277a1a343
commit c87467a824
6 changed files with 44 additions and 8 deletions

View File

@ -6,6 +6,11 @@
<component name="ChangeListManager">
<list default="true" id="72651396-d9d2-4022-b080-e21d75d1bedb" name="更改" comment="企业列表出来了">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/cloud-market-server/src/main/java/com/muyu/market/controller/MyApiController.java" beforeDir="false" afterPath="$PROJECT_DIR$/cloud-market-server/src/main/java/com/muyu/market/controller/MyApiController.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/cloud-market-server/src/main/java/com/muyu/market/mapper/MyApiMapper.java" beforeDir="false" afterPath="$PROJECT_DIR$/cloud-market-server/src/main/java/com/muyu/market/mapper/MyApiMapper.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/cloud-market-server/src/main/java/com/muyu/market/service/IMyApiService.java" beforeDir="false" afterPath="$PROJECT_DIR$/cloud-market-server/src/main/java/com/muyu/market/service/IMyApiService.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/cloud-market-server/src/main/java/com/muyu/market/service/impl/MyApiServiceImpl.java" beforeDir="false" afterPath="$PROJECT_DIR$/cloud-market-server/src/main/java/com/muyu/market/service/impl/MyApiServiceImpl.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/cloud-market-server/src/main/resources/mapper/market/MyApiMapper.xml" beforeDir="false" afterPath="$PROJECT_DIR$/cloud-market-server/src/main/resources/mapper/market/MyApiMapper.xml" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -180,6 +185,7 @@
<workItem from="1725553138436" duration="1569000" />
<workItem from="1725584707555" duration="7589000" />
<workItem from="1725605672086" duration="3347000" />
<workItem from="1725621072988" duration="3535000" />
</task>
<task id="LOCAL-00001" summary="初始化">
<created>1724047244829</created>
@ -489,7 +495,14 @@
<option name="project" value="LOCAL" />
<updated>1725610965944</updated>
</task>
<option name="localTasksCounter" value="45" />
<task id="LOCAL-00045" summary="企业列表出来了">
<created>1725621190899</created>
<option name="number" value="00045" />
<option name="presentableId" value="LOCAL-00045" />
<option name="project" value="LOCAL" />
<updated>1725621190899</updated>
</task>
<option name="localTasksCounter" value="46" />
<servers />
</component>
<component name="TypeScriptGeneratedFilesManager">

View File

@ -35,6 +35,16 @@ public class MyApiController extends BaseController
@Resource
private IMyApiService myApiService;
@PostMapping("/upd")
public Result updByUserIdAndApiId(@RequestBody MyApi myApi) {
if(myApi.getMyNum()==0){
return Result.error("次数不足");
}
Long userId = SecurityUtils.getUserId();
myApi.setUserId(userId);
return Result.success(myApiService.updByUserIdAndApiId(myApi));
}
/**
* api
*/

View File

@ -13,5 +13,5 @@ import org.apache.ibatis.annotations.Mapper;
*/
@Mapper
public interface MyApiMapper extends BaseMapper<MyApi>{
Integer updByUserIdAndApiId(MyApi myApi);
}

View File

@ -11,6 +11,8 @@ import com.baomidou.mybatisplus.extension.service.IService;
* @date 2024-09-06
*/
public interface IMyApiService extends IService<MyApi> {
public Integer updByUserIdAndApiId(MyApi myApi);
/**
* api
*

View File

@ -3,6 +3,7 @@ package com.muyu.market.service.impl;
import java.util.List;
import com.muyu.market.domain.SysDatawarehouse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.muyu.market.mapper.MyApiMapper;
import com.muyu.market.domain.MyApi;
@ -23,6 +24,13 @@ public class MyApiServiceImpl
extends ServiceImpl<MyApiMapper, MyApi>
implements IMyApiService {
@Autowired
private MyApiMapper mapper;
@Override
public Integer updByUserIdAndApiId(MyApi myApi) {
return mapper.updByUserIdAndApiId(myApi);
}
/**
* api
*

View File

@ -3,7 +3,7 @@
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.muyu.market.mapper.MyApiMapper">
<resultMap type="MyApi" id="MyApiResult">
<result property="myId" column="my_id" />
<result property="userId" column="user_id" />
@ -19,7 +19,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectMyApiList" parameterType="MyApi" resultMap="MyApiResult">
<include refid="selectMyApiVo"/>
<where>
<where>
<if test="userId != null "> and user_id = #{userId}</if>
<if test="apiId != null "> and api_id = #{apiId}</if>
<if test="myNum != null "> and my_num = #{myNum}</if>
@ -27,12 +27,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="myStates != null "> and my_states = #{myStates}</if>
</where>
</select>
<select id="selectMyApiByMyId" parameterType="Long" resultMap="MyApiResult">
<include refid="selectMyApiVo"/>
where my_id = #{myId}
</select>
<insert id="insertMyApi" parameterType="MyApi" useGeneratedKeys="true" keyProperty="myId">
insert into my_api
<trim prefix="(" suffix=")" suffixOverrides=",">
@ -62,15 +62,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</trim>
where my_id = #{myId}
</update>
<update id="updByUserIdAndApiId">
UPDATE my_api SET `my_num` = my_num-1 <if test="myNum==1" >,`my_states` = 'N'</if> WHERE `user_id` = #{userId} and `api_id` = #{apiId};
</update>
<delete id="deleteMyApiByMyId" parameterType="Long">
delete from my_api where my_id = #{myId}
</delete>
<delete id="deleteMyApiByMyIds" parameterType="String">
delete from my_api where my_id in
delete from my_api where my_id in
<foreach item="myId" collection="array" open="(" separator="," close=")">
#{myId}
</foreach>
</delete>
</mapper>
</mapper>