认清现实,放弃幻想,准备斗争
列表的结果需要关联查询,数据字典的数据也需要展示对应的文本内容而不是值,除了定义VO的方式,我们也可以使用扩展实体类的方式
在BorrowInfo类中扩展以下字段
//扩展字段
@ApiModelProperty(value = "姓名")
@TableField(exist = false)
private String name;@ApiModelProperty(value = "手机")
@TableField(exist = false)
private String mobile;@ApiModelProperty(value = "其他参数")
@TableField(exist = false)
private Mapparam = new HashMap<>();
添加 AdminBorrowInfoController
@Api(tags = "借款管理")
@RestController
@RequestMapping("/admin/core/borrowInfo")
@Slf4j
public class AdminBorrowInfoController {
@Resource
private BorrowInfoService borrowInfoService;
@ApiOperation("借款信息列表")
@GetMapping("/list")
public R list() {
List borrowInfoList = borrowInfoService.selectList();
return R.ok().data("list", borrowInfoList);
}
}
实现:BorrowInfoServiceImpl
@Resource
private DictService dictService;
@Override
public List selectList() {
List borrowInfoList = baseMapper.selectBorrowInfoList();
borrowInfoList.forEach(borrowInfo -> {
String returnMethod = dictService.getNameByParentDictCodeAndValue("returnMethod", borrowInfo.getReturnMethod());
String moneyUse = dictService.getNameByParentDictCodeAndValue("moneyUse", borrowInfo.getMoneyUse());
String status = BorrowInfoStatusEnum.getMsgByStatus(borrowInfo.getStatus());
borrowInfo.getParam().put("returnMethod", returnMethod);
borrowInfo.getParam().put("moneyUse", moneyUse);
borrowInfo.getParam().put("status", status);
});
return borrowInfoList;
}
接口:BorrowInfoMapper
List selectBorrowInfoList();
xml:BorrowInfoMapper.xml
创建 src/views/core/borrow-info/list.vue
借款列表
创建 src/views/core/borrow-info/detail.vue
借款详情
src/router/index.js
在“借款管理”下添加子路由
{
path: 'info-list',
name: 'coreBorrowInfoList',
component: () => import('@/views/core/borrow-info/list'),
meta: { title: '借款列表' }
},
{
path: 'info-detail/:id',
name: 'coreBorrowInfoDetail',
component: () => import('@/views/core/borrow-info/detail'),
meta: { title: '借款详情' },
hidden: true
}
创建 src/api/core/borrow-info.js
import request from '@/utils/request'
export default {
getList() {
return request({
url: `/admin/core/borrowInfo/list`,
method: 'get'
})
}
}
src/views/core/borrow-info/list.vue
src/views/core/borrow-info/list.vue
{{ scope.row.period }}个月
{{ scope.row.borrowYearRate * 100 }}%
查看
审批