12 changed files with 385 additions and 21 deletions
@ -0,0 +1,18 @@ |
|||
package com.yxt.supervise.system.useropenid; |
|||
|
|||
import com.baomidou.mybatisplus.annotation.TableName; |
|||
import lombok.Data; |
|||
|
|||
/** |
|||
* @author wangpengfei |
|||
* @date 2023/8/8 16:31 |
|||
*/ |
|||
@Data |
|||
@TableName("user_openid") |
|||
public class UserOpenid { |
|||
private String id; |
|||
private String sid; |
|||
private String mobile; |
|||
private String openid; |
|||
private String state; |
|||
} |
@ -0,0 +1,17 @@ |
|||
package com.yxt.supervise.system.useropenid; |
|||
|
|||
import com.yxt.common.core.dto.Dto; |
|||
import lombok.Data; |
|||
|
|||
/** |
|||
* @author wangpengfei |
|||
* @date 2023/8/8 16:32 |
|||
*/ |
|||
@Data |
|||
public class UserOpenidDto implements Dto { |
|||
private String id; |
|||
private String sid; |
|||
private String mobile; |
|||
private String openid; |
|||
private String state; |
|||
} |
@ -0,0 +1,42 @@ |
|||
package com.yxt.supervise.system.useropenid; |
|||
|
|||
import com.baomidou.mybatisplus.core.conditions.Wrapper; |
|||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
|||
import com.baomidou.mybatisplus.core.metadata.IPage; |
|||
import com.baomidou.mybatisplus.core.toolkit.Constants; |
|||
|
|||
import org.apache.ibatis.annotations.Delete; |
|||
import org.apache.ibatis.annotations.Mapper; |
|||
import org.apache.ibatis.annotations.Param; |
|||
import org.apache.ibatis.annotations.Select; |
|||
|
|||
import java.util.List; |
|||
|
|||
|
|||
@Mapper |
|||
public interface UserOpenidMapper extends BaseMapper<UserOpenid> { |
|||
|
|||
IPage<UserOpenidVo> selectPageVo(IPage<UserOpenid> page, @Param(Constants.WRAPPER) Wrapper<UserOpenid> qw); |
|||
|
|||
List<UserOpenidVo> selectListAllVo(@Param(Constants.WRAPPER) Wrapper<UserOpenid> qw); |
|||
|
|||
@Select("select * from sys_staff_post") |
|||
List<UserOpenidVo> selectListVo(); |
|||
|
|||
@Delete("delete from sys_staff_post where staffSid=#{staffSid} ") |
|||
void deleteByStaffSid(String staffSid); |
|||
|
|||
/** |
|||
* 根据员工sid查询员工的岗位信息 |
|||
* |
|||
* @param sid 员工的sid |
|||
* @return |
|||
*/ |
|||
UserOpenid selectByStaffSid(@Param("sid") String sid, @Param("postSid") String postSid); |
|||
|
|||
|
|||
|
|||
String selectPost(String sid); |
|||
|
|||
List<String> getPost(String staffSid); |
|||
} |
@ -0,0 +1,45 @@ |
|||
<?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.yxt.supervise.system.useropenid.UserOpenidMapper"> |
|||
<!-- <where> ${ew.sqlSegment} </where>--> |
|||
<!-- ${ew.customSqlSegment} --> |
|||
<select id="selectPageVo" resultType="com.yxt.supervise.system.useropenid.UserOpenidVo"> |
|||
SELECT * |
|||
FROM sys_staff_post |
|||
<where> |
|||
${ew.sqlSegment} |
|||
</where> |
|||
</select> |
|||
|
|||
<select id="selectListAllVo" resultType="com.yxt.supervise.system.useropenid.UserOpenidVo"> |
|||
SELECT * |
|||
FROM sys_staff_post |
|||
<where> |
|||
${ew.sqlSegment} |
|||
</where> |
|||
</select> |
|||
<!--根据员工的sid查询员工的岗位信息--> |
|||
<select id="selectByStaffSid" resultType="com.yxt.supervise.system.useropenid.UserOpenid"> |
|||
select * |
|||
from sys_staff_post |
|||
where staffSid = #{sid} |
|||
and postSid = #{postSid} |
|||
</select> |
|||
|
|||
|
|||
|
|||
<select id="selectPost" resultType="java.lang.String"> |
|||
select sr.sid |
|||
from sys_staff_post ssp |
|||
left join sys_post sp on sp.sid = ssp.postSid |
|||
left join sys_role sr on sp.parentSid = sr.postSid |
|||
where ssp.staffSid = #{sid} |
|||
</select> |
|||
|
|||
<select id="getPost" resultType="java.lang.String"> |
|||
select sp.name |
|||
from sys_staff_post ssp |
|||
left join sys_post sp on ssp.postSid = sp.sid |
|||
where ssp.staffSid = #{staffSid} |
|||
</select> |
|||
</mapper> |
@ -0,0 +1,17 @@ |
|||
package com.yxt.supervise.system.useropenid; |
|||
|
|||
import com.yxt.common.core.query.Query; |
|||
import lombok.Data; |
|||
|
|||
/** |
|||
* @author wangpengfei |
|||
* @date 2023/8/8 16:32 |
|||
*/ |
|||
@Data |
|||
public class UserOpenidQuery implements Query { |
|||
private String id; |
|||
private String sid; |
|||
private String mobile; |
|||
private String openid; |
|||
private String state; |
|||
} |
@ -0,0 +1,74 @@ |
|||
package com.yxt.supervise.system.useropenid; |
|||
|
|||
import com.yxt.common.base.config.RedisUtil; |
|||
import com.yxt.common.base.utils.StringUtils; |
|||
import com.yxt.common.core.query.PagerQuery; |
|||
import com.yxt.common.core.result.ResultBean; |
|||
import com.yxt.common.core.vo.PagerVo; |
|||
import com.yxt.supervise.system.sysuser.SysUser; |
|||
import com.yxt.supervise.system.sysuser.SysUserService; |
|||
import io.swagger.annotations.Api; |
|||
import io.swagger.annotations.ApiOperation; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.web.bind.annotation.*; |
|||
|
|||
import javax.servlet.http.HttpServletRequest; |
|||
import java.util.List; |
|||
|
|||
/** |
|||
* @author wangpengfei |
|||
* @date 2023/8/8 16:32 |
|||
*/ |
|||
@Api(tags = "用户和微信小程序openid") |
|||
@RestController |
|||
@RequestMapping("useropenid") |
|||
public class UserOpenidRest { |
|||
|
|||
@Autowired |
|||
private UserOpenidService UserOpenidService; |
|||
|
|||
|
|||
|
|||
public ResultBean<PagerVo<UserOpenidVo>> listPage(@RequestBody PagerQuery<UserOpenidQuery> pq) { |
|||
ResultBean rb = ResultBean.fireFail(); |
|||
PagerVo<UserOpenidVo> pv = UserOpenidService.listPageVo(pq); |
|||
return rb.success().setData(pv); |
|||
} |
|||
|
|||
|
|||
public ResultBean<List<UserOpenidVo>> listAll(@RequestBody UserOpenidQuery query) { |
|||
ResultBean rb = ResultBean.fireFail(); |
|||
List<UserOpenidVo> list = UserOpenidService.listAllVo(query); |
|||
return rb.success().setData(list); |
|||
} |
|||
|
|||
|
|||
public ResultBean<List<UserOpenidVo>> list() { |
|||
ResultBean rb = ResultBean.fireFail(); |
|||
List<UserOpenidVo> list = UserOpenidService.listVo(); |
|||
return rb.success().setData(list); |
|||
} |
|||
|
|||
@ApiOperation(value = "保存") |
|||
@PostMapping("/save") |
|||
public ResultBean save(@RequestBody UserOpenidDto dto) { |
|||
ResultBean rb = ResultBean.fireFail(); |
|||
UserOpenidService.saveOrUpdateDto(dto); |
|||
return rb.success(); |
|||
} |
|||
|
|||
@ApiOperation(value = "修改") |
|||
@PostMapping("/update") |
|||
public ResultBean update(@RequestBody UserOpenidDto dto, String sid) { |
|||
ResultBean rb = ResultBean.fireFail(); |
|||
UserOpenidService.updateBySid(dto.toMap(), sid); |
|||
return rb.success(); |
|||
} |
|||
|
|||
public ResultBean del(String ids) { |
|||
ResultBean rb = ResultBean.fireFail(); |
|||
UserOpenidService.delByIds(ids); |
|||
return rb.success(); |
|||
} |
|||
|
|||
} |
@ -0,0 +1,103 @@ |
|||
package com.yxt.supervise.system.useropenid; |
|||
|
|||
import cn.hutool.core.bean.BeanUtil; |
|||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|||
import com.baomidou.mybatisplus.core.metadata.IPage; |
|||
import com.yxt.common.base.service.MybatisBaseService; |
|||
import com.yxt.common.base.utils.PagerUtil; |
|||
import com.yxt.common.core.query.PagerQuery; |
|||
import com.yxt.common.core.vo.PagerVo; |
|||
|
|||
import org.apache.commons.lang3.StringUtils; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
import java.util.List; |
|||
import java.util.UUID; |
|||
|
|||
/** |
|||
* @author wangpengfei |
|||
* @date 2023/8/8 16:32 |
|||
*/ |
|||
@Service |
|||
public class UserOpenidService extends MybatisBaseService<UserOpenidMapper, UserOpenid> { |
|||
public PagerVo<UserOpenid> listPage(PagerQuery<UserOpenidQuery> pq) { |
|||
UserOpenidQuery query = pq.getParams(); |
|||
QueryWrapper<UserOpenid> qw = new QueryWrapper<>(); |
|||
IPage<UserOpenid> page = PagerUtil.queryToPage(pq); |
|||
IPage<UserOpenid> pagging = baseMapper.selectPage(page, qw); |
|||
PagerVo<UserOpenid> p = PagerUtil.pageToVo(pagging, null); |
|||
return p; |
|||
} |
|||
|
|||
public List<UserOpenid> listAll(UserOpenidQuery query) { |
|||
QueryWrapper<UserOpenid> qw = new QueryWrapper<>(); |
|||
return baseMapper.selectList(qw); |
|||
} |
|||
|
|||
// private QueryWrapper<UserOpenid> createQueryWrapper(UserOpenidQuery query) {
|
|||
// // todo: 这里根据具体业务调整查询条件
|
|||
// // 多字段Like示例:qw.and(wrapper -> wrapper.like("name", query.getName()).or().like("remark", query.getName()));
|
|||
// QueryWrapper<UserOpenid> qw = new QueryWrapper<>();
|
|||
//
|
|||
//
|
|||
// if (StringUtils.isNotBlank(query.getStaffSid())) {
|
|||
// qw.eq("staffSid", query.getStaffSid());
|
|||
// }
|
|||
//
|
|||
// if (StringUtils.isNotBlank(query.getOrgSid())) {
|
|||
// qw.eq("orgSid", query.getOrgSid());
|
|||
// }
|
|||
//
|
|||
// if (StringUtils.isNotBlank(query.getPostSid())) {
|
|||
// qw.eq("postSid", query.getPostSid());
|
|||
// }
|
|||
//
|
|||
// if (query.getStartDateStart() != null) {
|
|||
// qw.ge("startDate", query.getStartDateStart());
|
|||
// }
|
|||
// if (query.getStartDateEnd() != null) {
|
|||
// qw.le("startDate", query.getStartDateEnd());
|
|||
// }
|
|||
//
|
|||
// if (query.getIsDepetHead() != null) {
|
|||
// qw.eq("isDepetHead", query.getIsDepetHead());
|
|||
// }
|
|||
// return qw;
|
|||
// }
|
|||
|
|||
public PagerVo<UserOpenidVo> listPageVo(PagerQuery<UserOpenidQuery> pq) { |
|||
UserOpenidQuery query = pq.getParams(); |
|||
QueryWrapper<UserOpenid> qw = new QueryWrapper<>(); |
|||
IPage<UserOpenid> page = PagerUtil.queryToPage(pq); |
|||
IPage<UserOpenidVo> pagging = baseMapper.selectPageVo(page, qw); |
|||
PagerVo<UserOpenidVo> p = PagerUtil.pageToVo(pagging, null); |
|||
return p; |
|||
} |
|||
|
|||
public List<UserOpenidVo> listAllVo(UserOpenidQuery query) { |
|||
QueryWrapper<UserOpenid> qw = new QueryWrapper<>(); |
|||
return baseMapper.selectListAllVo(qw); |
|||
} |
|||
|
|||
public List<UserOpenidVo> listVo() { |
|||
return baseMapper.selectListVo(); |
|||
} |
|||
|
|||
public void saveOrUpdateDto(UserOpenidDto dto) { |
|||
UserOpenid entity = new UserOpenid(); |
|||
BeanUtil.copyProperties(dto, entity, "id", "sid"); |
|||
entity.setSid(UUID.randomUUID().toString()); |
|||
this.saveOrUpdate(entity); |
|||
} |
|||
|
|||
public UserOpenidVo fetchByIdVo(String id) { |
|||
UserOpenid entity = this.fetchById(id); |
|||
UserOpenidVo vo = new UserOpenidVo(); |
|||
BeanUtil.copyProperties(entity, vo); |
|||
return vo; |
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
} |
@ -0,0 +1,17 @@ |
|||
package com.yxt.supervise.system.useropenid; |
|||
|
|||
import com.yxt.common.core.vo.Vo; |
|||
import lombok.Data; |
|||
|
|||
/** |
|||
* @author wangpengfei |
|||
* @date 2023/8/8 16:32 |
|||
*/ |
|||
@Data |
|||
public class UserOpenidVo implements Vo { |
|||
private String id; |
|||
private String sid; |
|||
private String mobile; |
|||
private String openid; |
|||
private String state; |
|||
} |
Loading…
Reference in new issue