Commit 0cadb562 by wangtian

新增定制服务查询、修改接口;

新增条码图书查询接口。
parent a5a4a078
package io.office.common.enumpack.manage;
/**
* @author ZYF
* @description
* @date 2021/12/7
*/
public enum FunctionEnum {
Business_Information_Service_Platform("0", "商务信息服务平台"),
Import_Commodity_Data_Dulletin("1", "进口商品数据通报"),
Bar_Code_MicroStation("2","条码微站"),
Traceability_Platform("3","追溯平台"),
Bar_Code_Commercial_Bridge("4","条码商桥"),
Commodity_QR_Code("5","商品二维码"),
GDSN("6","GDSN"),
Barcode_RF_Software_Detection_Service("7","条码/射频/软件检测服务"),
ECODE("8","ECODE"),
Educational_Knowledge_Management_Platform("9","教育知识管理平台"),
Barcode_Information_Query("10","条码信息查询"),
Product_Service("11","产品服务"),
Platform_Service("12","平台服务"),
More_Customization("13","更多定制");
private String code;
private String msg;
FunctionEnum(String code) {
this.code = code;
}
FunctionEnum(String code, String message) {
this.code = code;
this.msg = message;
}
}
...@@ -114,4 +114,19 @@ public class ProductController extends AbstractController { ...@@ -114,4 +114,19 @@ public class ProductController extends AbstractController {
} }
} }
/**
* 分页查图书
* @param param:分页参数
* @return
*/
@RequestMapping("/api/findPage")
// @RequiresPermissions("manage:product:findPage")
public R findPage(@RequestBody Map<String,String> param){
Page<ProductEntity> pag = this.productService.findPage(
new Page(Integer.valueOf(param.get("page")),
Integer.valueOf(param.get("size"))));
PageUtils pageUtils = new PageUtils(pag);
return R.ok().put("page", pageUtils);
}
} }
package io.office.modules.manage.controller;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import io.office.modules.sys.controller.AbstractController;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import io.office.modules.manage.entity.UserFunctionBindingEntity;
import io.office.modules.manage.service.UserFunctionBindingService;
import io.office.common.utils.PageUtils;
import io.office.common.utils.R;
/**
* ${comments}
*
* @author zyf
* @email
* @date 2021-12-07 15:22:24
*/
@RestController
@RequestMapping("/userfunctionbinding")
public class UserFunctionBindingController extends AbstractController {
@Autowired
private UserFunctionBindingService userFunctionBindingService;
/**
* 查询
*/
@RequestMapping("/api/find")
public R find(){
Integer id=getUserId().intValue();
if(id==null){
return R.error("用户信息有误");
}
Object[] functionids = userFunctionBindingService.queryList(id);
return R.ok().put("functionids", functionids);
}
/**
* 修改
*/
@RequestMapping("/api/update")
// @RequiresPermissions("manage:userfunctionbinding:update")
public R update(@RequestBody Integer[] functionids){
Integer id=getUserId().intValue();
if(id==null){
return R.error("用户信息有误");
}
userFunctionBindingService.Modify(functionids,id);
return R.ok();
}
/**
* 保存
*/
@RequestMapping("/api/save")
// @RequiresPermissions("manage:userfunctionbinding:save")
public R save(@RequestBody Integer[] functionids){
//遍历插入数据
for (int functionid : functionids) {
UserFunctionBindingEntity ufb=new UserFunctionBindingEntity();
ufb.setUserId(getUserId().intValue());
ufb.setFuncId(functionid);
userFunctionBindingService.save(ufb);
}
return R.ok();
}
/**
* 列表
*/
@RequestMapping("/api/list")
// @RequiresPermissions("manage:userfunctionbinding:list")
public R list(@RequestParam Map<String, Object> params){
PageUtils page = userFunctionBindingService.queryPage(params);
return R.ok().put("page", page);
}
/**
* 信息
*/
@RequestMapping("/api/info/{id}")
// @RequiresPermissions("manage:userfunctionbinding:info")
public R info(@PathVariable("id") Integer id){
UserFunctionBindingEntity userFunctionBinding = userFunctionBindingService.getById(id);
return R.ok().put("userFunctionBinding", userFunctionBinding);
}
/**
* 删除
*/
@RequestMapping("/delete")
// @RequiresPermissions("manage:userfunctionbinding:delete")
public R delete(@RequestBody Integer[] ids){
userFunctionBindingService.removeByIds(Arrays.asList(ids));
return R.ok();
}
}
...@@ -20,4 +20,5 @@ import java.util.Map; ...@@ -20,4 +20,5 @@ import java.util.Map;
public interface ProductDao extends BaseMapper<ProductEntity> { public interface ProductDao extends BaseMapper<ProductEntity> {
List<ProductEntity> selectProductList(@Param("params") Map<String, Object> params, Page page); List<ProductEntity> selectProductList(@Param("params") Map<String, Object> params, Page page);
List<ProductEntity> findPage(Page page);
} }
package io.office.modules.manage.dao;
import io.office.modules.manage.entity.UserFunctionBindingEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.stereotype.Component;
import java.util.List;
/**
* ${comments}
*
* @author zyf
* @email
* @date 2021-12-07 15:22:24
*/
@Mapper
@Component
public interface UserFunctionBindingDao extends BaseMapper<UserFunctionBindingEntity> {
List<UserFunctionBindingEntity> queryListById(int id);
void deleteUserFunctionBindingById(int id);
}
package io.office.modules.manage.entity;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import lombok.Data;
/**
* ${comments}
*
* @author zyf
* @email
* @date 2021-12-07 15:22:24
*/
@Data
@TableName("user_function_binding")
public class UserFunctionBindingEntity implements Serializable {
private static final long serialVersionUID = 1L;
/**
* $column.comments
*/
@TableId
private Integer id;
/**
* $column.comments
*/
private Integer userId;
/**
* $column.comments
*/
private Integer funcId;
}
...@@ -29,5 +29,7 @@ public interface ProductService extends IService<ProductEntity> { ...@@ -29,5 +29,7 @@ public interface ProductService extends IService<ProductEntity> {
R verifyProduct(ProductEntity product, SysUserEntity user); R verifyProduct(ProductEntity product, SysUserEntity user);
Page<ProductEntity> selectProductList(Map<String, Object> params, Page page); Page<ProductEntity> selectProductList(Map<String, Object> params, Page page);
Page<ProductEntity> findPage(Page page);
} }
package io.office.modules.manage.service;
import com.baomidou.mybatisplus.extension.service.IService;
import io.office.common.utils.PageUtils;
import io.office.modules.manage.entity.UserFunctionBindingEntity;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
/**
* ${comments}
*
* @author zyf
* @email
* @date 2021-12-07 15:22:24
*/
@Service
public interface UserFunctionBindingService extends IService<UserFunctionBindingEntity> {
PageUtils queryPage(Map<String, Object> params);
Object[] queryList(Integer id);
void Modify(Integer[] functionids, int id);
}
...@@ -82,4 +82,11 @@ public class ProductServiceImpl extends ServiceImpl<ProductDao, ProductEntity> i ...@@ -82,4 +82,11 @@ public class ProductServiceImpl extends ServiceImpl<ProductDao, ProductEntity> i
return page; return page;
} }
@Override
public Page<ProductEntity> findPage(Page page) {
List<ProductEntity> list =this.productDao.findPage(page);
page.setRecords(list);
return page;
}
} }
\ No newline at end of file
package io.office.modules.manage.service.impl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.office.common.utils.PageUtils;
import io.office.common.utils.Query;
import io.office.modules.manage.dao.UserFunctionBindingDao;
import io.office.modules.manage.entity.UserFunctionBindingEntity;
import io.office.modules.manage.service.UserFunctionBindingService;
/**
* ${comments}
*
* @author zyf
* @email
* @date 2021-12-07 15:22:24
*/
@Service("userFunctionBindingService")
public class UserFunctionBindingServiceImpl extends ServiceImpl<UserFunctionBindingDao, UserFunctionBindingEntity> implements UserFunctionBindingService {
@Autowired
UserFunctionBindingDao userFunctionBindingDao;
@Override
public PageUtils queryPage(Map<String, Object> params) {
IPage<UserFunctionBindingEntity> page = this.page(
new Query<UserFunctionBindingEntity>().getPage(params),
new QueryWrapper<UserFunctionBindingEntity>()
);
return new PageUtils(page);
}
@Override
public Object[] queryList(Integer id) {
List<UserFunctionBindingEntity> userFunctionBindingEntities = userFunctionBindingDao.queryListById(id);
//查不到用户关联功能返回空数组
if (userFunctionBindingEntities == null) {
return null;
}
List<Integer> list = new ArrayList<>();
for (UserFunctionBindingEntity userFunctionBindingEntity : userFunctionBindingEntities) {
list.add(userFunctionBindingEntity.getFuncId());
}
Object[] functionids = list.toArray();
return functionids;
}
@Override
public void Modify(Integer[] functionids, int id) {
//先删除原先的用户功能关系
userFunctionBindingDao.deleteUserFunctionBindingById(id);
//遍历插入数据
for (int functionid : functionids) {
UserFunctionBindingEntity ufb = new UserFunctionBindingEntity();
ufb.setUserId(id);
ufb.setFuncId(functionid);
save(ufb);
}
}
}
\ No newline at end of file
...@@ -57,4 +57,7 @@ ...@@ -57,4 +57,7 @@
</if> </if>
order by a.id desc order by a.id desc
</select> </select>
<select id="findPage" resultType="io.office.modules.manage.entity.ProductEntity">
select * from product where levels > 0 and categoryid=1 ORDER BY levels DESC, adddate DESC
</select>
</mapper> </mapper>
\ No newline at end of file
<?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="io.office.modules.manage.dao.UserFunctionBindingDao">
<!-- 可根据自己的需求,是否要使用 -->
<resultMap type="io.office.modules.manage.entity.UserFunctionBindingEntity" id="userFunctionBindingMap">
<result property="id" column="id"/>
<result property="userId" column="user_id"/>
<result property="funcId" column="func_id"/>
</resultMap>
<delete id="deleteUserFunctionBindingById">
delete from user_function_binding where user_id=#{id}
</delete>
<select id="queryListById" resultType="io.office.modules.manage.entity.UserFunctionBindingEntity">
select * from user_function_binding where user_id=#{id}
</select>
</mapper>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment