教育门户网站模板,电视剧怎么做原创视频网站,做网站要求什么条件,网站设计心的apifox
简介
Apifox 是 API 文档、API 调试、API Mock、API 自动化测试一体化协作平台#xff0c;定位 Postman Swagger Mock JMeter#xff0c;由此可见apifox集功能于一身#xff0c;极大的提升了我们开发的效率#xff0c;不用再为postman网络连接失败而发愁…
apifox
简介
Apifox 是 API 文档、API 调试、API Mock、API 自动化测试一体化协作平台定位 Postman Swagger Mock JMeter由此可见apifox集功能于一身极大的提升了我们开发的效率不用再为postman网络连接失败而发愁更不用为swagger各种依赖冲突二苦恼
作用 下载
Apifox - API 文档、调试、Mock、测试一体化协作平台 - 接口文档工具接口自动化测试工具接口Mock工具API文档工具API Mock工具API自动化测试工具 文档
Apifox 快速入门 | Apifox 帮助文档 IDEA中集成
安装插件 获取令牌和id 配置 映射配置规则
如java-wtl-single:3398260,月木学途
java-wtl-single是项目的模块一般就是分布式模块如 3398260就是你的id
月木学途对应你的apifox的接口目录 java注解规范 生成接口 代码站位
package jkw.controller.back;import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import jkw.pojo.Admin;
import jkw.service.AdminService;
import jkw.vo.BaseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContext;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;/*** back后台用户*/
RestController
RequestMapping(/sys/admin)
CrossOrigin
public class AdminController {Autowiredprivate AdminService adminService;Autowiredprivate PasswordEncoder encoder;/*** 新增管理员** param admin 管理员* return*/PostMapping(/add)PreAuthorize(hasAnyAuthority(/sys/admin))public BaseResult add(Admin admin) {String password admin.getPassword();password encoder.encode(password);admin.setPassword(password);adminService.add(admin);return BaseResult.ok();}/*** 修改管理员设置空密码则还是原来密码** param admin 管理员* return*/PostMapping(/update)public BaseResult update(Admin admin) {String password admin.getPassword();if (StringUtils.hasText(password)) { // 密码不为空加密password encoder.encode(password);admin.setPassword(password);}adminService.update(admin);return BaseResult.ok();}/*** 删除管理员(附带对应的角色)** param aid 管理员id* return*/DeleteMapping(/delete)public BaseResult delete(Integer aid) {adminService.delete(aid);return BaseResult.ok();}/*** 修改管理员的状态** param aid 管理员id* return*/PostMapping(/updateStatus)public BaseResult updateStatus(Integer aid) {adminService.updateStatus(aid);return BaseResult.ok();}/*** 根据id查询管理员(详情)** param aid 管理员id* return*/GetMapping(/findById)public BaseResultAdmin findById(Integer aid) {Admin admin adminService.findById(aid);return BaseResult.ok(admin);}/*** 分页查询管理员** param page 当前页* param size 每页条数* return*/PreAuthorize(hasAnyAuthority(/sys/admin))GetMapping(/search)public BaseResultPageAdmin search(int page, int size) {PageAdmin adminPage adminService.search(page, size);return BaseResult.ok(adminPage);}/*** 修改管理员角色** param aid 管理员id* param rids 角色id* return*/PostMapping(/updateRoleToAdmin)public BaseResult updateRoleToAdmin(Integer aid, Integer[] rids) {adminService.updateRoleToAdmin(aid, rids);return BaseResult.ok();}/*** 获取登录管理员名** return 管理员名*/GetMapping(/getUsername)public BaseResultString getUsername() {// 1.获取会话对象SecurityContext context SecurityContextHolder.getContext();// 2.获取认证对象Authentication authentication context.getAuthentication();// 3.获取登录用户信息UserDetails userDetails (UserDetails) authentication.getPrincipal();String username userDetails.getUsername();return BaseResult.ok(username);}GetMapping(/findByUsername)public BaseResult findByUsername(String username) {Admin admin adminService.findByName(username);return BaseResult.ok(admin);}
}package jkw.service.impl;import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import jkw.mapper.GoodsSpecificationMapper;
import jkw.mapper.GoodsSpecificationOptionMapper;
import jkw.mapper.GoodsSpecificationOptionsMapper;
import jkw.pojo.GoodsSpecification;
import jkw.pojo.GoodsSpecificationOption;
import jkw.pojo.GoodsSpecificationOptions;
import jkw.service.GoodsSpecificationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;import java.util.List;Service
Transactional
public class GoodsSpecificationServiceImpl implements GoodsSpecificationService {Autowiredprivate GoodsSpecificationMapper goodsSpecificationMapper;Autowiredprivate GoodsSpecificationOptionMapper goodsSpecificationOptionMapper;Autowiredprivate GoodsSpecificationOptionsMapper goodsSpecificationOptionsMapper;Overridepublic void add(GoodsSpecification goodsSpecification) {goodsSpecificationMapper.insert(goodsSpecification);}Overridepublic void update(GoodsSpecification goodsSpecification) {goodsSpecificationMapper.updateById(goodsSpecification);}Overridepublic void delete(Integer id) {//删除商品规格的所有规格项QueryWrapperGoodsSpecificationOption queryWrapper new QueryWrapper();queryWrapper.eq(goodsSpecificationId, id);goodsSpecificationOptionMapper.delete(queryWrapper);//删除商品-规格项的数据ListGoodsSpecificationOption goodsSpecificationOptionList goodsSpecificationOptionMapper.selectList(queryWrapper);for (GoodsSpecificationOption goodsSpecificationOption : goodsSpecificationOptionList) {QueryWrapperGoodsSpecificationOptions queryWrapper1 new QueryWrapper();queryWrapper1.eq(goodsSpecificationOptionId, goodsSpecificationOption.getGoodsSpecificationId());goodsSpecificationOptionsMapper.delete(queryWrapper1);}//删除商品规格goodsSpecificationMapper.deleteById(id);}Overridepublic GoodsSpecification findById(Integer id) {return goodsSpecificationMapper.selectById(id);}Overridepublic PageGoodsSpecification search(int page, int size) {return goodsSpecificationMapper.selectPage(new Page(page, size), null);}Overridepublic ListGoodsSpecification findAll() {return goodsSpecificationMapper.selectList(null);}Overridepublic ListGoodsSpecification findAllByGoodsTypeId(Integer id) {QueryWrapperGoodsSpecification queryWrappernew QueryWrapper();queryWrapper.eq(goodsTypeId,id);return goodsSpecificationMapper.selectList(queryWrapper);}
}