Skip to content
This repository has been archived by the owner on Oct 19, 2023. It is now read-only.

[fix](PinController.java): fix API named getPinPermission and searchPin #54

Merged
merged 1 commit into from
Apr 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/main/java/com/example/backend/config/SecurityConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Excepti
.csrf().disable()
// 设置白名单
.authorizeHttpRequests()
.requestMatchers("/auth/**")
.requestMatchers("/auth/**", "/map/**", "/service/**",
"/forum/**", "/photo/**", "/ps-rel/**", "/user/**")
.permitAll()
// 保护剩余请求
.anyRequest()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ public CommonResult insertPin(@RequestBody Pin pin) {
}

@RequestMapping("/pin_search")
public CommonResult searchPin(@RequestBody Text text) {
ArrayList<Pin> pins = pinService.searchPin(text.getSearchContext());
public CommonResult searchPin(@RequestBody Text text, @RequestParam(name = "id") Integer id) {
ArrayList<Pin> pins = pinService.searchPin(text.getSearchContext(), id);
if (pins == null || pins.size() == 0)
return CommonResult.failed("搜索不到包含字段 '" + text.getSearchContext() + "' 的数据");
SearchInfo searchInfo = new SearchInfo();
Expand Down
13 changes: 13 additions & 0 deletions src/main/java/com/example/backend/domain/Pin.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ public class Pin implements Serializable {
*/
private String phone;

/**
* 地点联系电话
*/
private String visibility;

/**
* 用户id,个人用户创建pin为私有的,管理员创建pin为公开的
*/
Expand Down Expand Up @@ -100,6 +105,10 @@ public String getPhone() {
return phone;
}

public String getVisibility() {
return visibility;
}

public Integer getUser_id() {
return user_id;
}
Expand Down Expand Up @@ -140,6 +149,10 @@ public void setPhone(String phone) {
this.phone = phone;
}

public void setVisibility(String visibility) {
this.visibility = visibility;
}

public void setUser_id(Integer user_id) {
this.user_id = user_id;
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/example/backend/mapper/PinMapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
public interface PinMapper extends BaseMapper<Pin> {
int insertAll(Pin pin);

ArrayList<Pin> searchAll(String searchContext);
ArrayList<Pin> searchAll(String searchContext, Integer id);

int updateAll(Pin pin);

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/example/backend/service/PinService.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public interface PinService extends IService<Pin> {

int insertPin(Pin pin);

ArrayList<Pin> searchPin(String searchContext);
ArrayList<Pin> searchPin(String searchContext, Integer id);

int updatePin(Pin pin);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ public int insertPin(Pin pin) {
}

@Override
public ArrayList<Pin> searchPin(String searchContext) {
ArrayList<Pin> pins = pinMapper.searchAll(searchContext);
public ArrayList<Pin> searchPin(String searchContext, Integer id) {
ArrayList<Pin> pins = pinMapper.searchAll(searchContext, id);
return pins;
}

Expand Down
17 changes: 11 additions & 6 deletions src/main/resources/mapper/PinMapper.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<result property="type" column="p_type" jdbcType="INTEGER"/>
<result property="openTime" column="p_openTime" jdbcType="VARCHAR"/>
<result property="phone" column="p_phone" jdbcType="VARCHAR"/>
<result property="visibility" column="p_visibility" jdbcType="INTEGER"/>
<result property="user_id" column="u_id" jdbcType="INTEGER"/>
<result property="photo_id" column="ph_id" jdbcType="INTEGER"/>
<result property="forum_id" column="f_id" jdbcType="INTEGER"/>
Expand All @@ -20,27 +21,31 @@
<sql id="Base_Column_List">
p_id,p_name,p_pos,
p_brief,p_type,p_openTime,
p_phone,u_id,ph_id,
p_visibility,p_phone,u_id,ph_id,
f_id
</sql>
<insert id="insertAll">
insert into pin
(p_id,p_name,p_pos,p_brief,p_type,p_openTime,p_phone,u_id,ph_id,f_id)
(p_id,p_name,p_pos,p_brief,p_type,p_openTime,p_phone,p_visibility,u_id,ph_id,f_id)
values (#{id,jdbcType=NUMERIC}, #{name,jdbcType=VARCHAR}, #{position,jdbcType=VARCHAR},
#{brief,jdbcType=VARCHAR}, #{type,jdbcType=NUMERIC}, #{openTime,jdbcType=VARCHAR},
#{phone,jdbcType=VARCHAR}, #{user_id,jdbcType=NUMERIC}, #{photo_id,jdbcType=NUMERIC},
#{forum_id,jdbcType=NUMERIC})
#{phone,jdbcType=VARCHAR}, #{visibility,jdbcType=NUMERIC}, #{user_id,jdbcType=NUMERIC},
#{photo_id,jdbcType=NUMERIC}, #{forum_id,jdbcType=NUMERIC})
</insert>
<update id="updateAll">
update pin
set p_name=#{name}, p_pos=#{position}, p_brief=#{brief},
p_type=#{type}, p_openTime=#{openTime}, p_phone=#{phone}
p_type=#{type}, p_openTime=#{openTime}, p_phone=#{phone},
p_visibility=#{visibility}
where p_id=#{id}
</update>
<select id="searchAll" resultType="com.example.backend.domain.Pin" resultMap="BaseResultMap">
select * from pin where 1 = 0
<if test='searchContext != "null" and searchContext != ""'>
or p_name like '%${searchContext}%' or p_brief like '%${searchContext}%'
or p_name like '%${searchContext}%' and p_visibility = 1
or p_brief like '%${searchContext}%' and p_visibility = 1
or p_name like '%${searchContext}%' and u_id = #{id}
or p_brief like '%${searchContext}%' and u_id = #{id}
</if>
</select>
<select id="getPinById" resultType="com.example.backend.domain.Pin" resultMap="BaseResultMap">
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/sql/createPinTable.sql
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ CREATE TABLE `buaa_map`.`pin` (
`p_type` INT NOT NULL COMMENT '��ͼ��Tag' ,
`p_openTime` VARCHAR(100) NOT NULL COMMENT '�ص㿪��ʱ��' ,
`p_phone` VARCHAR(100) NOT NULL COMMENT '�ص���ϵ�绰' ,
`p_visibility` INT NOT NULL COMMENT '0����˽�ˣ�1��������' ,
`u_id` INT NOT NULL COMMENT '�û�id�������û�����pinΪ˽�еģ�����Ա����pinΪ������' ,
`ph_id` INT NOT NULL COMMENT '��ͼ�������Ƭ��id' ,
`f_id` INT NOT NULL COMMENT '��ͼ�������̳id' ,
Expand Down