Commit d429ebed by lpx

# 客服电话相关接口

parent a8f4ba1b
package com.jumeirah.api.merchant.controller;
import com.jumeirah.api.merchant.entity.param.ContactStaffParam;
import com.jumeirah.common.entity.ContactStaff;
import com.jumeirah.common.param.ContactStaffPageParam;
import com.jumeirah.common.param.ContactStaffQueryVo;
import com.jumeirah.common.service.ContactStaffService;
import io.geekidea.springbootplus.framework.common.api.ApiResult;
import io.geekidea.springbootplus.framework.common.controller.BaseController;
import io.geekidea.springbootplus.framework.core.pagination.Paging;
import io.geekidea.springbootplus.framework.core.validator.groups.Add;
import io.geekidea.springbootplus.framework.core.validator.groups.Update;
import io.geekidea.springbootplus.framework.log.annotation.OperationLog;
import io.geekidea.springbootplus.framework.log.enums.OperationLogType;
import io.geekidea.springbootplus.framework.shiro.jwt.JwtToken;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PathVariable;
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.sql.Timestamp;
/**
* 控制器
*
* @author xxx
* @since 2020-10-27
*/
@Slf4j
@RestController
@RequestMapping("/merchant/contactStaff")
@Api(value = "客服信息表API", tags = {"客服信息"})
public class ContactStaffController extends BaseController {
@Autowired
private ContactStaffService contactStaffService;
/**
* 添加
*/
@PostMapping("/add")
@OperationLog(name = "添加", type = OperationLogType.ADD)
@ApiOperation(value = "添加")
public ApiResult<Boolean> addContactStaff(@Validated(Add.class) @RequestBody ContactStaffParam contactStaffParam) throws Exception {
ContactStaff contactStaff = new ContactStaff();
JwtToken jwtToken = (JwtToken) SecurityUtils.getSubject().getPrincipal();
contactStaff.setPhone(contactStaffParam.getPhone())
.setMcId(jwtToken.getMcId());
boolean flag = contactStaffService.saveContactStaff(contactStaff);
return ApiResult.result(flag);
}
/**
* 修改
*/
@PostMapping("/update")
@OperationLog(name = "修改", type = OperationLogType.UPDATE)
@ApiOperation(value = "修改")
public ApiResult<Boolean> updateContactStaff(@Validated(Update.class) @RequestBody ContactStaffParam contactStaffParam) throws Exception {
ContactStaff contactStaff = new ContactStaff();
contactStaff.setId(contactStaffParam.getId())
.setPhone(contactStaffParam.getPhone())
.setUpdateTime(new Timestamp(System.currentTimeMillis()));
boolean flag = contactStaffService.updateContactStaff(contactStaff);
return ApiResult.result(flag);
}
/**
* 删除
*/
@PostMapping("/delete/{id}")
@OperationLog(name = "删除", type = OperationLogType.DELETE)
@ApiOperation(value = "删除")
public ApiResult<Boolean> deleteContactStaff(@PathVariable("id") Long id) throws Exception {
boolean flag = contactStaffService.deleteContactStaff(id);
return ApiResult.result(flag);
}
/**
* 分页列表
*/
@PostMapping("/getPageList")
@OperationLog(name = "分页列表", type = OperationLogType.PAGE)
@ApiOperation(value = "分页列表")
public ApiResult<Paging<ContactStaffQueryVo>> getContactStaffPageList(@Validated @RequestBody ContactStaffPageParam contactStaffPageParam) throws Exception {
Paging<ContactStaffQueryVo> paging = contactStaffService.getContactStaffPageList(contactStaffPageParam);
return ApiResult.ok(paging);
}
}
package com.jumeirah.api.merchant.entity.param;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import io.geekidea.springbootplus.framework.common.entity.BaseEntity;
import io.geekidea.springbootplus.framework.core.validator.groups.Update;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotNull;
/**
* @author xxx
* @since 2020-10-27
*/
@Data
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = true)
@ApiModel(value = "ContactStaff对象")
public class ContactStaffParam extends BaseEntity {
private static final long serialVersionUID = 1L;
@NotNull(message = "id不能为空", groups = {Update.class})
@ApiModelProperty("主键ID")
@TableId(value = "id", type = IdType.AUTO)
private Long id;
@ApiModelProperty("客服电话")
private String phone;
}
package com.jumeirah.common.controller;
import com.jumeirah.common.entity.ContactStaff;
import com.jumeirah.common.param.ContactStaffPageParam;
import com.jumeirah.common.param.ContactStaffQueryVo;
import com.jumeirah.common.service.ContactStaffService;
import io.geekidea.springbootplus.framework.common.api.ApiResult;
import io.geekidea.springbootplus.framework.common.controller.BaseController;
import io.geekidea.springbootplus.framework.core.pagination.Paging;
import io.geekidea.springbootplus.framework.core.validator.groups.Add;
import io.geekidea.springbootplus.framework.core.validator.groups.Update;
import io.geekidea.springbootplus.framework.log.annotation.OperationLog;
import io.geekidea.springbootplus.framework.log.enums.OperationLogType;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
/**
* 控制器
*
* @author xxx
* @since 2020-10-27
*/
/*@Slf4j
@RestController
@RequestMapping("/contactStaff")
@Api(value = "API", tags = {""})*/
public class ContactStaffController extends BaseController {
@Autowired
private ContactStaffService contactStaffService;
/**
* 添加
*/
@PostMapping("/add")
@OperationLog(name = "添加", type = OperationLogType.ADD)
@ApiOperation(value = "添加")
public ApiResult<Boolean> addContactStaff(@Validated(Add.class) @RequestBody ContactStaff contactStaff) throws Exception {
boolean flag = contactStaffService.saveContactStaff(contactStaff);
return ApiResult.result(flag);
}
/**
* 修改
*/
@PostMapping("/update")
@OperationLog(name = "修改", type = OperationLogType.UPDATE)
@ApiOperation(value = "修改")
public ApiResult<Boolean> updateContactStaff(@Validated(Update.class) @RequestBody ContactStaff contactStaff) throws Exception {
boolean flag = contactStaffService.updateContactStaff(contactStaff);
return ApiResult.result(flag);
}
/**
* 删除
*/
@PostMapping("/delete/{id}")
@OperationLog(name = "删除", type = OperationLogType.DELETE)
@ApiOperation(value = "删除")
public ApiResult<Boolean> deleteContactStaff(@PathVariable("id") Long id) throws Exception {
boolean flag = contactStaffService.deleteContactStaff(id);
return ApiResult.result(flag);
}
/**
* 获取详情
*/
@GetMapping("/info/{id}")
@OperationLog(name = "详情", type = OperationLogType.INFO)
@ApiOperation(value = "详情")
public ApiResult<ContactStaffQueryVo> getContactStaff(@PathVariable("id") Long id) throws Exception {
ContactStaffQueryVo contactStaffQueryVo = contactStaffService.getContactStaffById(id);
return ApiResult.ok(contactStaffQueryVo);
}
/**
* 分页列表
*/
@PostMapping("/getPageList")
@OperationLog(name = "分页列表", type = OperationLogType.PAGE)
@ApiOperation(value = "分页列表")
public ApiResult<Paging<ContactStaffQueryVo>> getContactStaffPageList(@Validated @RequestBody ContactStaffPageParam contactStaffPageParam) throws Exception {
Paging<ContactStaffQueryVo> paging = contactStaffService.getContactStaffPageList(contactStaffPageParam);
return ApiResult.ok(paging);
}
}
package com.jumeirah.common.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import io.geekidea.springbootplus.framework.common.entity.BaseEntity;
import io.geekidea.springbootplus.framework.core.validator.groups.Update;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotNull;
import java.sql.Timestamp;
/**
* @author xxx
* @since 2020-10-27
*/
@Data
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = true)
@ApiModel(value = "ContactStaff对象")
public class ContactStaff extends BaseEntity {
private static final long serialVersionUID = 1L;
@NotNull(message = "id不能为空", groups = {Update.class})
@ApiModelProperty("主键ID")
@TableId(value = "id", type = IdType.AUTO)
private Long id;
@ApiModelProperty("客服电话")
private String phone;
@ApiModelProperty("状态,0-正常,1-封禁,99-删除")
private Integer status;
@NotNull(message = "商家id不能为空")
@ApiModelProperty("商家id")
private Long mcId;
@ApiModelProperty("创建时间")
private Timestamp createTime;
@ApiModelProperty("更新时间")
private Timestamp updateTime;
}
package com.jumeirah.common.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.jumeirah.common.entity.ContactStaff;
import com.jumeirah.common.param.ContactStaffPageParam;
import com.jumeirah.common.param.ContactStaffQueryVo;
import org.springframework.stereotype.Repository;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Param;
import java.io.Serializable;
/**
* Mapper 接口
*
* @author xxx
* @since 2020-10-27
*/
@Repository
public interface ContactStaffMapper extends BaseMapper<ContactStaff> {
/**
* 根据ID获取查询对象
*
* @param id
* @return
*/
ContactStaffQueryVo getContactStaffById(Serializable id);
/**
* 获取分页对象
*
* @param page
* @param contactStaffPageParam
* @return
*/
IPage<ContactStaffQueryVo> getContactStaffPageList(@Param("page") Page page, @Param("param") ContactStaffPageParam contactStaffPageParam);
}
package com.jumeirah.common.param;
import io.swagger.annotations.ApiModel;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import io.geekidea.springbootplus.framework.core.pagination.BasePageOrderParam;
/**
* <pre>
* 分页参数对象
* </pre>
*
* @author xxx
* @date 2020-10-27
*/
@Data
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = true)
@ApiModel(value = "分页参数")
public class ContactStaffPageParam extends BasePageOrderParam {
private static final long serialVersionUID = 1L;
}
package com.jumeirah.common.param;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import java.io.Serializable;
import java.sql.Timestamp;
/**
* <pre>
* 查询结果对象
* </pre>
*
* @author xxx
* @date 2020-10-27
*/
@Data
@Accessors(chain = true)
@ApiModel(value = "ContactStaffQueryVo对象")
public class ContactStaffQueryVo implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty("主键ID")
private Long id;
@ApiModelProperty("客服电话")
private String phone;
@ApiModelProperty("状态,0-正常,1-封禁,99-删除")
private Integer status;
@ApiModelProperty("商家id")
private Long mcId;
@ApiModelProperty("创建时间")
private Timestamp createTime;
@ApiModelProperty("更新时间")
private Timestamp updateTime;
}
package com.jumeirah.common.service;
import com.jumeirah.common.entity.ContactStaff;
import com.jumeirah.common.param.ContactStaffPageParam;
import io.geekidea.springbootplus.framework.common.service.BaseService;
import com.jumeirah.common.param.ContactStaffQueryVo;
import io.geekidea.springbootplus.framework.core.pagination.Paging;
/**
* 服务类
*
* @author xxx
* @since 2020-10-27
*/
public interface ContactStaffService extends BaseService<ContactStaff> {
/**
* 保存
*
* @param contactStaff
* @return
* @throws Exception
*/
boolean saveContactStaff(ContactStaff contactStaff) throws Exception;
/**
* 修改
*
* @param contactStaff
* @return
* @throws Exception
*/
boolean updateContactStaff(ContactStaff contactStaff) throws Exception;
/**
* 删除
*
* @param id
* @return
* @throws Exception
*/
boolean deleteContactStaff(Long id) throws Exception;
/**
* 根据ID获取查询对象
*
* @param id
* @return
* @throws Exception
*/
ContactStaffQueryVo getContactStaffById(Long id) throws Exception;
/**
* 获取分页对象
*
* @param contactStaffPageParam
* @return
* @throws Exception
*/
Paging<ContactStaffQueryVo> getContactStaffPageList(ContactStaffPageParam contactStaffPageParam) throws Exception;
}
package com.jumeirah.common.service.impl;
import com.jumeirah.common.entity.ContactStaff;
import com.jumeirah.common.mapper.ContactStaffMapper;
import com.jumeirah.common.service.ContactStaffService;
import com.jumeirah.common.param.ContactStaffPageParam;
import com.jumeirah.common.param.ContactStaffQueryVo;
import io.geekidea.springbootplus.framework.common.service.impl.BaseServiceImpl;
import io.geekidea.springbootplus.framework.core.pagination.Paging;
import io.geekidea.springbootplus.framework.core.pagination.PageInfo;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.metadata.OrderItem;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.transaction.annotation.Transactional;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.beans.factory.annotation.Autowired;
/**
* 服务实现类
*
* @author xxx
* @since 2020-10-27
*/
@Slf4j
@Service
public class ContactStaffServiceImpl extends BaseServiceImpl<ContactStaffMapper, ContactStaff> implements ContactStaffService {
@Autowired
private ContactStaffMapper contactStaffMapper;
@Transactional(rollbackFor = Exception.class)
@Override
public boolean saveContactStaff(ContactStaff contactStaff) throws Exception {
return super.save(contactStaff);
}
@Transactional(rollbackFor = Exception.class)
@Override
public boolean updateContactStaff(ContactStaff contactStaff) throws Exception {
return super.updateById(contactStaff);
}
@Transactional(rollbackFor = Exception.class)
@Override
public boolean deleteContactStaff(Long id) throws Exception {
return super.removeById(id);
}
@Override
public ContactStaffQueryVo getContactStaffById(Long id) throws Exception {
return contactStaffMapper.getContactStaffById(id);
}
@Override
public Paging<ContactStaffQueryVo> getContactStaffPageList(ContactStaffPageParam contactStaffPageParam) throws Exception {
Page<ContactStaffQueryVo> page = new PageInfo<>(contactStaffPageParam, OrderItem.desc(getLambdaColumn(ContactStaff::getCreateTime)));
IPage<ContactStaffQueryVo> iPage = contactStaffMapper.getContactStaffPageList(page, contactStaffPageParam);
return new Paging<ContactStaffQueryVo>(iPage);
}
}
<?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.jumeirah.common.mapper.ContactStaffMapper">
<!-- 通用查询结果列 -->
<sql id="Base_Column_List">
id, phone, status, mc_id, create_time, update_time
</sql>
<select id="getContactStaffById" resultType="com.jumeirah.common.param.ContactStaffQueryVo">
select
<include refid="Base_Column_List"/>
from contact_staff where id = #{id}
</select>
<select id="getContactStaffPageList" parameterType="com.jumeirah.common.param.ContactStaffPageParam"
resultType="com.jumeirah.common.param.ContactStaffQueryVo">
select
<include refid="Base_Column_List"/>
from contact_staff
</select>
</mapper>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment