You've already forked FrameTour-BE
feat(scenic-account): 添加景区账号激活/停用功能并优化登录验证
- 新增激活/停用景区账号的接口和相关逻辑 - 在登录时增加账号激活状态的验证 - 更新数据库表结构,添加 isActive 字段 - 优化 MyBatis 映射文件,支持新功能
This commit is contained in:
@@ -39,6 +39,13 @@ public class ScenicAccountController {
|
|||||||
return result > 0 ? ApiResponse.success("更新成功") : ApiResponse.fail("更新失败");
|
return result > 0 ? ApiResponse.success("更新成功") : ApiResponse.fail("更新失败");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 激活/停用景区账号
|
||||||
|
@PostMapping("/updateActiveStatus/{id}")
|
||||||
|
public ApiResponse updateActiveStatus(@PathVariable Long id) {
|
||||||
|
int result = service.updateActiveStatus(id);
|
||||||
|
return result > 0 ? ApiResponse.success("操作成功") : ApiResponse.fail("操作失败");
|
||||||
|
}
|
||||||
|
|
||||||
// 更新景区账号
|
// 更新景区账号
|
||||||
@PostMapping("/update")
|
@PostMapping("/update")
|
||||||
public ApiResponse updateScenicAccount(@RequestBody ScenicAccountEntity entity) {
|
public ApiResponse updateScenicAccount(@RequestBody ScenicAccountEntity entity) {
|
||||||
|
@@ -14,6 +14,7 @@ public interface ScenicAccountMapper {
|
|||||||
int update(ScenicAccountEntity scenicAccount);
|
int update(ScenicAccountEntity scenicAccount);
|
||||||
int deleteById(Long id);
|
int deleteById(Long id);
|
||||||
int updateStatus(Long id);
|
int updateStatus(Long id);
|
||||||
|
int updateActiveStatus(Long id);
|
||||||
int deleteByScenicId(Long scenicId);
|
int deleteByScenicId(Long scenicId);
|
||||||
|
|
||||||
ScenicAccountEntity findAccountById(String id);
|
ScenicAccountEntity findAccountById(String id);
|
||||||
|
@@ -17,6 +17,7 @@ public class ScenicAccountEntity {
|
|||||||
private String account;
|
private String account;
|
||||||
private String password;
|
private String password;
|
||||||
private Integer status;
|
private Integer status;
|
||||||
|
private Integer isActive;
|
||||||
private Date createTime;
|
private Date createTime;
|
||||||
private Date updateTime;
|
private Date updateTime;
|
||||||
}
|
}
|
||||||
|
@@ -90,6 +90,9 @@ public class AppScenicServiceImpl implements AppScenicService {
|
|||||||
if (scenicAccount.getStatus() == 0) {
|
if (scenicAccount.getStatus() == 0) {
|
||||||
return ApiResponse.fail("账号已被禁用");
|
return ApiResponse.fail("账号已被禁用");
|
||||||
}
|
}
|
||||||
|
if (scenicAccount.getIsActive() == null || scenicAccount.getIsActive() != 1) {
|
||||||
|
return ApiResponse.fail("账号未激活");
|
||||||
|
}
|
||||||
if (!scenicAccount.getPassword().equals(scenicLoginReq.getPassword())) {
|
if (!scenicAccount.getPassword().equals(scenicLoginReq.getPassword())) {
|
||||||
return ApiResponse.fail("密码错误");
|
return ApiResponse.fail("密码错误");
|
||||||
}
|
}
|
||||||
|
@@ -17,5 +17,7 @@ public interface ScenicAccountService {
|
|||||||
|
|
||||||
int updateStatus(Long id);
|
int updateStatus(Long id);
|
||||||
|
|
||||||
|
int updateActiveStatus(Long id);
|
||||||
|
|
||||||
ScenicAccountEntity getScenicAccountByAccount(String account);
|
ScenicAccountEntity getScenicAccountByAccount(String account);
|
||||||
}
|
}
|
@@ -72,6 +72,11 @@ public class ScenicAccountServiceImpl implements ScenicAccountService {
|
|||||||
return mapper.updateStatus(id);
|
return mapper.updateStatus(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int updateActiveStatus(Long id) {
|
||||||
|
return mapper.updateActiveStatus(id);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ScenicAccountEntity getScenicAccountByAccount(String account) {
|
public ScenicAccountEntity getScenicAccountByAccount(String account) {
|
||||||
ScenicAccountEntity accountEntity = mapper.getByAccount(account);
|
ScenicAccountEntity accountEntity = mapper.getByAccount(account);
|
||||||
|
@@ -141,6 +141,6 @@ public class WxMpUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
generateWXAQRCode("wxe7ff26af70bfc37c", "5252fbbc68513bc77b7cc0052b9f9695", "trial", "pages/home/index?scenicId=3978838215909052416", "dhg_t.jpg");
|
generateWXAQRCode("wxe7ff26af70bfc37c", "5252fbbc68513bc77b7cc0052b9f9695", "trial", "pages/home/index?scenicId=3930324797233434624&morphId=22", "zt_p_t.jpg");
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -2,8 +2,8 @@
|
|||||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||||
<mapper namespace="com.ycwl.basic.mapper.ScenicAccountMapper">
|
<mapper namespace="com.ycwl.basic.mapper.ScenicAccountMapper">
|
||||||
<insert id="add">
|
<insert id="add">
|
||||||
insert into scenic_account(id, is_super, name, phone, account, password, create_time, update_time)
|
insert into scenic_account(id, is_super, name, phone, account, password, is_active, create_time, update_time)
|
||||||
values (#{id}, #{isSuper}, #{name}, #{phone}, #{account}, #{password}, now(), now())
|
values (#{id}, #{isSuper}, #{name}, #{phone}, #{account}, #{password}, #{isActive}, now(), now())
|
||||||
</insert>
|
</insert>
|
||||||
<insert id="addAccountScenicRelation">
|
<insert id="addAccountScenicRelation">
|
||||||
insert into account_scenic(account_id, scenic_id, is_admin)
|
insert into account_scenic(account_id, scenic_id, is_admin)
|
||||||
@@ -24,6 +24,9 @@
|
|||||||
<if test="password != null and password != ''">
|
<if test="password != null and password != ''">
|
||||||
password = #{password},
|
password = #{password},
|
||||||
</if>
|
</if>
|
||||||
|
<if test="isActive != null">
|
||||||
|
is_active = #{isActive},
|
||||||
|
</if>
|
||||||
update_time = now()
|
update_time = now()
|
||||||
</set>
|
</set>
|
||||||
where id = #{id}
|
where id = #{id}
|
||||||
@@ -39,6 +42,17 @@
|
|||||||
END)
|
END)
|
||||||
where id = #{id}
|
where id = #{id}
|
||||||
</update>
|
</update>
|
||||||
|
<update id="updateActiveStatus">
|
||||||
|
update scenic_account
|
||||||
|
set is_active = (CASE
|
||||||
|
WHEN is_active = 1 THEN
|
||||||
|
0
|
||||||
|
WHEN is_active = 0 THEN
|
||||||
|
1
|
||||||
|
ELSE 1
|
||||||
|
END)
|
||||||
|
where id = #{id}
|
||||||
|
</update>
|
||||||
<delete id="deleteById">
|
<delete id="deleteById">
|
||||||
delete from scenic_account where id = #{id}
|
delete from scenic_account where id = #{id}
|
||||||
</delete>
|
</delete>
|
||||||
@@ -53,12 +67,12 @@
|
|||||||
</delete>
|
</delete>
|
||||||
<select id="getSuperAccountOfScenic"
|
<select id="getSuperAccountOfScenic"
|
||||||
resultType="com.ycwl.basic.model.pc.scenic.entity.ScenicAccountEntity">
|
resultType="com.ycwl.basic.model.pc.scenic.entity.ScenicAccountEntity">
|
||||||
select a.id, b.scenic_id, b.is_admin as isSuper, a.name, a.phone, a.account, a.password, a.create_time, a.update_time
|
select a.id, b.scenic_id, b.is_admin as isSuper, a.name, a.phone, a.account, a.password, a.status, a.is_active, a.create_time, a.update_time
|
||||||
from scenic_account a left join account_scenic b on a.id = b.account_id
|
from scenic_account a left join account_scenic b on a.id = b.account_id
|
||||||
where b.scenic_id = #{scenicId} and b.is_admin = 1
|
where b.scenic_id = #{scenicId} and b.is_admin = 1
|
||||||
</select>
|
</select>
|
||||||
<select id="getByAccount" resultType="com.ycwl.basic.model.pc.scenic.entity.ScenicAccountEntity">
|
<select id="getByAccount" resultType="com.ycwl.basic.model.pc.scenic.entity.ScenicAccountEntity">
|
||||||
select id, scenic_id, is_super, name, phone, account, password, status,create_time, update_time
|
select id, scenic_id, is_super, name, phone, account, password, status, is_active, create_time, update_time
|
||||||
from scenic_account
|
from scenic_account
|
||||||
where account = #{account}
|
where account = #{account}
|
||||||
</select>
|
</select>
|
||||||
|
Reference in New Issue
Block a user