commit
e6f9f1e41a
@ -0,0 +1,33 @@
|
||||
package com.sky.controller.user;
|
||||
|
||||
import com.sky.entity.Category;
|
||||
import com.sky.result.Result;
|
||||
import com.sky.service.CategoryService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import java.util.List;
|
||||
|
||||
@RestController("userCategoryController")
|
||||
@RequestMapping("/user/category")
|
||||
@Api(tags = "C端-分类接口")
|
||||
public class CategoryController {
|
||||
|
||||
@Autowired
|
||||
private CategoryService categoryService;
|
||||
|
||||
/**
|
||||
* 查询分类
|
||||
* @param type
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
@ApiOperation("查询分类")
|
||||
public Result<List<Category>> list(Integer type) {
|
||||
List<Category> list = categoryService.list(type);
|
||||
return Result.success(list);
|
||||
}
|
||||
}
|
@ -0,0 +1,55 @@
|
||||
package com.sky.controller.user;
|
||||
|
||||
import com.sky.constant.JwtClaimsConstant;
|
||||
import com.sky.dto.UserLoginDTO;
|
||||
import com.sky.entity.User;
|
||||
import com.sky.properties.JwtProperties;
|
||||
import com.sky.result.Result;
|
||||
import com.sky.service.UserService;
|
||||
import com.sky.utils.JwtUtil;
|
||||
import com.sky.vo.UserLoginVO;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
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.util.HashMap;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/user/user")
|
||||
@Api(tags = "C端用户相关接口")
|
||||
@Slf4j
|
||||
public class UserController {
|
||||
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
@Autowired
|
||||
private JwtProperties jwtProperties;
|
||||
/*
|
||||
* 微信登录
|
||||
* */
|
||||
@ApiOperation("微信登录")
|
||||
@PostMapping("/login")
|
||||
public Result<UserLoginVO> login(@RequestBody UserLoginDTO userLoginDTO){
|
||||
log.info("微信用户登录:{}",userLoginDTO.getCode());
|
||||
|
||||
//微信登录
|
||||
User user = userService.wxLogin(userLoginDTO);
|
||||
|
||||
//为微信用户生成jwt令牌
|
||||
HashMap<String, Object> claims = new HashMap<>();
|
||||
claims.put(JwtClaimsConstant.USER_ID,user.getId());
|
||||
String token = JwtUtil.createJWT(jwtProperties.getUserSecretKey(), jwtProperties.getUserTtl(), claims);
|
||||
|
||||
UserLoginVO userLoginVO = UserLoginVO.builder()
|
||||
.id(user.getId())
|
||||
.openid(user.getOpenid())
|
||||
.token(token)
|
||||
.build();
|
||||
return Result.success(userLoginVO);
|
||||
}
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
package com.sky.mapper;
|
||||
|
||||
import com.github.pagehelper.Page;
|
||||
import com.sky.annotation.AutoFill;
|
||||
import com.sky.enumeration.OperationType;
|
||||
import com.sky.dto.CategoryPageQueryDTO;
|
||||
import com.sky.entity.Category;
|
||||
import org.apache.ibatis.annotations.Delete;
|
||||
import org.apache.ibatis.annotations.Insert;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface CategoryMapper {
|
||||
|
||||
/**
|
||||
* 插入数据到category表
|
||||
* @param category 包含要插入的数据的Category对象
|
||||
*/
|
||||
@Insert("insert into category(type, name, sort, status, create_time, update_time, create_user, update_user)" +
|
||||
" VALUES" +
|
||||
" (#{type}, #{name}, #{sort}, #{status}, #{createTime}, #{updateTime}, #{createUser}, #{updateUser})")
|
||||
@AutoFill(OperationType.INSERT) // 自动填充创建时间和更新时间等字段
|
||||
void insert(Category category);
|
||||
|
||||
/**
|
||||
* 分页查询分类信息
|
||||
* @param categoryPageQueryDTO 包含分页查询条件的对象
|
||||
* @return 返回分页后的分类列表
|
||||
*/
|
||||
Page<Category> pageQuery(CategoryPageQueryDTO categoryPageQueryDTO);
|
||||
|
||||
/**
|
||||
* 根据id删除分类
|
||||
* @param id 要删除的分类的ID
|
||||
*/
|
||||
@Delete("delete from category where id = #{id}")
|
||||
void deleteById(Long id);
|
||||
|
||||
/**
|
||||
* 根据id修改分类信息
|
||||
* @param category 包含要更新的数据的Category对象
|
||||
*/
|
||||
@AutoFill(OperationType.UPDATE) // 自动填充更新时间等字段
|
||||
void update(Category category);
|
||||
|
||||
/**
|
||||
* 根据类型查询分类列表
|
||||
* @param type 分类的类型
|
||||
* @return 返回对应类型的分类列表
|
||||
*/
|
||||
List<Category> list(Integer type);
|
||||
}
|
Loading…
Reference in new issue