HuMi详记之二

mac2024-06-05  53

- 问题一 :这个接口是前台的,登录的情况下不应该是拒绝访问未授权资源

解决方法:添加注解==》@LoginAccess :个人理解意思》当在controller层时添加上是权限不会拦截的作用
- 当禁止启用中台数据时前台相应伙伴类型不显示

解决方法:前台列表数据回传来的 为0 就显示,为1 不显示

配送上代码更容易看懂
- web层(FrontPartnerTypeController)
package com.humi.partner.front.web; import com.humi.cloud.common.model.Result; import com.humi.cloud.security.support.annotation.LoginAccess; import com.humi.partner.front.model.partnerType.PartnerTypeListQueryResponse; import com.humi.partner.front.service.FrontPartnerTypeService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.MediaType; import org.springframework.web.bind.annotation.*; import javax.validation.Valid; import java.util.concurrent.Callable; /** * <pre> * @Auther: lishijie * @Date: 2019/10/24 10:03 * Ver Date Author Detail * ---------------------------------------------------------------------- * 1.0 2019/10/24 10:03 lishijie@360humi.com new file. * @Description:Codes * </pre> */ @RestController @RequestMapping("/front/partner_type") @Api(tags = "前台-伙伴类型", protocols = MediaType.APPLICATION_JSON_UTF8_VALUE) class FrontPartnerTypeController { @Autowired FrontPartnerTypeService frontPartnerTypeService; @LoginAccess @GetMapping("/lib/list") @ApiOperation(value = "查询伙伴类型列表",notes ="伙伴类型",response = PartnerTypeListQueryResponse.class) public Callable<Result> getPartnerTypeLibPage( ){ return () -> frontPartnerTypeService.getPertnerType(); } @LoginAccess @GetMapping("/getApplyStatus") @ApiOperation(value = "判断申请类型", notes = "输入申请类型状态") public Callable<Result> getApplyStatus(@Valid @ApiParam("通过partnerTypeId判断") @RequestParam("partnerTypeId") String partnerTypeId) { return () -> frontPartnerTypeService.getApplyStatus(partnerTypeId); } }
- service层(FrontPartnerTypeService)
package com.humi.partner.front.service; import java.util.Arrays; import java.util.List; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.humi.cloud.common.model.Result; import com.humi.cloud.mybatis.support.model.Page; import com.humi.cloud.security.support.utils.SecurityUtil; import com.humi.partner.common.dict.PartnerBaseStatus; import com.humi.partner.common.entity.PartnerBase; import com.humi.partner.common.entity.PartnerType; import com.humi.partner.common.service.PartnerBaseService; import com.humi.partner.common.service.PartnerTypeService; import com.humi.partner.front.dao.FrontPartnerTypeMapper; import com.humi.partner.front.model.partnerType.PartnerTypeListQueryRequest; import com.humi.partner.front.model.partnerType.PartnerTypeListQueryResponse; import com.humi.partner.manager.dao.ManagerPartnerTypeMapper; import org.apache.commons.lang.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; /** * <pre> * @Auther: lishijie * @Date: 2019/10/24 09:08 * Ver Date Author Detail * ---------------------------------------------------------------------- * 1.0 2019/10/24 09:08 lishijie@360humi.com new file. * @Description:Codes * </pre> */ @Service public class FrontPartnerTypeService extends ServiceImpl<ManagerPartnerTypeMapper,PartnerType> { @Autowired PartnerTypeService partnerTypeService; @Autowired PartnerBaseService partnerBaseService; @Autowired FrontPartnerTypeMapper frontPartnerTypeMapper; /** * 查询伙伴类型信息 * @param * @return */ public Result getPertnerType(){ Result result = new Result(); List<PartnerType> list = this.list(); if(list != null && !list.isEmpty()){ result.setData(list); } return result; } /** * 获取指定伙伴类型的申请状态 * @param partnerTypeId 伙伴类型ID * @return */ public Result getApplyStatus(String partnerTypeId){ if (StringUtils.isBlank(partnerTypeId)){ return Result.fail("参数不能为空"); } String userId = SecurityUtil.getUser().getSourceId(); PartnerBase partnerBase = this.partnerBaseService.getOne(new LambdaQueryWrapper<PartnerBase>().eq(PartnerBase::getApplyType, partnerTypeId).eq(PartnerBase::getUserId, userId)); Result result = new Result(); if (null != partnerBase ){ return Result.ok("查询成功",PartnerBaseStatus.format(partnerBase.getApplyStatus()).getCode()); } result.setData(""); return result; } }
- dao层()
package com.humi.partner.front.dao; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.humi.cloud.mybatis.support.model.Page; import com.humi.partner.common.entity.PartnerType; import com.humi.partner.front.model.partnerType.PartnerTypeListQueryRequest; import com.humi.partner.front.model.partnerType.PartnerTypeListQueryResponse; import org.springframework.stereotype.Repository; import java.util.List; /** * @author AAD * 伙伴类型操作 */ @Repository public interface FrontPartnerTypeMapper extends BaseMapper<PartnerType>{ /** * 分页查询订单 * @param page * @return */ List<PartnerTypeListQueryResponse> getPartnerTypePages(Page<PartnerTypeListQueryResponse, PartnerTypeListQueryRequest> page); }
-dao层里有 mapper层()
<?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.humi.partner.front.dao.FrontPartnerTypeMapper"> <!--分页查询-伙伴类型--> <select id="getPartnerTypePages" resultType="com.humi.partner.front.model.partnerType.PartnerTypeListQueryResponse"> SELECT pt.id, pt.partner_name, pt.use_flag FROM partner_type pt WHERE pt.valid=1 ORDER BY id DESC </select> </mapper>
- model层
1》(PartnerTypeListQueryRequest)
package com.humi.partner.front.model.partnerType; import io.swagger.annotations.ApiModelProperty; import lombok.AllArgsConstructor; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.NoArgsConstructor; import java.util.Date; /** * @Auther: lishijie * @Date: 2019/10/11 10:59 * @Description:Codes are far away from bugs with the animal protecting */ @Data @NoArgsConstructor @AllArgsConstructor @EqualsAndHashCode(callSuper = false) public class PartnerTypeListQueryRequest { @ApiModelProperty(value = " *") private static final long serialVersionUID = -7444862584825481149L; @ApiModelProperty(value = "伙伴类型id") private String id; @ApiModelProperty(value = "每页大小【查询必填】", position = -1001, example = "10") Integer size= 10; @ApiModelProperty(value = "当前页码", position = -1000, example = "1") Integer current= 1; @ApiModelProperty(value = "伙伴类型 ") private String partnerName; @ApiModelProperty(value = "是否启用:0停用;1启用 ") private Integer useFlag; }
2》(PartnerTypeListQueryResponse)
package com.humi.partner.front.model.partnerType; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; import java.util.Date; /** * @Auther: lishijie * @Date: 2019/10/11 10:59 * @Description:Codes are far away from bugs with the animal protecting */ @Data @NoArgsConstructor @AllArgsConstructor @ApiModel("伙伴类型列表返回对象") public class PartnerTypeListQueryResponse { @ApiModelProperty(value = " *") private static final long serialVersionUID = -7444868364825481149L; @ApiModelProperty(value = "伙伴类型id") private String id; @ApiModelProperty(value = "伙伴类型 ") private String partnerName; @ApiModelProperty(value = "是否启用:0停用;1启用 ") private Integer useFlag; }
最新回复(0)