Commit e2264a09 authored by tianyiming's avatar tianyiming

赋码说明相关

parent 82df05e8
package com.yeejoin.amos.boot.module.tzs.api.dto;
import com.baomidou.mybatisplus.annotation.TableField;
import io.swagger.annotations.ApiModel;
import lombok.Data;
@Data
@ApiModel(value = "UserCheckStatusDto", description = "用户是否点击下次不在提示")
public class UserCheckStatusDto {
/**
* 用户名
*/
@TableField("user_name")
private String userName;
/**
* 是否勾选下次不在提示
*/
@TableField("status")
private String status;
}
package com.yeejoin.amos.boot.module.tzs.api.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.yeejoin.amos.boot.biz.common.entity.BaseEntity;
import lombok.Data;
import lombok.experimental.Accessors;
/**
* 装备分类
*
* @author system_generator
* @date 2021-10-20
*/
@Data
@Accessors(chain = true)
@TableName("biz_user_check_status")
public class UserCheckStatus extends BaseEntity {
private static final long serialVersionUID = 1L;
/**
* 用户名
*/
@TableField("use_name")
private String useName;
/**
* 是否勾选下次不在提示
*/
@TableField("status")
private String status;
}
package com.yeejoin.amos.boot.module.tzs.api.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.amos.boot.module.tzs.api.entity.UserCheckStatus;
public interface UserCheckStatusMapper extends BaseMapper<UserCheckStatus> {
}
package com.yeejoin.amos.boot.module.tzs.api.service;
import com.yeejoin.amos.boot.module.tzs.api.entity.UserCheckStatus;
/**
* 首页弹窗相关
*/
public interface IUserCheckStatusService {
UserCheckStatus getUserCheckStatus(String useName);
UserCheckStatus updateUserCheckStatus(String useName, String status);
}
package com.yeejoin.amos.boot.module.tzs.biz.controller;
import com.alibaba.fastjson.JSON;
import com.yeejoin.amos.boot.biz.common.bo.ReginParams;
import com.yeejoin.amos.boot.biz.common.controller.BaseController;
import com.yeejoin.amos.boot.biz.common.utils.RedisKey;
import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
import com.yeejoin.amos.boot.module.tzs.api.entity.UserCheckStatus;
import com.yeejoin.amos.boot.module.tzs.api.service.IUserCheckStatusService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.typroject.tyboot.core.foundation.context.RequestContext;
import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
/**
* 装备分类
*
* @author system_generator
* @date 2021-10-20
*/
@RestController
@Api(tags = "首页弹窗提示")
@RequestMapping(value = "/user-check")
public class UserCheckStatusController extends BaseController {
@Autowired
IUserCheckStatusService userCheckStatusService;
@Autowired
RedisUtils redisUtils;
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@RequestMapping(value = "/getUserCheckStatus", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "获取用户是否点击下次不在提示", notes = "获取用户是否点击下次不在提示")
public ResponseModel<UserCheckStatus> getUserCheckStatus() {
ReginParams reginParams = JSON.parseObject(redisUtils.get(RedisKey.buildReginKey(RequestContext.getExeUserId(), RequestContext.getToken())).toString(), ReginParams.class);
if (ObjectUtils.isEmpty(reginParams)) {
return null;
}
String useName = reginParams.getUserModel().getUserName();
return ResponseHelper.buildResponse(userCheckStatusService.getUserCheckStatus(useName));
}
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@RequestMapping(value = "/updateUserCheckStatus", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "更改用户选择状态", notes = "更改用户选择状态")
public ResponseModel<UserCheckStatus> updateUserCheckStatus(@RequestParam(value = "status") String status) {
ReginParams reginParams = JSON.parseObject(redisUtils.get(RedisKey.buildReginKey(RequestContext.getExeUserId(), RequestContext.getToken())).toString(), ReginParams.class);
if (ObjectUtils.isEmpty(reginParams)) {
return null;
}
String useName = reginParams.getUserModel().getUserName();
return ResponseHelper.buildResponse(userCheckStatusService.updateUserCheckStatus(useName,status));
}
}
package com.yeejoin.amos.boot.module.tzs.biz.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.yeejoin.amos.boot.module.tzs.api.dto.UserCheckStatusDto;
import com.yeejoin.amos.boot.module.tzs.api.entity.UserCheckStatus;
import com.yeejoin.amos.boot.module.tzs.api.mapper.UserCheckStatusMapper;
import com.yeejoin.amos.boot.module.tzs.api.service.IUserCheckStatusService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
import org.typroject.tyboot.core.rdbms.service.BaseService;
/**
* 装备分类服务实现类
*
* @author system_generator
* @date 2021-10-20
*/
@Service
@Slf4j
public class UserCheckStatusServiceImpl extends BaseService<UserCheckStatusDto, UserCheckStatus, UserCheckStatusMapper> implements IUserCheckStatusService {
@Autowired
UserCheckStatusMapper userCheckStatusMapper;
@Override
public UserCheckStatus getUserCheckStatus(String useName) {
UserCheckStatus userCheckStatus = userCheckStatusMapper.selectOne(new QueryWrapper<UserCheckStatus>().eq("use_name", useName));
if (ObjectUtils.isEmpty(userCheckStatus)) {
UserCheckStatus checkStatus = new UserCheckStatus();
checkStatus.setUseName(useName);
checkStatus.setStatus("0");
int result = userCheckStatusMapper.insert(checkStatus);
if (result == 1) {
return userCheckStatus;
} else {
return null;
}
}
return userCheckStatus;
}
@Override
public UserCheckStatus updateUserCheckStatus(String useName, String status) {
if(!ObjectUtils.isEmpty(useName)){
UserCheckStatus checkStatus = new UserCheckStatus();
checkStatus.setUseName(useName);
checkStatus.setStatus(status);
int result = userCheckStatusMapper.update(checkStatus,new QueryWrapper<UserCheckStatus>().eq("use_name", useName));
if (result == 1) {
return checkStatus;
}
}
return null;
}
}
\ No newline at end of file
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