| @@ -0,0 +1,95 @@ | |||
| package com.iformall.controller.sm; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.annotation.SystemControllerLog; | |||
| import com.iformall.common.ErrorCode; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.controller.base.BaseController; | |||
| import com.iformall.domain.po.base.BaseEntity; | |||
| import com.iformall.domain.po.sm.MouldPatch; | |||
| import com.iformall.domain.po.sm.MouldPatchSign; | |||
| import com.iformall.domain.po.sm.UserInviteCode; | |||
| import com.iformall.enums.EnumYesOrNo; | |||
| import com.iformall.service.sm.MouldPatchService; | |||
| import com.iformall.service.sm.MouldPatchSignService; | |||
| import com.iformall.service.sm.UserInviteCodeService; | |||
| import com.iformall.utils.sign.AppUtils; | |||
| import io.swagger.annotations.Api; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| import io.swagger.annotations.ApiImplicitParams; | |||
| import io.swagger.annotations.ApiOperation; | |||
| import org.apache.commons.lang3.StringUtils; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.web.bind.annotation.*; | |||
| import java.util.List; | |||
| @RestController | |||
| @RequestMapping("inviteCode") | |||
| @Api(description = "邀请码接口") | |||
| public class UserInviteCodeController extends BaseController { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @Autowired | |||
| private UserInviteCodeService userInviteCodeService; | |||
| @ApiOperation("分页列表接口") | |||
| @GetMapping("list") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||
| public ResultData list(@ModelAttribute UserInviteCode record, Integer pageNum, Integer pageSize) { | |||
| logger.debug("[" + getIpAddr() + "] UserInviteCodeController::list"); | |||
| if (record == null) record = new UserInviteCode(); | |||
| record.setSortColumns(BaseEntity.SortField.UpdateDate_DESC); | |||
| final PageInfo<UserInviteCode> page = userInviteCodeService.listAsPage(record, pageNum, pageSize); | |||
| return new ResultData(page); | |||
| } | |||
| @ApiOperation("新增接口") | |||
| @PostMapping("save") | |||
| @SystemControllerLog(description = "-新增") | |||
| public ResultData save(@RequestBody UserInviteCode record) { | |||
| logger.debug("[" + getIpAddr() + "] UserInviteCodeController::saveOrUpdate"); | |||
| if(StringUtils.isBlank(record.getInviteName())){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||
| } | |||
| record.setId(null); | |||
| record.setInviteCode(AppUtils.getAppId()); | |||
| UserInviteCode inviteCode = new UserInviteCode(); | |||
| inviteCode.setInviteCode(record.getInviteCode()); | |||
| inviteCode = userInviteCodeService.selectOne(inviteCode); | |||
| if(inviteCode != null){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"生成邀请码重复,请重新生成"); | |||
| } | |||
| record.updateTenantInfo(getTenantInfo()); | |||
| userInviteCodeService.saveOrUpdate(record); | |||
| return new ResultData(record); | |||
| } | |||
| @ApiOperation("根据id删除接口") | |||
| @GetMapping("/del") | |||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||
| @SystemControllerLog(description = "删除") | |||
| public ResultData delete(Long id) { | |||
| logger.debug("[" + getIpAddr() + "] UserInviteCodeController::delete"); | |||
| userInviteCodeService.deleteById(id); | |||
| return new ResultData(); | |||
| } | |||
| @ApiOperation("根据id查询接口") | |||
| @GetMapping("/findById") | |||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||
| @SystemControllerLog(description = "查询") | |||
| public ResultData findById(Long id) { | |||
| logger.debug("[" + getIpAddr() + "] UserInviteCodeController::findById"); | |||
| UserInviteCode inviteCode = userInviteCodeService.getById(id); | |||
| return new ResultData(inviteCode); | |||
| } | |||
| } | |||
| @@ -106,6 +106,14 @@ public class BaseController { | |||
| return new TenantEntity(); | |||
| } | |||
| public WxCUserBasicInfo getCUser() { | |||
| HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); | |||
| WxCUserBasicInfo baseuser = (WxCUserBasicInfo) request.getAttribute(Constant.REQUEST_C_USER_KEY); | |||
| if (baseuser == null) { | |||
| throw new MallinkException(ErrorCode.USER_IS_EMPTY); | |||
| } | |||
| return baseuser; | |||
| } | |||
| public Long getMemberId() { | |||
| HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); | |||
| @@ -0,0 +1,71 @@ | |||
| package com.iformall.controller; | |||
| import com.iformall.common.ErrorCode; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.domain.po.WxCUserBasicInfo; | |||
| import com.iformall.domain.po.sm.UserInviteCode; | |||
| import com.iformall.enums.EnumYesOrNo; | |||
| import com.iformall.service.sm.UserInviteCodeService; | |||
| import io.swagger.annotations.Api; | |||
| import io.swagger.annotations.ApiOperation; | |||
| import org.apache.commons.lang3.StringUtils; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.web.bind.annotation.*; | |||
| import java.util.Map; | |||
| @RestController | |||
| @RequestMapping("/api/inviteCode") | |||
| @Api(description = "模板接口") | |||
| public class UserInviteCodeController extends BaseController { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @Autowired | |||
| private UserInviteCodeService userInviteCodeService; | |||
| @ApiOperation("使用邀请码") | |||
| @PostMapping("update") | |||
| public ResultData saveOrUpdate(@RequestBody Map<String, String> map) { | |||
| logger.debug("[" + getIpAddr() + "] UserInviteCodeController::saveOrUpdate"); | |||
| String code = map.get("inviteCode"); | |||
| if(StringUtils.isBlank(code)){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||
| } | |||
| UserInviteCode inviteCode = new UserInviteCode(); | |||
| inviteCode.setUserId(getMemberId()); | |||
| inviteCode = userInviteCodeService.selectOne(inviteCode); | |||
| if(inviteCode != null){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"该会员已使用邀请码"); | |||
| } | |||
| inviteCode = new UserInviteCode(); | |||
| inviteCode.setInviteCode(code); | |||
| inviteCode.setStatus(EnumYesOrNo.NO.getCode()); | |||
| inviteCode = userInviteCodeService.selectOne(inviteCode); | |||
| if(inviteCode == null){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"该邀请码未找到或已失效"); | |||
| } | |||
| WxCUserBasicInfo basicUser = getCUser(); | |||
| inviteCode.setStatus(EnumYesOrNo.YES.getCode()); | |||
| inviteCode.setUserId(basicUser.getId()); | |||
| inviteCode.setUserPhone(basicUser.getPhone()); | |||
| inviteCode.setUserDate(basicUser.getCreateDate()); | |||
| userInviteCodeService.saveOrUpdate(inviteCode); | |||
| return new ResultData(); | |||
| } | |||
| @ApiOperation("根据id查询接口") | |||
| @GetMapping("/find") | |||
| public ResultData find() { | |||
| logger.debug("[" + getIpAddr() + "] UserInviteCodeController::find"); | |||
| UserInviteCode inviteCode = new UserInviteCode(); | |||
| inviteCode.setUserId(getMemberId()); | |||
| inviteCode = userInviteCodeService.selectOne(inviteCode); | |||
| return new ResultData(inviteCode); | |||
| } | |||
| } | |||
| @@ -73,7 +73,9 @@ public class AuthorizationInterceptor extends HandlerInterceptorAdapter { | |||
| if(basicInfo == null){ | |||
| throw new MallinkException(ErrorCode.NET_TOKEN_INVALID.getCode(), "URL:" + request.getRequestURL() + " token失效,请重新登录"); | |||
| } | |||
| request.setAttribute(Constant.LOGIN_MEMBER_KEY,basicInfo.getId()); | |||
| request.setAttribute(Constant.REQUEST_C_USER_KEY, basicInfo); | |||
| return true; | |||
| } | |||
| @@ -0,0 +1,41 @@ | |||
| package com.iformall.domain.po.sm; | |||
| import com.baomidou.mybatisplus.annotation.TableName; | |||
| import com.iformall.domain.po.base.BaseEntity; | |||
| import com.iformall.domain.po.base.TenantEntity; | |||
| import lombok.Data; | |||
| import lombok.EqualsAndHashCode; | |||
| import java.util.Date; | |||
| @TableName(value = "user_invite_code") | |||
| @Data | |||
| @EqualsAndHashCode(callSuper = true) | |||
| public class UserInviteCode extends TenantEntity { | |||
| protected Long id; | |||
| @io.swagger.annotations.ApiModelProperty(value="邀请码",name="inviteCode") | |||
| private String inviteCode; | |||
| @io.swagger.annotations.ApiModelProperty(value="邀请码",name="inviteName") | |||
| private String inviteName; | |||
| @io.swagger.annotations.ApiModelProperty(value="EnumYesOrNo 是否使用",name="status") | |||
| private Integer status; | |||
| @io.swagger.annotations.ApiModelProperty(value="用户ID",name="userId") | |||
| private Long userId; | |||
| @io.swagger.annotations.ApiModelProperty(value="用户手机号",name="userPhone") | |||
| private String userPhone; | |||
| @io.swagger.annotations.ApiModelProperty(value="用户注册时间",name="userDate") | |||
| private Date userDate; | |||
| @io.swagger.annotations.ApiModelProperty(value="创建时间",name="createDate") | |||
| private Date createDate; | |||
| @io.swagger.annotations.ApiModelProperty(value="更新时间",name="updateDate") | |||
| private Date updateDate; | |||
| } | |||
| @@ -0,0 +1,16 @@ | |||
| package com.iformall.mapper; | |||
| import com.iformall.common.CommonMapper; | |||
| import com.iformall.domain.po.sm.UserInviteCode; | |||
| import org.apache.ibatis.annotations.Param; | |||
| import java.util.List; | |||
| public interface UserInviteCodeMapper extends CommonMapper<UserInviteCode, String> { | |||
| List<UserInviteCode> findList(UserInviteCode record); | |||
| int deleteById(@Param("id")Long id); | |||
| UserInviteCode findOne(UserInviteCode inviteCode); | |||
| } | |||
| @@ -0,0 +1,44 @@ | |||
| package com.iformall.service.sm; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.domain.po.sm.UserInviteCode; | |||
| import java.util.List; | |||
| public interface UserInviteCodeService { | |||
| List<UserInviteCode> getList(UserInviteCode record); | |||
| /** | |||
| * 根据实体查询分页列表 | |||
| * | |||
| * @param record | |||
| * @return | |||
| */ | |||
| PageInfo<UserInviteCode> listAsPage(UserInviteCode record, Integer pageIndex, Integer pageSize); | |||
| /** | |||
| * 根据Id获得实体 | |||
| * | |||
| * @param id | |||
| * @return | |||
| */ | |||
| UserInviteCode getById(Long id); | |||
| /** | |||
| * 保存或更新实体 | |||
| * | |||
| * @param record | |||
| */ | |||
| void saveOrUpdate(UserInviteCode record); | |||
| /** | |||
| * 根据Id删除实体 | |||
| * | |||
| * @param id | |||
| */ | |||
| void deleteById(Long id); | |||
| UserInviteCode selectOne(UserInviteCode inviteCode); | |||
| } | |||
| @@ -0,0 +1,66 @@ | |||
| package com.iformall.service.sm.impl; | |||
| import com.github.pagehelper.PageHelper; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.common.IdWorker; | |||
| import com.iformall.domain.po.sm.UserInviteCode; | |||
| import com.iformall.mapper.UserInviteCodeMapper; | |||
| import com.iformall.service.sm.UserInviteCodeService; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.stereotype.Service; | |||
| import java.util.Date; | |||
| import java.util.List; | |||
| @Service | |||
| public class UserInviteCodeServiceImpl implements UserInviteCodeService { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @Autowired | |||
| UserInviteCodeMapper userInviteCodeMapper; | |||
| @Override | |||
| public List<UserInviteCode> getList(UserInviteCode record) { | |||
| return userInviteCodeMapper.findList(record); | |||
| } | |||
| @Override | |||
| public PageInfo<UserInviteCode> listAsPage(UserInviteCode record, Integer pageIndex, Integer pageSize) { | |||
| return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> userInviteCodeMapper.findList(record)); | |||
| } | |||
| @Override | |||
| public UserInviteCode getById(Long id) { | |||
| return userInviteCodeMapper.selectById(id); | |||
| } | |||
| @Override | |||
| public void saveOrUpdate(UserInviteCode record) { | |||
| Date now = new Date(); | |||
| if (record.getId() == null) { | |||
| //record.setId(UUID.randomUUID().toString().replaceAll("-", "")); | |||
| final IdWorker idWorker = IdWorker.get(); | |||
| record.setId(idWorker.nextId()); | |||
| record.setCreateDate(now); | |||
| record.setUpdateDate(now); | |||
| userInviteCodeMapper.insert(record); | |||
| } else { | |||
| record.setUpdateDate(now); | |||
| userInviteCodeMapper.updateById(record); | |||
| } | |||
| } | |||
| @Override | |||
| public void deleteById(Long id) { | |||
| userInviteCodeMapper.deleteById(id); | |||
| } | |||
| @Override | |||
| public UserInviteCode selectOne(UserInviteCode inviteCode) { | |||
| return userInviteCodeMapper.findOne(inviteCode); | |||
| } | |||
| } | |||
| @@ -91,8 +91,11 @@ | |||
| and `status` = #{status} | |||
| </if> | |||
| <if test=" null != startDate and null!=endDate"> | |||
| and `create_date` between #{startDate} and #{endDate} | |||
| <if test=" null != startDate "> | |||
| and create_date >= #{startDate} | |||
| </if> | |||
| <if test=" null != endDate"> | |||
| and create_date < #{endDate} | |||
| </if> | |||
| <if test=" null != ids "> | |||
| @@ -0,0 +1,74 @@ | |||
| <?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.iformall.mapper.UserInviteCodeMapper"> | |||
| <resultMap id="BaseResultMap" type="com.iformall.domain.po.sm.UserInviteCode"> | |||
| <id column="id" jdbcType="BIGINT" property="id" /> | |||
| <result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/> | |||
| <result column="parent_tenant_id" jdbcType="VARCHAR" property="parentTenantId" /> | |||
| <result column="invite_code" jdbcType="VARCHAR" property="inviteCode" /> | |||
| <result column="invite_name" jdbcType="VARCHAR" property="inviteName" /> | |||
| <result column="status" jdbcType="INTEGER" property="status" /> | |||
| <result column="user_id" jdbcType="BIGINT" property="userId" /> | |||
| <result column="user_phone" jdbcType="VARCHAR" property="userPhone" /> | |||
| <result column="user_date" jdbcType="TIMESTAMP" property="userDate"/> | |||
| <result column="create_date" jdbcType="TIMESTAMP" property="createDate"/> | |||
| <result column="update_date" jdbcType="TIMESTAMP" property="updateDate"/> | |||
| </resultMap> | |||
| <sql id="allColumns"> | |||
| `id`,`invite_code`,`invite_name`,`status` | |||
| ,`user_id`,`user_phone`,`user_date` | |||
| ,`create_date`,`update_date` | |||
| </sql> | |||
| <sql id="dynamicWhereConditions"> | |||
| where `is_del` = 0 | |||
| <if test=" null != id "> | |||
| and `id` = #{id} | |||
| </if> | |||
| <if test=" null != inviteCode and '' != inviteCode"> | |||
| and `invite_code` like concat('%', #{inviteCode},'%') | |||
| </if> | |||
| <if test=" null != inviteName and '' != inviteName"> | |||
| and `invite_name` like concat('%', #{inviteName},'%') | |||
| </if> | |||
| <if test=" null != status "> | |||
| and `status` = #{status} | |||
| </if> | |||
| <if test=" null != userId "> | |||
| and `user_id` = #{userId} | |||
| </if> | |||
| <if test=" null != userPhone and '' != userPhone"> | |||
| and `user_phone` like concat('%', #{userPhone},'%') | |||
| </if> | |||
| <if test=" null != ids "> | |||
| and id in | |||
| <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")"> | |||
| #{idItem} | |||
| </foreach> | |||
| </if> | |||
| <if test=" null != sortColumns"> order by ${sortColumns} </if> | |||
| </sql> | |||
| <select id="findList" parameterType="com.iformall.domain.po.sm.UserInviteCode" resultMap="BaseResultMap"> | |||
| select <include refid="allColumns" /> from user_invite_code | |||
| <include refid="dynamicWhereConditions" /> | |||
| </select> | |||
| <select id="findOne" parameterType="com.iformall.domain.po.sm.UserInviteCode" resultMap="BaseResultMap"> | |||
| select <include refid="allColumns" /> from user_invite_code | |||
| <include refid="dynamicWhereConditions" /> | |||
| </select> | |||
| <delete id="deleteById" parameterType="java.util.HashMap"> | |||
| update user_invite_code set is_del = 1,update_date = now() where id = #{id} | |||
| </delete> | |||
| </mapper> | |||
| @@ -75,8 +75,11 @@ | |||
| and `video_status` = #{videoStatus} | |||
| </if> | |||
| <if test=" null != startDate and null!=endDate"> | |||
| and `create_date` between #{startDate} and #{endDate} | |||
| <if test=" null != startDate "> | |||
| and create_date >= #{startDate} | |||
| </if> | |||
| <if test=" null != endDate"> | |||
| and create_date < #{endDate} | |||
| </if> | |||
| <if test=" null != ids "> | |||