浏览代码

收音机用户端

xiaoyunquan 2 年之前
父节点
当前提交
3cddeed131

+ 1 - 1
svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/radio/WlyyRadioEndpoint.java

@ -17,7 +17,7 @@ import org.springframework.web.bind.annotation.*;
 * @slogan 他化自在,我自逍遥
 */
@RestController
@RequestMapping(value = "/raido",produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@RequestMapping(value = "/raido/manager",produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Api(value = "收音机音频", description = "收音机音频管理接口", tags = {"wlyy基础服务 - 收音机音频管理接口"})
public class WlyyRadioEndpoint extends EnvelopRestEndpoint {

+ 44 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/radio/WlyyRadioEndpoint.java

@ -0,0 +1,44 @@
package com.yihu.jw.care.endpoint.radio;
import com.yihu.jw.care.service.radio.WlyyRadioService;
import com.yihu.jw.restmodel.web.PageEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
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.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/**
 * @author xyq
 * @create 2022-07-04 13:39
 * @slogan 他化自在,我自逍遥
 */
@RestController
@RequestMapping(value = "/raido",produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Api(value = "收音机音频接口", description = "收音机音频接口", tags = {"收音机音频接口"})
public class WlyyRadioEndpoint extends EnvelopRestEndpoint {
    @Autowired
    private WlyyRadioService radioService;
    @ApiOperation(value = "分页获取收音机列表")
    @GetMapping(value = "/getRadioPage")
    public PageEnvelop getRadioPage(@ApiParam(name = "name",value = "名字搜索") @RequestParam(required = false) String name,
                                    @ApiParam(name = "frequency",value = "频率搜索") @RequestParam(required = false) String frequency,
                                    @ApiParam(name = "page",value = "页码") @RequestParam(required = false,defaultValue = "1")Integer page,
                                    @ApiParam(name = "pageSize",value = "每页大小") @RequestParam(required = false,defaultValue = "20")Integer pageSize){
        try {
            return radioService.getRadioPage(name, frequency, page, pageSize);
        }catch (Exception e){
            return failedPageEnvelopException2(e);
        }
    }
}

+ 50 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/radio/WlyyRadioService.java

@ -0,0 +1,50 @@
package com.yihu.jw.care.service.radio;
import com.yihu.jw.restmodel.web.PageEnvelop;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
/**
 * @author xyq
 * @create 2022-07-04 13:43
 * @slogan 他化自在,我自逍遥
 */
@Service
public class WlyyRadioService {
    @Autowired
    private JdbcTemplate jdbcTemplate;
    /**
     * 分页条件查询收音机列表
     * @param name
     * @param frequency
     * @param page
     * @param pageSize
     * @return
     */
    public PageEnvelop getRadioPage(String name,String frequency,Integer page,Integer pageSize){
        page = page>0?page-1:0;
        String colSql = "SELECT id,name,frequency,introduction,url,sort_num sortNum, " +
                " CAST(DATE_FORMAT(create_time,'%Y-%m-%d %H:%i:%S') as char) createTime,CAST(status as UNSIGNED) status ";
        String sql = " from wlyy_radio " +
                " where status = 1 ";
        if(StringUtils.isNotBlank(name)){
            sql += " and name like '%"+name+"%' ";
        }
        if(StringUtils.isNotBlank(frequency)){
            sql += " and frequency like '%"+frequency+"%' ";
        }
        String orderSql = " order by sort_num limit "+page*pageSize+","+pageSize;
        List<Map<String, Object>> list = jdbcTemplate.queryForList(colSql+sql+orderSql);
        String countSql = "SELECT count(*) ";
        Long count = jdbcTemplate.queryForObject(countSql+sql, Long.class);
        return PageEnvelop.getSuccessListWithPage("查询成功",list,page,pageSize,count);
    }
}