景区账号管理
This commit is contained in:
parent
d9619e6fea
commit
da72e7e0a9
@ -0,0 +1,68 @@
|
|||||||
|
package com.ycwl.basic.controller.pc;
|
||||||
|
|
||||||
|
import com.github.pagehelper.PageHelper;
|
||||||
|
import com.github.pagehelper.PageInfo;
|
||||||
|
import com.ycwl.basic.model.pc.scenic.entity.ScenicAccountEntity;
|
||||||
|
import com.ycwl.basic.model.pc.scenic.req.ScenicAccountReqQuery;
|
||||||
|
import com.ycwl.basic.service.pc.ScenicAccountService;
|
||||||
|
import com.ycwl.basic.utils.ApiResponse;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/api/scenicAccount/v1")
|
||||||
|
public class ScenicAccountController {
|
||||||
|
@Autowired
|
||||||
|
private ScenicAccountService service;
|
||||||
|
|
||||||
|
// 添加景区账号
|
||||||
|
@PostMapping("/add")
|
||||||
|
public ApiResponse addScenicAccount(@RequestBody ScenicAccountEntity entity) {
|
||||||
|
int result = service.addScenicAccount(entity);
|
||||||
|
return result > 0 ? ApiResponse.success("添加成功") : ApiResponse.fail("添加失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 删除景区账号
|
||||||
|
@DeleteMapping("/delete/{id}")
|
||||||
|
public ApiResponse deleteScenicAccount(@PathVariable Long id) {
|
||||||
|
int result = service.deleteScenicAccount(id);
|
||||||
|
return result > 0 ? ApiResponse.success("删除成功") : ApiResponse.fail("删除失败");
|
||||||
|
}
|
||||||
|
@PostMapping("/updateStatus/{id}")
|
||||||
|
public ApiResponse updateStatus(@PathVariable Long id) {
|
||||||
|
int result = service.updateStatus(id);
|
||||||
|
return result > 0 ? ApiResponse.success("更新成功") : ApiResponse.fail("更新失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 更新景区账号
|
||||||
|
@PostMapping("/update")
|
||||||
|
public ApiResponse updateScenicAccount(@RequestBody ScenicAccountEntity entity) {
|
||||||
|
int result = service.updateScenicAccount(entity);
|
||||||
|
return result > 0 ? ApiResponse.success("更新成功") : ApiResponse.fail("更新失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 根据ID查询景区账号
|
||||||
|
@GetMapping("/get/{id}")
|
||||||
|
public ApiResponse getScenicAccount(@PathVariable Long id) {
|
||||||
|
ScenicAccountEntity entity = service.getScenicAccountById(id);
|
||||||
|
return entity != null ? ApiResponse.success(entity) : ApiResponse.fail("未找到该账号");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 根据景区ID查询超级账号
|
||||||
|
@GetMapping("/super/{scenicId}")
|
||||||
|
public ApiResponse getSuperAccount(@PathVariable Long scenicId) {
|
||||||
|
ScenicAccountEntity entity = service.getSuperAccountByScenicId(scenicId);
|
||||||
|
return entity != null ? ApiResponse.success(entity) : ApiResponse.fail("未找到超级账号");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 新增分页查询接口
|
||||||
|
@PostMapping("/page")
|
||||||
|
public ApiResponse<PageInfo<ScenicAccountEntity>> pageQuery(@RequestBody ScenicAccountReqQuery req) {
|
||||||
|
PageHelper.startPage(req.getPageNum(), req.getPageSize());
|
||||||
|
List<ScenicAccountEntity> list = service.pageQuery(req);
|
||||||
|
PageInfo<ScenicAccountEntity> pageInfo = new PageInfo<>(list);
|
||||||
|
return ApiResponse.success(pageInfo);
|
||||||
|
}
|
||||||
|
}
|
@ -1,8 +1,11 @@
|
|||||||
package com.ycwl.basic.mapper;
|
package com.ycwl.basic.mapper;
|
||||||
|
|
||||||
import com.ycwl.basic.model.pc.scenic.entity.ScenicAccountEntity;
|
import com.ycwl.basic.model.pc.scenic.entity.ScenicAccountEntity;
|
||||||
|
import com.ycwl.basic.model.pc.scenic.req.ScenicAccountReqQuery;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface ScenicAccountMapper {
|
public interface ScenicAccountMapper {
|
||||||
ScenicAccountEntity getByAccount(String account);
|
ScenicAccountEntity getByAccount(String account);
|
||||||
@ -14,4 +17,6 @@ public interface ScenicAccountMapper {
|
|||||||
int deleteByScenicId(Long scenicId);
|
int deleteByScenicId(Long scenicId);
|
||||||
|
|
||||||
ScenicAccountEntity findAccountById(String id);
|
ScenicAccountEntity findAccountById(String id);
|
||||||
|
List<ScenicAccountEntity> pageQuery(ScenicAccountReqQuery req);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,35 @@
|
|||||||
|
package com.ycwl.basic.model.pc.scenic.req;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import com.ycwl.basic.model.common.BaseQueryParameterReq;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@Data
|
||||||
|
@ApiModel("景区账号分页查询请求参数")
|
||||||
|
public class ScenicAccountReqQuery extends BaseQueryParameterReq {
|
||||||
|
@ApiModelProperty("景区ID")
|
||||||
|
private Long scenicId;
|
||||||
|
|
||||||
|
@ApiModelProperty("账号名称")
|
||||||
|
private String account;
|
||||||
|
|
||||||
|
@ApiModelProperty("账号状态(1启用/0关闭)")
|
||||||
|
private Integer status;
|
||||||
|
|
||||||
|
@ApiModelProperty("是否超级管理员(1是/0否)")
|
||||||
|
private Integer isSuper;
|
||||||
|
|
||||||
|
@ApiModelProperty("创建时间起始")
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||||
|
private Date startTime;
|
||||||
|
|
||||||
|
@ApiModelProperty("创建时间结束")
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||||
|
private Date endTime;
|
||||||
|
}
|
@ -0,0 +1,19 @@
|
|||||||
|
package com.ycwl.basic.service.pc;
|
||||||
|
|
||||||
|
import com.ycwl.basic.model.pc.scenic.entity.ScenicAccountEntity;
|
||||||
|
import com.ycwl.basic.model.pc.scenic.req.ScenicAccountReqQuery;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface ScenicAccountService {
|
||||||
|
int addScenicAccount(ScenicAccountEntity entity);
|
||||||
|
int deleteScenicAccount(Long id);
|
||||||
|
int updateScenicAccount(ScenicAccountEntity entity);
|
||||||
|
ScenicAccountEntity getScenicAccountById(Long id);
|
||||||
|
ScenicAccountEntity getSuperAccountByScenicId(Long scenicId);
|
||||||
|
|
||||||
|
// 新增分页查询方法定义
|
||||||
|
List<ScenicAccountEntity> pageQuery(ScenicAccountReqQuery req);
|
||||||
|
|
||||||
|
int updateStatus(Long id);
|
||||||
|
}
|
@ -0,0 +1,56 @@
|
|||||||
|
package com.ycwl.basic.service.pc.impl;
|
||||||
|
|
||||||
|
import com.ycwl.basic.model.pc.scenic.entity.ScenicAccountEntity;
|
||||||
|
import com.ycwl.basic.model.pc.scenic.req.ScenicAccountReqQuery;
|
||||||
|
import com.ycwl.basic.service.pc.ScenicAccountService;
|
||||||
|
import com.ycwl.basic.utils.SnowFlakeUtil;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import com.ycwl.basic.mapper.ScenicAccountMapper;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class ScenicAccountServiceImpl implements ScenicAccountService {
|
||||||
|
@Autowired
|
||||||
|
private ScenicAccountMapper mapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int addScenicAccount(ScenicAccountEntity entity) {
|
||||||
|
if (entity.getId() == null) {
|
||||||
|
entity.setId(SnowFlakeUtil.getLongId());
|
||||||
|
}
|
||||||
|
return mapper.add(entity);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int deleteScenicAccount(Long id) {
|
||||||
|
return mapper.deleteById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int updateScenicAccount(ScenicAccountEntity entity) {
|
||||||
|
return mapper.update(entity);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ScenicAccountEntity getScenicAccountById(Long id) {
|
||||||
|
return mapper.findAccountById(String.valueOf(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ScenicAccountEntity getSuperAccountByScenicId(Long scenicId) {
|
||||||
|
return mapper.getSuperAccountOfScenic(scenicId);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 新增分页查询实现
|
||||||
|
@Override
|
||||||
|
public List<ScenicAccountEntity> pageQuery(ScenicAccountReqQuery req) {
|
||||||
|
return mapper.pageQuery(req);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int updateStatus(Long id) {
|
||||||
|
return mapper.updateStatus(id);
|
||||||
|
}
|
||||||
|
}
|
@ -54,4 +54,28 @@
|
|||||||
from scenic_account
|
from scenic_account
|
||||||
where id = #{id}
|
where id = #{id}
|
||||||
</select>
|
</select>
|
||||||
|
<select id="pageQuery" resultType="com.ycwl.basic.model.pc.scenic.entity.ScenicAccountEntity">
|
||||||
|
SELECT * FROM scenic_account
|
||||||
|
<where>
|
||||||
|
<if test="scenicId != null">
|
||||||
|
AND scenic_id = #{scenicId}
|
||||||
|
</if>
|
||||||
|
<if test="account != null">
|
||||||
|
AND account LIKE CONCAT('%', #{account}, '%')
|
||||||
|
</if>
|
||||||
|
<if test="status != null">
|
||||||
|
AND status = #{status}
|
||||||
|
</if>
|
||||||
|
<if test="isSuper != null">
|
||||||
|
AND is_super = #{isSuper}
|
||||||
|
</if>
|
||||||
|
<if test="startTime != null">
|
||||||
|
AND create_time >= #{startTime}
|
||||||
|
</if>
|
||||||
|
<if test="endTime != null">
|
||||||
|
AND create_time <= #{endTime}
|
||||||
|
</if>
|
||||||
|
</where>
|
||||||
|
ORDER BY create_time DESC
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
Loading…
x
Reference in New Issue
Block a user